GM:S 1.4 [solved] Very new to vertex buffers

Discussion in 'Programming' started by marasovec, Mar 5, 2019.

  1. marasovec

    marasovec Member

    Joined:
    Sep 15, 2016
    Posts:
    307
    I heard that vertex buffers are much faster than d3d so I tried to make a simple 3D triangle but it gives me this error:

    VERTEX BUILDER: Vertex format does not contain selected type.
    at gml_Object_object32_CreateEvent_1 (line 10) - vertex_position_3d(buff, 0, 0, 0);
    ######################################################

    Here is my code
    Code:
    vertex_format_begin();
    vertex_format_add_position();
    vertex_format_add_colour();
    vertex_format_add_textcoord();
    format = vertex_format_end();
    
    buff = vertex_create_buffer();
    
    vertex_begin(buff, format);
    vertex_position_3d(buff, 0, 0, 0);
    vertex_colour(buff, c_white, 1);
    vertex_texcoord(buff, 0, 0);
    vertex_position_3d(buff, 20, 20, 32);
    vertex_colour(buff, c_white, 1);
    vertex_texcoord(buff, 1, 0);
    vertex_position_3d(buff, 50, 50, 16);
    vertex_colour(buff, c_white, 1);
    vertex_texcoord(buff, 1, 1);
    vertex_end(buff);
    
     
  2. Simon Gust

    Simon Gust Member

    Joined:
    Nov 15, 2016
    Posts:
    3,146
    Here in your format creation
    Code:
    vertex_format_add_position();
    
    this is only for 2D positions, not 3D ones.

    try this
    Code:
    vertex_format_add_position_3d();
    
     
  3. marasovec

    marasovec Member

    Joined:
    Sep 15, 2016
    Posts:
    307
    *facepalm*
    Thanks so much
     

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