I know it should be simple, but antialiasing using GL_POLYGON_SMOOTH doesn’t work for me.
I render the scene offscreen and then write the data to a tga file (see code). All settings are as they should be (I think). So what am I doing wrong? Any help will be appreciated.
Here are the relevant bits from my code:
glDrawBuffer(GL_BACK);
// transformations
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(627, -2.5, 260, 627, -2.5, 160, 1, 0, 0);glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(31, (float) width / (float) height, 0.005, 2000);// settings
glShadeModel(GL_SMOOTH);
glBlendFunc(GL_SRC_ALPHA_SATURATE, GL_ONE);
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
glEnable(GL_BLEND);
glEnable(GL_POLYGON_SMOOTH);
glDisable(GL_DEPTH_TEST);glClearColor(0.0, 0.0, 0.0, 0.0);
// draw scene
glClear(GL_COLOR_BUFFER_BIT);glColor4f(1, 1, 0, 1);
glBegin(GL_POLYGON);
glVertex3f(590, 20, 2);
glVertex3f(620, -33, 2);
glVertex3f(660, 0, 2);
glEnd();glColor4f(1, 0, 0, 1);
glBegin(GL_POLYGON);
glVertex3f(580, -80, 0);
glVertex3f(670, 33, 0);
glVertex3f(630, -70, 0);
glEnd();[…]
/* Here I check some OpenGL variables: GL_RED_BITS, GL_GREEN_BITS,
GL_BLUE_BITS and GL_ALPHA_BITS are 8 each, GL_RGBA_MODE, GL_BLEND
and GL_POLYGON_SMOOTH are true, GL_DEPTH_TEST is false.
The OpenGL version string is “1.2 Mesa 3.2” */glFlush();
glBuffer->makeCurrent();
glFinish();// read binary data
binData = new unsigned char[widthheight3];
glReadBuffer(GL_BACK);
glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, binData);// make tga header
imgData = new unsigned char[widthheight3 + 18];
imgData[0] = 0;
imgData[1] = 0;
imgData[2] = 2;
imgData[12] = width%256;
imgData[13] = width>>8;
imgData[14] = height%256;
imgData[15] = height>>8;
imgData[16] = 24;
imgData[17] = 32;// write tga data
for (int i=0; i<widthheight; i++) {
imgData[18+i3] = binData[i*3+2];
imgData[18+i3+1] = binData[i*3+1];
imgData[18+i3+2] = binData[i*3];
}
delete binData;
[…]
[This message has been edited by Shagrath (edited 01-09-2001).]