애니메이션 렌더링과 헤드 업 디스플레이 렌더링을 반복하는 코드를 작성하려고합니다. 애니메이션은 작동하지만 애니메이션의 투영 행렬과 HUD의 다른 직교 투영 행렬을 전환하는 데 어려움을 겪고 있습니다.Projection 및 ModelView 행렬 저장 및 복원
init();
while (isAnimationRunning) {
drawAnimation();
drawHUD();
}
표면의 초기화는 :
void init(){
glEnableClientState(GL10.GL_VERTEX_ARRAY);
glClearColor(1, 1, 1, 1);
glMatrixMode(GL11.GL_PROJECTION);
glLoadIdentity();
glViewport(0, 0, windowWidth, windowHeight);
GLU.gluPerspective(gl11, 45.0f, windowWidth/windowHeight, 0.1f, 100.0f);
}
그리고 애니메이션 코드
void drawAnimation() {
glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL10.GL_MODELVIEW);
glLoadIdentity();
GLU.gluLookAt(gl11, x, y, zoom, x, y, 0, 0, 1, 0);
drawAnimationTextures();
}
하고 코드를 렌더링 다음
메인 루프가 실행 HUD 렌더링의 경우
void drawHUD(){
glMatrixMode(GL10.GL_MODELVIEW);
glPushMatrix();
// IF THIS LINE IS REMOVED THE ANIMATION DISPLAYS BUT NOT THE HUD
glLoadIdentity();
glClear(GL10.GL_COLOR_BUFFER_BIT);
GLU.gluLookAt(gl11, 0, 0, 2, 0, 0, 0, 0, 1, 0);
glMatrixMode(GL10.GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
GLU.gluPerspective(gl11, 45, aspectRatio, 0.1f, 100.0f);
glOrthof(-aspectRatio, aspectRatio, -1, 1, -4, 4);
drawHUDTexture();
glPopMatrix();
glMatrixMode(GL10.GL_MODELVIEW);
glPopMatrix();
}
이 코드가 구현되면 화면이 비어 있습니다. 어떤 아이디어가 문제 일 수 있겠습니까?
//////////////////////// 왜 두 루틴의 프레임 버퍼를 삭제하는
void drawTexture(float x, float y, float z, float sizeX, float sizeY,...){
glEnable(GL10.GL_TEXTURE_2D);
glPushMatrix();
bindTexture(texture);
glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
glFrontFace(GL10.GL_CW);
glColor4f(RGB[0], RGB[1], RGB[2], alpha);
glTranslatef(x, y, z);
glScalef(sizeX, sizeY, sizeZ);
glVertexPointer(3, GL10.GL_FLOAT, 0, squareVertexBuffer);
glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureBuffer);
glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);
glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
glPopMatrix();
}
이 정수는 나눗셈입니까? 'GLU.gluPerspective (gl11, 45.0f, windowWidth/windowHeight, 0.1f, 100.0f);'drawTexture() 함수의 내용은 무엇입니까? – Tim
안녕하세요. division truncation이 아니라 gluPespective에서 그 문제를 다루었습니다. drawTexture() 위에 게시했습니다. 이것 좀 봐 줘서 고마워. –