I’ve started studying openGL on openframeworks, kinda overwhelmed with its gigantic specification (The most popular guide book weighs 3lbs!). Anyway, this is my first step. A rotating cube with blue and red lighting. Moving? Yes, both kinematically and emotionally.

void testApp::setup(){
ofSetWindowTitle("OpenGL - test02");
ofBackground(0, 0, 0);
counter = 0.0;
GLfloat light0pos[] = { 100.0, 300.0, 800.0, 1.0 };
GLfloat light1pos[] = { 500.0, 300.0, 0.0, 1.0 };
GLfloat blue[] = { 0.2, 0.4, 1.0, 0.8 };
GLfloat red[] = { 1.0, 0.3, 0.4, 0.5 };
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHT1);
glLightfv(GL_LIGHT0, GL_DIFFUSE, red);
glLightfv(GL_LIGHT1, GL_AMBIENT, blue);
glLightfv(GL_LIGHT0, GL_POSITION, light0pos);
glLightfv(GL_LIGHT1, GL_POSITION, light1pos);
}
void testApp::draw(){
GLdouble vertex[][3] = {
{ -100.0, -100.0, -100.0 },
{ 100.0, -100.0, -100.0 },
{ 100.0, 100.0, -100.0 },
{ -100.0, 100.0, -100.0 },
{ -100.0, -100.0, 100.0 },
{ 100.0, -100.0, 100.0 },
{ 100.0, 100.0, 100.0 },
{ -100.0, 100.0, 100.0 }
};
int edge[][2] = {
{ 0, 1 },
{ 1, 2 },
{ 2, 3 },
{ 3, 0 },
{ 4, 5 },
{ 5, 6 },
{ 6, 7 },
{ 7, 4 },
{ 0, 4 },
{ 1, 5 },
{ 2, 6 },
{ 3, 7 }
};
int face[][4] = {
{ 0, 1, 2, 3 },
{ 1, 5, 6, 2 },
{ 5, 4, 7, 6 },
{ 4, 0, 3, 7 },
{ 4, 5, 1, 0 },
{ 3, 2, 6, 7 }
};
GLdouble normal[][3] = {
{ 0.0, 0.0,-1.0 },
{ 1.0, 0.0, 0.0 },
{ 0.0, 0.0, 1.0 },
{-1.0, 0.0, 0.0 },
{ 0.0,-1.0, 0.0 },
{ 0.0, 1.0, 0.0 }
};
GLfloat red[] = { 0.8, 0.2, 0.2, 1.0 };
GLfloat white[] = { 1.0, 1.0, 1.0, 1.0 };
ofPushMatrix();
ofTranslate(ofGetWidth()/2.0, ofGetHeight()/2.0, 0.0);
ofRotateY(counter);
ofRotateZ(counter * 1.1);
counter += 0.01;
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glColor3d(1.0, 1.0, 1.0);
glBegin(GL_QUADS);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, red);
for (int j = 0; j < 6; ++j) {
glNormal3dv(normal[j]);
for (int i = 0; i < 4; ++i) {
glVertex3dv(vertex[face[j][i]]);
}
}
glEnd();
ofPopMatrix();
}