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

Primitive Texture not drawing full image

I have an issue with the texture vertex drawing functions. I have a ds grid being crated for a texture to be spread over it and then manipulated to create a waving pattern. However when i increase the resolution of the grid/mesh below 20 pixels per rectangle it just stops drawing the verteces at some point:
fish.png

If i decrease the resolution of the grid (make the rectangles bigger and less of them) then it works fine.

Here is a sample of the draw code:
GML:
draw_set_colour(c_white);
draw_primitive_begin_texture(pr_trianglelist, texture);

var _width = ds_grid_width(pointGrid) - 1;
var _height = ds_grid_height(pointGrid) - 1;

for(var i = 0; i <= _width; i++)
{
    for(var j = 0; j <= _height; j++)
    {
        var _tl = pointGrid[# i, j]; //Top Left
        if i < _width
        && j < _height
        {
            var _tr = pointGrid[# i + 1, j]; //Top Right
            var _bl = pointGrid[# i, j + 1]; //Bottom Left
            var _br = pointGrid[# i + 1, j + 1]; //Bottom Right
            
            draw_vertex_texture(_tl[0], _tl[1], _tl[2], _tl[3]);
            draw_vertex_texture(_tr[0], _tr[1], _tr[2], _tr[3]);
            draw_vertex_texture(_bl[0], _bl[1], _bl[2], _bl[3]);
                                        
            draw_vertex_texture(_bl[0], _bl[1], _bl[2], _bl[3]);
            draw_vertex_texture(_tr[0], _tr[1], _tr[2], _tr[3]);
            draw_vertex_texture(_br[0], _br[1], _br[2], _br[3]);
            
            //show_debug_message(string(_tl));
        }
        draw_point(_tl[X], _tl[Y]);
    }
}

draw_primitive_end();
I'm wondering if there's just a limit with the textured meshes but that would be a pain if there is. Thanks for any help you can offer
 

Simon Gust

Member
There is a limit of 1000 vertices. I'm not sure if you can get away with starting a primitive mid loop though.
You can try a vertex buffer and hope it's limit is higher.
 
There is a limit of 1000 vertices. I'm not sure if you can get away with starting a primitive mid loop though.
You can try a vertex buffer and hope it's limit is higher.
Thanks for the info. It seems the vertices cut off at around 250 of them. The primitives begin before the loop then the loop adds the vertices. I'll give the buffer ago and see if that helps. Thanks a lot
 
I know it's not related to what you're asking, but I'd personally recommend switching to a shader for the wave. Far fewer triangles, less overhead, and a much smoother effect.
 
  • Like
Reactions: Tyg

Fern

Member
Vertex buffers don't have a limit. That's the next step if you don't want to change too much of your code.
 
I know it's not related to what you're asking, but I'd personally recommend switching to a shader for the wave. Far fewer triangles, less overhead, and a much smoother effect.
Thanks for the tip. I wasn't doing it for the wave affect specifically. Just messing with the texture primitives. In 13 years of Game Maker never looked into them before until now


Vertex buffers don't have a limit. That's the next step if you don't want to change too much of your code.
Great, thanks a lot :)
 
Top