Using pyopengl, I am trying to create a cylinder. The top of the cylinder is not circular whilst the bottom is as shown in the image linked below. I would like to know how to fix this, if its the way I have coded it or simply the way I have done it does not work with pyopengl. I am using Pygame 1.9.2, Python 3.5 and PyOpenGL-3.1.0.
https://i.stack.imgur.com/KYPLY.jpg
import pygame
from pygame.locals import *
from OpenGL.GL import *
from OpenGL.GLU import *
def securityCamera(radius,halflength,slices):
glBegin(GL_TRIANGLES)
for i in range(1,slices+1):
angleSize=(2*math.pi)/slices
theta=i*angleSize
nextTheta=(i+1)*angleSize
glColor3fv((0/256,0/256,0/256))
glVertex3f(radius*math.cos(nextTheta), halflength, radius*math.cos(nextTheta))
glVertex3f(radius*math.cos(theta), halflength, radius*math.sin(theta))
glVertex3f(0.0, halflength, 0.0)
glVertex3f(radius*math.cos(nextTheta), -halflength, radius*math.sin(nextTheta))
glVertex3f(radius*math.cos(theta), -halflength, radius*math.sin(theta))
glVertex3f(0.0, -halflength, 0.0)
glEnd()
glBegin(GL_QUADS)
for i in range(1,slices+1):
angleSize=(2*math.pi)/slices
theta=i*angleSize
nextTheta=(i+1)*angleSize
glColor3fv((256/256,256/256,256/256))
glVertex3f(radius*math.cos(theta), halflength, radius*math.sin(theta))
glVertex3f(radius*math.cos(nextTheta), halflength, radius*math.cos(nextTheta))
glVertex3f(radius*math.cos(theta), -halflength, radius*math.sin(theta))
glVertex3f(radius*math.cos(nextTheta), -halflength, radius*math.sin(nextTheta))
glEnd()