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); } } } |