OpenGL (ES) -- Rotating a circle renders only half the circle
I have successfully drawn circles and applied translations and scaling on them. When I rotate a circle by only 1 degree (or any degree), a half circle is drawn. I am using an ortho perspective. Why is this?
translateX = (float) (ratio * (xCoor - windowWidth / 2)) / (windowWidth / 2);
translateY = (float) (-(yCoor - windowHeight / 2)) / (windowHeight / 2);
gl11.glBindBuffer(GL11.GL_ARRAY_BUFFER, vertexPointerCircleHR);
gl11.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, indexPointerCircleHR);
gl11.glVertexPointer(3, GL10.GL_FLOAT, 0, 0);
circleRotation++;
gl11.glPushMatrix();
gl11.glColor4f(...);
gl11.glScalef(...);
gl11.glTranslatef(translateX, translateY, 0);
gl11.glRotatef(1,translateX,translateY, 0); //or circleRotation
gl11.glDrawElements(GL11.GL_TRIANGLE_FAN, verticesCircle,
GL11.GL_UNSIGNED_SHORT, 0);
gl11.glPopMatrix();
Thank开发者_如何学Cs for reading.
glRotate
receives the angle and a 3d vector that will be the axis of rotation (Axis-angle representation).
If you're using orthogonal projection I assume you're doing a 2D rotation in front of the camera, and normally that's around the Z axis (0, 0, 1) or maybe (0, 0, -1).
You should probably replace your call with glRotatef(circleRotation, 0, 0, 1)
.
Obviously without a texture or different vertex colors you won't notice a thing.
精彩评论