Hi, I want to put GLSL shader in my game to get realistic shadows and lighting. But when I use polygons GL_POLYGON ,they are totally black. Only thing that works OK with shader is glutSolid bullshit like glutSolidTeapot and glutSolidCube and so on. So I wanted to know the source of glutSolidCube function and I didnt found the source but I found that it somehow calculates the normals of each polygon. My question is how to attach normal to polygon. I don't want to use some default defined bullshit cause it is useless when you are making custom maps nad objects, it is good only for testing ,that's all (unfortunately each tutorial I've seen uses it). All I want is to know:
1.when I have some polygon using GL_POLYGON, how to give normals to it.
2.if you know 1., maybe you know how it would be with gluTesselator?

//google "cross product" for how these calculations work
   GLvoid CalculateVectorNormal(GLfloat fVert1[], GLfloat fVert2[],

                             GLfloat fVert3[], GLfloat *fNormalX,
                             GLfloat *fNormalY, GLfloat *fNormalZ)
    GLfloat Qx, Qy, Qz, Px, Py, Pz;

   Qx = fVert2[0]-fVert1[0];
   Qy = fVert2[1]-fVert1[1];
   Qz = fVert2[2]-fVert1[2];
   Px = fVert3[0]-fVert1[0];
   Py = fVert3[1]-fVert1[1];
   Pz = fVert3[2]-fVert1[2];

   *fNormalX = Py*Qz - Pz*Qy;
   *fNormalY = Pz*Qx - Px*Qz;
   *fNormalZ = Px*Qy - Py*Qx;



   // Calculate the vector normal coming out of the 3D polygon.
   CalculateVectorNormal(fVert1, fVert2, fVert3, &fNormalX,
                         &fNormalY, &fNormalZ);
   // Set the normal vector for the polygon
   glNormal3f(fNormalX, fNormalY, fNormalZ);


This question has already been answered. Start a new discussion instead.