flickering geometry
Hi guys, i'm a beginner with OpenGL...
i'm trying to draw a translucent rectangle on my terrain, but the rectangle keeps flickering on one of triangle.
I have tried to render it as a triangle strip, but the problem still persist..
could some one please give me some pointers on how should i resolve the issue?
following is the code that i wrote to render the rectangle....
glDisable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING);
glDisable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBegin(GL_TRIANGLE_STRIP);
glColor4f(glowR, glowG, 0.0f, glowTransparency);
glVertex3d(MAP_SIZE_X, 0, 0);
glColor4f(glowR, glowG, 0.0f, glowTransparency);
glVertex3d(0, 0, 0);
glColor4f(glow2R, glow2G, 0.0f, glowTransparency);
glVertex3d(MAP_SIZE_X, 0, MAP_SIZE_Z);
glColor4f(glow2R, glow2G, 0.0f, glowTransparency);
glVertex3d(0, 0, MAP_SIZE_Z);
glEnd();
glDepthMask(GL_TRUE);
glEnable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);
glEnable(GL_LIGHTING);
this is the main file, with the projection matrices, viewport and stuff...
/**
* Render the scene
*/
void RenderScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
//set projection matrix and view volume
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho (0,1024,0,768, -100, 0);
glMultMatrixd(proj_homograph);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); //Reset modelview matrix for new frame.
if(isCalibrationStarted())
{
//calibrate the system
calibrateSystem();
}
else
{
glRotatef(Rotate, 0, 0, 1);
if(locateShape)
{
generateTerrain();
}
else
{
drawSun();
renderCalibration();
}
renderTerrain();
//Draw translucent objects last
if(!locateShape)
{
if(showTerrain)
{
renderWater();
renderEruption();
drawDawn();
}
else if(isWaterShown())
{
renderWater();
}
}
}//end of else
glFlush();
glutSwapBuffers();
}
//****************************** idle function *******************************
static void idle( void )
{
glutPostRedisplay();
}
//***************************** reshape function *******************************
static void reshape( int width, int height )
{
glViewport(0, 0, (GLint)width, (GLint)height);
}
void initialiseGraphics()
{
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(0,0);
glutInitWindowSize(1024,768);
projNo = glutCreateWindow("Sandbox Alive!");
glutFullScreen();
glutDisplayFunc(RenderScene);
glutIdleFunc( idle );
glutReshapeFunc( reshape );
ShowCursor(false);
//glutSetWindow(projNo);
glShadeModel(GL_SMOOTH); // Enable Smooth Shading
glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
glClearDepth(1.0f); // Depth Buffer Setup
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
glEnable(GL_CULL_FACE); // Enable Culling
glFrontFace(GL_CCW); // Draw CCW front-facing polygons only
glEnable(GL_POLYGON_SMOOTH); // Antialiasing Polygons
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
void initialise()
{
initialiseGraphics();
initialiseUI();
initialiseLight();
initialiseWater();
initialiseTerrain();
initialiseCloud();
initialiseValues();
initialiseVolcanoEngine();
//initialise projector homograph
Matrix temp = proj_computeHomograph(point3D, proj_point2D, 6);
temp = cam_computeHomograph(point3D, cam_point2D, 6);
initialiseCam();
previewCam();
cout << "done init" << endl;
}
//************************** Main Function *******************************
int main(int argc, char* argv[])
{
totalHorX = (abs(MAP_SIZE_X/stripeWidth) - rowIndex + 1)/incrementStep + 1;
totalVerZ = (abs(MAP_SIZE_Z/stripeWidth) - colIndex + 1)/incrementStep + 1;
glutInit(&argc, argv);
initialise();
glutMainLoop();
return 0;
}
this is a picture and a youtube video of the problem
http://img243.imageshack.us/my.php?image=snc00238hh3.jpg
actually the effect is more pronounced when viewed on the screen.
however, the screenshot couldn't capture the glitches at all
the rectangle is splitted into 2 triangles, wif the top triangle occupy the top left corner, top right corner and bottom right corner.
This triangle flickers alot, has those zebra stripes effect running across.
The other lower triangle has no issue at all
any help will be greatly appreciated!
http://img243.imageshack.us/my.php?image=snc00238hh3.jpg
actually the effect is more pronounced when viewed on the screen.
however, the screenshot couldn't capture the glitches at all
the rectangle is splitted into 2 triangles, wif the top triangle occupy the top left corner, top right corner and bottom right corner.
This triangle flickers alot, has those zebra stripes effect running across.
The other lower triangle has no issue at all
any help will be greatly appreciated!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement