Does buffer_set_surface() work?
See title. I'm trying to create a lookup texture for a shader, and the sanest way to do it that I can see is:
-
Fill a buffer with your data (32-bit floats in my case, which map nicely to the 4 color channels).
-
Move the buffer data to a surface.
-
Get the texture handle for the surface and pass to shader as a uniform.
The issue I'm having is that the data in the buffer doesn't make it to the surface. The surface always draws as transparent black (verified with debugger).
Here is the code I'm using to fill the buffer:
//buffer debuggery
var moop = buffer_create(4*4*screenWidth,buffer_fast,1)
buffer_seek(moop,buffer_seek_start,0);
repeat (4*4*screenWidth)
{
buffer_write(moop,buffer_u8,irandom(255));
}
//clear our data surface
surface_set_target(floorDataSurf);
draw_clear_alpha(c_blue,1);
surface_reset_target();
buffer_set_surface(moop,floorDataSurf,0,0,0);
I have confirmed with a hex editor that the buffer was full of random values before I called buffer_set_surface(), and that the surface was filled entirely with zeroes afterwards.
I know the buffer is the correct size because making it smaller or larger causes the function to fail, leaving the surface its previous color.
I am using windows 7 and GMS 1.4.1763.
Posted Jul 20, 2017, 4:25 AM UTC
are you using windows? I believe buffer_set_surface only works on windows. I don't know what else it could be besides programer error. Make sure you check all the usual things, setting to correct surface, not overwriting surface elsewhere, using correct variable scope, etc..
Someone needs to tell yoyogames there needs to be better ways to get data into shaders. Mobile phones holding everything back... if it wasn't for those damn things gamemaker could reach its fullest potential... but, "cross platform compatability". :(