Opengl/DirectX OOP

Started by
2 comments, last by Quisnam 14 years, 5 months ago
Hello! I have been making games in C++ for quite a while, but always using GDI++ and the console. I had some experience with DirectX but it didnt go too well, so I have decided to increase my overall C++ knowledge first. Recently, I have decided its time to really learn a 3d API. I'm using allot of OOP and I think using OOP generates cleaner code, so I'm wondering which of the two most popular 3d API's (Opengl and Directx) is better suited for an OOP aproach? Thanks in advance.
Advertisement
Quote:Original post by Quisnam
which of the two most popular 3d API's (Opengl and Directx) is better suited for an OOP aproach?

Both are object oriented, but OpenGL does object management in C style - you work with objects through OpenGL's functions rather than through classes.
Both are OO, however OpenGL's bind-to-edit semantics significantly complicate its use. You need to be very careful with bound state. Either:

  • code defensively and always reset state to its previous condition before returning from a method, or

  • trash state at will, but make sure that every method resets it to a known condition when called


Unfortunately, both approaches carry performance penalties.

There is work being done on a direct-state-access extension that would bring OpenGL on par with D3D on this front, but this will take some time before becoming a core feature (if ever).

[OpenTK: C# OpenGL 4.4, OpenGL ES 3.0 and OpenAL 1.1. Now with Linux/KMS support!]

Thanks for the replies lightbringer and Fiddler.
I think using DirectX would be better for me in this case, I'm not worried allot about it being crossplatform, plus I'm used to MSDN already.
Got to finish some of my old projects first, then I'll be learning DirectX.

This topic is closed to new replies.

Advertisement