3 ms·
Minor correction: OpenGL actually works great for 2D as well. There are versions of all the API functions that accept vertices with 2 dimensions instead of 3. A
by witten 17y ago
Minor correction: OpenGL actually works great for 2D as well. There are versions of all the API functions that accept vertices with 2 dimensions instead of 3. And you can quite easily make vertex buffer objects with only 2 dimensions.
- daeken 17y agoYou have the ortho modes and all that, but that's not really 2d drawing. Doing things like concave shapes with specific line drawing (especially if you want decent anti-aliasing) is complex and expensive, since OpenGL isn't particularly well suited for it. Of course, on the DirectX side you have the DirectDraw vs Direct2D mess, not to mention that the APIs are very poorly designed (in my opinion, at least). Doing 2D stuff in OpenGL isn't terrible, but it's certainly not well suited to it. In most cases, something like SDL ends up being easier and rarely too much slower (well, unless you're scaling/rotating...).
- witten 17y agoIt's true that OpenGL doesn't have built-in support for things like concave shapes, but you can always do tessellation and feed GL triangles. (Some tessellation options were mentioned in the article.) I've found that for my particular uses, the hardware acceleration you get with GL makes it worth it for 2D, even if it's perhaps not otherwise as well-suited for that as SDL.
- daeken 17y agoYou know, this makes me think. Are there any good 2D libraries for OpenGL? I've seen a few, but they all seemed very special-purpose or were either poorly designed or just didn't work. It'd be interesting to have a nice library like SDL, but sitting on top of real hardware acceleration.
- Jach 17y agoJust wait for SDL 1.3 to mature. From the wikipedia article: "SDL 1.3 is a major update to the SDL 1.2 codebase. It replaces several parts of the 1.2 API with more general support for multiple input and output options. Some feature additions include multiple window support, multiple input device support (many mice, many keyboards, etc.), hardware-accelerated 2D graphics, and better Unicode support."
- ronaldj 17y agoCocos2d is a 2d library that sits on top of OpenGL ES for the iPhone, it's rather nice.
- greyfade 17y agoCairo comes to mind. It has an OpenGL backend that works very well. Qt also has a GL drawing engine, which turned out to be a good move on Trolltech's part.
- Quiark 17y agoDirectDraw/Direct2D has been deprecated long time ago in favor of Direct3D. So basically you are in the same position as with OpenGL.
- daeken 17y agoNo, that's not true. DirectDraw was deprecated with no replacement, then Direct2D was created for Windows 7/Win2k8R2.