View Full Version : 2D Bitmap Objects with Custom Lighting

Neil E
12-27-2012, 05:13 PM
I ported a programme in 2D in MSDOS to DirectX 3 (a long time ago;) now I want to port it to OpenGL. Surfaces in DirectDraw allowed quick work of it (when there was a DirectDraw,) but now I want to draw on multiple hardware configurations. The programme consists of 16x16 rotated sprites. The sprites are hard-coded in the programme itself. What is drawn on the screen is a combination of the sprites with some lighting model where each pixel is calculated independently for each frame.

Does OpenGL have a bitmap object that I could constantly update? Should I use a Pixel Buffer Object (how would I do that?) or a Frame Buffer Object to perform render-to-texture? and how would I store something so small (I thought 64x64 was the smallest it can handle?) Can I get a "surface," or simulate a surface to which to render? and how to do it quickly?

Dark Photon
12-27-2012, 05:41 PM
It sounds like these rotated sprites all precomputed and basically static images. So just upload these to one or more textures on startup. If you use a texture array, you can just shove them all in different slices of the same 2D texture array. Or you can store them in 16 separate 2D textures, if you didn't want to use a texture array for some reason. You could also atlas them into a single 2D texture, but that has annoying disadvantages with regards to addressing and filtering, so I'd recommend against that.

Does OpenGL have a bitmap object that I could constantly update
Doesn't sound like you need to update the bitmap (texture). You just draw with the right texture (or texture slice) for this frame.

Neil E
12-28-2012, 07:43 AM
That is a good suggestion, but my lighting model takes proximity to the light into account as well, sort of like it's an overhead light, and multiple light sources that are moving.

Neil E
01-02-2013, 09:21 PM
That would be a great suggestion, but the it has multiple dynamic lights; different lights could light different pixels. They also move around and are slightly "above" the sprites so the near light is different from a far light.