• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Get_Pixel alternative

IGameArt

Member
Hey guys, it's been a while since I've really dug into the new buffers system but I remember seeing something about how much faster accessing a buffer directly is compared to using surface_get_pixel.

So my question is, what's the most efficient (read absolute fastest) way to get the rgba values of a specific pixel in a surface/sprite?
 
D

Deleted member 13992

Guest
Are you looking to read more than a handful of pixels per frame? A whole surface maybe? If so, best to use a shader for that kind of work. That would be the fastest, but also more advanced.
 

IGameArt

Member
I'm trying to create an array carrying the values of each pixel in an image. This is not meant to be a realtime effect, it will be performed one time. And I cannot do it with a shader because shaders will not give me a value but merely display what data I put into it on the screen. I need to just find a faster way of getting the data of a certain pixel.
 
H

Homunculus

Guest
You are probably looking for buffer_get_surface . Once the buffer containing the RGBA values of the surface is set, reading its values should definitely be a lot faster than using getpixel functions.
 

TheouAegis

Member
If you aren't using too many colors, you could consider making a ds_list of all the colors, create a second buffer that's 1/4 the size of the surface buffer, then retrieve the index in the list of each color and write the index to the second buffer. Now the second buffer has a 1-byte value for each pixel instead of a 4-byte value.
 
Top