OpenGL light test

Free Image Hosting at www.ImageShack.us
I'm having trouble with OpenGL lighting, and want to determing if its a driver problem, or a code problem. I had this same problem in the last pyweek too... Could any willing volunteers please run the below code, and tell me if they get a flat shaded or a lit sphere? In the attached screenshot, you can see that there is clearly no lighting effects happening... If anyone can tell me what I'm doing wrong, I'd appreciate the help...
#!/usr/bin/python2.5
import pygame
from pygame.locals import *
from OpenGL.GL import *
from OpenGL.GLU import *

        
def main():
    pygame.display.set_mode((1024,768), DOUBLEBUF|OPENGL)

    #GL Setup
    glShadeModel(GL_SMOOTH)
    glEnable(GL_DEPTH_TEST)
    glDepthFunc(GL_LEQUAL)
    glClearDepth(1.0)

    #Viewport Setup
    glViewport(0, 0, 1024, 768)
    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    gluPerspective(45.0, 1024.0/768, 0.1, 100)
    glMatrixMode(GL_MODELVIEW)
    glLoadIdentity()

    #sphere setup
    q = gluNewQuadric()
    glFrontFace(GL_CCW)
    gluQuadricTexture(q, GL_TRUE)
    gluQuadricNormals(q, GLU_FLAT)
    gluQuadricOrientation(q, GLU_OUTSIDE)

    #lighting setup
    glEnable(GL_LIGHTING)
    glEnable(GL_LIGHT1)
    glLightfv(GL_LIGHT1, GL_AMBIENT, (0.0, 0.0, 0.0, 1.0))
    glLightfv(GL_LIGHT1, GL_DIFFUSE, (1.0, 1.0, 1.0, 1.0))
    glLightfv(GL_LIGHT1, GL_SPECULAR, (1.0, 1.0, 1.0, 1.0))
    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (1.0, 1.0, 1.0, 1.0))
    glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, (0.0, 0.0, 0.0, 1.0))
    glEnable(GL_COLOR_MATERIAL)
    glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE)
    glLightfv(GL_LIGHT1, GL_POSITION, (0.0, 0.0, 0.0))

    while True:
        glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
        glLoadIdentity()
        glTranslatef(0.0, -1.0, -5.0)
        gluSphere(q, 1.0, 32, 32)

        pygame.display.flip()
        for event in pygame.event.get():
            if event.type in (QUIT, KEYDOWN):
                return

if __name__ == "__main__":
    main()


(log in to comment)

Comments

Hello,

When I run that code, I get a completely white (not grey) circle.

Hope that helps. :/
Try this:

glLightfv(GL_LIGHT1, GL_POSITION, (0.0, 0.0, 0.0, 1.0))

Without the 1.0 on the end, OpenGL (actually PyOpenGL) thinks you want a directional light source.
Hey, I have the same problem :/
I hope this fixes it!
Okay, it does fix the lighting problem that way :D

Now I have a different lighting problem though...
I'll post again later after I've uploaded my pre-week game so you can see what I mean.

Basically, if I use one texture it causes my lighting to go really funky, but other textures are fine, *shrug*
Cool that fixed the problem. Thanks aerojockey! I don't know how I missed that!