2012-03-15 4 views
1

화면의 왼쪽 하단에 디버깅 정보 (FPS, 카메라 위치 및 회전 등)를 인쇄하려고합니다. glTranslate()glRasterPos2f()을 사용하여 문제없이 작동하도록 설정했지만 창 크기를 조정하면 텍스트가 더 이상 모서리에 완전히 들어 가지 않으며 창 밖으로 늘어나는 정도에 따라 텍스트가 나타날 수 있습니다. 화면의 중앙에 위치하거나, ​​끊어지기 시작할 수 있습니다. glPrint()을 사용하여 왼쪽에서 10px, 오른쪽에서 10px의 텍스트를 인쇄 할 수 있습니까?OpenGL : 화면에 상대적으로 glPrint() 위치를 설정하십시오.

GLvoid glPrint(const char *fmt, ...){     // Custom GL "Print" Routine 
    char  text[256];        // Holds Our String 
    va_list  ap;          // Pointer To List Of Arguments 
    va_start(ap, fmt);         // Parses The String For Variables 
     vsprintf(text, fmt, ap);      // And Converts Symbols To Actual Numbers 
    va_end(ap);           // Results Are Stored In Text 

    glPushAttrib(GL_LIST_BIT);       // Pushes The Display List Bits 
    glListBase(base - 32);        // Sets The Base Character to 32 
    glCallLists(strlen(text), GL_UNSIGNED_BYTE, text); // Draws The Display List Text 
    glPopAttrib();          // Pops The Display List Bits 
} 

void GLOUT(float xLocation, float yLocation, float colorRed, float colorGreen, float colorBlue){ 
    glDisable(GL_TEXTURE_2D); 
    glLoadIdentity(); 
    glTranslatef(0,0,-.002); 
    glColor3f(colorRed,colorGreen,colorBlue); 
    glRasterPos2f(xLocation/10000, yLocation/10000); 
    glPopMatrix(); 
} 

enter image description here

답변

2

렌더링 HUD의 다른 오버레이 물건 트릭, 그들을 위해 뷰포트와 투사의보다 편리한 조합으로 전환하는 것입니다 : 여기

내가 사용하고있는 코드입니다.

OpenGL을 사용하면 특정 투영법을 고집하지 않아도됩니다. Windows의 크기 조정 핸들러에서 뷰포트 및 투영을 설정했는지 맞습니까? 제안 : 그 코드를 드로잉 기능으로 옮기고 (잘하면) 그렇게하는 주현절을 가지십시오.

관련 문제