Recommended Posts

I''m working on converting a game of mine from standard Allegro/DirectX to OpenGL/SDL. It''s a 2d shooter that I''m about %30 finished with, but I want to switch to a OpenGL rendering backend for my own various reasons. (If you''re curious, screenshots of the current version are available right here.)
Anyway, I''m using orthogonal projection and sprite-sheet textures for translating my 2D bitmaps into quad objects within OpenGL. (I then animate my sprites by just changing the texcoords for each frame.) All of it is working well and fine, but I did run into a slight problem.
I want to be able to use rotating/scaled texture-mapped quads to cut down on the number of frames of animation. (ie: Storing just a single ship image and then glRotating it to whatever I angle want, instead of storing X frames of pre-rotated bitmaps.) However, this presents me with a problem.
I use pixel-perfect collision detection in my existing game engine, and it''s trivial to read the current frame of animation for a sprite as it currently stands. But when using the OpenGL method to transform my quads, I no longer have access to the resulting scaled/rotated bitmap.
I think I can get around this with glCopyTexImage2D, or even the nVidia render-to-bitmap extension, but I''m not if that''s going to be very cost effective. I suppose I could render the sprite-quad to a small viewport and then glReadPixels it, sort of like in that radial blur tutorial from NeHe.
Anyone got any suggestions on how to do this? Go easy, I''m new to this OpenGL stuff.
---
http://www.gapingwolf.com

0

Share this post

Link to post

Share on other sites

If you don't use/nned the alpha component, you can do a custom sprite loading routine that also adds an alpha channel, like this: 0 alpha where there is no ship (black pixels), and 255 alpha where there is the actual ship.Then, you can just read the alpha component from the screen (back buffer), for the collision detection. I don't remember the function used to get one pixel, from the screen buffer, but try reading the Red Book, it should be there somewhere.

Latter edit: After looking at some screenshots, I seen that you are using the alpha component, so nevermind my suggestion