Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: 2D Bitmap Objects with Custom Lighting

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2012
    Posts
    6

    2D Bitmap Objects with Custom Lighting

    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?

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,220
    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.

  3. #3
    Junior Member Newbie
    Join Date
    Dec 2012
    Posts
    6
    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.

  4. #4
    Junior Member Newbie
    Join Date
    Dec 2012
    Posts
    6
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •