Drawing 2D

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?

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))

i got it, i was using a depth buffer
sorry for annoying

No problem, that is what we are for :slight_smile: