1. Hey! Guest! The 32nd GMC Jam will take place between Feb 22nd, 12:00 UTC (Friday noon) and Feb 25th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

How to create MUCH buffers (262144) without any array and without slow compile

Discussion in 'Programming' started by Edgamer63, Feb 12, 2019 at 8:16 PM.

  1. Edgamer63

    Edgamer63 Member

    Joined:
    Jan 24, 2018
    Posts:
    21
    hello, i want to know how do i create 262144 buffers without slowing down the compiler..


    Yeah, i created a code that is 262144 lines, creating buffers like [Obviously with a machine created by me that creates auto-code :3 ]:
    ______________
    Code:

    global.buffer1 = buffer_create(1,buffer_grow,1);
    global.buffer2 = buffer_create(1,buffer_grow,1);
    global.buffer3 = buffer_create(1,buffer_grow,1);
    [...]
    ____________________________________

    But The compiler slow down so much, so i want to create this quantity , to perform a better quality to my game xD, because i can handle global buffer with only a real number like : "buffer_poke(512,255,buffer_u8,64)"

    SO... There's another solution than creating a BIG ONE BUFFER, Like, making faster compiling, or creating a own function but outside gamemaker that can do it and pass buffer to my game?....

    OR, Does GM2 support Compiling 262144 lines very faster?

    [It consumes a lot of memory with the Array-Created Buffers]

    PD: Thanks to the guy who is decided to answer this with a good way :D.
    PD: It sounds crazy, but i think it's posible in GM 1.4 :v
     
  2. The Sorcerer

    The Sorcerer Member

    Joined:
    Jan 3, 2019
    Posts:
    138
    o_O

    How's one line for you?

    Code:
    for(i = 0; i < 262144; i++) global.buffer[i] = buffer_create(1,buffer_grow,1);
    

    Gotta be a better method than using a quarter of a million buffers though. I'd reconsider what it is you are trying to do.
     
  3. Joe Ellis

    Joe Ellis Member

    Joined:
    Aug 30, 2016
    Posts:
    662
    Or what about this:

    num_buffers = 262144
    repeat num_buffers
    {buffer_create(1, buffer_grow, 1)}

    You dont need to store the buffers in anything, once created they're stored in an internal array anyway.

    You can test it by putting this in the draw event:

    var i = -1;
    repeat num_buffers
    {draw_text(200, 200 + (i * 16), string(buffer_peek(++i, 0, buffer_u8)))}


    But I'm wondering why you need to do this? Is it to make a grid that takes up less memory than an array?
     
    Last edited: Feb 12, 2019 at 9:44 PM

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice