From: Montana, P. M <pat...@lm...> - 2003-04-17 17:02:41
|
Philippe,=20 Here is some code that we use for tessellating polygons. I'm not 100% = sure we did it correctly, but it does seem to work OK. When I have more than = one GL4Java display in the same application, I'll sometimes get a native = error outside the JVM related to the tesselation callbacks. But I don't know = if I'm doing something wrong, or it is a library bug. (BTW, the 'Triplet' = class below is just a simple class we wrote to hold an x,y,z.)=20 -Mark=20 private void tesselatePolygon( GLFunc gl_, GLUFunc glu_ )=20 {=20 int size =3D pointList.size();=20 Triplet point =3D null;=20 double coords[] =3D new double[3];=20 long polyTess =3D createTesselator( gl_, glu_ );=20 glu_.gluTessBeginPolygon( polyTess, (double[]) null );=20 glu_.gluTessBeginContour( polyTess );=20 for( int ii=3D0; ii<size; ii++ )=20 {=20 point =3D (Triplet) pointList.get( ii );=20 coords[0] =3D point.getX();=20 coords[1] =3D point.getY();=20 coords[2] =3D 0.0;=20 double tmpData[] =3D new double[2];=20 tmpData[0] =3D coords[0];=20 tmpData[1] =3D coords[1];=20 glu_.gluTessVertex( polyTess, coords, tmpData );=20 }=20 glu_.gluTessEndContour( polyTess );=20 glu_.gluTessEndPolygon( polyTess );=20 glu_.gluDeleteTess( polyTess );=20 // Here is where we used to release memory used internally by = tesselator=20 // in Magician=20 }=20 =20 private long createTesselator( GLFunc gl_, GLUFunc glu_ )=20 {=20 long polyTess =3D glu_.gluNewTess();=20 glu_.gluTessCallback( polyTess, glu_.GLU_TESS_BEGIN, gl_,=20 "glBegin", "(I)V", 0, 0, 0, 0, 0 );=20 glu_.gluTessCallback( polyTess, glu_.GLU_TESS_VERTEX, gl_,=20 "glVertex2dv", "([D)V", 2, 0, 0, 0, 0 );=20 glu_.gluTessCallback( polyTess, glu_.GLU_TESS_END, gl_,=20 "glEnd", "()V", 0, 0, 0, 0, 0 );=20 glu_.gluTessCallback( polyTess, glu_.GLU_TESS_ERROR, this,=20 "error_callback", "(I)V", 0, 0, 0, 0, 0 );=20 glu_.gluTessCallback( polyTess, glu_.GLU_TESS_COMBINE, this,=20 "combine_callback", "([D[D[D[D)V", 2, 0, 0, 2, = 0 ); glu_.gluTessProperty( polyTess, GLUEnum.GLU_TESS_WINDING_RULE,=20 GLUEnum.GLU_TESS_WINDING_ODD );=20 return( polyTess );=20 }=20 =20 public void error_callback( int error )=20 {=20 System.err.println( "PolygonPrimitive2d.error_callback() - "=20 + "tesselation error was generated: " + error );=20 System.err.flush();=20 }=20 =20 public void combine_callback( double[] coords, double[] vertexData,=20 double[] weights, double[] data )=20 {=20 data[0] =3D coords[0];=20 data[1] =3D coords[1];=20 }=20 =20 =20 armand darman wrote:=20 hi,=20 I need to tessellate concav polygons with GL4java.=20 But GL4java functions (like gluTessCallBack for=20 instance)don't have the same parameters than OpenGL=20 ones.=20 Where could I find, or could you give me a whole=20 description of those functions in GL4java?=20 Thank you very much!!=20 from: Philippe, student.=20 =20 ___________________________________________________________=20 Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en fran=E7ais !=20 Yahoo! Mail : http://fr.mail.yahoo.com <http://fr.mail.yahoo.com> =20 -------------------------------------------------------=20 This sf.net email is sponsored by:ThinkGeek=20 Welcome to geek heaven.=20 http://thinkgeek.com/sf <http://thinkgeek.com/sf> =20 _______________________________________________=20 gl4java-usergroup mailing list=20 gl4...@li...=20 https://lists.sourceforge.net/lists/listinfo/gl4java-usergroup <https://lists.sourceforge.net/lists/listinfo/gl4java-usergroup>=20 |