This isn’t an invitation to flame, or debate openGL vs anything else. I have a particular application, written in C++ for Windows (XP and Vista, and no immediate need to run it elsewhere), and it makes a whole lot of calls to the GDI, basically Rectangle, Polygon (always for triangles), and LineTo. Purely 2D work, and the polygons drawn are numerous and typically tiny (in some occasionally useful situations, they reduce to single pixels).
Performance is utterly abysmal. I can watch the window repaint, and times of 2-5 seconds are not uncommon. (On a laptop with what is probably crummy, integrated video). I’d really like the repaint time to be a handful of milliseconds. The worst-case scenario is about a million triangles (one pixel each at 1280x960). So I’m assuming I really, really want hardware acceleration for this.
So here’s my wishlist and not wished-list. Is openGL a good fit?
- Trivial to install and build and call, using straight C++ in Microsoft Dev Studio 7.1.
- Will work today, will work tomorrow without modification. This is not a tool I want to revisit over and over. I just want it to work.
- Fast; a worst-case scenario of a million triangles in, say, 0.2 seconds, isn’t laughable. (This worst case is extreme; often I have whole regions without any triangles to draw (ie, left black) and the triangles to be drawn are usually larger than a pixel.) If all it’s going to do is paint a bitmap using the CPU, and then flip the bitmap, I’m not sure that will cut it.
- I only need 2D primitives (am happy to use ortho projection in 3D).
- My “textures” are simply colors, and few of those; I don’t need shading or bitmaps. No alpha blending, fog, complex stuff.
- Ideally, I could tell openGL not to cull triangles because I didn’t specify them with the right winding. But if forced, I can organize all my triangles to be counterclockwise. (The layout of the triangles is generated once, and saved; all I have to do at runtime is figure out which ones are in the bounding rectangle, and draw those with the right colors.)
- The same code should work on XP and Vista(Aero).
- Will work over multiple displays (aka extended desktop) on the same system (caveat: really only has to work on one display or the other, but I have to be able to move it.)
- Will work reasonably well if handed the triangles individually (I know fans are probably faster and move less data, but I hope not to do that much work. I do know when two triangles are adjacent and tile a rectangle, and the same color, but that’s as far as I want to push it.)
- Will let me have a “regular” window frame. (I have menus and I want to keep them.)
- Dropping text on the screen, specifying a starting pixel x,y position, isn’t too hard.
I know I could probably do this in DirectX. The last time I played with DirectX was years ago; it was hard, and I think the interface has changed multiple times since then. DirectX is too much learning curve and debugging hell.
Is openGL going to work for me? Please, no flames, be gentle.