Draw primitives on textures?

Started by
0 comments, last by Lord_Evil 15 years, 10 months ago
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
Advertisement
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.
If I was helpful, feel free to rate me up ;)If I wasn't and you feel to rate me down, please let me know why!

This topic is closed to new replies.

Advertisement