2016-09-26 3 views
1

나는 7 년 전에 작성한 프로그램을 다시 불러 들이기 위해 노력하고 있습니다. Qt로 작성되었으며 일부 OpenGL을 사용하여 응용 프로그램이 표시하는 이미지에 프레임 선을 그립니다. 문제는 'gluOrtho2D'가 사용되었지만 더 이상 발견되지 않는다는 것입니다. 내가 어떻게 문제를 해결할 수 있는지 궁금하다. 여기에 코드입니다 : 내 머리 뒤쪽에서Qt 앱에서 'gluOrtho2d'를 바꾸는 방법

void MSContext::ResizePaint(int width, int height) 
{ 
    // setup viewport, projection etc.: 
    glViewport(0, 0, (GLint)width, (GLint)height); 
    glMatrixMode(GL_PROJECTION); 
    glLoadIdentity(); 
    gluOrtho2D(0.0, (GLdouble) width, 0.0, (GLdouble) height); 
    glMatrixMode(GL_MODELVIEW); 

    glClearColor(0.5, 0.5, 0.5, 1.0); 
    glShadeModel(GL_FLAT); 
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1); 

    CreatePrintCropMarks(); 
} 

void MSContext::CreatePrintCropMarks() 
{ 
    GLuint print45CropId = openGLListMgr()->print45CropId(); 
    glNewList(print45CropId, GL_COMPILE); 
    { 
     qreal lineSize = 4.0; 
     // Shrink down the canvas by 4 pixels so that the crop will show up 
     const QRectF& viewPort = primaryCanvas()->imageView()->viewRectangle(); 
     QRectF shrunkingCanvas = viewPort.adjusted(lineSize, lineSize, -lineSize, -lineSize); 

     QRectF print45Crop = GetCropRect(shrunkingCanvas, 5, 4); 
     QRectF print57Crop = GetCropRect(print45Crop, 7, 5); 

     glLineWidth(lineSize/2); 
     glLineStipple(1,0xFF00); 
     DrawBox(print57Crop); 
     glLineWidth(lineSize); 
     glLineStipple(1,0xFFFF); 
     DrawBox(print45Crop); 
    } 
    glEndList(); 
} 
+1

: gluOrtho2D은 C'thulhu과 오후의 차 한 잔을 즐기는 고대 eldergod처럼 들린다. – user4581301

답변

2

, 나는이 기능의 들어 본 적이없는 것 왜 궁금 ... (구식)는 OpenGL에서 좋은 대안이 밝혀졌습니다. SGI GLU implementation에서 :

void GLAPIENTRY             
gluOrtho2D(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top) 
{ 
    glOrtho(left, right, bottom, top, -1, 1); 
} 

그래서 당신은 쓸 수 있습니다 : 주제 오프

glOrtho(0.0, (GLdouble) width, 0.0, (GLdouble) height, -1, 1);