void draw(fl_Gl_Window cube) { instance_data* cube_data = (instance_data*)Fl_Gl_Window_other_data(cube); cube_data->lasttime = cube_data->lasttime+cube_data->speed; Fl_Gl_Window_set_other_data(cube, cube_data); if (!Fl_Gl_Window_valid(cube)) { glLoadIdentity(); glViewport(0,0,Fl_Gl_Window_w(cube),Fl_Gl_Window_h(cube)); glEnable(GL_DEPTH_TEST); glFrustum(-1,1,-1,1,2,10000); glTranslatef(0,0,-10); flc_gl_font(FL_HELVETICA_BOLD, 16 ); } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); glRotatef((float)(cube_data->lasttime*1.6),0,0,1); glRotatef((float)(cube_data->lasttime*4.2),1,0,0); glRotatef((float)(cube_data->lasttime*2.3),0,1,0); glTranslatef(-1.0, 1.2f, -1.5); glScalef((float)(cube_data->size),(float)(cube_data->size),(float)(cube_data->size)); drawcube(cube_data->wire); glPopMatrix(); flc_gl_color(FL_GRAY); glDisable(GL_DEPTH_TEST); flc_gl_draw_with_xy(cube_data->wire ? "Cube: wire" : "Cube: flat", -4.5f, -4.5f ); glEnable(GL_DEPTH_TEST); }
void display2() { GLint i = 0; glutSetWindow(id2); glPushMatrix(); glLoadIdentity(); gluLookAt(5, 12, 16, 0, 0, 0, 0, 1, 0); glLightfv(GL_LIGHT0, GL_POSITION, light0_position); drawglobalaxes(); for(i = 0; i <= 30; i++) { glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); drawglobalaxes(); glPushMatrix(); drawlocalaxes(); glPopMatrix(); glutSwapBuffers(); } for(i = 0; i <= 30; i++) { glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); drawglobalaxes(); glPushMatrix(); glTranslatef(0.1*i, 0.0, 0.0); drawlocalaxes(); glPopMatrix(); glutSwapBuffers(); } for(i = 0; i <= 30; i++) { glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); drawglobalaxes(); glPushMatrix(); glTranslatef(3.0, 0.0, 0.0); glRotatef(3.0*i, 0.0, 1.0, 0.0); drawlocalaxes(); glPopMatrix(); glutSwapBuffers(); } for(i = 0; i <= 30; i++) { glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); drawglobalaxes(); glPushMatrix(); glTranslatef(3.0, 0.0, 0.0); glRotatef(90, 0.0, 1.0, 0.0); glTranslatef(0.2*i, 0.0, 0.0); drawlocalaxes(); glPopMatrix(); glutSwapBuffers(); } for(i = 0; i <= 30; i++) { glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); drawglobalaxes(); glPushMatrix(); glTranslatef(3.0, 0.0, 0.0); glRotatef(90, 0.0, 1.0, 0.0); glTranslatef(6.0, 0.0, 0.0); drawlocalaxes(); glPopMatrix(); glutSwapBuffers(); } for(i = 0; i <= 30; i++) { glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); drawglobalaxes(); glPushMatrix(); glTranslatef(3.0, 0.0, 0.0); glRotatef(90, 0.0, 1.0, 0.0); glTranslatef(6.0, 0.0, 0.0); drawlocalaxes(); drawcube(); glPopMatrix(); glutSwapBuffers(); } for(i = 0; i <= 30; i++) { glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); drawglobalaxes(); glPushMatrix(); glTranslatef(3.0, 0.0, 0.0); glRotatef(90, 0.0, 1.0, 0.0); glTranslatef(6.0, 0.0, 0.0); drawcube(); glPopMatrix(); glutSwapBuffers(); } glPopMatrix(); glutSwapBuffers(); glFlush(); }
void display(void) { if (is_depth) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); else glClear(GL_COLOR_BUFFER_BIT); /* draw the floor */ glBegin(GL_QUADS); glColor3f(0.2f, 0.2f, 0.2f); glVertex3f(-100.0, 0.0, -100.0); glColor3f(0.4f, 0.4f, 0.4f); glVertex3f(-100.0, 0.0, 100.0); glColor3f(0.6f, 0.6f, 0.6f); glVertex3f(100.0, 0.0, 100.0); glColor3f(0.8f, 0.8f, 0.8f); glVertex3f(100.0, 0.0, -100.0); glEnd(); /* draw 12 cubes with different colors */ drawcube(75, 57, 2); drawcube(-65, -12, 3); drawcube(50, -50, 1); drawcube(-56, 17, 2); drawcube(67, 12, 3); drawcube(-87, 32, 1); drawcube(-26, 75, 2); drawcube(57, 82, 3); drawcube(-3, 12, 1); drawcube(46, 35, 2); drawcube(37, -2, 3); glutSwapBuffers(); }