Vertex buffer(Solved)

Discussion in 'Programming' started by Dreambig, Sep 1, 2017.

  1. Dreambig

    Dreambig Guest

    Whenever I run this code

    d=sprite_get_texture(sprite3,1)
    draw_set_color(c_white)
    for(Timesrun=0;Timesrun<121;Timesrun+=1)
    {draw_primitive_begin_texture(pr_trianglefan,d)
    draw_vertex_texture(PointI[S,p],LineI[S,p],imx[S,p],imy[S,p])
    p+=1
    draw_vertex_texture(PointI[S,p],LineI[S,p],imx[S,p],imy[S,p])
    p+=1
    draw_vertex_texture(PointI[S,p],LineI[S,p],imx[S,p],imy[S,p])
    p+=1
    draw_vertex_texture(PointI[S,p],LineI[S,p],imx[S,p],imy[S,p])
    draw_primitive_end()
    S+=1 p=1 if S=121{S=1 p=1 Timesrun=0 }
    }

    I get

    ___________________________________________
    ############################################################################################
    FATAL ERROR in
    action number 1
    of Draw Event
    for object object3:

    Fatal Error: Can not create vertex buffer of size 98304 bytes
    20965 vertex buffers allocated with total size of 2012960 KB
    at gml_Object_object3_DrawEvent_1 (line 12) - draw_primitive_end()
    ############################################################################################

    Whenever I change the 121 in S=121 to 122, it shows the picture, but it won't change the picture even if I change the values. I checked, and the values were able to be changed, just that the picture wasn't changing.


    How do I fix this?
     
  2. flyingsaucerinvasion

    flyingsaucerinvasion Member

    Joined:
    Jun 20, 2016
    Posts:
    2,163
    You're resetting the variable that you use to control the length of the loop, from inside of the loop! And as a result it looks like the loop continues until you run out of memory.

    Out of curiosity, how long does that loop run before you see the error message? Seconds? Fractions of a second? Minutes?
     
    Dreambig likes this.
  3. Dreambig

    Dreambig Guest

    Thanks, I put that part of the code out of the loop and it works. I let it run for 9 minutes and nothing bad happened after I changed the code, before it didn't even make it to the room.
     

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