Github Page:

Reading a color data from a surface is a very slow process. It's a known technique to get the surface to a buffer (which is sometimes called pixel buffer on different platforms) and look the data up from the buffer to make it faster.

These scripts make this process easier. All the commands used are GMS commands. No external resource is used.

The pack contains 3 rooms which you can use to check the performance.

Currently HTML5 module doesn't have buffer_exists included. So It's not working for HTML5. The issue seems to be fixed by Mark on the issue tracker, but it is not released yet as I am writing this.

Tested on Windows and Mac. Mac has a different color data order. So there is an option for the in the scripts.

Performance Tip: Looking up data from arrays is slightly faster than looking up data from buffers. That's why I used an array to hold the parameters and the buffer itself. So pbuffer is actually an array that contains the real buffer. Looks like this:

[surface_width, surface_height, buffer]

Note: I'm aware that there is one more asset on the marketplace that does the same thing. This one is a bit more detailed than that. The other one has some minor issues I'm sure that will be fixed. The reason I released this despite having that is, this is a piece of a bigger toolkit I'm working on right now. So It will be a dependency for the new asset. Since the other one is a free asset, I don't think this harms the other user.

There is a README file in the pack but here is a peek at how you use it:

var pbuffer = pbuffer_create_from_surface(some_surface);
var pix = pbuffer_get_pixel(pbuffer, some_x, some_y);
_red     = pbuffer_pixel_get_r(pix);
_green = pbuffer_pixel_get_g(pix);
_blue    = pbuffer_pixel_get_b(pix);

Check the README.gml.

TL;DR: It's not a new trick. It's actually a very well known technique which is used widely. Get it, use it. It's SUPER FAST.

More info

End User Licence Agreement (EULA).

Version 1.2.3. Published May 12, 2017

Created with GameMaker: Studio v1.99.533

Age Rating: 4+

Average Rating

This asset hasn't received enough reviews yet.

Your review

You can only review assets you've bought.

No reviews yet

No reviews have been left for this asset - be the first!

Package contents

Loading, please wait

What is the issue?

Back to Top