Render to texture or blitting data to texture?
by Mark Rose · in Torque Game Builder · 10/07/2007 (3:03 pm) · 0 replies
Hi guys,
I have an array with a bunch of colour information. I manipulate this array (let's say it's 64x64) in a c++ function I've written. It's a 2d effect, much like a fire effect etc.
Now, I need to blit that data into a texture that can be used on screen. I'm currently cheating using a very round-about sort of way. It works, but it's far too slow. I can't up the resolution to 128x128 or it runs too slowly on my machine.
How I'm currently doing it:
I get a pointer to an object, then I get the ImageMapName() and cast that to a t2dImageMapDataBlock. If that's valid, I get a handle for getImageMapFrameTexture(0), and then call getBitmap() to get a GBitmap pointer. I then copy my data into gbitmap->GetAddress() and then call handle.refresh() to refresh that data. This is obviously a slow and long winded approach.
The question is, does anyone know the correct approach? Handle.refresh() is the slow part (the part that actually updates the texture). Am I just calling this in the wrong place, causing an engine stall, or should I not be using any of that method?
Has anyone written render-to-texture or preferably blit/memcopy to texture stuff that they are happy to share?
Many thanks :)
-Mark
I have an array with a bunch of colour information. I manipulate this array (let's say it's 64x64) in a c++ function I've written. It's a 2d effect, much like a fire effect etc.
Now, I need to blit that data into a texture that can be used on screen. I'm currently cheating using a very round-about sort of way. It works, but it's far too slow. I can't up the resolution to 128x128 or it runs too slowly on my machine.
How I'm currently doing it:
I get a pointer to an object, then I get the ImageMapName() and cast that to a t2dImageMapDataBlock. If that's valid, I get a handle for getImageMapFrameTexture(0), and then call getBitmap() to get a GBitmap pointer. I then copy my data into gbitmap->GetAddress() and then call handle.refresh() to refresh that data. This is obviously a slow and long winded approach.
The question is, does anyone know the correct approach? Handle.refresh() is the slow part (the part that actually updates the texture). Am I just calling this in the wrong place, causing an engine stall, or should I not be using any of that method?
Has anyone written render-to-texture or preferably blit/memcopy to texture stuff that they are happy to share?
Many thanks :)
-Mark