How i can make that a polygon fill the 80% of the width of the screen?

前端 未结 1 1522
梦谈多话
梦谈多话 2021-01-21 04:45

I have a simple square (polygon), and i want that it fills the 80% of the width of the screen

In other words, i want to position the square on the center on the center o

相关标签:
1条回答
  • 2021-01-21 05:29

    Use a projection that allows you to address the viewport in terms of ratios. Like this:

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity()
    glOrtho(0, 1, 0, 1, -1, 1);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    

    Now your OpenGL coordinates map the range [0,1]² to your screen. A 80% width would be 0.8 in the x coordinate.

    0 讨论(0)
提交回复
热议问题