alternative to glTexSubImage2D()?

Member
Posts: 194
Joined: 2009.02
Post: #1
I have an array that I would like to upload it into a texture, and then render it to the screen, every frame. Is there a faster way to do this than calling glTexSubImage2D() ?
Quote this message in a reply
Member
Posts: 30
Joined: 2009.02
Post: #2
Heya Nelson, how's the game coming along?

Anyway the fastest (and only) alternative I know of is to use FBOs (frame buffer objects). They're extra buffers you can render to, and you can use them to render or otherwise send data to a texture without any glTexImage or glTexSubimage calls. It IS an OpenGL extension, so I'd keep some sort of fallback in place depending on the user's card.

I haven't used them yet so I have no idea what performance increase you'll see, but everywhere I look agrees that they're faster then using glTexImage/submage.

Here is a neat little tutorial that has a really good explanation of what the heck they are, then demonstrates rendering to a texture with one.
Quote this message in a reply
Member
Posts: 194
Joined: 2009.02
Post: #3
Hey metacollin, the game's coming along well though at the moment I'm fooling around with iphone graphics techniques. How's your game coming?

I intended to say that I am using opengl es in the op but forgot.

I'm a little familiar with fbos and my understanding is that you can't upload raw data, such as an array of floats, directly into the fbo- you'd have to first put it into a texture and that would require a call to glTexSubImage2D(), but please correct me if I'm wrong. Just to be clear, I'm not trying to render something into a texture, I'm trying to upload data into it.
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #4
No, there is no other way to load a texture really. How many textures do you need? Can you not just upload them all at once?

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: 194
Joined: 2009.02
Post: #5
Skorche Wrote:No, there is no other way to load a texture really. How many textures do you need? Can you not just upload them all at once?

Yeah that's pretty much the conclusion I've come to.

What I was trying to do was to put all of my light/shadow data into an array which would be recalculated each frame, upload the array to a texture, render the texture to the screen to generate lighting and shadows- I was generating the shadows by ray-tracing between light sources and surfaces this method is very slow but might have been fast enough if not for the 10-15 frame drop caused by glTexSubImage2D. As I originally suspected this approach is too slow all around so I'm now experimenting with other approaches.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Cocoa alternative to aglUseFont Ryan Witmer 1 2,798 Oct 9, 2009 05:35 PM
Last Post: OneSadCookie