LWJGL
May 22, 2012, 04:56:31 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL 2.8.3 released!
 
   Home   Help Search Login Register  



Pages: [1]
  Print  
Author Topic: [SOLVED] problem with gluTessBeginContour function  (Read 1664 times)
zik
Newbie
*
Posts: 9


« on: February 12, 2010, 00:27:21 »

Hi,
In my program I'm doing this :

Code:
GLUtessellator tesselator = GLU.gluNewTess();
//tesselator.gluTessNormal(0, 0, 1);
tesselator.gluTessCallback(GLU.GLU_TESS_BEGIN, tesscallback);
tesselator.gluTessCallback(GLU.GLU_TESS_VERTEX, tesscallback);
tesselator.gluTessCallback(GLU.GLU_TESS_COMBINE, tesscallback);
tesselator.gluTessCallback(GLU.GLU_TESS_END, tesscallback);
tesselator.gluTessCallback(GLU.GLU_TESS_ERROR, tesscallback);
//tesselator.gluTessCallback(GLU.GLU_TESS_BEGIN_DATA,tesscallback );
//tesselator.gluTessCallback(GLU.GLU_TESS_COMBINE_DATA,tesscallback );
GL11.glDeleteLists(priority, 1);
GL11.glNewList(priority, GL11.GL_COMPILE);
GL11.glPolygonOffset(1.0f, 1.0f);
GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);
GL11.glColor3f(color[0],color[1] ,color[2]);
GL11.glDisable(GL11.GL_POLYGON_SMOOTH);
GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL );
GL11.glEnable(GL11.GL_LINE_SMOOTH);
GL11.glTranslatef(0.0f, 0.0f,0.01f);
tesselator.gluTessProperty(GLU.GLU_TESS_WINDING_RULE, GLU.GLU_TESS_WINDING_NONZERO);
tesselator.gluBeginPolygon();
for(List<double[]> poligons_list:vertex){
tesselator.gluTessBeginContour();
for(double[] vertex_list:poligons_list){
tesselator.gluTessVertex(vertex_list, 0, vertex_list);
}
tesselator.gluTessEndContour();
}
tesselator.gluEndPolygon();
When it passes the function "gluTessBeginContour();", i got an error 100154:GLU_TESS_MISSING_END_CONTOUR.
And i don't know why i got this error ?

thanx for your help.
Logged
broumbroum
Prolific Timewaster
****
Posts: 285



WWW
« Reply #1 on: February 14, 2010, 06:12:11 »

what does the tesscallback contain ?

=> http://lwjgl.org/forum/index.php/topic,3028.msg17389.html#msg17389
Logged

Sf3JSwing project (Apache License) -  http://sf.net/projects/sf3jswing
Sf3jswing Project Forum - http://apps.sourceforge.net/phpbb/sf3jswing/ (recent updates)
Mercurial Repository - http://sf3jswing.hg.sourceforge.net/hgweb/sf3jswing/sf3jswing/summary
zik
Newbie
*
Posts: 9


« Reply #2 on: February 15, 2010, 09:11:06 »

It contains :
Code:
private GLUtessellatorCallback tesscallback = new GLUtessellatorCallback() {

public void vertexData(Object vertexData, Object polygonData) {}

public void vertex(Object vertexData) {
double[] vertex = (double[]) vertexData;
GL11.glVertex3d(vertex[0], vertex[1], vertex[2]);
}

public void errorData(int errnum, Object polygonData) {}

public void error(int errnum) {
String estring;
     estring = GLU.gluErrorString(errnum);
     System.err.println("Tessellation Error Number: " + errnum);
     System.err.println("Tessellation Error: " + estring);
}

public void endData(Object polygonData) {}

public void end() {
GL11.glEnd();
}

public void edgeFlagData(boolean boundaryEdge, Object polygonData) {}

public void edgeFlag(boolean boundaryEdge) {}

public void combineData(double[] coords, Object[] data, float[] weight, Object[] outData, Object polygonData) {}

public void combine(double[] coords, Object[] data, float[] weight, Object[] outData) {
double[] vertex = new double[6];
vertex[0]=coords[0];
vertex[1]=coords[1];
vertex[2]=coords[2];
   outData[0] = vertex;
   //for (int i = 3; i < 6; i++)
    //vertex[i] = weight[0] * ((double[]) data[0])[i] + weight[1]
    //* ((double[]) data[1])[i] + weight[2] * ((double[]) data[2])[i] + weight[3]
       //* ((double[]) data[3])[i];
}

public void beginData(int type, Object polygonData) {}

public void begin(int type) {
GL11.glBegin(type);
}
};
Edit:
NB : The list of polygons seem to be drawn correctly
Logged
broumbroum
Prolific Timewaster
****
Posts: 285



WWW
« Reply #3 on: February 17, 2010, 14:08:23 »

using the provided adapter should solve your problem :
Code:
GLUtessellatorCallbackAdapter tessCb = new GLUtessellatorCallbackAdapter() {

                                @Override
                                public void begin(int type) {
                                    GL11.glBegin(type);
                                }

                                @Override
                                public void vertex(Object vertexData) {
                                    float[] vert = (float[]) vertexData;
                                    GL11.glVertex2f(vert[0], vert[1]);
                                }

                                public void combine(double[] coords, Object[] data, float[] weight, Object[] outData) {
                                    for (int i = 0; i < outData.length; i++) {
                                        float[] combined = new float[6];
                                        combined[0] = (float) coords[0];
                                        combined[1] = (float) coords[1];
                                        /*combined[2] = (float) coords[2];
                                        for (int j = 3; j < 6; j++) {
                                        for(int d = 0; d < data.length; d++)
                                        combined[j] = weight[d] * data[d][j];
                                        }*/
                                        outData[i] = combined;
                                    }
                                }

                                @Override
                                public void end() {
                                    GL11.glEnd();
                                }
                            };
Logged

Sf3JSwing project (Apache License) -  http://sf.net/projects/sf3jswing
Sf3jswing Project Forum - http://apps.sourceforge.net/phpbb/sf3jswing/ (recent updates)
Mercurial Repository - http://sf3jswing.hg.sourceforge.net/hgweb/sf3jswing/sf3jswing/summary
zik
Newbie
*
Posts: 9


« Reply #4 on: February 18, 2010, 01:53:10 »

My tessCallbackadapter is the same as yours.
The only differences are :
- i have implemented the error callback to check any arrors
- i'm not working with 2d vertex, but 3d vertex,

I don't think it's the problem...?
Logged
broumbroum
Prolific Timewaster
****
Posts: 285



WWW
« Reply #5 on: February 18, 2010, 23:06:17 »

you dont use the lwgl glutesscallbackadapter whose source code is impl by default. And so data[] is lost within ur cbacks . have a look at lwgl src. Smiley
Logged

Sf3JSwing project (Apache License) -  http://sf.net/projects/sf3jswing
Sf3jswing Project Forum - http://apps.sourceforge.net/phpbb/sf3jswing/ (recent updates)
Mercurial Repository - http://sf3jswing.hg.sourceforge.net/hgweb/sf3jswing/sf3jswing/summary
zik
Newbie
*
Posts: 9


« Reply #6 on: February 22, 2010, 05:59:19 »

Ok, sorry, i didn't see the difference between GLUtessellatorCallbackAdapter and GLUtessellatorCallback !
Now i'm using GLUtessellatorCallbackAdapter :

Code:
private GLUtessellatorCallbackAdapter tesscallback = new GLUtessellatorCallbackAdapter(){
@Override
public void begin(int type) {
   GL11.glBegin(type);
}

@Override
public void vertex(Object vertexData) {
   double[] vert = (double[]) vertexData;
   GL11.glVertex3d(vert[0], vert[1],vert[2]);
}

public void combine(double[] coords, Object[] data, float[] weight, Object[] outData) {
   for (int i = 0; i < outData.length; i++) {
      double[] combined = new double[6];
      combined[0] = (double) coords[0];
      combined[1] = (double) coords[1];
      combined[2] = (double) coords[2];
      outData[i] = combined;
   }
}

@Override
public void end() {
   GL11.glEnd();
}

public void error(int errnum) {
   String estring;
   estring = GLU.gluErrorString(errnum);
   System.err.println("Tessellation Error Number: " + errnum);
   System.err.println("Tessellation Error: " + estring);
}
};


I got now the same errors.
But if I use the function tesselator.gluNextContour(GLU.GLU_EXTERIOR);, I don't get any errors.
Code:
tesselator.gluBeginPolygon();
for(List<double[]> poligons_list:vertex){
tesselator.gluNextContour(GLU.GLU_EXTERIOR);
//tesselator.gluTessBeginContour();
for(double[] vertex_list:poligons_list){
tesselator.gluTessVertex(vertex_list, 0, vertex_list);
}
//tesselator.gluTessEndContour();
}
tesselator.gluEndPolygon();
I don't understand why I can't use : tesselator.gluTessBeginContour(); and  tesselator.gluTessEndContour(); ?
Logged
broumbroum
Prolific Timewaster
****
Posts: 285



WWW
« Reply #7 on: February 22, 2010, 07:27:27 »

try tesselator.gluBeginPolygon(null); instead of    tesselator.gluBeginPolygon();
and /or switch those two lines :
Code:
tesselator.gluTessProperty(GLU.GLU_TESS_WINDING_RULE, GLU.GLU_TESS_WINDING_NONZERO);
tesselator.gluBeginPolygon();
so do I :
Code:
tesselator.gluBeginPolygon(null);
tesselator.gluTessProperty(GLU.GLU_TESS_WINDING_RULE, GLU.GLU_TESS_WINDING_NONZERO);
Logged

Sf3JSwing project (Apache License) -  http://sf.net/projects/sf3jswing
Sf3jswing Project Forum - http://apps.sourceforge.net/phpbb/sf3jswing/ (recent updates)
Mercurial Repository - http://sf3jswing.hg.sourceforge.net/hgweb/sf3jswing/sf3jswing/summary
zik
Newbie
*
Posts: 9


« Reply #8 on: February 22, 2010, 09:08:39 »

I can't call tesselator.gluBeginPolygon(null) because the function tesselator.gluBeginPolygon() with 1 argument doesn't exist.
And if I switch the 2 lines as you say :

Code:
tesselator.gluTessProperty(GLU.GLU_TESS_WINDING_RULE, GLU.GLU_TESS_WINDING_NONZERO);
tesselator.gluBeginPolygon();

 by

Code:
tesselator.gluBeginPolygon();
tesselator.gluTessProperty(GLU.GLU_TESS_WINDING_RULE, GLU.GLU_TESS_WINDING_NONZERO);

I have the same result, and always the same errors.


Edit:
The problem was: I was using tesselator.gluBeginPolygon(); instead of tesselator.gluTessBeginPolygon(null);
and tesselator.gluEndPolygon(); instead of tesselator.gluTessEndPolygon(); !
I don't know the difference between this 2 functions.
Thanks a lot Broumbroum ! Now there is no error !
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!