gllRotatef does not produce a rotation

Hi, I am trying to rotate a simple square, but I am not seeing nay differences when I call glrotatef. My code:

glClear (GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
glOrtho (-1,1,-1,1,1,20);
float yRotationAngle = 0.3f;
glTranslatef(0.0f, 0.0f, -5.0f); 
glRotatef (yRotationAngle, 0, 1, 0);
glBegin (GL_QUADS);
		glColor3f (1,0,0); glVertex3f (.75,.75,0);
		glColor3f (0,1,0); glVertex3f (.75,-.75,0);
		glColor3f (0,0,1); glVertex3f (-.75,-.75,0);
		glColor3f (1,1,1); glVertex3f (-.75,.75,0);

	glEnd ();

Outside it, I have this call to glViewport inside X11 setup code:

do {
		XNextEvent (dpy, &xev);
 		if (xev.type == Expose) {
			XGetWindowAttributes (dpy,win,&gwa);
			glViewport (0,0,gwa.width,gwa.height);
			draw ();
			glXSwapBuffers (dpy,win);
		}

Check your glMatrixMode - from your code, it looks like you’re trying to rotate the projection matrix.

If only one matrix is being modified, it won’t matter which one. The distinction only matters for lighting.

But based upon the above code, nothing should be rendered. The glOrtho call maps Z=-1 to the near plane and Z=-20 to the far plane, but the quad is being drawn in the Z=0 plane, so it should fail the near plane test.

I changed the code to:

float yRotationAngle = 0.3f;
glTranslatef(0.0f, 0.0f, 5.0f); 
glRotatef (yRotationAngle, 0, 1, 0);
glBegin (GL_QUADS);
		glColor3f (1,0,0); glVertex3f (.75,.75,0);
		glColor3f (0,1,0); glVertex3f (.75,-.75,0);
		glColor3f (0,0,1); glVertex3f (-.75,-.75,0);
		glColor3f (1,1,1); glVertex3f (-.75,.75,0);

	glEnd ();

Which also gives me an empty window. However, removing the gltranslatef, does produce a window with a quad on it. However, is not rotated.

Changing
glTranslatef(0.0f, 0.0f, 5.0f); to

glTranslatef(0.0f, 0.0f, -5.0f); did not help, just removing it makes the quad to show up. And now there is no glOrtho

I’d like to point out that glRotatef’s angle parameter is in degrees, not radians. The above code constructs a rotation of 0.3 degrees, which is probably too small to be noticeable.

Hi. I did change the yRotationAngle from 0.3f to 30.3f, which produced different result, but it certainly did not like a rotation to me:

This last one is also with 30 degress, but it happens after I close the screenshot capturing program. If I call it again and also close it a second time, it return to the form os screenshot n°2:

You’re rotating about the Y axis, which is initially vertical. I suspect you probably want a rotation about the Z axis.