In OpenGL, can I draw a pixel that exactly at the coordinates (5, 5)?

后端 未结 5 1124
陌清茗
陌清茗 2021-02-19 06:35

By (5, 5) I mean exactly the fifth row and fifth column.

I found it very hard to draw things using screen coordinates, all the coordinates in OpenGL is relative, and usu

5条回答
  •  无人及你
    2021-02-19 06:56

    I did a bit of 3D programming several years back and, while I'm far from an expert, I think you are overlooking a very important difference between classical bitmapped DrawPixel(x, y) graphics and the type of graphics done with Direct3D and OpenGL.

    Back in the days before 3D, computer graphics was mostly about bitmaps, which is to say collections of colored dots. These dots had a 1:1 relationship with the pixels on your monitor.

    However, that had numerous drawbacks, including making 3D very difficult and requiring bitmaps of different sizes for different display resolutions.

    In OpenGL/D3D, you are dealing with vector graphics. Lines are defined by points in a 3-dimensional coordinate space, shapes are defined by lines and so on. Surfaces can have textures, lights can be added, as can various types of lighting effects etc. This entire scene, or a part of it, can then be viewed through a virtual camera.

    What you 'see' though this virtual camera is a projection of the scene onto a 2D surface. We're still dealing with vector graphics at this point. However, since computer displays consist of discrete pixels, this vector image has to be rasterized, which transforms the vector into a bitmap with actual pixels.

    To summarize, you can't use screen/window coordinates because OpenGL is based on vector graphics.

提交回复
热议问题