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... -------------------------------------- |