PDA

View Full Version : GL_SMOOTH & normals issues



mesomam
03-11-2011, 06:49 AM
Hi,
I have been looking all over the web for a way to use GL_Smooth in my project and I have found out that it has something to do with vertex normals,
but i wasnt able to make it work for me, can someone in here help me or direct me please to some guide that will tell me how to use them?
My drawing function looks like this:


glClear (GL_COLOR_BUFFER_BIT);
glPushMatrix();

glLoadIdentity();

x = radius * cos(rotX) * cos(rotY);
y = radius * sin(rotX);
z = -radius * cos(rotX)* sin(rotY);

gluLookAt(x,y,z,0,0,0,0,1,0);

glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glShadeModel( GL_SMOOTH );

glutSolidSphere(.5, 20, 20);

glPopMatrix();
glutSwapBuffers();

when everything else that i need to do works good(I needed to create a 3d "Flythrough mode" using the arrow keys which worked, the the only problem i have now is making it use the GL_SMOOTH Shading feature)

Thanks a lot (=

McLeary
03-11-2011, 07:14 AM
Didn't get the problem. What your code does is to set up the camera location, this is not to do with vertex normals of your model. What exactly you are getting when GL_SMOOTH is enabled?

I think you should know that GL_SMOOTH requires a per-vertex normal to work properly, maybe that's is the problem.

take a look at glNormal (http://www.khronos.org/opengles/documentation/opengles1_0/html/glNormal.html)

mesomam
03-11-2011, 11:18 AM
thanks for the quick answer,
no i wasnt able to do that right yet
am i suppose to calculate the normal for each vertex or will it be enough to write:


glNormal3f(curr.x,curr.y,curr.z);
glVertex3f(curr.x, curr.y, curr.z);
beacuse if it is so simple than i have encountered a problem with the lighting now - it doesnt look as it should have been( i need to make a "Diffuse reflection" light model)
and again thanks you really helped me getting in the right direction