I have searched alot this site but couldn\'t exactly find what is exactly my problem. Most of the similar problems had used console and the glut library. But since I\'m new to O
Since edge flags
are deprecated in modern OpenGL, I would avoid using a polygon fill mode to draw the outlines. If I understand your screenshot correctly, you are getting lines on the interior edges of the two triangles used to draw your rectangle.
Instead draw a red GL_LINE_LOOP
that uses the 4 corners of your rectangle... this is the preferred technique for portability reasons, since GL_QUADS
are also deprecated.
glColor3f (1.0f, 0.0f, 0.0f);
glBegin (GL_LINE_LOOP);
glVertex3f (RectangleToDraw.at (0), RectangleToDraw.at (1), -1.0f);
glVertex3f (RectangleToDraw.at (0), RectangleToDraw.at (3), -1.0f);
glVertex3f (RectangleToDraw.at (2), RectangleToDraw.at (3), -1.0f);
glVertex3f (RectangleToDraw.at (2), RectangleToDraw.at (1), -1.0f);
glEnd ();
Also, your screenshot appears to be suffering from attempting to texture the outline. Disable GL_TEXTURE_2D
before you draw your lines.