PDA

View Full Version : (Help, Please?) Tesselators and Texturing Tesselators



Quinn
12-01-2005, 01:04 PM
Hello, I want to thank anyone helps me in advance, but I'm hitting a problem with all compilers that are utilizing OpenGL+Glut. Tesselators and Quadrics both, are implying a LoadException error, when I am running Visual Studio .Net 2003. Though, when running the vsvars32.bat, included in the common tools of Visual Studio, the application compiled and executes flawlessly -- which coherently, is my first issue. I've tried looking up on the internet, for someone having a similar problem, and it seems like nobody else is. Any insight?

My second problem is that I am trying to apply a texture to a tesselated object. Below are snippets from my code --- could anyone please help me with what I would want to set my textcoords, or what not to...


double cubeside[4][3] =
{
8, 0, 8,
8, 0, -8,
-8, 0, -8,
-8, 0, 8
};

double window[14][3] =
{
0, 0, 2,
-1.5, 0, 1.7,
-1.7, 0, 0.5,
-1.7, 0, -2.0,
1.7, 0, -2.0,
1.7, 0, 0.5,
1.5, 0, 1.7,

0, 0, 2,
-1.5, 0, 1.7,
-1.7, 0, 0.5,
-1.7, 0, -2.0,
1.7, 0, -2.0,
1.7, 0, 0.5,
1.5, 0, 1.7,
};
tess = gluNewTess();

gluTessCallback(tess, GLU_TESS_VERTEX, (TESSCALLBACK)vertexCallback);
gluTessCallback(tess, GLU_TESS_BEGIN, (TESSCALLBACK)beginCallback);
gluTessCallback(tess, GLU_TESS_COMBINE, (TESSCALLBACK)combineCallback);
gluTessCallback(tess, GLU_TESS_END, endCallback);
glNewList(startlist + 1, GL_COMPILE);
glColor3f(0.0f, 0.0f, 0.0f);
glPushMatrix();
glRotated(90,0.0,0.0,1.0);
gluTessProperty(tess, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_POSITIVE);
gluTessBeginPolygon(tess, NULL);
gluTessBeginContour(tess);
gluTessVertex(tess, cubeside[0], cubeside[0]);
gluTessVertex(tess, cubeside[1], cubeside[1]);
gluTessVertex(tess, cubeside[2], cubeside[2]);
gluTessVertex(tess, cubeside[3], cubeside[3]);
gluTessEndContour(tess);
gluTessBeginContour(tess);
gluTessVertex(tess, window[0], window[0]);
gluTessVertex(tess, window[1], window[1]);
gluTessVertex(tess, window[2], window[2]);
gluTessVertex(tess, window[3], window[3]);
gluTessVertex(tess, window[4], window[4]);
gluTessVertex(tess, window[5], window[5]);
gluTessVertex(tess, window[6], window[6]);
gluTessEndContour(tess);
gluTessEndPolygon(tess);
glPopMatrix();
glEndList();
/************************************************** **********************/
/* Function:
Tesselator Callback: Begin */
/************************************************** **********************/
void CALLBACK beginCallback(GLenum which)
{
glBegin(which);
}

/************************************************** **********************/
/* Function:
Tesselator Callback: End */
/************************************************** **********************/
void CALLBACK endCallback(void)
{
glEnd();
}

/************************************************** **********************/
/* Function:
Tesselator Callback: Vertex */
/************************************************** **********************/
void CALLBACK vertexCallback(GLvoid *vertex)
{
const GLdouble *pointer;
pointer = (GLdouble *) vertex;

//if ((GLdouble*) vertex == cubeside[0]);
// glTexCoord2f(1.0, 1.0);
//if ((GLdouble*) vertex == cubeside[1])
// glTexCoord2f(1.0, 0.0);
//if ((GLdouble*) vertex == cubeside[2])
// glTexCoord2f(0.0, 0.0);
//if ((GLdouble*) vertex == cubeside[3])
// glTexCoord2f(1.0, 0.0);

glVertex3dv(pointer);

}
/************************************************** **********************/
/* Function:
Tesselator Callback: Combine */
/************************************************** **********************/
void CALLBACK combineCallback(GLdouble coords[3],
GLdouble *vertex_data[4],
GLfloat weight[4], GLdouble **dataOut )
{
GLdouble *vertex;
int i;

vertex = (GLdouble *) malloc(6 * sizeof(GLdouble));

vertex[0] = coords[0];
vertex[1] = coords[1];
vertex[2] = coords[2];

for (i = 3; i < 6; i++)
vertex[i] = weight[0] * vertex_data[0][i]
+ weight[1] * vertex_data[1][i]
+ weight[2] * vertex_data[2][i]
+ weight[3] * vertex_data[3][i];
*dataOut = vertex;
}Basically, I've interpreted that the texture coordinates are to be handled in the VertexCallback, but forsakenly, I'm too retarded to understand how to manipulate it to handle it correctly, please help!

Thank you, again... in advance.

Quinn
12-03-2005, 10:09 AM
Ok, just tried putting a #pragma unmanaged before my tesselator declaration, and now I can utilize Visual Studio .Net to handle my compiles, without the type load. I still haven't figured out my texture coordinate issue.