I have a 2D array of color data (say, a height map or mini-map) that I want to draw as a 320x240 pixel image to show on the screen and update as quickly as possible in real-time.
Current method uses nested For loops for column and width to read the rgb value from each element of the 2D array and calls DrawBox(rgb,x,y,x+1,y+1) for each pixel one by one. Is there something faster that can be done all at once that I don’t know about?
I do reuse the icon each frame by drawing on top of it to make the new frame. And I avoid calling DrawBox if the new rgb value for the pixel is same as the old one from the previous frame. Most pixels still update most pixels each frame.
ID:2954041
Nov 29 2024, 5:17 pm (Edited on Nov 29 2024, 6:03 pm)
|
|
Dec 3 2024, 5:01 am
|
|
You will crash out the Dyn.rsc real fast with this method. There is no best practice for this in BYOND.
|
I can get a couple frames per second using this method at 320x240 and then I upscale to final size with matrix transforms.
I've also done 800x600 with no upscaling but it updates at ~0.5 fps. This is just on a Microsoft Surface tablet. 75% of the computation is figuring out what color to make each pixel and it looks like about 25% is the actual drawing. Maybe when vectors come out in the next update that'll change. Certainly won't be able to do a first person shooter. |