• Advertisement
Sign in to follow this  

OpenGL: Drawing a Texture onto Another Texture

This topic is 2907 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

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
Advertisement
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
Sign in to follow this  

  • Advertisement