Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sprite transparency in OpenGL?
Author Message
Luminary
Posts: 5,059
Joined: 2002.04
Post: #16
To be clear: you have no need to call glTexSubImage2D for a sprite game. TexSubImage2D *is* slow, because it involves transferring data from the CPU to the GPU.

Create your textures once, bind and draw as necessary each frame.

And, GeForce 2MX?! Why are you using a ten year old graphics card?
Quote this message in a reply
Member
Posts: 96
Joined: 2011.07
Post: #17
yep. doesn't sound very feasible. still, as a thought experiment it sounds intriguing. What about VBOs? Isn't that kind of like a "hardware sprite"?

[Normally, I have a new mesh/quad for every frame, i.e., vertex pointer, but I keep my textures bound once (usually)].

respect,
pk

iFrog is coming.
Quote this message in a reply
Member
Posts: 260
Joined: 2005.05
Post: #18
(2011.12.20 11:21 AM)OneSadCookie Wrote:  To be clear: you have no need to call glTexSubImage2D for a sprite game. TexSubImage2D *is* slow, because it involves transferring data from the CPU to the GPU.

Now wait a minute. I think you just confused glTexSubImage2D with glReadPixels? The glTexSubImage2D call is fast and optimized and should not transfer data to the CPU. Rather, it is the backup call if you can't use FBOs (if you find FBOs to hard to use or you use an ancient system that doesn't support them.) But glReadPixels (combined with a glTexImage) is exactly what you describe, drawing to a texture the slow way. over the CPU.

But for the main question I agree, you are not likely to save time by doing more work, in this case render all sprites to a texture and then render that. And transparency for 2D sprites is easy. Get those done and start thinking about the harder parts, like a good collision detection/collision handling system.
Quote this message in a reply
Sage
Posts: 1,416
Joined: 2002.09
Post: #19
No, he said transferring from the CPU to the GPU. Refreshing a texture every frame is most certainly slower than reusing the same one over.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Member
Posts: 96
Joined: 2011.07
Post: #20
I just started thinking about "mesh sprites" that are 2D meshes with minimal or no transparency. Designing them would be different than making animated quads (where you usually have quite a lot of transparency). The bound bitmap would be more like a palette/texture, like with 3D objects.

respect,
pk

iFrog is coming.
Quote this message in a reply
Luminary
Posts: 5,059
Joined: 2002.04
Post: #21
You could certainly do that, but why bother?
Quote this message in a reply
Member
Posts: 260
Joined: 2005.05
Post: #22
(2012.01.07 07:26 AM)Skorche Wrote:  No, he said transferring from the CPU to the GPU. Refreshing a texture every frame is most certainly slower than reusing the same one over.
Same thing. If you use glTexSubImage2D, you don't transfer in either direction, it is all on the GPU.
Quote this message in a reply
Luminary
Posts: 5,059
Joined: 2002.04
Post: #23
TexSubImage2D is CPU->GPU.
CopyTexSubImage2D is GPU->GPU.
Quote this message in a reply
Member
Posts: 96
Joined: 2011.07
Post: #24
(2012.01.07 11:03 AM)OneSadCookie Wrote:  You could certainly do that, but why bother?

I'm thinking about cutting down the app size by avoiding a lot of texture sprites and somewhat a different look.

respect,
pk

iFrog is coming.
Quote this message in a reply
Luminary
Posts: 5,059
Joined: 2002.04
Post: #25
I don't think it would save any app size or allow any different look...
Quote this message in a reply
Member
Posts: 96
Joined: 2011.07
Post: #26
(2012.02.16 03:35 PM)OneSadCookie Wrote:  I don't think it would save any app size or allow any different look...

We can settle the score over a game of chess...

respect,
pk

iFrog is coming.
Quote this message in a reply
Sage
Posts: 1,416
Joined: 2002.09
Post: #27
(2012.02.16 03:35 PM)OneSadCookie Wrote:  I don't think it would save any app size or allow any different look...

Sure it would. With sprite animation you have to store a lot of discrete frames. With meshes you could do a lot of effects that are traditionally done with 3D models. Think like Another World or Flashback for example.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  OpenGL ES 2.0, 2D Alpha Transparency Artifacts Macmenace 3 3,669 2010.03.28 11:18 PM
Last Post: AnotherJake
  libpng transparency problem wyrmmage 3 2,714 2007.03.01 05:53 PM
Last Post: OneSadCookie
  OpenGL Sprite Structure Stalin55 2 2,018 2006.08.18 03:40 PM
Last Post: AnotherJake
  SDL + OpenGL Sprite Loading Problem Greywhind 3 2,917 2006.06.29 04:44 PM
Last Post: OneSadCookie
  Strange transparency errors... thingythekid 4 2,859 2005.08.24 05:01 AM
Last Post: thingythekid