Jump to content
  • Advertisement
Sign in to follow this  
DAN200

OpenGL Rendering to Offscreen surface then rendering that onto screen

This topic is 5392 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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).

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
PBuffers are what you want. You can set them as the buffer for OpenGL to render to and then bind them to a texture later.

As for what cards support this here is a list of all the cards that support the WGL_ARB_render_texture extension.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!