/*********************** * Johnny Jetpack * by Paul Adam and Jamie Bradley * * misc.c * * this file contains miscilaneous, global lighting and material functions *************************/ #include #include #include /***************************************************** This function simply disables lighting *****************************************************/ void disable(void) { glDisable(GL_LIGHTING); glDisable(GL_NORMALIZE); return; } /***************************************************** This function simply turns on lighting *****************************************************/ void lighting(void) { GLfloat position[] = {25, 25, 0, 1}; GLfloat position1[] = {-25, 25, 0, 1.0}; GLfloat amb[] = {1.0, 0.0, 0.0, 1.0}; GLfloat diff[] = {1.0, 0.0, 0.0, 1.0}; GLfloat spec[] = {1.0, 1.0, 1.0, 1.0}; glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_LIGHT1); glEnable(GL_NORMALIZE); glDepthFunc(GL_LESS); glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 150.0); glLightfv(GL_LIGHT0, GL_POSITION, position); glLightfv(GL_LIGHT1, GL_AMBIENT, amb); glLightfv(GL_LIGHT1, GL_DIFFUSE, diff); glLightfv(GL_LIGHT1, GL_SPECULAR, spec); glLightfv(GL_LIGHT1, GL_POSITION, position1); glLightf(GL_LIGHT1, GL_SPOT_CUTOFF, 120.0); glEnable(GL_LIGHTING); return; } /******************************************************* This function simply sets the material parameters for a filled polygon. The array is either red, green or gray, which are given above. To add a color, simply specify a new color (as a 4D array -> (red, green, blue, 1) where red, green and blue range from 0->1), and call this function before you draw the object. *********************************************************/ void Set_Mat (float col[]) { GLfloat mat_shininess = 128.0 * 0.4; glMaterialfv(GL_FRONT, GL_SPECULAR, col); glMaterialfv(GL_FRONT, GL_AMBIENT, col); glMaterialfv(GL_FRONT, GL_DIFFUSE, col); glMaterialfv(GL_FRONT, GL_SHININESS, &mat_shininess); return; }