lwjgl/src/native/common/org_lwjgl_opengl_GLU.cpp

332 lines
12 KiB
C++
Raw Normal View History

2002-08-15 11:46:18 -04:00
/*
* Copyright (c) 2002 Light Weight Java Game Library Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
2002-08-11 07:49:32 -04:00
*
2002-08-15 11:46:18 -04:00
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
2002-08-11 07:49:32 -04:00
*
2002-08-15 11:46:18 -04:00
* * Neither the name of 'Light Weight Java Game Library' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* $Id$
2002-08-11 07:49:32 -04:00
*
2002-08-15 11:46:18 -04:00
* GLU library.
2002-08-11 07:49:32 -04:00
*
2002-08-15 11:46:18 -04:00
* @author cix_foo <cix_foo@users.sourceforge.net>
* @version $Revision$
2002-08-11 07:49:32 -04:00
*/
#include "org_lwjgl_opengl_GLU.h"
2002-08-17 10:13:12 -04:00
#include "extgl.h"
#include "checkGLerror.h"
#include "callbacks/GLUQuadricCallbacks.h"
2002-08-17 10:13:12 -04:00
/*
* Class: org_lwjgl_opengl_GLU
* Method: getString
*/
2003-06-24 08:24:55 -04:00
JNIEXPORT jstring JNICALL Java_org_lwjgl_opengl_GLU_gluGetString(JNIEnv * env, jclass clazz, jint p0)
2002-08-17 10:13:12 -04:00
{
const char * msg = (const char *) gluGetString((GLint) p0);
jstring ret = env->NewStringUTF(msg);
return ret;
}
/*
* Class: org_lwjgl_opengl_GLU
* Method: errorString
*/
2003-06-24 08:24:55 -04:00
JNIEXPORT jstring JNICALL Java_org_lwjgl_opengl_GLU_gluErrorString(JNIEnv * env, jclass clazz, jint p0)
2002-08-17 10:13:12 -04:00
{
const GLubyte * msg = gluErrorString((GLint) p0);
jstring ret = env->NewStringUTF((const char *) msg);
return ret;
}
/*
* Class: org_lwjgl_opengl_GLU
* Method: ortho2D
*/
2003-06-24 08:24:55 -04:00
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLU_gluOrtho2D(JNIEnv * env, jclass clazz, jdouble p0, jdouble p1, jdouble p2, jdouble p3)
2002-08-17 10:13:12 -04:00
{
gluOrtho2D((GLdouble) p0, (GLdouble) p1, (GLdouble) p2, (GLdouble) p3);
CHECK_GL_ERROR
}
/*
* Class: org_lwjgl_opengl_GLU
* Method: perspective
*/
2003-06-24 08:24:55 -04:00
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLU_gluPerspective(JNIEnv * env, jclass clazz, jdouble p0, jdouble p1, jdouble p2, jdouble p3)
2002-08-17 10:13:12 -04:00
{
gluPerspective((GLdouble) p0, (GLdouble) p1, (GLdouble) p2, (GLdouble) p3);
CHECK_GL_ERROR
}
/*
* Class: org_lwjgl_opengl_GLU
* Method: pickMatrix
*/
2003-06-24 08:24:55 -04:00
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLU_gluPickMatrix(JNIEnv * env, jclass clazz, jdouble p0, jdouble p1, jdouble p2, jdouble p3, jobject buffer)
2002-08-17 10:13:12 -04:00
{
2003-06-24 08:24:55 -04:00
GLint *address = (GLint *)env->GetDirectBufferAddress(buffer);
gluPickMatrix((GLdouble) p0, (GLdouble) p1, (GLdouble) p2, (GLdouble) p3, address);
2002-08-17 10:13:12 -04:00
CHECK_GL_ERROR
}
/*
* Class: org_lwjgl_opengl_GLU
* Method: lookAt
*/
2003-06-24 08:24:55 -04:00
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLU_gluLookAt(JNIEnv * env, jclass clazz, jdouble p0, jdouble p1, jdouble p2, jdouble p3, jdouble p4, jdouble p5, jdouble p6, jdouble p7, jdouble p8)
2002-08-17 10:13:12 -04:00
{
gluLookAt((GLdouble) p0, (GLdouble) p1, (GLdouble) p2, (GLdouble) p3, (GLdouble) p4, (GLdouble) p5, (GLdouble) p6, (GLdouble) p7, (GLdouble) p8);
CHECK_GL_ERROR
}
/*
* Class: org_lwjgl_opengl_GLU
* Method: project
*/
2003-06-24 08:24:55 -04:00
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_GLU_gluProject(JNIEnv * env, jclass clazz, jdouble p0, jdouble p1, jdouble p2, jobject buffer, jobject buffer2, jobject buffer3, jobject buffer4, jobject buffer5, jobject buffer6)
2002-08-17 10:13:12 -04:00
{
2003-06-24 08:24:55 -04:00
const GLdouble *address = (const GLdouble *)env->GetDirectBufferAddress(buffer);
const GLdouble *address2 = (const GLdouble *)env->GetDirectBufferAddress(buffer2);
const GLint *address3 = (const GLint *)env->GetDirectBufferAddress(buffer3);
GLdouble *address4 = (GLdouble *)env->GetDirectBufferAddress(buffer4);
GLdouble *address5 = (GLdouble *)env->GetDirectBufferAddress(buffer5);
GLdouble *address6 = (GLdouble *)env->GetDirectBufferAddress(buffer6);
jint ret = (jint) gluProject((GLdouble) p0, (GLdouble) p1, (GLdouble) p2, address, address2, address3, address4, address5, address6);
2002-08-17 10:13:12 -04:00
CHECK_GL_ERROR
return ret;
}
/*
* Class: org_lwjgl_opengl_GLU
* Method: unProject
*/
2003-06-24 08:24:55 -04:00
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_GLU_gluUnProject(JNIEnv * env, jclass clazz, jdouble p0, jdouble p1, jdouble p2, jobject buffer, jobject buffer2, jobject buffer3, jobject buffer4, jobject buffer5, jobject buffer6)
2002-08-17 10:13:12 -04:00
{
2003-06-24 08:24:55 -04:00
const GLdouble *address = (const GLdouble *)env->GetDirectBufferAddress(buffer);
const GLdouble *address2 = (const GLdouble *)env->GetDirectBufferAddress(buffer2);
const GLint *address3 = (const GLint *)env->GetDirectBufferAddress(buffer3);
GLdouble *address4 = (GLdouble *)env->GetDirectBufferAddress(buffer4);
GLdouble *address5 = (GLdouble *)env->GetDirectBufferAddress(buffer5);
GLdouble *address6 = (GLdouble *)env->GetDirectBufferAddress(buffer6);
jint ret = (jint) gluUnProject((GLdouble) p0, (GLdouble) p1, (GLdouble) p2, address, address2, address3, address4, address5, address6);
2002-08-17 10:13:12 -04:00
CHECK_GL_ERROR
return ret;
}
/*
* Class: org_lwjgl_opengl_GLU
* Method: scaleImage
*/
2003-06-24 08:24:55 -04:00
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_GLU_gluScaleImage(JNIEnv * env, jclass clazz, jint p0, jint p1, jint p2, jint p3, jobject buffer, jint p5, jint p6, jint p7, jobject buffer2)
2002-08-17 10:13:12 -04:00
{
2003-06-24 08:24:55 -04:00
const void *address = (const void *)env->GetDirectBufferAddress(buffer);
void *address2 = (void *)env->GetDirectBufferAddress(buffer2);
jint ret = (jint) gluScaleImage((GLint) p0, (GLint) p1, (GLint) p2, (GLint) p3, address, (GLint) p5, (GLint) p6, (GLint) p7, address2);
2002-08-17 10:13:12 -04:00
CHECK_GL_ERROR
return ret;
}
/*
* Class: org_lwjgl_opengl_GLU
* Method: build1DMipmaps
*/
2003-06-24 08:24:55 -04:00
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_GLU_gluBuild1DMipmaps(JNIEnv * env, jclass clazz, jint p0, jint p1, jint p2, jint p3, jint p4, jobject buffer)
2002-08-17 10:13:12 -04:00
{
2003-06-24 08:24:55 -04:00
const void *address = (const void *)env->GetDirectBufferAddress(buffer);
jint ret = (jint) gluBuild1DMipmaps((GLint) p0, (GLint) p1, (GLint) p2, (GLint) p3, (GLint) p4, address);
2002-08-17 10:13:12 -04:00
CHECK_GL_ERROR
return ret;
}
/*
* Class: org_lwjgl_opengl_GLU
* Method: build2DMipmaps
*/
2003-06-24 08:24:55 -04:00
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_GLU_gluBuild2DMipmaps(JNIEnv * env, jclass clazz, jint p0, jint p1, jint p2, jint p3, jint p4, jint p5, jobject buffer)
2002-08-17 10:13:12 -04:00
{
2003-06-24 08:24:55 -04:00
const void *address = (const void *)env->GetDirectBufferAddress(buffer);
jint ret = (jint) gluBuild2DMipmaps((GLint) p0, (GLint) p1, (GLint) p2, (GLint) p3, (GLint) p4, (GLint) p5, address);
2002-08-17 10:13:12 -04:00
CHECK_GL_ERROR
return ret;
}
/*
* Class: org_lwjgl_opengl_GLU
* Method: newQuadric
*/
2003-06-24 08:24:55 -04:00
JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_GLU_gluNewQuadric(JNIEnv * env, jclass clazz)
{
2003-06-24 08:24:55 -04:00
GLUquadricObj *ret = gluNewQuadric();
CHECK_GL_ERROR
return env->NewDirectByteBuffer(ret, 0);
}
/*
* Class: org_lwjgl_opengl_GLU
* Method: cylinder
*/
2003-06-24 08:24:55 -04:00
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLU_gluCylinder(JNIEnv * env, jclass clazz, jobject quad, jdouble baseRadius, jdouble topRadius, jdouble height, jint slices, jint stacks)
{
2003-06-24 08:24:55 -04:00
GLUquadricObj *address = (GLUquadricObj *)env->GetDirectBufferAddress(quad);
gluCylinder(address, (GLdouble) baseRadius, (GLdouble) topRadius, (GLdouble) height, (GLint) slices, (GLint) stacks);
CHECK_GL_ERROR
}
/*
* Class: org_lwjgl_opengl_GLU
* Method: deleteQuadric
*/
2003-06-24 08:24:55 -04:00
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLU_gluDeleteQuadric(JNIEnv * env, jclass clazz, jobject quad)
{
2003-06-24 08:24:55 -04:00
GLUquadricObj *address = (GLUquadricObj *)env->GetDirectBufferAddress(quad);
gluDeleteQuadric(address);
GLUQuadricCallbacks::clear();
CHECK_GL_ERROR
}
/*
* Class: org_lwjgl_opengl_GLU
* Method: disk
*/
2003-06-24 08:24:55 -04:00
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLU_gluDisk
(JNIEnv * env, jclass clazz, jobject quad, jdouble innerRadius, jdouble outerRadius, jint slices, jint loops)
{
2003-06-24 08:24:55 -04:00
GLUquadricObj *address = (GLUquadricObj *)env->GetDirectBufferAddress(quad);
gluDisk(address, (GLdouble) innerRadius, (GLdouble) outerRadius, (GLint) slices, (GLint) loops);
CHECK_GL_ERROR
}
/*
* Class: org_lwjgl_opengl_GLU
* Method: partialDisk
*/
2003-06-24 08:24:55 -04:00
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLU_gluPartialDisk
(JNIEnv * env, jclass clazz, jobject quad, jdouble innerRadius, jdouble outerRadius,
jint slices, jint loops, jdouble startAngle, jdouble sweepAngle)
{
2003-06-24 08:24:55 -04:00
GLUquadricObj *address = (GLUquadricObj *)env->GetDirectBufferAddress(quad);
gluPartialDisk(address, (GLdouble) innerRadius, (GLdouble) outerRadius,
(GLint) slices, (GLint) loops, (GLdouble) startAngle, (GLdouble) sweepAngle);
CHECK_GL_ERROR
}
/*
* Class: org_lwjgl_opengl_GLU
* Method: quadricDrawStyle
*/
2003-06-24 08:24:55 -04:00
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLU_gluQuadricDrawStyle
(JNIEnv * env, jclass clazz, jobject quad, jint drawStyle)
{
2003-06-24 08:24:55 -04:00
GLUquadricObj *address = (GLUquadricObj *)env->GetDirectBufferAddress(quad);
gluQuadricDrawStyle(address, (GLenum) drawStyle);
CHECK_GL_ERROR
}
/*
* Class: org_lwjgl_opengl_GLU
* Method: quadricNormals
*/
2003-06-24 08:24:55 -04:00
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLU_gluQuadricNormals
(JNIEnv * env, jclass clazz, jobject quad, jint normals)
{
2003-06-24 08:24:55 -04:00
GLUquadricObj *address = (GLUquadricObj *)env->GetDirectBufferAddress(quad);
gluQuadricNormals(address, (GLenum) normals);
CHECK_GL_ERROR
}
/*
* Class: org_lwjgl_opengl_GLU
* Method: quadricOrientation
*/
2003-06-24 08:24:55 -04:00
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLU_gluQuadricOrientation
(JNIEnv * env, jclass clazz, jobject quad, jint orientation)
{
2003-06-24 08:24:55 -04:00
GLUquadricObj *address = (GLUquadricObj *)env->GetDirectBufferAddress(quad);
gluQuadricOrientation(address, (GLenum) orientation);
CHECK_GL_ERROR
}
/*
* Class: org_lwjgl_opengl_GLU
* Method: quadricTexture
*/
2003-06-24 08:24:55 -04:00
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLU_gluQuadricTexture
(JNIEnv * env, jclass clazz, jobject quad, jboolean textureCoords)
{
2003-06-24 08:24:55 -04:00
GLUquadricObj *address = (GLUquadricObj *)env->GetDirectBufferAddress(quad);
gluQuadricTexture(address, (GLboolean) textureCoords);
CHECK_GL_ERROR
}
/*
* Class: org_lwjgl_opengl_GLU
* Method: sphere
*/
2003-06-24 08:24:55 -04:00
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLU_gluSphere
(JNIEnv * env, jclass clazz, jobject quad, jdouble radius, jint slices, jint stacks)
{
2003-06-24 08:24:55 -04:00
GLUquadricObj *address = (GLUquadricObj *)env->GetDirectBufferAddress(quad);
gluSphere(address, (GLdouble) radius, (GLint) slices, (GLint) stacks);
CHECK_GL_ERROR
}
/*
* Class: org_lwjgl_opengl_GLU
* Method: quadricCallback
* Signature: (IILjava/lang/String;)V
*/
2003-06-24 08:24:55 -04:00
/*JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLU_gluQuadricCallback__IILjava_lang_String_2
(JNIEnv * env, jclass clazz, jobject quad, jint type, jstring method)
{
2003-06-24 08:24:55 -04:00
GLUquadricObj *address = (GLUquadricObj *)env->GetDirectBufferAddress(quad);
GLUQuadricCallbacks::set(address,
new JavaMethod(env, obj, env->GetStringUTFChars(method, 0)),
type);
CHECK_GL_ERROR
}
2003-06-24 08:24:55 -04:00
*/
/*
* Class: org_lwjgl_opengl_GLU
* Method: quadricCallback
* Signature: (IILjava/lang/Object;Ljava/lang/String;)V
*/
2003-06-24 08:24:55 -04:00
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLU_gluQuadricCallback__IILjava_lang_Object_2Ljava_lang_String_2
(JNIEnv * env, jclass clazz, jobject quad, jint type, jobject target, jstring method)
{
2003-06-24 08:24:55 -04:00
GLUquadricObj *address = (GLUquadricObj *)env->GetDirectBufferAddress(quad);
GLUQuadricCallbacks::set(address,
new JavaMethod(env, target, env->GetStringUTFChars(method, 0)),
type);
CHECK_GL_ERROR
}