Removed quadrics
This commit is contained in:
parent
0c6f4731a6
commit
c89cea204c
|
@ -1,79 +0,0 @@
|
|||
//
|
||||
// File: GLUQuadricCallback.cc
|
||||
// Author: alterself
|
||||
//
|
||||
// Created on November 28, 2002, 8:21 PM
|
||||
//
|
||||
|
||||
#include "GLUQuadricCallbacks.h"
|
||||
|
||||
JavaMethod* GLUQuadricCallbacks::errorCallback;
|
||||
|
||||
//
|
||||
// Constructor
|
||||
///
|
||||
GLUQuadricCallbacks::GLUQuadricCallbacks()
|
||||
{
|
||||
errorCallback = NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Destructor
|
||||
//
|
||||
GLUQuadricCallbacks::~GLUQuadricCallbacks()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
void GLUQuadricCallbacks::clear() {
|
||||
if (errorCallback != NULL) {
|
||||
delete errorCallback;
|
||||
}
|
||||
}
|
||||
|
||||
typedef void (GLAPIENTRY *callback_t)();
|
||||
|
||||
void GLUQuadricCallbacks::set(GLUquadricObj *globj, JavaMethod* cb, jint type)
|
||||
{
|
||||
switch (type) {
|
||||
case GLU_ERROR:
|
||||
/* If we are already refering to a callback, get rid of it */
|
||||
if (errorCallback != NULL) {
|
||||
delete errorCallback;
|
||||
}
|
||||
if (cb == NULL) {
|
||||
gluQuadricCallback(globj,
|
||||
(GLenum) type,
|
||||
NULL);
|
||||
}
|
||||
else {
|
||||
errorCallback = cb;
|
||||
gluQuadricCallback(globj,
|
||||
(GLenum) type,
|
||||
(callback_t) GLUQuadricCallbacks::gluError);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CALLBACK GLUQuadricCallbacks::gluError(GLenum type) {
|
||||
|
||||
if (errorCallback == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
JNIEnv * env = errorCallback->env;
|
||||
jobject obj = errorCallback->obj;
|
||||
|
||||
jclass cls = (jclass) env->GetObjectClass(obj);
|
||||
|
||||
jmethodID mid = env->GetMethodID(cls,
|
||||
errorCallback->method.c_str(),
|
||||
"(I)V");
|
||||
|
||||
if (mid == 0) {
|
||||
return;
|
||||
}
|
||||
/* Hopefully this will end up calling the java method for handling GLU_ERROR for this quad */
|
||||
env->CallVoidMethod(obj, mid, (jint) type);
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
//
|
||||
// File: GLUQuadricCallbacks.h
|
||||
// Author: alterself
|
||||
//
|
||||
// Created on November 28, 2002, 8:21 PM
|
||||
//
|
||||
|
||||
#ifndef _GLUQuadricCallbacks_H
|
||||
#define _GLUQuadricCallbacks_H
|
||||
|
||||
#include "extgl.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "JavaMethod.h"
|
||||
|
||||
#ifndef CALLBACK
|
||||
#define CALLBACK
|
||||
#endif
|
||||
|
||||
|
||||
class GLUQuadricCallbacks {
|
||||
public:
|
||||
GLUQuadricCallbacks();
|
||||
~GLUQuadricCallbacks();
|
||||
|
||||
static void CALLBACK gluError(GLenum);
|
||||
static void set(GLUquadricObj *, JavaMethod*, jint);
|
||||
static void clear();
|
||||
protected:
|
||||
|
||||
private:
|
||||
static JavaMethod* errorCallback;
|
||||
};
|
||||
#endif /* _GLUQuadricCallbacks_H */
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
//
|
||||
// File: Callback.h
|
||||
// Author: alterself
|
||||
//
|
||||
// Created on November 28, 2002, 3:37 PM
|
||||
//
|
||||
|
||||
#ifndef _JavaMethod_H
|
||||
#define _JavaMethod_H
|
||||
#include <string>
|
||||
#include <jni.h>
|
||||
|
||||
class JavaMethod {
|
||||
public:
|
||||
JavaMethod(JNIEnv *newEnv, jobject newObj, std::string newMethod)
|
||||
{
|
||||
env = newEnv;
|
||||
obj = newObj;
|
||||
method = newMethod;
|
||||
}
|
||||
~JavaMethod()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JNIEnv* env;
|
||||
jobject obj;
|
||||
std::string method;
|
||||
protected:
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif /* _JavaMethod_H */
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
noinst_LTLIBRARIES = libcallbacks.la
|
||||
|
||||
libcallbacks_la_SOURCES = $(COMMON) $(CALLBACKS)
|
||||
libcallbacks_la_CPPFLAGS = -D_DEBUG
|
||||
|
||||
INCLUDES = -I../
|
||||
|
||||
COMMON = \
|
||||
JavaMethod.h
|
||||
|
||||
CALLBACKS = \
|
||||
GLUQuadricCallbacks.cpp \
|
||||
GLUQuadricCallbacks.h
|
|
@ -1,75 +0,0 @@
|
|||
This is just the start of my callback implementation.
|
||||
|
||||
Unfortunatly, you cant pass a non static method as a function pointer...
|
||||
So we can only have callbacks for a single GLU object. However,
|
||||
according to the OpenGL redbook... this should not be an issue. For example
|
||||
the redbook states that, a single tess object should be used for an
|
||||
entire program... and reused for each tessleation.
|
||||
|
||||
The implementation:
|
||||
|
||||
JavaMethod: a data object that contains information on the method to call.
|
||||
|
||||
GLUQuadricCallbacks: a class for working with quadric callbacks
|
||||
|
||||
eventually you can expect callbacks for glu nurbs and glu tesselators.
|
||||
Of course callbacks for other object types should be easy to do using this framework.
|
||||
|
||||
|
||||
Note as elegent as I wanted, but it works.
|
||||
|
||||
You would write a callback like this:
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_opengl_GLU
|
||||
* Method: quadricCallback
|
||||
* Signature: (IILjava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLU_quadricCallback__IILjava_lang_String_2
|
||||
(JNIEnv * env, jobject obj, jint quad, jint type, jstring method)
|
||||
{
|
||||
GLUQuadricCallbacks::set(quad,
|
||||
new JavaMethod(env, obj, env->GetStringUTFChars(method, 0)),
|
||||
type);
|
||||
CHECK_GL_ERROR
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_opengl_GLU
|
||||
* Method: quadricCallback
|
||||
* Signature: (IILjava/lang/Object;Ljava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLU_quadricCallback__IILjava_lang_Object_2Ljava_lang_String_2
|
||||
(JNIEnv * env, jobject obj, jint quad, jint type, jobject target, jstring method)
|
||||
{
|
||||
GLUQuadricCallbacks::set(quad,
|
||||
new JavaMethod(env, target, env->GetStringUTFChars(method, 0)),
|
||||
type);
|
||||
CHECK_GL_ERROR
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_opengl_GLU
|
||||
* Method: deleteQuadric
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLU_deleteQuadric(JNIEnv * env, jobject obj, jint quad)
|
||||
{
|
||||
gluDeleteQuadric((GLUquadricObj *) quad);
|
||||
GLUQuadricCallbacks::clear();
|
||||
CHECK_GL_ERROR
|
||||
}
|
||||
|
||||
|
||||
|
||||
and call it from java:
|
||||
|
||||
/* myquadric is a reference to a GLUquadricObj returned by glu.newQuadric()
|
||||
* GLU.ERROR is the callback type
|
||||
* errorCallback is the method you wish to be called */
|
||||
glu.quadricCallback(myquadric, GLU.ERROR, "errorCallback");
|
||||
|
||||
or
|
||||
|
||||
glu.quadricCallback(myquadric, GLU.ERROR, someObject, "errorCallback");
|
||||
|
Loading…
Reference in New Issue