Skip to content

Instantly share code, notes, and snippets.

@Akira-Hayasaka
Created August 23, 2011 08:37
Show Gist options
  • Save Akira-Hayasaka/1164666 to your computer and use it in GitHub Desktop.
Save Akira-Hayasaka/1164666 to your computer and use it in GitHub Desktop.
openGL light
glEnable(GL_POLYGON_SMOOTH);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
glEnable(GL_NORMALIZE);
glEnable(GL_COLOR_MATERIAL);
glDisable(GL_BLEND);
glPolygonMode(GL_BACK, GL_FILL );
glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
glShadeModel(GL_SMOOTH);
glColor3f(0.5, 0.5, 0.5);
GLfloat on[] = {1.0};
GLfloat off[] = {0.0};
glLightModelfv( GL_LIGHT_MODEL_TWO_SIDE,on);
GLfloat shininess[] = {0};
glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT, materialAmbient);
glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE, materialDiffuse);
glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR, materialSpecular);
glMaterialfv(GL_FRONT_AND_BACK,GL_SHININESS,shininess);
GLfloat lightPosition[] = { 0.0f, 0.0f, -100.0, 0.0f };
GLfloat lightDiffuse[] = { 1.00, 0.99, 0.98, 1.0};
GLfloat lightSpecular[] = { 0.10, 0.10, 0.10, 1.0};
GLfloat lightAmbient[] = { 0.45, 0.43, 0.44, 1.0};
glLightfv(GL_LIGHT0,GL_POSITION, lightPosition);
glLightfv(GL_LIGHT0,GL_DIFFUSE, lightDiffuse);
glLightfv(GL_LIGHT0,GL_SPECULAR, lightSpecular);
glLightfv(GL_LIGHT0,GL_AMBIENT, lightAmbient);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment