C
Cash Munkey
Guest
Hey forum, I'm looking for a little help understanding how the vertex_submit() function receives a texture.
Consider a fairly simple vertex with position, color, and texture. This would be declared in obj_triangle.create step.
And for the sake of simplicity, all I want to do is draw a single, right triangle with sides of length 32 (pixels). This happens in obj_triangle.draw.
(Also, assume that spr_block_32 is a 32x32 pixel sprite that exists in the project.)
My question is with the last line of the second code block. I am using sprite_get_texture() following the Example provided in the documentation for vertex_submit(). BUT also, the documentation for sprite_get_texture() indicates that it returns a special pointer for the (whole) sprite texture page. The behavior I'm seeing is that the example above will only draw the primitive correctly if spr_block_32 is the ONLY sprite on the texture page (otherwise the drawn image just looks like noise/static).
Is there a function I'm missing to get the cell of sprite on a texture page? Or am I misunderstanding how vertex buffers use textures?
Consider a fairly simple vertex with position, color, and texture. This would be declared in obj_triangle.create step.
Code:
vertex_format_begin();
vertex_format_add_position();
vertex_format_add_colour();
vertex_format_add_texcoord();
vtx_format = vertex_format_end();
vtx_buff = vertex_create_buffer();
(Also, assume that spr_block_32 is a 32x32 pixel sprite that exists in the project.)
Code:
vertex_begin(vtx_buff, vtx_format);
vertex_position(vtx_buff, 100, 100);
vertex_colour(vtx_buff, c_white, 1);
vertex_texcoord(vtx_buff, 0, 0);
vertex_position(vtx_buff, 131, 100);
vertex_colour(vtx_buff, c_white, 1);
vertex_texcoord(vtx_buff, 1, 0);
vertex_position(vtx_buff, 100, 131);
vertex_colour(vtx_buff, c_white, 1);
vertex_texcoord(vtx_buff, 0, 1);
vertex_end(vtx_buff);
vertex_submit(vtx_buff, pr_trianglelist, sprite_get_texture(spr_block_32, 0));
Is there a function I'm missing to get the cell of sprite on a texture page? Or am I misunderstanding how vertex buffers use textures?