How can I specify vertices in pixels in OpenGL?
问题 I want to write a small project with OpenGL C++ and I want to use pixel instead of float value, for example like that: glVertext2f(420, 300); Instead of: glVertex2f(0.4, -0.34); Is it possible? 回答1: If you want to use pixel coordinates your rendering, it's pretty easy to do so using an orthographic matrix, which you can create using glOrtho. Assuming your window is 800x600 you could use the following code: // Set your projection matrix glMatrixMode(GL_PROJECTION); glOrtho(0, 800, 0, 600, -1,