From: Sven G. <sgo...@ja...> - 2000-07-06 20:28:54
|
Dear Users, Dear Rob, I analysed the problem of using VertexPointer (-> Arrays) ! Now, we do have a problem :-) The semantics of the gl*Pointer methods is, that the data referenced by the pointer (which is passed to GL as an argument), is used LATER ! One GL Context hold's the data pointer for each: - vertex array - normal array - color array - ... The data's pointer can be hold, after calling glEnableClientState(GLEnum.GL_VERTEX_ARRAY); So - at all time, the data, to which the reference points, must be AVAIABLE till the next call of the appropiate: glDisableClientState(..) In GL4Java, we use the following code: JNIEXPORT void JNICALL Java_gl4java_GLFuncJauJNInf_glVertexPointer__III_3B ( JNIEnv *env, jobject obj, jint size, jint type, jint stride, jbyteArray ptr) { static void (CALLBACK *__func_ptr__)(GLint, GLenum, GLsizei, const GLvoid *) = NULL; jbyte *ptr3 = NULL; if(__func_ptr__==NULL) { __func_ptr__ = (void (CALLBACK *)(GLint, GLenum, GLsizei, const GLvoid *)) getGLProcAddressHelper("glVertexPointer", NULL, 1, 0); if(__func_ptr__==NULL) return; } if(ptr!=NULL) { ptr3 = (*env)->GetByteArrayElements(env, ptr, 0); } __func_ptr__ ( (GLint) size, (GLenum) type, (GLsizei) stride, (const GLvoid *) ptr3 ); if(ptr!=NULL) { (*env)->ReleaseByteArrayElements(env, ptr, ptr3, 0); } } The problem is, that the JVM can implement two ways for accessing arrays: - make a copy - "pinning" - just pass the real pointer Both methods use a garbage collection lock on the used array ! A JVM, which uses pinning, just passes us the pointer of such an object ! The GL machine can use the data later - well, if the garbage collector does not removed the non-locked data (by us) ! Well, if the copy method is used, a horrible scenario exists ! The GL machine accesses data, referenced by the given pointer before, but the data is de-allocated / freed by the Release call ! The solution is: IF used the copy method, for each type (Vertex, Color, ...) AND for each GL-Context: - not call Release, till: - a new gl*Pointer call is made - a glDisableClientState(*) is called So the data must being hold that long ! IF used the pinning method: - nothing must be changed ... But we can use the upper implementation, to be sure, that the garbage collector has not release the ressources ! Generally, I am currently optimizing the array implementation ! The usage of identifying the method (copy,pinning) and using this for the Release call (0, JNI_ABORT) ! The redundant call of Set*ArrayRegion is removed now ! This optimisation and bugfix, will be released with GL4Java 2.4.1 ! Yours, Sven Goethel Rob Grzywinski wrote: > > I am using MSJVM v5.00.3167 under Win95 and I just > upgraded to GL4Java2.4.0.0. My application, which > uses display lists extensively, now displays all > objects as if their 1st coordinate was at infinity (so > all objects have an infinite line shooting out from > them). Also selection against any object causes an > invalid page fault in module MSJAVA.DLL. I'm working > to isolate the problem and post the code, but I wanted > to get the word out to see if anyone else has a > similar problem. > > BTW: when I use Sun's JRE1.1.8 on the same machine > with 2.4.0.0 everything is fine (all objects render as > they did under 2.3.X.X). > > BTW2: yes, I recompiled and restarted the machine :) > > Rob Grzywinski > rgr...@ya... > > __________________________________________________ > Do You Yahoo!? > Get Yahoo! Mail - Free email you can access from anywhere! > http://mail.yahoo.com/ > > _______________________________________________ > gl4java-usergroup mailing list > gl4...@li... > http://lists.sourceforge.net/mailman/listinfo/gl4java-usergroup -- mailto:sgo...@ja... www : http://www.jausoft.com voice : +49-521-2399440, +49-170-2115963; fax: +49-521-2399442 |