PDA

View Full Version : Drawing 2D



AhmedSabry
02-13-2008, 04:49 AM
Hello All
I am beginner in OpenGL, and I am coding some 2D staff now, I had initialized OpenGL by
gluOrtho2D(-10.0f,10.0f,-10.0f,10.0f);
Then in my render function I tried the following
glLineWidth(3);
glBegin(GL_LINES);
glColor3f(1.0f,1.0f,0.0f);//Yellow Line
glVertex2f(7.0f,3.0f);
glVertex2f(5.0f,-3.0f);
glColor3f(1.0f,0.0f,0.0f);//Red Line
glVertex2f(5.0f,3.0f);
glVertex2f(7.0f,-3.0f);
glEnd();
And it works fine and I got the 2 lines drawn
But for my surprise I got the yellow line drawn over the red line, which should be in contrast
Is there any one have explanation?

Zengar
02-13-2008, 05:06 AM
What do you mean by "in contrast"? If you want the second (red) line to occlude the first one, try disabling the depth test (glDisable(GL_DEPTH_TEST))

AhmedSabry
02-13-2008, 05:15 AM
i got it, i was using a depth buffer
sorry for annoying

Zengar
02-13-2008, 05:19 AM
No problem, that is what we are for :)