The tokens accepted by glBegin are
- GL_POINTS
- GL_LINES
- GL_TRIANGLES
- GL_TRIANGLE_FAN
- GL_TRIANGLE_STRIP
- GL_QUADS
- GL_QUAD_STRIP
and
- GL_POLYGON
The token used by you, GL_LINE (not the missing trailing S) is not valid for glBegin.
The statement glEnd;
will evaluate the address of the function glEnd and silently discard the result. Could it be, that you have a Pascal or Delphi background? In C like languages you have to add a matched pair of parentheses to make it a function call. Functions that don't take a parameter are called with an empty pair of parentheses. E.g. in your case glEnd();
.
Not related to your problem. All of the code in resizeGL
should go to the head of paintGL
(use the widget's width()
and height()
getters). Also what you have in initializeGL
belongs to paintGL
.
The proper use of initializeGL
is to do one-time initialization, like loading textures, and shaders, preparing FBOs and such.
resizeGL
is meant to re-/initialize stuff that depends on the window's size and which is quite time consuming to change, like renderbuffers and/or textures used as attachment in FBOs used for window sized post-processing or similar. Setting the projection matrix does not belong there, and neither does the viewport. Those go into paintGL
.
glDepthFunc, glClearColor and glClearDepth directly influence the drawing process and as such belong with the drawing code.
Also you should not use the immediate mode (glBegin … glEnd) at all. It's been outdated ever since OpenGL-1.1 was released over 15 years ago. Use Vertex Arrays, with the possible addition of Buffer Objects.