Lighting in OpenGL
I'm writing a 2d game in OpenGL. Every object is a textured quad. These object are stored in an array and then applied on top of eachother (I'm using GL_MODELVIEW). Now I want to implement some lighting. I don't want to use GL_LIGHTING 'cause it's too expensive (and number of light sources is limited).
Does anyone has any idea of how i can implement lighting without GL_LIGHT-s?
I've already thought of editing textures (and lighten the screen pixel by pixel), but that's even more expensive than GL_LIGHTING (think of assigning textures to 2500 quads 30 times a second!).
What kind of lighting effects are you looking for? Spot lights? Directional lighting? If you doing a 2D game I don't think you're going to see a huge framerate problem due to opengl lighting. You might want to try it out and then evaluate if you need to do your own specialized lighting.
OpenGL gives you up to Eight light sources Per Polygon. Just use one and reset its attributes to the nearest light source to whatever poly you are drawing.
You could darken your entire scene and draw blended lightmaps on top.
Or, even better, you could draw your light maps first, Im pretty sure you can setup the blend function to draw a pixel at an intensity based on what the pixel contains. Blend in any polys that are near light sources (they will be brighter where the light map was brighter), and then draw the rest at a dim level like glColor3f(0.2f,0.2f,0.2f). Thats how I would try to do it, but it depends on what exactly you want to get out of it and what would be the most practical based on your current implementation.
I agree with MrWizard. Just use OpenGL's lighting. I mean, if full 3D games can use it, than I am sure your 2D game can use it :p
Have you ever done 3D? The reason I ask is that you say you are doing a 2D game, but in order to do your own lighting routines the mathematics for that is all in 3D, and you would probably just soon realize that it isn't worth the hassle.
Like the others, I don't see why you are trying to avoid GL_LIGHTs for those reasons. But if you really want to, you can simply blend your textures with a black background.