25 #ifndef INCLUDED_OpenGLCube_h_GUID_CC4A4D86_AD2D_4FBC_82F1_877BEEBA8434 26 #define INCLUDED_OpenGLCube_h_GUID_CC4A4D86_AD2D_4FBC_82F1_877BEEBA8434 30 static const GLfloat matspec[4] = {0.5, 0.5, 0.5, 0.0};
31 static const float red_col[] = {1.0, 0.0, 0.0};
32 static const float grn_col[] = {0.0, 1.0, 0.0};
33 static const float blu_col[] = {0.0, 0.0, 1.0};
34 static const float yel_col[] = {1.0, 1.0, 0.0};
35 static const float lightblu_col[] = {0.0, 1.0, 1.0};
36 static const float pur_col[] = {1.0, 0.0, 1.0};
38 glScaled(radius, radius, radius);
39 glMaterialfv(GL_FRONT, GL_SPECULAR, matspec);
40 glMaterialf(GL_FRONT, GL_SHININESS, 64.0);
42 glColor3fv(lightblu_col);
43 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, lightblu_col);
44 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, lightblu_col);
45 glNormal3f(0.0, 0.0, -1.0);
46 glVertex3f(1.0, 1.0, -1.0);
47 glVertex3f(1.0, -1.0, -1.0);
48 glVertex3f(-1.0, -1.0, -1.0);
49 glVertex3f(-1.0, 1.0, -1.0);
53 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, blu_col);
54 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, blu_col);
55 glNormal3f(0.0, 0.0, 1.0);
56 glVertex3f(-1.0, 1.0, 1.0);
57 glVertex3f(-1.0, -1.0, 1.0);
58 glVertex3f(1.0, -1.0, 1.0);
59 glVertex3f(1.0, 1.0, 1.0);
63 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, yel_col);
64 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, yel_col);
65 glNormal3f(0.0, -1.0, 0.0);
66 glVertex3f(1.0, -1.0, 1.0);
67 glVertex3f(-1.0, -1.0, 1.0);
68 glVertex3f(-1.0, -1.0, -1.0);
69 glVertex3f(1.0, -1.0, -1.0);
73 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, grn_col);
74 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, grn_col);
75 glNormal3f(0.0, 1.0, 0.0);
76 glVertex3f(1.0, 1.0, 1.0);
77 glVertex3f(1.0, 1.0, -1.0);
78 glVertex3f(-1.0, 1.0, -1.0);
79 glVertex3f(-1.0, 1.0, 1.0);
83 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, pur_col);
84 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, pur_col);
85 glNormal3f(-1.0, 0.0, 0.0);
86 glVertex3f(-1.0, 1.0, 1.0);
87 glVertex3f(-1.0, 1.0, -1.0);
88 glVertex3f(-1.0, -1.0, -1.0);
89 glVertex3f(-1.0, -1.0, 1.0);
93 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, red_col);
94 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, red_col);
95 glNormal3f(1.0, 0.0, 0.0);
96 glVertex3f(1.0, -1.0, 1.0);
97 glVertex3f(1.0, -1.0, -1.0);
98 glVertex3f(1.0, 1.0, -1.0);
99 glVertex3f(1.0, 1.0, 1.0);
104 #endif // INCLUDED_OpenGLCube_h_GUID_CC4A4D86_AD2D_4FBC_82F1_877BEEBA8434 void draw_cube(double radius)
Fixed-function pipeline OpenGL code to draw a cube.
Definition: OpenGLCube.h:29