Rendering to Offscreen surface then rendering that onto screen
Hey, I'm currently writing an awesome 2D platformer tile engine using OpenGL in Orthographic mode. As part of this, I'm using some funky glBlendMode settings to make an image based lighting system, where a lightmap for the entire screen is to be constructed from certain object textures in the scene (ie. if the player is holding a flashlight, the flashlight itself would be rendered to the screen, and the light beam texture would be rendered to the lightmap). This lightmap will then be blended over the main screen to darken the areas where there is no light and keep bright the areas where there are (using glBlendMode(GL_ZERO, GL_SRC_COLOR) and a textured quad that fills the screen if you're interested).
Now, the thing is, I need a way to store and render to this lightmap buffer, and then render it over the screen as a texture. I have the system working perfectly for a static lightmap texture, but I don't know anything about how I would define or select a surface to construct this in real time.
I hope this post made sence, I'll post some diagrams if theres any confusion, but does anyone know of a way this can be done? Preferably not using any extensions.
You can use glCopyTexImage2D to copy the buffer into a texture. This is kind of slow, so you could consider using the render-to-texture extension.
Anyway, are you sure you absolutely need to save the lightmap to a texture? Maybe you could just construct the lightmap on the buffer and then render the tiles using glBlendFunc(GL_ZERO,GL_SRC_COLOR).
Anyway, are you sure you absolutely need to save the lightmap to a texture? Maybe you could just construct the lightmap on the buffer and then render the tiles using glBlendFunc(GL_ZERO,GL_SRC_COLOR).
I fairly sure I can't just render it on without a buffer in any order, seeing as my "world" contains several overlapping alpha blended layers, and my lightmaps will contain several additive blended overlapping lights.
I'm looking into this Render To Texture buissness, it seems like its supported in pretty much all graphics cards... correct me if I'm wrong on that one.
I'm looking into this Render To Texture buissness, it seems like its supported in pretty much all graphics cards... correct me if I'm wrong on that one.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement