What's the best way to draw background pixel by pixel?



I want to draw all pixels in the room individually, whats the best way to do so?
Every pixel's color will be calculated from the math formula that uses x and y position as input.
Should I use surface?
Should I draw 1x1 sprite and move it along?
Or something else ?
Also it would be cool to be able to save drawing as an image.


Yeah, a surface could be good. Loop through all pixell using 2 foor loops.
var xx, yy;
var sw = 800;
var sh = 800;
my_surf = surface_create(sw, sh);
draw_clear_alpha(c_black, 0);
for(yy=0; yy<sh; yy++)
     for(xx=0; xx<sw; xx++)
     draw_sprite_ext(spr_pixel, 0, xx, yy, 1, 1, 0, the_color_you_need, 1);
Then draw that surface or convert it to a background using ackground_create_from_surface.


The forum's immigrant
You know... all this can be achieved in shaders... within fragment shader, you can check on every pixel of a specified drawing (can be background as well) and you can modify each pixel within that drawing much quicker and efficiently.

Here is a quick look up on how that works:

texture2D( image, pixel coordinate)

The image argument is to pickup a drawing for using in the shader. You can gm_Basetexture or specify your own sample using uniforms. Pixel coordinate is basically which pixel you want to look up on in the drawing.

So you want to check each one. That is simple. With a texture coordinate attribute, you pass it to the fragment shader and use the attributes xy.

texture2D( gm_Basetexture, v_vTexturecoord.xy)

So you can modify every pixel with any calculations you want to do.

If you want a quick tutorial, checl out xor's tutorials on shaders. They definitely helpped me and pretty sure it will help you too.

If you dont have gms and using gm8 or something,... go for surface technique then. Its all good.