// Display callback void myDraw(void) { // Clear the screen glClearColor( 0.0, 0.0, 0.0, 1.0); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); // Apply shader program glUseProgram( shaderProgram1 ); // glColor3f(1.0, 0.5, 0.25); // cout << dr->getX() << endl; // cout << dr->getY() << endl; // Draw polygon with data dimensions glUseProgram( shaderProgram1 ); glBegin( GL_POLYGON ); switch(axis) { case 2: // view yz plane (move along x) glTexCoord3f( tx, 0.0, 0.0 ); glVertex3f( tx, 0.0, 0.0 ); glTexCoord3f( tx, 1.0, 0.0 ); glVertex3f( tx, 1.0, 0.0 ); glTexCoord3f( tx, 1.0, 1.0 ); glVertex3f( tx, 1.0, 1.0 ); glTexCoord3f( tx, 0.0, 1.0 ); glVertex3f( tx, 0.0, 1.0 ); break; case 1: // view xz plane (move along y) glTexCoord3f( 0.0, ty, 0.0 ); glVertex3f( 0.0, ty, 0.0 ); glTexCoord3f( 1.0, ty, 0.0 ); glVertex3f( 1.0, ty, 0.0 ); glTexCoord3f( 1.0, ty, 1.0 ); glVertex3f( 1.0, ty, 1.0 ); glTexCoord3f( 0.0, ty, 1.0 ); glVertex3f( 0.0, ty, 1.0 ); break; case 0: // view xy plane (move along z) glTexCoord3f( 0.0, 0.0, tz ); glVertex3f( 0.0, 0.0, tz ); glTexCoord3f( 1.0, 0.0, tz ); glVertex3f( 1.0, 0.0, tz ); glTexCoord3f( 1.0, 1.0, tz ); glVertex3f( 1.0, 1.0, tz ); glTexCoord3f( 0.0, 1.0, tz ); glVertex3f( 0.0, 1.0, tz ); break; } glEnd(); drawCage(); // Swap buffers glutSwapBuffers(); }
/* 화면그림 */ void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); drawCage(); for (int i = 0; i < 5; i++) { drawObject(stObj[i]); } //여기서부터 팔 그림 drawArmBand(); glTranslatef(armData.x, (LARGE_CUBE_SIZE /2)+0.5, armData.z); renderArm(&band); glRotatef(45,0,1,0); renderArm(&hand); glPushMatrix(); renderArm(&claw1); renderArm(&claw5); glPopMatrix(); glPushMatrix(); renderArm(&claw2); renderArm(&claw6); glPopMatrix(); glPushMatrix(); renderArm(&claw3); renderArm(&claw7); glPopMatrix(); glPushMatrix(); renderArm(&claw4); renderArm(&claw8); glPopMatrix(); if (armData.visible == VISIBLE) { glTranslatef(0,-0.5,0); glRotatef(-45,0,1,0); renderArm(&hanggedObject); } //glutPostRedisplay(); glutSwapBuffers(); }
void display(void) { glViewport(0,0,(GLsizei)WINDOW_WIDTH,(GLsizei)WINDOW_HEIGHT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(40,(GLfloat)WINDOW_WIDTH/(GLfloat)WINDOW_HEIGHT, 1, 100); gluLookAt(0,15, 20, 0, 0, 0, 0, 1, 0); int i; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); init_light(); drawCage(); for (i = 0; i < 5; i++) { drawObject(stObj[i]); } drawArmBand(); glLoadIdentity(); glTranslatef(armData.x, (LARGE_CUBE_SIZE /2)+0.5, armData.z); renderArm(&band); glRotatef(45,0,1,0); renderArm(&hand); glPushMatrix(); renderArm(&claw1); renderArm(&claw5); glPopMatrix(); glPushMatrix(); renderArm(&claw2); renderArm(&claw6); glPopMatrix(); glPushMatrix(); renderArm(&claw3); renderArm(&claw7); glPopMatrix(); glPushMatrix(); renderArm(&claw4); renderArm(&claw8); glPopMatrix(); if (armData.visible == VISIBLE) { glTranslatef(0,-0.5,0); glRotatef(-45,0,1,0); renderArm(&hanggedObject); } glPushAttrib(GL_TRANSFORM_BIT // to backup & restore "current matrix mode" | GL_ENABLE_BIT); // to backup & restore "depth test" and "lighting" status glDisable(GL_DEPTH_TEST); glDisable(GL_LIGHTING); glMatrixMode(GL_PROJECTION); glPushMatrix(); // not to mess up the projection matrix... glLoadIdentity(); glOrtho(0, WINDOW_WIDTH, 0, WINDOW_HEIGHT, -1, 1); glMatrixMode(GL_MODELVIEW); glPushMatrix(); // not to mess up the modelview matrix... glLoadIdentity(); { char buf[128]; int i; sprintf(buf, "claw position: (%f, %f, %f)", armData.x, armData.y ,armData.z); glColor3f(1,1,1); glRasterPos3f(10, 10, 0); for(i = 0 ; i < strlen(buf) ; i++) { glutBitmapCharacter(GLUT_BITMAP_9_BY_15, buf[i]); } } glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glPopAttrib(); glViewport(638,0,150,150); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(40,150/150,1, 100); //glOrtho(, 2.0, -2, 2, 1, 10); gluLookAt(armData.x,armData.y,armData.z, armData.x,-6,armData.z, 0, 0, -1); glMatrixMode(GL_MODELVIEW); init_light(); drawCage(); for (i = 0; i < 5; i++) { drawObject(stObj[i]); } drawArmBand(); glLoadIdentity(); glTranslatef(armData.x, (LARGE_CUBE_SIZE /2)+0.5, armData.z); renderArm(&band); glRotatef(45,0,1,0); renderArm(&hand); glPushMatrix(); renderArm(&claw1); renderArm(&claw5); glPopMatrix(); glPushMatrix(); renderArm(&claw2); renderArm(&claw6); glPopMatrix(); glPushMatrix(); renderArm(&claw3); renderArm(&claw7); glPopMatrix(); glPushMatrix(); renderArm(&claw4); renderArm(&claw8); glPopMatrix(); if (armData.visible == VISIBLE) { glTranslatef(0,-0.5,0); glRotatef(-45,0,1,0); renderArm(&hanggedObject); } glutSwapBuffers(); }