add normals and enable lighting
This commit is contained in:
parent
65e011b55c
commit
aee1265ebd
10
opengl.cpp
10
opengl.cpp
@ -11,6 +11,10 @@ int main()
|
||||
// Set color and depth clear value
|
||||
glClearDepth(1.f);
|
||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
glColor3f(1.f, 1.f, 1.f);
|
||||
|
||||
// Enable Z-buffer read and write
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
@ -55,31 +59,37 @@ int main()
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
glNormal3f(0, 0, -1);
|
||||
glVertex3f(-50.f, -50.f, -50.f);
|
||||
glVertex3f(-50.f, 50.f, -50.f);
|
||||
glVertex3f( 50.f, 50.f, -50.f);
|
||||
glVertex3f( 50.f, -50.f, -50.f);
|
||||
|
||||
glNormal3f(0, 0, 1);
|
||||
glVertex3f(-50.f, -50.f, 50.f);
|
||||
glVertex3f(-50.f, 50.f, 50.f);
|
||||
glVertex3f( 50.f, 50.f, 50.f);
|
||||
glVertex3f( 50.f, -50.f, 50.f);
|
||||
|
||||
glNormal3f(-1, 0, 0);
|
||||
glVertex3f(-50.f, -50.f, -50.f);
|
||||
glVertex3f(-50.f, 50.f, -50.f);
|
||||
glVertex3f(-50.f, 50.f, 50.f);
|
||||
glVertex3f(-50.f, -50.f, 50.f);
|
||||
|
||||
glNormal3f(1, 0, 0);
|
||||
glVertex3f(50.f, -50.f, -50.f);
|
||||
glVertex3f(50.f, 50.f, -50.f);
|
||||
glVertex3f(50.f, 50.f, 50.f);
|
||||
glVertex3f(50.f, -50.f, 50.f);
|
||||
|
||||
glNormal3f(0, -1, 0);
|
||||
glVertex3f(-50.f, -50.f, 50.f);
|
||||
glVertex3f(-50.f, -50.f, -50.f);
|
||||
glVertex3f( 50.f, -50.f, -50.f);
|
||||
glVertex3f( 50.f, -50.f, 50.f);
|
||||
|
||||
glNormal3f(0, 1, 0);
|
||||
glVertex3f(-50.f, 50.f, 50.f);
|
||||
glVertex3f(-50.f, 50.f, -50.f);
|
||||
glVertex3f( 50.f, 50.f, -50.f);
|
||||
|
Loading…
x
Reference in New Issue
Block a user