PDA

View Full Version : no image after rectf



Gary Bennett
12-05-2011, 11:08 AM
The code works until The following code is inserted before the image code is run.

glColor3f (0.2, 0.2, 0.2);
glRectf(0.0f,0.00f, 120.0f, 60.0f);
glEnd();

All I get is the gray rectangle. If I comment out the above code all image code works fine.

What am I missing?

BionicBytes
12-05-2011, 02:08 PM
You are not supposed to have glEnd after glRect.
GlRect by definition is the following series of commands:
glBegin (gl_Polygon)
glVertex ...
glVertex ...
glVertex ...
glVertex ...
glEnd

Gary Bennett
12-08-2011, 08:47 AM
I have the same results after removing the glEnd(). I found by accident that the

glColor3f (0.2, 0.2, 0.2);
glRectf(0.0f,0.00f, 120.0f, 60.0f);

is after the image code, everything is displayed correctly.
Why does it matter?

BionicBytes
12-08-2011, 12:10 PM
May be its in between a glBegin and glEnd already. Can't say without seeing all the drawing code.

Gary Bennett
12-09-2011, 07:11 AM
Somehow I missed that glRectf cannot be in between a glBegin and glEnd. I have not found an error yet. I will keep looking. I thought if such a condition existed I would get some kind of error. If there was any kind of error I thought I would notified somehow, compiler error or something. Do I have to look for errors?

BionicBytes
12-10-2011, 04:03 PM
It won't be a compiler error but an OpenGL error. You have to call glGetError every frame. In fact in you keep calling that function continuously in a loop until it returns back no error. You might find it returns back invalid operation for such violations such as glRect between glBegin and glEnd.