0
我在空白窗口中創建了兔子和鴨子圖像。我的計劃是顯示它兩次:一次自己和另一個像旋轉90度的圖像。我嘗試過第二次創建圖像,並通過更改值來改變圖像,但很困難,根本無法工作。需要使用哪些軸來旋轉平面中的圖像並以正確的方式完成。如何旋轉90度的計算機繪圖
void myInit(void){
glClearColor(1.0, 1.0, 1.0, 0); // the background is white
glColor3f(0.0f, 0.0f, 0.0f); // set drawing color
gluOrtho2D(0.0, (GLdouble) screenWidth, 0.0, (GLdouble) screenHeight);
}
void drawBunny(){
glClear(GL_COLOR_BUFFER_BIT);
// draw the outline of box (bunny)
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2i(50,50);
glVertex2i(150,50);
glVertex2i(150,100);
glVertex2i(50,100);
glEnd();
//draw bunny tail
glLineWidth(1);
glBegin(GL_LINE_STRIP);
glVertex2i(50,50);
glVertex2i(50,35);//2nd wider top/bottom
glVertex2i(70,35);//1st- shrink tail left/right
glVertex2i(70,50);//1st- shrink tail left/right
glEnd();
// draw first ear
glBegin(GL_LINE_LOOP);
glVertex2i(175,85);
glVertex2i(175,100);
glVertex2i(150,100);
glVertex2i(150,85);
glEnd();
//draw second ear
glBegin(GL_LINE_LOOP);
glVertex2i(175,70);
glVertex2i(175,100);
glVertex2i(150,100);
glVertex2i(150,70);
glEnd();
// draw the head
glBegin(GL_LINE_LOOP);
glVertex2i(150,100);
glVertex2i(150,110);
glVertex2i(125,110);
glVertex2i(125,100);
glEnd();
// draw first feet
glBegin(GL_LINE_LOOP);
glVertex2i(110,60);
glVertex2i(110,75);
glVertex2i(30,75); //decrease value increase feet
glVertex2i(30,60);
glEnd();
//draw second feet
glBegin(GL_LINE_LOOP);
glVertex2i(50,100);
glVertex2i(50,85);
glVertex2i(30,85); //decrease value increase feet
glVertex2i(30,100);
glEnd();
//* draw eyes
glBegin(GL_LINE_LOOP);
glVertex2i(140,100);
glVertex2i(140,105);
glVertex2i(135,105);
glVertex2i(135,100);
glEnd();
glFlush();
}
int main (int argc, char** argv){
glutInit(&argc, argv); // initialize the toolkit
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); // set display mode
glutInitWindowPosition(100,150); // set window position
glutInitWindowSize(screenWidth,screenHeight); // set window size
glutCreateWindow("House"); // create & open window
glutDisplayFunc(drawBunny); // register redraw function
myInit();
glutMainLoop(); // loop forever
}
** + 1個** - 一個小的點但是:'glutSwapBuffers(...)'是不是在這個正確的場景。像素格式是單緩衝的。雖然我不會建議首先使用單緩衝像素格式('GLUT_SINGLE'),但這是我們在這裏的: - \ –
@ AndonM.Coleman感謝您的警告,我閱讀了您正確的文檔。在單緩衝情況下,此功能不起作用。 –
我昨晚玩完這一切後發現問題。轉換順序是問題。 glTranslatef(100,100,0); glRotatef(180.0f,0.0f,0.0f,1.0f); glScalef(-1.0f,1.0f,1.0f); @Cagkan Toptas –