Sign in to follow this  
EnigmaticCoder

OpenGL: Drawing a Texture onto Another Texture

Recommended Posts

I just switched from rendering with SDL to rendering with OpenGL and using SDL for creating the window. With SDL I could call SDL_BlitSurface(source, clip region, destination, position) and blit one surface onto another. Is this possible with OpenGL?

Share this post


Link to post
Share on other sites
If you want to overlay an image over your scene, you need to create a textured quad with your RGBA sprite, and then draw that primitive on top of your other scene geometry with blending enabled. There's no simple blit function.

Something like:

//Draw Scene
....
//End Scene

glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); (assumes black=transparent)

//Draw Textured Quad
...
//End Quad

glDisable(GL_BLEND);

Share this post


Link to post
Share on other sites
Not directly, but thing work differently in OpenGL, just draw textures to the screen. If you need to get this rendering into another texture, you can use Framebuffer Objects (FBOs) to draw to textures instead to the default framebuffer.

Share this post


Link to post
Share on other sites
I'm working on a game that allows the player to dig through dirt. I want to store the tunnels on a surface that's bigger than the width and height of the screen. Then, every frame, I want to render that surface to the screen (only what fits on the screen). When ever I dig more tunnels, I will add to the tunnel surface, opposed to drawing all the tunnels to the screen every frame.

[Edited by - EnigmaticCoder on March 9, 2010 1:50:07 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this