OpenGL: Drawing a Texture onto Another Texture
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?
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);
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);
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.
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]
[Edited by - EnigmaticCoder on March 9, 2010 1:50:07 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement