making composite textures
I'm making a 2d isometric rpg in opengl and I use textured quads for all the sprites. I need to be able to copy equipment (textures) to the character texture to create a composite character texture who appears wearing all his equiptment. How should I go about this?
I wouldn't copy them to the character texture, I'd just draw additional quads with the equipment textures.
Why wouldn't you copy them into the character texture(and is it ever possible to do so)?
The real question is, why should you? You can draw zillions of textured quads at any given time, why worry about it? Yes you can update your textures with glTexSubImage2D if you really insist on copying the graphics over in software, but my guess is that there isn't much point to go through the extra hassle unless you find that you're really struggling with performance issues.
You're much more likely to hit performance issues using CopyTexSubImage2D than you are just drawing a few extra quads. The GPU *likes* drawing quads. It's good at it. Let it do what it was intended to.
OneSadCookie Wrote:You're much more likely to hit performance issues using CopyTexSubImage2D than you are just drawing a few extra quads...Oh yeah, definitely if you're doing it frequently, like every frame or something. But if you want to permanently (or semi-permanently as the case may be) change what the texture looks like, glTexSubImage2D will affect that change, and you *will* get better performance drawing one quad rather than two. Still not recommended unless you really find your back up against the wall though. Like you said, let it do the job it was designed for -- drawing more quads is a *good* thing!
Thanks for the helpful responses. I have one other unrelated question I'd like to ask concerning opengl. Now keep in mind my knowledge in opengl is extremely limited... currently how I handle drawing sprites(including overlapping tiles) in the proper order of their depth(or y screen coord as it would be for my engine) by keeping a 2d array of quads which I load (and draw) with all my sprite and tile quads every frame. This method seems to work fine, but my question is could this be done in a easier and more efficient manner through opengl(and the z-buffer im assuming)?
I don't think there is really any advantage to using depth buffer sorting over your own method, unless you really muck it up somehow, like reordering the entire scene each frame or something. I guess it depends on how you do it. I don't think I'd really worry about it too much -- I certainly don't with sprites
Just relying on the z-buffer brings its own nightmares when you're working with transparent textures. If you've already got your own z-sorting system, I wouldn't change it.