Sign in to follow this  

Draw primitives on textures?

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

Hi! I'm making a 2D game engine and I want to draw a primitive (or actually do anything on a texture that I can do on the framebuffer) on a texture but I can't seem to find a simple solution for this. The first thing I thought about was using an auxiliary color buffer but my graphic card doesn't support that. (btw, is it common with auxiliary color buffers on graphic cards?) The only solution I can find is to 1) use glCopyTexSubImage2D() to store the current color buffer in a temporary texture (or save it somewhere else, maybe the accumulation buffer is faster?) 2) use glTexImage2D() to draw the texture, that I want to draw a primitive on, (or whatever I want to do with the texture) on the color buffer 3) draw a primitive (or whatever I want to do with the texture) on the color buffer 4) use glCopyTexSubImage2D() to store the part of the color buffer that contains the modified image by replacing the original texture 5) use glTexImage2D() to draw the temporary screen texture back on the framebuffer This is probably not just very slow but it also have some restrictions, for example the texture can't have larger dimensions than the screen. Is there another easy way that I've just completely missed or something else that's at least better than my solution to this problem? BTW, can't you paint primitives on SDL_Surface's in the SDL library? If so, how are these surfaces realised? Thanks! Martin

Share this post


Link to post
Share on other sites
You can use PBOs or FBOs and render a fullscreen quad with the texture to them plus the primitives you want.

BTW, what exactly do you want to achieve?

It might also be sufficient to just draw the primitives on a separate texture and blend both together on the screen. Depends on what is your goal.

Share this post


Link to post
Share on other sites

This topic is 3457 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.

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