OpenGL trying to Draw Multiple 2d Textures, only 1st one appears

前端 未结 2 393
名媛妹妹
名媛妹妹 2021-01-20 18:45

I\'ve got a problem in that I\'m trying to draw a solar system using textures (one texture for each planet) and as I draw my textures, only the 1st one appears. None of the

2条回答
  •  -上瘾入骨i
    2021-01-20 19:17

    gluOrtho2D() doesn't issue a glLoadIdentity() like you seem to expect.

    Generally you only set your projection matrix once per frame.

    Try something like this:

    void DrawFrame()
    {
        ...
    
        glMatrixMode( GL_PROJECTION );
        glLoadIdentity();
        gluOrtho2D(0, this.Width, 0, this.Height);
    
        glMatrixMode( GL_MODELVIEW );
        glLoadIdentity();
        // "camera" transform(s)
    
        foreach object
        {
            glPushMatrix();
            // per-object matrix transform(s)
    
            // draw object
    
            glPopMatrix();
        }
    }
    

提交回复
热议问题