• 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!

Buffers and surface layers

  • Thread starter Deleted member 16767
  • Start date
D

Deleted member 16767

Guest
I have surface layers in my painting app. If I use buffer_grow, it only loads the last layer that was drawn on. And if I use buffer_seek_start it loads the first layer that was drawn on. But I want to load every single layer that has been drawn on.

Here's the code. What do I do?

GML:
var pos = buffer_seek(buffersurf, buffer_grow, 0);
buffer_load_ext(buffersurf,fileload,pos)

if surface_exists(global.final_surf)
{
buffer_set_surface(buffersurf,global.final_surf,0)
}
 

GMWolf

aka fel666
Your code only calls buffer_set_surface once, and on one surface. So it's only going to load that one surface.

What you need is some sort of loop to call buffer_set_surface on all your surfaces with the right offset.
 
D

Deleted member 16767

Guest
A loop just creates the same image on all layers.
 

GMWolf

aka fel666
That would mean you are continually reading the same portion of the buffer.
For each surface, you need to calculate where in the buffer to read from.

A surface will use width × height × 4 bytes of memory.
 
D

Deleted member 16767

Guest
Like this?

buffersurf1 = buffer_create(room_width * room_height, buffer_grow, 1);
buffersurf2 = buffer_create(room_width * room_height, buffer_grow, 1);
buffersurf3 = buffer_create(room_width * room_height, buffer_grow, 1);
 

GMWolf

aka fel666
Do you know about arrays?
Also, how familiar are you with buffers?
You could have a single buffer large enough for all surfaces, and use the right offset in buffer_set_surfave.


Like this?

buffersurf1 = buffer_create(room_width * room_height, buffer_grow, 1);
buffersurf2 = buffer_create(room_width * room_height, buffer_grow, 1);
buffersurf3 = buffer_create(room_width * room_height, buffer_grow, 1);
Have you tried this?
What happens?

Best advice I can give you is: write stuff. See what happens.
 
Top