I am confused about how glPerspective works. I know in theory what it does but I am confused about it when trying to use it.
Here is my code (I used Pygame to create the window):
import pygame, sys
from OpenGL.GL import *
from OpenGL.GLU import *
pygame.init()
clock = pygame.time.Clock()
display = (800,600)
screen = pygame.display.set_mode(display,pygame.DOUBLEBUF|pygame.OPENGL)
# Perspective
gluPerspective(0, (display[0]/display[1]),0.1,50.0)
# Transformations
glScalef(0.5,0.5,0.5)
glTranslatef(0.0,0.0,0.0)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
glBegin(GL_POLYGON)
glVertex3f(-1.0,-1.0,0.0)
glVertex3f(1.0,-1.0,0.0)
glVertex3f(0.0,1.0,0.0)
glEnd()
pygame.display.flip()
clock.tick(120)
There are 2 specific things I am confused about:
I can only see the polygon when the field of view is at 0; it disappears at any higher value, even something like 0.001. Shouldn't it just get smaller? I am generally confused about this, doesn't a fov of 0 mean that we cannot see anything?
I have set the clipping range from 0.1 to 50, so in the current example the polygon drawn should not disappear since it is too close. I even set the glTranslatef to 0 for all dimensions to make sure it is below the lower clipping range. But it is still shown.
So many thanks in advance!