http://www.hindbrain.net/example.jpg
Is there a way to get less ragged edges on such a shape?
Here's the essential code:
GLdouble shape[4][3] = {
{-3, 3.8, 0},
{ 0, 3.0, 0},
{ 3, 3.8, 0},
{ 0, 3.7, 0}
};
int InitGL(GLvoid) {
glShadeModel(GL_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
return TRUE;
}
GLuint compile(void) {
GLuint id = glGenLists(1);
if(!id) return id;
GLUtesselator *tess = gluNewTess();
if(!tess) return 0;
gluTessCallback(tess, GLU_TESS_BEGIN, (void (CALLBACK *)())
tessBeginCB);
gluTessCallback(tess, GLU_TESS_END, (void (CALLBACK *)())tessEndCB);
gluTessCallback(tess, GLU_TESS_ERROR, (void (CALLBACK *)())
tessErrorCB);
gluTessCallback(tess, GLU_TESS_VERTEX, (void (CALLBACK *)())
tessVertexCB);
glNewList(id, GL_COMPILE);
glColor3ub(0, 255, 255);
gluTessBeginPolygon(tess, 0);
gluTessBeginContour(tess);
gluTessVertex(tess, shape[0], shape[0]);
gluTessVertex(tess, shape[1], shape[1]);
gluTessVertex(tess, shape[2], shape[2]);
gluTessVertex(tess, shape[3], shape[3]);
gluTessEndContour(tess);
gluTessEndPolygon(tess);
glEndList();
gluDeleteTess(tess);
return id;
}
int draw(GLvoid) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f, -3.5f, -6.0f);
glEnable( GL_BLEND );
glEnable(GL_POLYGON_SMOOTH);
glCallList(listId1);
glDisable(GL_POLYGON_SMOOTH);
glDisable( GL_BLEND );
return TRUE;
}
thanks,
Bob
Use full screen anti-aliasing rather than polygon smoothing.
If you must use polygon smoothing, use the correct blend method (src
alpha saturate, one) and order your polygons from front to back.
--
Andy V
You need to enable full-screen antialiasing, this is done
when you create the window so how you do it will depend
on whatever you're using to make your windows. Basically
you choose a pixel format with multisampling.
Whatever you do don't try to use polygon smoothing, it's
obsolete and opens up a world of pain.
--
<\___/>
/ O O \
\_____/ FTB.
http://www.topaz3d.com/ - New 3D editor for real time simulation