Original Post
I have a basic program to draw a lighted red cube on the screen with one light source, with all sides having the same material. However, it is not working. I had a mucc more complecated program, but when it didn''t work i methodicly took out pieces to find the problem but cam up with nothing. I''m am new to OpenGL programming, but i thought i was beyond this kind of simple lighting, so what is wrong with this program? (its a GLUT console app that is supposed to draw a green cube on the screen, but draws merely a white square.
[ccode]
#include "GL/glut.h"
GLfloat vertices[][3] = {{-1,-1,-1},{1,-1,-1},{1,1,-1},{-1,1,-1},{-1,-1,1},{1,-1,1},{1,1,1},{-1,1,1}};
GLfloat normals[][3] = {{-1,-1,-1},{1,-1,-1},{1,1,-1},{-1,1,-1},{-1,-1,1},{1,-1,1},{1,1,1},{-1,1,1}};
// the light we will use
GLfloat LightAmbient[]= { 0.5f, 0.5f, 0.5f, 1.0f };
GLfloat LightDiffuse[]= { 1.0f, 1.0f, 1.0f, 1.0f };
GLfloat LightPosition[]= { 4.0f, 0.0f, 2.0f, 1.0f };
// the material
GLfloat MaterialAmbient[] = {1,0,0,1};
GLfloat MaterialDiffuse[] = {1,0,0,1};
GLfloat MaterialSpecular[] = {1,0,0,1};
GLfloat MaterialShininess = 100;
void polygon(int a, int b, int c, int d)
{
// draw one square from vertex array
glBegin(GL_POLYGON);
glNormal3fv(normals ' Target=_Blank>Link
RELIGION IS THE ROOT OF ALL EVIL