2011-12-25 2 views
7

그냥 OpenGL에 원통을 그려야합니다. 나는 많은 샘플을 발견했지만 모두 Z 축에 실린더를 그립니다. 나는 그것들을 x 축이나 y 축으로 원한다. 어떻게해야합니까? 아래의 코드는 코드가 Z 방향으로 실린더를 그릴 내가 그 모든에OpenGL에서 y 축 또는 x 축으로 원통을 그리는 방법

GLUquadricObj *quadratic; 
    quadratic = gluNewQuadric(); 
    gluCylinder(quadratic,0.1f,0.1f,3.0f,32,32); 

답변

4

사용 glPushMatrixglRotatef 실린더를 그리고 glPopMatrix하여 도면을 마무리 렌더링 돼요.

예 : glRotatef(yRotationAngle, 0.0f, 1.0f, 0.0f); // Rotate your object around the y axis on yRotationAngle radians

예 : OnRender() 기능 예를 들어 당신은 당신의 좌표계 회전 glRotate(angle, x, y, z)을 사용할 수 있습니다

void OnRender() { 
    glClearColor(1.0f, 0.0f, 0.0f, 1.0f); // Clear the background 
    glClear(GL_COLOR_BUFFER_BIT); //Clear the colour buffer 
    glLoadIdentity(); // Load the Identity Matrix to reset our drawing locations 

    glRotatef(yRotationAngle, 0.0f, 1.0f, 0.0f); // Rotate our object around the y axis on yRotationAngle radians 

    // here *render* your cylinder (create and delete it in the other place. Not while rendering) 
    gluCylinder(quadratic,0.1f,0.1f,3.0f,32,32); 

    glFlush(); // Flush the OpenGL buffers to the window 
} 
관련 문제