From: Dave G. <da...@sm...> - 2000-09-07 10:51:52
|
Hi there Quick (and probably stupid) question: I am having problems removing a GLCanvas from an applet space. The sequence is as follows: (+) create the applet space (+) create myGLCanvas at (say) 75% of applet width and height (in this = instance, myGLCanvas is a GLAnimCanvas which is not using drawlists) (+) add(myGLCanvas) (+) start myGLCanvas on some keypress (+) stop myGLCanvas on some keypress (+) Now, when I hit some other key, I want the GLCanvas to shut down, = and remove itself from the applet space. But the following code does not = work -- it leaves the GLCanvas on the screen, and right at the front of = the z-priority: public void canvasDestroy(GLCanvas canvas) { remove(canvas); canvas.stop(); canvas.destroy(); layout(); } FYI, canvas.destroy() is as follows (note I have copied the glj* calls = to ensure they fire): public void destroy() { glj.gljFree(); glj.setEnabled(false); glj.gljDestroy(); cvsDispose(); } I have tried mucking about with Containers and ComponentPeers but I = still cannot get GLCanvas or GLAnimCanvas to release its draw space. Is = there something obvious that I am doing wrong? Any help would be much appreciated! Cheers, Dave. |
From: Olivier M. <Oli...@cy...> - 2000-09-08 07:30:47
|
Hello, I am experiencing a crash in the native gl4java.GLUFuncJauJNI.gluTessEndPolygon method (I guess it's a crash of the native gluTessEndPolygon function) while translating a C++ source to Java. The problem is that the C++ source do work perfectly while the Java one crashes. So I wonder I understood properly the Java gluTesselator principles... Note that I use the GLU from SGI sample implementation because the one provided with Mesa is buggy (this might also be the source of the problem is Sven assumes we use MesaGLU...). Here is a sample of my source code which seems correct to my eyes: (see below) I tryed many things to get cues about what's happening in the code, without success. Thanks for help! -Olivier import gl4java.GLFunc; import gl4java.GLUFunc; import gl4java.GLEnum; import gl4java.GLUEnum; public class GlRenderer implements GLEnum, GLUEnum { GLFunc gl; GLUFunc glu; int tesselator=0; static public void init(GLFunc glFunc,GLUFunc gluFunc) { r.gl = glFunc; r.glu = gluFunc; tesselator = glu.gluNewTess(); glu.gluTessCallback(tesselator,GLU_TESS_BEGIN,gl,"glBegin","(I)V",0,0,0,0,0); glu.gluTessCallback(tesselator,GLU_TESS_VERTEX,this,"gluTessVertex","([D)V",6,0,0,0,0); glu.gluTessCallback(tesselator,GLU_TESS_END,gl,"glBegin","()V",0,0,0,0,0); glu.gluTessCallback(tesselator,GLU_TESS_ERROR,this,"gluError","(I)V",0,0,0,0,0); glu.gluTessCallback(tesselator,GLU_TESS_COMBINE,this,"gluTessCombine","([D[D[F[D)V",3,4,4,6,0); } void glError() { int e = gl.glGetError(); System.err.println(glu.gluErrorString(e)); } void gluError(int e) { System.err.println(glu.gluErrorString(e)); } void gluTessCombine(double coords[/*3*/],double vertex_data[/*4*/],float weight[/*4*/],double[/*6*/] dataOut) { // just do nothing System.out.println("Combine"); } void gluTessVertex(double[/*6*/] vertex) { System.out.println("gluTessVertex"); double [] normal = new double[3]; System.arraycopy(vertex,3,normal,0,3); gl.glNormal3dv(normal); gl.glVertex3dv(vertex); } void drawFace(double [/*n*/][/*6*/] point,boolean convex,boolean ccw) { int n = point.length; System.out.println("There are "+n+" points:"); for(int i=0;i<n;i++) { for(int j=0;j<6;j++) System.out.print(point[i][j]+" "); System.out.println(); } System.out.println("tesselator = "+tesselator); if (convex) { switch(n) { case 0: case 1: case 2: return; case 3: gl.glBegin(GL_TRIANGLES); break; case 4: gl.glBegin(GL_QUADS); break; default: gl.glBegin(GL_POLYGON); break; } for(int i=0;i<n;i++) { gl.glNormal3d(point[i][3],point[i][4],point[i][5]); gl.glVertex3d(point[i][0],point[i][1],point[i][2]); } gl.glEnd(); } else { glu.gluTessProperty(tesselator,GLU_TESS_WINDING_RULE,GLU_TESS_WINDING_POSITIVE); glu.gluTessBeginPolygon(tesselator,(double [])null); glu.gluTessBeginContour(tesselator); for(int i=0;i<n;i++) glu.gluTessVertex(tesselator,point[i],point[i]); glu.gluTessEndContour(tesselator); glu.gluTessEndPolygon(tesselator); } } } |
From: Jean-Yves B. <jea...@wa...> - 2000-09-08 08:11:43
|
Hello Olivier, I also got some crash problem with tesselation. Particularly with ERROR and COMBINE callbacks. I noticed usually, the reason was the callback declaration format and function signature parameters. I also tried several combination. You may try the following: // Call back declaration // ------------------------ gluFunc.gluTessCallback( tesselator, gluFunc.GLU_TESS_VERTEX, this, "vertexCallback", "([D)V", 6, 0, 0, 0, 0); gluFunc.gluTessCallback( tesselator, gluFunc.GLU_TESS_BEGIN, this, "beginCallback", "(I)V", 0, 0, 0, 0, 0); gluFunc.gluTessCallback( tesselator, gluFunc.GLU_TESS_END, this, "endCallback", "()V", 0, 0, 0, 0, 0); /*gluFunc.gluTessCallback( tesselator, gluFunc.GLU_TESS_ERROR, this, "errorCallback", "(I)V", 0, 0, 0, 0, 0); >> CRASH*/ gluFunc.gluTessCallback( tesselator, gluFunc.GLU_TESS_COMBINE, this, "combineCallback", "([D[D[F[D)V", 3, 4*6, 4, 6, 0); // Call back implementation //------------------------------ public void beginCallback(int which) { .... } public void vertexCallback(double[/*6*/] vertex) { double[] col = new double[3]; System.arraycopy(vertex, 0, col, 0, 3); >> Differ from you code. .... } public void errorCallback(int errorCode) { throw(new Exception("....")); } public void endCallback() { .... } public void combineCallback(double coords[/*3*/], double vertex_data[/*4x6*/], float weight[/*4*/], double[/*6*/] dataOut ) { throw(new Exception("....")); } I fact, the gl4java implementation for tesselation is not very clear to me. Last minute remark about your code: In your END call back declaration, you put a "glBegin" String! Are you it is what you want ? glu.gluTessCallback(tesselator,GLU_TESS_END,gl,"glBegin","()V",0,0,0,0,0); Bye. Olivier Michel a *crit : > Hello, > > I am experiencing a crash in the native > gl4java.GLUFuncJauJNI.gluTessEndPolygon method (I guess it's a crash of > the native gluTessEndPolygon function) while translating a C++ source to > Java. The problem is that the C++ source do work perfectly while the > Java one crashes. So I wonder I understood properly the Java > gluTesselator principles... Note that I use the GLU from SGI sample > implementation because the one provided with Mesa is buggy (this might > also be the source of the problem is Sven assumes we use MesaGLU...). > > Here is a sample of my source code which seems correct to my eyes: (see > below) > > I tryed many things to get cues about what's happening in the code, > without success. Thanks for help! > > -Olivier > > import gl4java.GLFunc; > import gl4java.GLUFunc; > import gl4java.GLEnum; > import gl4java.GLUEnum; > > public class GlRenderer implements GLEnum, GLUEnum { > GLFunc gl; > GLUFunc glu; > int tesselator=0; > static public void init(GLFunc glFunc,GLUFunc gluFunc) { > r.gl = glFunc; > r.glu = gluFunc; > tesselator = glu.gluNewTess(); > > glu.gluTessCallback(tesselator,GLU_TESS_BEGIN,gl,"glBegin","(I)V",0,0,0,0,0); > > glu.gluTessCallback(tesselator,GLU_TESS_VERTEX,this,"gluTessVertex","([D)V",6,0,0,0,0); > > glu.gluTessCallback(tesselator,GLU_TESS_END,gl,"glBegin","()V",0,0,0,0,0); > > glu.gluTessCallback(tesselator,GLU_TESS_ERROR,this,"gluError","(I)V",0,0,0,0,0); > > glu.gluTessCallback(tesselator,GLU_TESS_COMBINE,this,"gluTessCombine","([D[D[F[D)V",3,4,4,6,0); > > } > void glError() { > int e = gl.glGetError(); > System.err.println(glu.gluErrorString(e)); > } > void gluError(int e) { > System.err.println(glu.gluErrorString(e)); > } > void gluTessCombine(double coords[/*3*/],double > vertex_data[/*4*/],float weight[/*4*/],double[/*6*/] dataOut) { > // just do nothing > System.out.println("Combine"); > } > void gluTessVertex(double[/*6*/] vertex) { > System.out.println("gluTessVertex"); > double [] normal = new double[3]; > System.arraycopy(vertex,3,normal,0,3); > gl.glNormal3dv(normal); > gl.glVertex3dv(vertex); > } > void drawFace(double [/*n*/][/*6*/] point,boolean convex,boolean ccw) > { > int n = point.length; > System.out.println("There are "+n+" points:"); > for(int i=0;i<n;i++) { for(int j=0;j<6;j++) > System.out.print(point[i][j]+" "); System.out.println(); } > System.out.println("tesselator = "+tesselator); > > if (convex) { > switch(n) { > case 0: > case 1: > case 2: return; > case 3: gl.glBegin(GL_TRIANGLES); break; > case 4: gl.glBegin(GL_QUADS); break; > default: gl.glBegin(GL_POLYGON); break; > } > for(int i=0;i<n;i++) { > gl.glNormal3d(point[i][3],point[i][4],point[i][5]); > gl.glVertex3d(point[i][0],point[i][1],point[i][2]); > } > gl.glEnd(); > } else { > > glu.gluTessProperty(tesselator,GLU_TESS_WINDING_RULE,GLU_TESS_WINDING_POSITIVE); > > glu.gluTessBeginPolygon(tesselator,(double [])null); > glu.gluTessBeginContour(tesselator); > for(int i=0;i<n;i++) > glu.gluTessVertex(tesselator,point[i],point[i]); > glu.gluTessEndContour(tesselator); > glu.gluTessEndPolygon(tesselator); > } > } > } > > _______________________________________________ > gl4java-usergroup mailing list > gl4...@li... > http://lists.sourceforge.net/mailman/listinfo/gl4java-usergroup -- -------------------------------------- Jean-Yves BRUD POLYQUARK - Ingenierie & Creation 3D Palahou - 31330 LARRA France Tel: 05.62.79.03.33 Fax: 05.62.79.03.38 Mail: jea...@wa... -------------------------------------- |
From: Sven G. <sgo...@ja...> - 2000-09-08 10:09:39
|
Jean-Yves BRUD wrote: > > Hello Olivier, > > I also got some crash problem with tesselation. Particularly with > ERROR and COMBINE callbacks. > Ok - let's fix it now ! Because I am a very lazy guy :-), please send the complete code (a running class with main) in a zip archive ! Please note, that the demos: tess.java, tessdemo.java & tesswind.java does run - at least under unix and win32+sun-jvm ! Please also note, that there may be some problems with the MS-JVM & some MS-OpenGL implementations :-( Please add info's about your os, jvm (vendor+version), OpenGL vendor+version ! THANXS ! > I noticed usually, the reason was the callback declaration format and > function signature parameters. I also tried several combination. > You may try the following: > > // Call back declaration > // ------------------------ > > /*gluFunc.gluTessCallback( tesselator, gluFunc.GLU_TESS_ERROR, > this, "errorCallback", "(I)V", 0, 0, 0, 0, 0); >> CRASH*/ > public void errorCallback(int errorCode) > { > throw(new Exception("....")); > } > THIS error implementation is NOT OK !!!! You should not throw an exception ... ! Please note, that the callback java methods are called out of the opengl machine !! The java callback's should be as short as possible. An exceptions wants to unwind the java stack to find a catch block, or to leave the thread/process ! This may break the opengl machine ! Just do some printout, flag change or something else (see tess.java) ! Yours, Sven > I fact, the gl4java implementation for tesselation is not very clear > to me. > Well, let's do a Q&A session ! Then we may can generate a little HOWTO ! I thought, the little demos are clear :-( > Last minute remark about your code: > In your END call back declaration, you put a "glBegin" String! Are you > it is what you want ? > glu.gluTessCallback(tesselator,GLU_TESS_END,gl,"glBegin","()V",0,0,0,0,0); > :-) See above - add a good archive + os+jvm+opengl info's to follow your problem ... > Bye. > Peace, Sven -- mailto:sgo...@ja... www : http://www.jausoft.com ; pgp: http://www.jausoft.com/gpg/ voice : +49-521-2399440, +49-170-2115963; fax: +49-521-2399442 |
From: Olivier M. <Oli...@cy...> - 2000-09-08 11:56:09
|
Jean-Yves, As you sugguested, I commented out the ERROR callback, but it didn't fixed the problem. I also commented out the COMBINE callback without more success. > Last minute remark about your code: > In your END call back declaration, you put a "glBegin" String! Are you > it is what you want ? Oops. I just fixed this, but this was not the cause of the crash. Actually, the callback functions are not even called since they do not System.out.println. It crashes before, in the gluTessEndPolygon(). Sven, I seem to have understood the gluTesselator implementation you did since the tesselator demos works and are pretty clear to me. However, when I tryed my own tesselation system, it crashed hard. I am afraid I cannot give you my app as is because it's huge and requires a very heavy installation with clients / servers. However, I will try to make a simple example isolating the problem similar to the demos/MiscDemos/tess* that hopefully will exhibit the same crash, and give this demo to you (give me a few days). Thank you very much! -Olivier |
From: Sven G. <sgo...@ja...> - 2000-09-08 12:04:08
|
Olivier Michel wrote: > > > Sven, > > I seem to have understood the gluTesselator implementation you did since > the tesselator demos works and are pretty clear to me. However, when > I tryed my own tesselation system, it crashed hard. I am afraid I cannot > give you my app as is because it's huge and requires a very heavy > installation with clients / servers. However, I will try to make a > simple example isolating the problem similar to the > demos/MiscDemos/tess* that hopefully will exhibit the same crash, and > give this demo to you (give me a few days). > > Thank you very much! > It is a pleasure. Well, may be the "bug" will hopefully be fixed by yourself, while creating the little example :-) I am waiting .. Any more participants within the tesselator bug/problem ? Yours, Sven > -Olivier > -- mailto:sgo...@ja... www : http://www.jausoft.com ; pgp: http://www.jausoft.com/gpg/ voice : +49-521-2399440, +49-170-2115963; fax: +49-521-2399442 |
From: Olivier M. <Oli...@cy...> - 2000-09-13 06:48:46
|
Sven Goethel wrote: > Olivier Michel wrote: > > > > > > Sven, > > > > I seem to have understood the gluTesselator implementation you did since > > the tesselator demos works and are pretty clear to me. However, when > > I tryed my own tesselation system, it crashed hard. I am afraid I cannot > > give you my app as is because it's huge and requires a very heavy > > installation with clients / servers. However, I will try to make a > > simple example isolating the problem similar to the > > demos/MiscDemos/tess* that hopefully will exhibit the same crash, and > > give this demo to you (give me a few days). > > > > Thank you very much! > > > > It is a pleasure. > > Well, may be the "bug" will hopefully be fixed by yourself, > while creating the little example :-) > > I am waiting .. All right. I could not reproduce the bug in a simple example derivated from tess.java. However, I could fix it in my software. Anyway, something weird was happening, which might lie rather in GLU than in GL4Java. Actually I did two things which fixed the problem: 1) The tesselator crashed because the last point submitted was the same (i.e., same coords) as the first point and the GLU tesselator didn't liked that at all :(. So, before I submit points to the tesselator, I now check if the first one and the last one have the same coords and if this is the case, I do not submit the last one to the tesselator. Ok, this one might be understandable. 2) I removed the callback setup calls (gluTessCallback) from my GL initialization method (which creates the tesselator with gluNewTess and sets up all the GL stuff, like glEnable, glHint, glShadeModel, glPolygonMode, etc.) and moved them into the method that draws the tesselated polygon (just before calling gluTessBeginPolygon). This fixed the crashed in the native gluTessEndPolygon. This one is much weirder, isn't it ? I am using the GLU from SGI sample implementation on Linux whose tesselator is not (or less) bugged than the GLU tesselator coming with Mesa. If someone has any idea on why the bug (2) occured, I would be very happy to investigate it further. It might come from the fact, that in between calling my GL init method and the tesselated face drawing method, I call many other GLU functions (especially for drawing cylinders with quadrics). This might perturbate the GLU... I hope this could help others facing the same problem. -Olivier |