void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glLightfv(GL_LIGHT0, GL_POSITION, position); // Note that glLightfv cannot be called inside a glBegin-glEnd block glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); glLightfv(GL_LIGHT0, GL_SPECULAR, specular); glTranslatef(0.0, 0.0, transZ); glRotatef(rotY, 0.0, 1.0, 0.0); displayFaces(); glutSwapBuffers(); }
void display(void) { if (initialized == false) { myInit(); initialized = true; } #pragma mark blendMask 1/2: 1. Enable GL_DEPTH_TEST, 2. TRUE DEPTHMASK 3. DISABLE blend //glDepthFunc(GL_LEQUAL); glDepthFunc(GL_LESS); // The Type Of Depth Test To Do glEnable(GL_DEPTH_TEST); glDepthMask(GL_TRUE); // Turn ON Writing To The Depth-Buffer glDisable(GL_BLEND); //------------------------------------------------------------material vriables //define the material of the object float no_mat[] = { 0.0, 0.0, 0.0, 1.0 }; float mat_white[] = { 1.0, 1.0, 1.0, 1.0 }; float mat_gray1[] = { 0.3, 0.3, 0.3, 1.0 }; float mat_gray2[] = { 0.5, 0.5, 0.5, 1.0 }; float mat_red[] = { 1.0, 0.2, 0.1, 1.0 }; float mat_orange[] = { 0.7, 0.5, 0.1, 1.0 }; float mat_yellow[] = { 0.8, 0.8, 0.1, 1.0 }; float mat_green[] = { 0.0, 1.0, 0.0, 1.0 }; float mat_blue[] = { 0.1, 0.1, 0.8, 1.0 }; float mat_purple[] = { 0.8, .1, 0.8, 1.0 }; float no_shininess[] = { 0.0 }; float low_shininess[] = { 5.0 }; float high_shininess[] = { 100.0 }; float mat_bright[] = {1.0, 0.7, 0.1, 1.0}; float no_mat_a[] = { 0.0, 0.0, 0.0, 0.5 }; float mat_white_a[] = { 1.0, 1.0, 1.0, 0.5 }; float mat_gray1_a[] = { 0.3, 0.3, 0.3, 0.5 }; float mat_gray2_a[] = { 0.5, 0.5, 0.5, 0.5 }; float mat_red_a[] = { 1.0, 0.2, 0.1, 0.5 }; float mat_orange_a[] = { 0.7, 0.5, 0.1, 0.5 }; float mat_yellow_a[] = { 0.8, 0.8, 0.1, 0.5 }; float mat_green_a[] = { 0.0, 1.0, 0.0, 0.5 }; float mat_blue_a[] = { 0.1, 0.1, 0.8, 0.5 }; float mat_purple_a[] = { 0.8, .1, 0.8, 0.5 }; float mat_more_a[] = { 0.8, .1, 0.8, 0.2 }; float mat_less_a[] = { 0.8, .1, 0.8, 0.8 }; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); /* glBegin( GL_QUADS ); glTexCoord2f(0, 0); glVertex3f(-.5, -.5, 0); glTexCoord2f(1, 0); glVertex3f(.5, -.5, 0); glTexCoord2f(1, 1); glVertex3f(.5, .5, 0); glTexCoord2f(0, 1); glVertex3f(-.5, .5, 0); glEnd(); */ #pragma mark - //------------------------------------------------------------Spot for Obj (white Torus) glTranslatef(0.0, 0.0, -10.0); //set origin of shape (5 units into the distance) glRotatef(rotX1, 0.0, 1.0, 0.0); // whole world rotation glPushMatrix(); glTranslatef(-0.5, 1.1, 2.0); //glRotatef(rotX1, 1.0, 0.0, 0.0); glTranslatef((sin(rotX1*0.1))*0.4, 0.0, 0.0); glRotatef(90., 1.0, 1.0, 0.0); glLightfv(GL_LIGHT3, GL_POSITION, pos); //spot light3 (Sun) glMaterialfv(GL_FRONT, GL_AMBIENT, mat_gray1); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_white); glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_white_a); glMaterialfv(GL_FRONT, GL_EMISSION, mat_gray2); glutSolidTorus(0.03, 0.1, 32, 32); glPopMatrix(); //------------------------------------------------------------Red Sphere glPushMatrix(); glTranslatef(2.3, 0.0, -2.0 + sin(rotX1*0.2)); glLightfv(GL_LIGHT2, GL_POSITION, pos); //spot light2 glRotatef(-rotX1, 1.0, 0.0, 0.0); // glutSolidTorus(0.3, 0.8, 32, 32); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_red); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_orange); glMaterialfv(GL_FRONT, GL_SHININESS, low_shininess); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_red); glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); glutSolidSphere(0.45, 10, 10); //glutSolidCube(.5); glPopMatrix(); glPushMatrix(); //glTranslatef(2.0, 0.0, -2.0); glTranslatef(2.3, 0.0, -2.0 + sin(rotX1*0.2)); glRotatef(-rotX1, .0, .0, 1.0); glTranslatef(.0, 1.0, .0); glRotatef(-rotX1, .0, 1.0, .0); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_purple); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_orange); glMaterialfv(GL_FRONT, GL_SHININESS, low_shininess); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_blue); glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); glutSolidCube(.2); glPopMatrix(); //------------------------------------------------------------Sun glPushMatrix(); // glTranslatef(-3.0, -3, -2.0); // glRotatef(rotX1, 1.0, 0.0, 0.0); glTranslatef(.0, 1, -2.0); glRotatef(rotX1, .0, 0.0, 1.0); glTranslatef(2.0, .1, 0.0); glLightfv(GL_LIGHT0, GL_POSITION, pos); // sun light glMaterialfv(GL_FRONT, GL_AMBIENT, mat_red); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_orange); glMaterialfv(GL_FRONT, GL_SHININESS, low_shininess); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_red); glMaterialfv(GL_FRONT, GL_EMISSION, mat_bright); glutSolidSphere(0.15, 10, 10); // Sun glPopMatrix(); //end matrix //printNormal(1.0, 0.0, 0.0, 0.0, 1.0, 0.0); //------------------------------------------------------------Land glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_green); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_blue); glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, high_shininess); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_less_a); glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, no_mat); #pragma mark - #pragma mark texture //------------------------------------------------------------Tex Binding glEnable( GL_TEXTURE_2D ); glBindTexture( GL_TEXTURE_2D, tex ); float numz = 14.0; float numx = 8.0; for (int z = -numz; z <= numz; z ++){ glBegin(GL_QUAD_STRIP); for (int x = -numx; x <= numx; x ++){ vec3 p0; vec3 p1; vec3 p2; p0.x = x; p0.y = -2; p0.z = z; p1.x = x; p1.y = -2; p1.z = z + 1; p2.x = x + 1; p2.y = -2; p2.z = z; vec3 norm = calulateNormal(p0, p1, p2); glNormal3d(norm.x, norm.y, norm.z); float u, v; u = ((x) + numx) / (numx * 2.); v = ((z+1.) + numz) / (numz * 2.); glTexCoord2f(u, v); glVertex3d(x, sin(z+1) * (sin(3.3*x))-2, z+1); u = ((x) + numx) / (numx * 2.); v = ((z) + numz) / (numz * 2.); glTexCoord2f(u, v); glVertex3d(x, sin(z) * (sin(3.3*x))-2, z); } glEnd(); } glBindTexture( GL_TEXTURE_2D, 0 ); glDisable( GL_TEXTURE_2D ); //------------------------------------------------------------Tex UnBinding #pragma mark blendMask 2/2: 1. Enable blend, 2. Enable BlendFunc 3. False depth mask 4. material alpha value glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE); // Blending Function For Translucency Based On Source Alpha Value ( NEW ) glDepthMask( GL_FALSE ); // Turn Off Writing To The Depth-Buffer //------------------------------------------------------------Obj glEnable( GL_TEXTURE_2D ); glBindTexture( GL_TEXTURE_2D, tex ); glPushMatrix(); glTranslatef(0.0, -0.5, 2.0); glRotatef(rotX1, 0.0, 1.0, 0.0); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_white); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_white); glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_more_a); glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); displayFaces(); glPopMatrix(); glBindTexture( GL_TEXTURE_2D, 0 ); glDisable( GL_TEXTURE_2D ); //------------------------------------------------------------Blue Sphere glPushMatrix(); glTranslatef(-2.3, cos(rotX1*0.2), -2.0); glLightfv(GL_LIGHT1, GL_POSITION, pos); //spot light1 glRotatef(rotX1, 1.0, 0.0, 0.0); //glutSolidSphere(0.8, 10, 10); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_blue); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_orange); glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_green_a); glMaterialfv(GL_FRONT, GL_EMISSION, mat_blue); glutSolidSphere(0.45, 10, 10); //glutSolidCube(.5); glRotatef(rotX1, 1.0, 0.0, 0.0); glTranslatef(.0, 1.0, .0); //glutWireCube(.1); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_orange); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_green); glMaterialfv(GL_FRONT, GL_SHININESS, low_shininess); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_blue); glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); glutSolidCube(.1); glPopMatrix(); rotX1 += 0.05; #pragma mark Morph gl Drawing 3/4 //------------------------------------------------------------Morphing Obj GLfloat tx,ty,tz; // Temp X, Y & Z Variables vec3 q; // Holds Returned Calculated Values For One VertexglBegin(GL_POINTS); // Begin Drawing Points printf("key %i morph %i, verts %i\n", key, morph, morph1.verts); //glPointSize(2.0); glLineWidth(2.0); glTranslatef(0., 2., 0); glBegin(GL_LINE_STRIP); // Begin Drawing Points for(int i=0;i<morph1.verts;i++) // Loop Through All The Verts Of morph1 (All Objects Have { // The Same Amount Of Verts For Simplicity, Could Use maxver Also) if(morph) { q=calculate(i); } else { q.x=q.y=q.z=0; // If morph Is True Calculate Movement Otherwise Movement=0 } helper.points[i].x-=q.x; // Subtract q.x Units From helper.points[i].x (Move On X Axis) helper.points[i].y-=q.y; // Subtract q.y Units From helper.points[i].y (Move On Y Axis) helper.points[i].z-=q.z; // Subtract q.z Units From helper.points[i].z (Move On Z Axis) tx=helper.points[i].x; // Make Temp X Variable Equal To Helper's X Variable ty=helper.points[i].y; // Make Temp Y Variable Equal To Helper's Y Variable tz=helper.points[i].z; // Make Temp Z Variable Equal To Helper's Z VariableglColor3f(0,1,1); // Set Color To A Bright Shade Of Off Blue glVertex3f(tx,ty,tz); // Draw A Point At The Current Temp Values (Vertex) glColor3d(1.0,0.5,1.0); // Darken Color A Bit tx-=2*q.x; ty-=2*q.y; ty-=2*q.y; // Calculate Two Positions Ahead glVertex3f(tx,ty,tz); // Draw A Second Point At The Newly Calculate Position glColor3f(0.,0.,1.); // Set Color To A Very Dark Blue tx-=2*q.x; ty-=2*q.y; ty-=2*q.y; // Calculate Two More Positions Ahead glVertex3f(tx,ty,tz); // Draw A Third Point At The Second New Position if (i == 100) printf("%f %f %f\n", tx, ty, tz); } // This Creates A Ghostly Tail As Points Move glEnd(); // Done Drawing Points if(morph && step<=steps)step++; else { morph=0; sour=dest; step=0;} glutSwapBuffers(); }
void display(void) { if (initialized == false) { myInit(); initialized = true; } #pragma mark blendMask 1/2: 1. Enable GL_DEPTH_TEST, 2. TRUE DEPTHMASK 3. DISABLE blend glDepthFunc(GL_LEQUAL); //glDepthFunc(GL_LESS); glEnable(GL_DEPTH_TEST); glDepthMask(GL_TRUE); // Turn ON Writing To the Depth-Buffer glDisable(GL_BLEND); //------------------------------------------------------------material vriables //define the material of the object float no_mat[] = { 0.0, 0.0, 0.0, 1.0 }; float mat_white[] = { 1.0, 1.0, 1.0, 1.0 }; float mat_gray1[] = { 0.3, 0.3, 0.3, 1.0 }; float mat_gray2[] = { 0.5, 0.5, 0.5, 1.0 }; float mat_red[] = { 1.0, 0.2, 0.1, 1.0 }; float mat_orange[] = { 0.7, 0.5, 0.1, 1.0 }; float mat_yellow[] = { 0.8, 0.8, 0.1, 1.0 }; float mat_green[] = { 0.0, 1.0, 0.0, 1.0 }; float mat_blue[] = { 0.1, 0.1, 0.8, 1.0 }; float mat_purple[] = { 0.8, .1, 0.8, 1.0 }; float no_shininess[] = { 0.0 }; float low_shininess[] = { 5.0 }; float high_shininess[] = { 100.0 }; float mat_bright[] = {1.0, 0.7, 0.1, 1.0}; float no_mat_a[] = { 0.0, 0.0, 0.0, 0.5 }; float mat_white_a[] = { 1.0, 1.0, 1.0, 0.5 }; float mat_gray1_a[] = { 0.3, 0.3, 0.3, 0.5 }; float mat_gray2_a[] = { 0.5, 0.5, 0.5, 0.5 }; float mat_red_a[] = { 1.0, 0.2, 0.1, 0.5 }; float mat_orange_a[] = { 0.7, 0.5, 0.1, 0.5 }; float mat_yellow_a[] = { 0.8, 0.8, 0.1, 0.5 }; float mat_green_a[] = { 0.0, 1.0, 0.0, 0.5 }; float mat_blue_a[] = { 0.1, 0.1, 0.8, 0.5 }; float mat_purple_a[] = { 0.8, .1, 0.8, 0.5 }; float mat_more_a[] = { 0.8, .1, 0.8, 0.2 }; float mat_less_a[] = { 0.8, .1, 0.8, 0.8 }; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // glColor3f(1.0, 1.0, 1.0); //set color of rectangle /* glColor4f(1.0, 1.0, 1.0, 1.0); glBegin( GL_QUADS ); glTexCoord2f(0, 0); glVertex3f(-.5, -.5, 0); glTexCoord2f(1, 0); glVertex3f(.5, -.5, 0); glTexCoord2f(1, 1); glVertex3f(.5, .5, 0); glTexCoord2f(0, 1); glVertex3f(-.5, .5, 0); glEnd(); */ #pragma mark - //------------------------------------------------------------Spot for Obj glTranslatef(0.0, 0.0, -5.0); //set origin of shape (5 units into the distance) //glRotatef(rotX1, 1.0, 1.0, 0.0); // whole world rotation glPushMatrix(); glTranslatef(-0.5, 1.1, 2.0); //glRotatef(rotX1, 1.0, 0.0, 0.0); glTranslatef((sin(rotX1*0.1))*0.4, 0.0, 0.0); glRotatef(90., 1.0, 1.0, 0.0); glLightfv(GL_LIGHT3, GL_POSITION, pos); //spot light3 (Sun) glMaterialfv(GL_FRONT, GL_AMBIENT, mat_gray1); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_white); glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_white_a); glMaterialfv(GL_FRONT, GL_EMISSION, mat_gray2); glutSolidTorus(0.03, 0.1, 32, 32); glPopMatrix(); //------------------------------------------------------------Red Sphere glPushMatrix(); glTranslatef(2.3, 0.0, -2.0 + sin(rotX1*0.2)); glLightfv(GL_LIGHT2, GL_POSITION, pos); //spot light2 glRotatef(-rotX1, 1.0, 0.0, 0.0); // glutSolidTorus(0.3, 0.8, 32, 32); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_red); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_orange); glMaterialfv(GL_FRONT, GL_SHININESS, low_shininess); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_red); glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); glutSolidSphere(0.45, 10, 10); //glutSolidCube(.5); glPopMatrix(); glPushMatrix(); //glTranslatef(2.0, 0.0, -2.0); glTranslatef(2.3, 0.0, -2.0 + sin(rotX1*0.2)); glRotatef(-rotX1, .0, .0, 1.0); glTranslatef(.0, 1.0, .0); glRotatef(-rotX1, .0, 1.0, .0); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_purple); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_orange); glMaterialfv(GL_FRONT, GL_SHININESS, low_shininess); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_blue); glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); glutSolidCube(.2); glPopMatrix(); //------------------------------------------------------------Sun glPushMatrix(); // glTranslatef(-3.0, -3, -2.0); // glRotatef(rotX1, 1.0, 0.0, 0.0); glTranslatef(.0, 1, -2.0); glRotatef(rotX1, .0, 0.0, 1.0); glTranslatef(2.0, .1, 0.0); glLightfv(GL_LIGHT0, GL_POSITION, pos); // sun light glMaterialfv(GL_FRONT, GL_AMBIENT, mat_red); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_orange); glMaterialfv(GL_FRONT, GL_SHININESS, low_shininess); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_red); glMaterialfv(GL_FRONT, GL_EMISSION, mat_bright); glutSolidSphere(0.15, 10, 10); // Sun glPopMatrix(); //end matrix //printNormal(1.0, 0.0, 0.0, 0.0, 1.0, 0.0); //------------------------------------------------------------Land glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_gray1); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_red); glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, high_shininess); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_orange); glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, no_mat); #pragma mark - #pragma mark texture //------------------------------------------------------------Tex Binding glEnable( GL_TEXTURE_2D ); glBindTexture( GL_TEXTURE_2D, tex ); float numz = 14.0; float numx = 8.0; for (int z = -numz; z <= numz; z ++){ glBegin(GL_QUAD_STRIP); for (int x = -numx; x <= numx; x ++){ vec3 p0; vec3 p1; vec3 p2; p0.x = x; p0.y = -2; p0.z = z; p1.x = x; p1.y = -2; p1.z = z + 1; p2.x = x + 1; p2.y = -2; p2.z = z; vec3 norm = calulateNormal(p0, p1, p2); glNormal3d(norm.x, norm.y, norm.z); float u, v; u = ((x) + numx) / (numx * 2.); v = ((z+1.) + numz) / (numz * 2.); glTexCoord2f(u, v); glVertex3d(x, sin(z+1) * (sin(3.3*x))-2, z+1); u = ((x) + numx) / (numx * 2.); v = ((z) + numz) / (numz * 2.); glTexCoord2f(u, v); glVertex3d(x, sin(z) * (sin(3.3*x))-2, z); } glEnd(); } glBindTexture( GL_TEXTURE_2D, 0 ); glDisable( GL_TEXTURE_2D ); //------------------------------------------------------------Tex UnBinding #pragma mark blendMask 2/2: 1. Enable blend, 2. Enable BlendFunc 3. False depth mask 4. material alpha value glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE); // Blending Function For Translucency Based On Source Alpha Value ( NEW ) glDepthMask( GL_FALSE ); // Turn Off Writing To The Depth-Buffer //------------------------------------------------------------Obj glEnable( GL_TEXTURE_2D ); glBindTexture( GL_TEXTURE_2D, tex ); glPushMatrix(); glTranslatef(0.0, -0.5, 2.0); glRotatef(rotX1, 0.0, 1.0, 0.0); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_white); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_white); glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_more_a); glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); displayFaces(); glPopMatrix(); glBindTexture( GL_TEXTURE_2D, 0 ); glDisable( GL_TEXTURE_2D ); //------------------------------------------------------------Blue Sphere glPushMatrix(); glTranslatef(-2.3, cos(rotX1*0.2), -2.0); glLightfv(GL_LIGHT1, GL_POSITION, pos); //spot light1 glRotatef(rotX1, 1.0, 0.0, 0.0); //glutSolidSphere(0.8, 10, 10); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_blue_a); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_orange_a); glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_green_a); glMaterialfv(GL_FRONT, GL_EMISSION, mat_blue_a); glutSolidSphere(0.45, 10, 10); //glutSolidCube(.5); glRotatef(rotX1, 1.0, 0.0, 0.0); glTranslatef(.0, 1.0, .0); //glutWireCube(.1); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_orange); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_green); glMaterialfv(GL_FRONT, GL_SHININESS, low_shininess); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_blue); glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); glutSolidCube(.1); glPopMatrix(); glutSwapBuffers(); rotX1 += .25; }