почему сцена не начинается с центра экрана в opengl в macos - PullRequest
0 голосов
/ 18 февраля 2020

Начальная позиция сцены, установленная как (0,0,0), находится в центре вашей сцены. Однако в MACOS (10.15.2) сцена начинается не с центра, а начинается с нижнего правого края. Что является причиной этого? На windows сцена начинается с центра. код draw (), reshape () и setup () выглядит следующим образом:

void setup()
{
    width  = 600;                                   // initialise global window variables
    height = 400;                                   // define in your header: int width, height;
    glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE);  // enable 3D rendering and double buffering
    glutInitWindowSize(width, height);              // set window size
    glutCreateWindow("My Scene");                   // create and show window (named MyScene)
}
void reshape(int _width, int _height)
{
    // update global dimension variables
    width  = _width;
    height = _height;
    // calculate new aspect ratio
    GLdouble aspect = static_cast<GLdouble>(width) / static_cast<GLdouble>(height);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();     // reset matrix
    gluPerspective(45.0, aspect, 1, 1000);
    glViewport(0, 0, width, height);
    glMatrixMode(GL_MODELVIEW); // return matrix mode to modelling and viewing
}
void draw()
{
    glClearColor(1.f, 1.f, 1.f, 1.f);                   // set background colour
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear buffers
    glMatrixMode(GL_MODELVIEW);                         // set for model and viewing operations
    glLoadIdentity();                                   // reset drawing

    glTranslatef(0.f, 0.f, -100.f);                     // move drawing further back in the scene
    glColor3f(0.f, 0.f, 0.f);                           // set draw colour to black
    glutWireCube(10.f);                                 // draw outlined cube

    checkGLError();
    glutSwapBuffers();                                  // execute all commands, swap buffers
}
...