Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Tier 2 - Direct updating of images being mapped onto 3D faces or sprites.

Author
Message
Westa
12
Years of Service
User Offline
Joined: 28th Oct 2011
Location:
Posted: 22nd Oct 2017 04:33 Edited at: 22nd Oct 2017 04:44
Hi All,

Looking for some suggestions on the best way to optimize the direct update of the contents of images in Tier 2.

Ive put some sample code here that mocks out what im looking to achieve - that explains it best.



But it seems like double handling - effectively doing two copies of the data per frame.

So the question really comes down to --- is there a way to directly write to the image itself and tell the system its been updated.

Without having to work through the memblock - or beyond that - maybe directly writing to the OpenGL texture which I assume is happening internally?

Any thoughts or advice would be greatly appreciated

Cheers

Westa
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 26th Oct 2017 22:37
The best, and fastest, way to modify an image is to draw to it with the GPU using SetRenderToImage. Otherwise you have to go through a memblock and do it on the CPU. If the image is small then the CPU method will work reasonably quickly.
Westa
12
Years of Service
User Offline
Joined: 28th Oct 2011
Location:
Posted: 27th Oct 2017 01:11
Hi Paul,

How would I go about doing that efficiently ... its a 320 by 240 buffer at the moment - that needs to be updated every frame

Are u suggested using something like a for loop using drawline(); to each pixel ? Or is there are better way to draw a single pixel like drawpixel( x , y , r , g , b);

So in pseudocode would I go something like ?
=============================================

SetRenderToImage ( 1 )

SetVirtiualScreen( ImageWidth ,ImageHeight )

ClearScreen()

for x = 0 to width
for y = 0 to height
drawline ( x , y , x , y , getRfrombuffer(x,y), getGfrombuffer(x,y), getBfrombuffer(x,y) )
loop y
loop x

SetRenderToScreen()

=============================================
cheers

westa

Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 27th Oct 2017 01:57
It could certainly be done that way, but I don't know how efficient it would be, since you're still technically setting every pixel via the CPU with a massive for loop. I was thinking more about using sprites to construct larger sections of the image, if this were feasible in your case. The fewer sprites and draw lines you use the faster it would be. But I would consider 320x240 small enough to consider using the CPU approach with memblocks. If it's fast enough for your needs then stick with that.

Login to post a reply

Server time is: 2024-03-29 08:38:56
Your offset time is: 2024-03-29 08:38:56