Friday, 27 September 2013

SolidCone not visible in OpenGL

SolidCone not visible in OpenGL

I am new to OpenGL so I imagine that I have overlooked something simple
but I have seemed to have lost my cone. In the code below I set up my
viewport and its glOrtho. Then I try to draw a cone. It should be placed
in the middle of the bottom edge of the window, it should also follow the
mouse so that the base is facing the mouse. But the cone never appears. I
have tried different translations and different rotations, I have tried to
take those out, I have even tried to give it color to make it appear, but
nothing. So where is my cone?
###called when the window is created, or reshaped
def reshape(self, height, width):
if height >= 90 and width >= 90:
self.index_location_dict =
self.create_index_location_dict(height, width)
self.height = height
self.width = width
glViewport(0, 0, height, width)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
glOrtho(0.0, height, width, 0.0, -20.0, 20.0)
glEnable(GL_DEPTH_TEST)
else:
self.game_over = True
###called by the a display function
def draw_cannon(self):
glPushMatrix()
glTranslatef(self.width/2, 0.0, 0.0)
rotation_angle = self.cannon_rotation()
glRotatef(rotation_angle, 0, 0, 1)
glutSolidCone(10, 20, 50, 50)
glPopMatrix()

No comments:

Post a Comment