Problem lighting a sphere

Started by porjo, April 21, 2008, 12:22:23

Previous topic - Next topic

porjo

Firstly I'm new to OpenGL, so just learning.

I have my lighting setup the way I want and can render a nice looking sphere using a gluSphere which is properly shaded etc. I've just tried switching out the gluSphere for a sphere generated using the method of subdividing a 20 sided polyhedron (http://glprogramming.com/red/chapter02.html#name8 - basically cut-and-paste from the example there straight into my code).

Now I only get solid color on the sphere - not even flat shading!? If I comment out the line calling the subdivision method, and uncomment the gluSphere draw method, it looks OK. How can I get smooth shading on the subdivision sphere?

I read up on how the lighting system works and about normal vectors etc but I can't see what I'm doing wrong. There's some stuff there about vertex winding - clockwise vs counter-clockwise affecting which face becomes the 'front' & 'back', but I'm not really sure where to start with that. I tried setting the lighting model to be two-sided, but that didn't make any difference.

Any pointers would be appreciated. :P

porjo


I've found that by disabling GL11.GL_CULL_FACE , everything now renders properly...so I'm guessing that what I had drawn was inside-out, with the 'front' faces on the inside and the 'back' faces on the outside!!??

I'm still trying to get my head around the whole front/back, clockwise/counterclockwise thing. How could I easily change the draw function to flip the faces around?