Please help,
I have a two part question -> not related but I wanted to only place one posting. I hope someone can help.
The first question (probably the easiest):
What is the quickest way to display a String/text to the screen with OpenGL (using GLUT)? I want the text to be stationary (global) and not move when the user rotates the rendered image.
The second question:
Currently I am tessellating a non-convex polygon but I don’t know how to place the correct normal for the lighting of the tessellated result. Can anybody tell me how this is done?
Below is a snippet of my code (in Java JOGL but the idea should carry):
tessellCallBack tessCallback = new tessellCallBack(gl, glu);
GLUtessellator tobj = glu.gluNewTess();
glu.gluTessCallback(tobj, GLU.GLU_TESS_VERTEX, tessCallback);
glu.gluTessCallback(tobj, GLU.GLU_TESS_BEGIN, tessCallback);
glu.gluTessCallback(tobj, GLU.GLU_TESS_END, tessCallback);
glu.gluTessCallback(tobj, GLU.GLU_TESS_ERROR, tessCallback);
glu.gluTessCallback(tobj, GLU.GLU_TESS_COMBINE, tessCallback);
...
// Where faces is a Vector of Face Objects
// that contain X, Y, Z and normal[3]
for (int i = 0; i < faces.size(); i++) {
double[][] outPts = face.getOutPtsArray();
// Get the NORMAL for this Shape (FACE)
norm = face.getNormal();
gl.glNormal3f(norm[0], norm[1], norm[2]);
glu.gluTessBeginPolygon(tobj, null);
glu.gluTessBeginContour(tobj);
for (int j = 0; j < outPts.length; j++) {
glu.gluTessVertex(tobj, outPts[j], 0, outPts[j]);
}// End of INNER FOR-LOOP
glu.gluTessEndContour(tobj);
glu.gluTessEndPolygon(tobj);
}// End of OUTER FOR-LOOP
glu.gluDeleteTess(tobj);
...
// Inner Class Implementing Callbacks for Tessellation
class tessellCallBack implements GLUtessellatorCallback {
// I believe the problem is here since this is
// called when vertices intersect but am unsure
public void combine(double[] coords, Object[] data, float[] weight, Object[] outData) {
double[] vertex = new double[3];
vertex[0] = coords[0];
vertex[1] = coords[1];
vertex[2] = coords[2];outData[0] = vertex;
}// End of combine()
}// End of Inner Tessellation Class
Thanks to anyone with any help/hints.