SOLVED Problem drawing textured primitive

A

Amegatron

Guest
Hello! Once again I got some troubles with GMS and still do not understad it, maybe because I'm still new to it.

What do I have:
1) A 256x256 sprite called spr_moon which has the following checkboxes set to true: tile (both horiz and vert), separate texture page.
2) I'm drawing a textured polygon using draw_vertex_texture function.

My code is such inside one of object's Draw script:
GML:
var tex = sprite_get_texture(spr_moon, 0);
var texWidth = 256;
var texHeight = 256;

draw_primitive_begin_texture(pr_trianglelist, tex);
for (var i = 0; i < ds_list_size(upperPolygonTriangles)/2; i++) {
    var _x = ds_list_find_value(upperPolygonTriangles, i*2);
    var _y = ds_list_find_value(upperPolygonTriangles, i*2 + 1);
    var _u = _x / texWidth;
    var _v = _y / texHeight;
    draw_vertex_texture(_x, _y, _u, _v);
}
draw_primitive_end();
The problem is that when I launch the game, the texture is tiled really weird, see this screenshot:
tile_texture_bugged.jpg
But, if invoke game_restart() function (I bind "R" key for that), the game restarts as it is supposed to, and then the level is drawn absolutely fine:
tile_texture_after_restart.jpg
Could you please help me understand: is it either me not understanding something, or it is GMS2 again being buggy?
 
A

Amegatron

Guest
Small UPD:
1) I tried switching to using vertex buffers for drawing those surfaces
2) I tried to both texture_flush and texture_prefetch functions
None of that helped, the problem still exists. Will try to reproduce the problem in a clean project.

UPD2: yeah, just created a small separate project where I draw a polygon (just using pr_trianglelist and pr_trianglestrip) and the bug is still there. How did nobody else face such thing? :/ It is not BETA of GMS2, it is already 2.2 My first ever project in it and I've already found two critical bugs x_X
 
Last edited by a moderator:
A

Amegatron

Guest
gpu_set_texrepeat may be what you want
Thank you! It helps :) Though, I think it is still strange that after game_restart() it is repeated by itself. I mean, if it never repeated (after game restart), I would have been pretty sure I'm doing something wrong ... But since it started to repeat after the restart without any actions from my side, I find it strange anyway :/
 
Top