Elfinitiy
09-12-2011, 10:07 AM
Ok so I have a cube
static const GLfloat vert[] =
{
0.5f, 0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f,
0.5f, 0.5f, 0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f,
0.5f, 0.5f, 0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f,
-0.5f, 0.5f, 0.5f, -0.5f, 0.5f, -0.5f, -0.5f, -0.5f, -0.5f, -0.5f, -0.5f, 0.5f,
-0.5f,-0.5f, -0.5f, 0.5f, -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, -0.5f, -0.5f, 0.5f,
0.5f, -0.5f, -0.5f, -0.5f, -0.5f, -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f
};//Quad
and its normals
static const GLfloat norm[] =
{
0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1,
-1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0,
0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0,
1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0,
0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0,
0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1
};
But whenever I look straight down everything turns black.
I think it's Normal problems,but I checked and they seem right.
static GLfloat material_specular[] = {1.0,1.0,1.0,1.0,};
static GLfloat material_shininess = 5.0;
static GLfloat light_position[] = {1.0,1000,1.0,0.0};
static GLfloat light_ambient[] = {1.0,1.0,0.0,1.0};This is lightning parameters,and the Lightning code
void light()
{
glMaterialfv(GL_FRONT,GL_SPECULAR,material_specula r);
glMaterialfv(GL_FRONT,GL_SHININESS,&material_shini ness);
glLightfv(GL_LIGHT0,GL_POSITION,light_position);
glLightfv(GL_LIGHT0,GL_SPECULAR,light_ambient);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
}
http://img705.imageshack.us/img705/6956/whatimean.png (http://imageshack.us/photo/my-images/705/whatimean.png/)
Uploaded with ImageShack.us (http://imageshack.us)
static const GLfloat vert[] =
{
0.5f, 0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f,
0.5f, 0.5f, 0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f,
0.5f, 0.5f, 0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f,
-0.5f, 0.5f, 0.5f, -0.5f, 0.5f, -0.5f, -0.5f, -0.5f, -0.5f, -0.5f, -0.5f, 0.5f,
-0.5f,-0.5f, -0.5f, 0.5f, -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, -0.5f, -0.5f, 0.5f,
0.5f, -0.5f, -0.5f, -0.5f, -0.5f, -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f
};//Quad
and its normals
static const GLfloat norm[] =
{
0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1,
-1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0,
0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0,
1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0,
0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0,
0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1
};
But whenever I look straight down everything turns black.
I think it's Normal problems,but I checked and they seem right.
static GLfloat material_specular[] = {1.0,1.0,1.0,1.0,};
static GLfloat material_shininess = 5.0;
static GLfloat light_position[] = {1.0,1000,1.0,0.0};
static GLfloat light_ambient[] = {1.0,1.0,0.0,1.0};This is lightning parameters,and the Lightning code
void light()
{
glMaterialfv(GL_FRONT,GL_SPECULAR,material_specula r);
glMaterialfv(GL_FRONT,GL_SHININESS,&material_shini ness);
glLightfv(GL_LIGHT0,GL_POSITION,light_position);
glLightfv(GL_LIGHT0,GL_SPECULAR,light_ambient);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
}
http://img705.imageshack.us/img705/6956/whatimean.png (http://imageshack.us/photo/my-images/705/whatimean.png/)
Uploaded with ImageShack.us (http://imageshack.us)