Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Is opengl appropriate for 2d games?


Asked by Idris Rojas on Dec 09, 2021 FAQ



OpenGL is quite appropriate for 2D games. Although it is generally used for 3D, the same functionality can be used for 2D games. That is to say, anything you can do with 3D OpenGL will be applicable with "2D" OpenGL. Some further information can be found at this location.
Also,
While OpenGL is a 3D API, you can still use it to make 2D games. You can fake a 2D environment in 3D through various techniques, such as contraining data to a plane. However, there is limited support in the actual API for doing this in an obvious fashion (there's no "turn on 2D mode" function, for example).
Besides, As you can see, there is no perception of depth in the orthographic projection. This makes it ideal for 2D games, where you want a layered approach to drawing things. Since there is no distortion as objects are placed further away from the camera, you can draw 2D sprites that you want behind other sprites, further back.
In this manner,
It’s also important to note that OpenGL is just a library. If you download it with the intention to create games, you’re also going to need a compiler, other libraries and perhaps even a host of other development tools. No licensed required by developers Limited help documentation
Accordingly,
OpenGL is definitely faster than GDI when it comes to texturing, alpha blending, etc. However depending on system and GPU pure GDI may outperform OpenGL for so simple things like drawing an arc or filling a complex self intersecting polygon with complex winding rules.