Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  possible glGetDoublev implementation problem  (Read 666 times)
0 Members and 1 Guest are viewing this topic.
Offline dimamarkman

JGO n00b
*

Posts: 6


Java games rock!


« on: 2003-10-25 18:34:20 »

after some discussion in java-dev Apple's list
I took a look at glGetDoublev implementation:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
JNIEXPORT void JNICALL
Java_net_java_games_jogl_impl_macosx_MacOSXGLImpl_glGetDoublev(JNIEnv *env, jobject _unused, jint pname, jdoubleArray params) {
  GLdouble * _ptr1 = NULL;
  if (params != NULL) {
    _ptr1 = (GLdouble *) (*env)->GetPrimitiveArrayCritical(env, params, NULL);
  }
  glGetDoublev((GLenum) pname, (GLdouble *) _ptr1);
  if (params != NULL) {
    (*env)->ReleasePrimitiveArrayCritical(env, params, _ptr1, JNI_ABORT);
  }
}


I can see at least 2 possible problem there:
1. GetPrimitiveArrayCritical could return NULL, so using that _ptr1 isn't recommended
2. GetPrimitiveArrayCritical could use copy, so JNI_ABORT isn't appropriate in ReleasePrimitiveArrayCritical

and just comment (GLdouble *) casting in glGetDoublev
isn't necessary, because _ptr1 was declared as GLdouble*


so I'd recommend the following code instead

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
JNIEXPORT void JNICALL
Java_net_java_games_jogl_impl_macosx_MacOSXGLImpl_glGetDoublev(JNIEnv *env, jobject _unused, jint pname, jdoubleArray params) {
        GLdouble * _ptr1 = NULL;
      jboolean isCopiedArray = JNI_FALSE;
        if (params == NULL)  return;
          _ptr1 = (GLdouble *) (*env)->GetPrimitiveArrayCritical(env, params,& isCopiedArray);
      if(_ptr1 == NULL) return;
        glGetDoublev((GLenum) pname,  _ptr1);
          (*env)->ReleasePrimitiveArrayCritical(env, params, _ptr1,(isCopiedArray == JNI_TRUE)?0:JNI_ABORT);
}



Pages: [1]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.154 seconds with 21 queries.