// Zoom into the cube inline void scene1(float scene_time) { tglClear(TGL_COLOR_BUFFER_BIT); float min_zoom = -10; float max_zoom = -2.5; float zoom = min_zoom + (max_zoom-min_zoom) * (float)scene_time/timeline[scene]; tglMatrixMode(TGL_MODELVIEW); tglLoadIdentity(); tglTranslatef(0, 0, zoom); tglBegin(TGL_LINES); for(int p=0; p<8; ++p) { tglVertex3fv(cube[cubestrip1[p]]); } tglEnd(); tglBegin(TGL_LINES); for(int p=0; p<8; ++p) { tglVertex3fv(cube[cubestrip2[p]]); } tglEnd(); tglSwap(); delay(50); }
// Spinning Cube! inline void scene2(float scene_time) { int i = scene_time / 25; tglClear(TGL_COLOR_BUFFER_BIT); float zoom = 0; if(scene_time > 5000) zoom = 0.5*sin((float)(i-20)/10.0); float rot_speed = 1.0; if(scene_time > 12000) rot_speed += (float)(scene_time - 12000) / 1500.0; tglMatrixMode(TGL_MODELVIEW); tglLoadIdentity(); tglTranslatef(0, 0, -2.5+zoom); tglRotatef((float)(i % 360) * rot_speed, 0, 1, 0); tglRotatef((float)(i % 360) * rot_speed, 1, 1, 0); tglBegin(TGL_LINES); for(int p=0; p<8; ++p) { tglVertex3fv(cube[cubestrip1[p]]); } tglEnd(); tglBegin(TGL_LINES); for(int p=0; p<8; ++p) { tglVertex3fv(cube[cubestrip2[p]]); } tglEnd(); tglSwap(); }
void TinyGLRenderer::clear() { tglClear(TGL_COLOR_BUFFER_BIT | TGL_DEPTH_BUFFER_BIT); tglColor3f(1.0f, 1.0f, 1.0f); }