mirror of
https://github.com/Adamcake/Bolt.git
synced 2026-04-29 13:12:37 -04:00
library: fix vertex2d_xy y direction
This commit is contained in:
@@ -1925,7 +1925,8 @@ or smaller than that area, proportionally.
|
||||
@subsection vertexxy
|
||||
|
||||
Given an index of a vertex in a batch, returns its X and Y position on
|
||||
the screen, in pixel coordinates.
|
||||
the screen, in pixel coordinates. As with all pixel coordinates in the
|
||||
Bolt API, this is relative to the top-left pixel of the screen.
|
||||
|
||||
@node batch2d-vertexatlasxy
|
||||
@subsection vertexatlasxy
|
||||
@@ -1943,7 +1944,13 @@ its associated image in the batch's texture atlas, in pixel coordinates.
|
||||
@subsection vertexuv
|
||||
|
||||
Given an index of a vertex in a batch, returns the vertex's associated
|
||||
"UV" coordinates.
|
||||
"UV" coordinates. The values will be floating-point numbers in the range
|
||||
0.0 - 1.0.
|
||||
|
||||
Unlike with 3D render events, these UVs are relative to the entire
|
||||
texture atlas, not to the sub-image. However they may fall outside the
|
||||
bounds of the sub-image, in which case they're usually expected to wrap
|
||||
around within it.
|
||||
|
||||
The values will be floating-point numbers in the range 0.0 - 1.0. They
|
||||
are relative to image in the texture atlas.
|
||||
@@ -2202,8 +2209,10 @@ local x, y, w, h = event:atlasxywh(meta)
|
||||
|
||||
Given a vertex number, returns the vertex's associated "UV" coordinates.
|
||||
|
||||
The values will be floating-point numbers in the range 0.0 - 1.0. They
|
||||
are relative to image in the texture atlas.
|
||||
The values will be floating-point numbers, usually in the range 0.0 -
|
||||
1.0. They are relative to image in the texture atlas. They may fall
|
||||
outside the image (and therefore outside the range 0.0 - 1.0), in which
|
||||
case they're expected to wrap around within the image.
|
||||
|
||||
@node render3d-vertexcolour
|
||||
@subsection vertexcolour
|
||||
|
||||
@@ -1445,13 +1445,14 @@ void _bolt_gl_onDrawElements(GLenum mode, GLsizei count, GLenum type, const void
|
||||
vertex_userdata.atlas_size = &attributes[c->bound_program->loc_aTextureUVAtlasExtents];
|
||||
vertex_userdata.tex_uv = &attributes[c->bound_program->loc_aTextureUV];
|
||||
vertex_userdata.colour = &attributes[c->bound_program->loc_aVertexColour];
|
||||
vertex_userdata.screen_height = roundf(2.0 / projection_matrix[5]);
|
||||
|
||||
struct GLPluginTextureUserData tex_userdata;
|
||||
tex_userdata.tex = tex;
|
||||
|
||||
struct RenderBatch2D batch;
|
||||
batch.screen_width = roundf(2.0 / projection_matrix[0]);
|
||||
batch.screen_height = roundf(2.0 / projection_matrix[5]);
|
||||
batch.screen_height = vertex_userdata.screen_height;
|
||||
batch.index_count = count;
|
||||
batch.vertices_per_icon = 6;
|
||||
batch.is_minimap = tex_target && tex_target->is_minimap_tex_small;
|
||||
@@ -1687,11 +1688,13 @@ void _bolt_gl_onViewport(GLint x, GLint y, GLsizei width, GLsizei height) {
|
||||
|
||||
static void _bolt_gl_plugin_drawelements_vertex2d_xy(size_t index, void* userdata, int32_t* out) {
|
||||
struct GLPluginDrawElementsVertex2DUserData* data = userdata;
|
||||
if (!_bolt_get_attr_binding_int(data->c, data->position, data->indices[index], 2, out)) {
|
||||
if (_bolt_get_attr_binding_int(data->c, data->position, data->indices[index], 2, out)) {
|
||||
out[1] = (int32_t)data->screen_height - (out[1] + 1);
|
||||
} else {
|
||||
float pos[2];
|
||||
_bolt_get_attr_binding(data->c, data->position, data->indices[index], 2, pos);
|
||||
out[0] = (int32_t)roundf(pos[0]);
|
||||
out[1] = (int32_t)roundf(pos[1]);
|
||||
out[1] = (int32_t)data->screen_height - ((int32_t)roundf(pos[1]) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -336,6 +336,7 @@ struct GLPluginDrawElementsVertex2DUserData {
|
||||
struct GLAttrBinding* atlas_size;
|
||||
struct GLAttrBinding* tex_uv;
|
||||
struct GLAttrBinding* colour;
|
||||
uint32_t screen_height;
|
||||
};
|
||||
|
||||
struct GLPluginDrawElementsVertex3DUserData {
|
||||
|
||||
Reference in New Issue
Block a user