computational form 23,
play 14,
information 13,
everybityoumake 12,
atoz 10,
processingtext 10,
mapping 9,
mobility 9,
nime 9,
fabricatinginformation 8,
interactivesound 7,
locative 7,
thesis 7,
ubicomp 5,
blah 4,
thinking 4,
isco 3,
pcomp 3,
assistive technologies 1,
howto 1,
visualization 1
CompForm Assignment 10 · posted by vaibhav bhawsar Dec 31, 2007
Problem 1. Add the OpenGL lighting code to your project. This code may be placed in the init() function or in the displayFunc(), if you want to move or change the light.
void init ( GLvoid )
{
glShadeModel( GL_SMOOTH );
glClearColor( 0.1, 0.1, 0.1, 1.0 );
glEnable ( GL_COLOR_MATERIAL );
glEnable( GL_BLEND );
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_DEPTH_TEST);
//turn on GL lighting
glEnable(GL_LIGHTING);
// turn on first light
glEnable(GL_LIGHT0);
//setup lighting params
float ambientLight[4] = { 0, 0, 0, 1.0 }; //r,g,b,a //omni
float diffuseLight[4] = { 1, 1, 1, 1.0 }; //r,g,b,a //color of the light bulb
float specularLight[4] = { 0.8, 0.8, 0.8, 1.0 }; //r,g,b,a //the shiny part of the object
float lightPosition[4] = { 500, 500, 1000, 1.0 }; //x,y,z,other //pos of the light
//which light, property, propoertyvalue
glLightfv(GL_LIGHT0,GL_AMBIENT,ambientLight);
glLightfv(GL_LIGHT0,GL_DIFFUSE,diffuseLight);
glLightfv(GL_LIGHT0,GL_SPECULAR,specularLight);
glLightfv(GL_LIGHT0,GL_POSITION,lightPosition);
//enable glColor3f to affect the material color
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
}
Comment
Commenting is closed for this article.