aboutsummaryrefslogtreecommitdiff
path: root/src/graphics/vertex.c
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-08-21 21:57:31 +0200
committerdec05eba <dec05eba@protonmail.com>2022-08-21 21:57:31 +0200
commit7a80f0de04c3b07d88ba2ab3e51544d38fe924f6 (patch)
tree4e67621a944e3686ba724fa953a52eddc8610fe7 /src/graphics/vertex.c
parentffb6d86c557b2327b2a6363c0d805d717695dce4 (diff)
Attempt to fix vertex draw when using texcoords without a texture (such as when using a shader)
Diffstat (limited to 'src/graphics/vertex.c')
-rw-r--r--src/graphics/vertex.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/graphics/vertex.c b/src/graphics/vertex.c
index b45f38c..e55c180 100644
--- a/src/graphics/vertex.c
+++ b/src/graphics/vertex.c
@@ -1,4 +1,5 @@
#include "../../include/mgl/graphics/vertex.h"
+#include "../../include/mgl/graphics/texture.h"
#include "../../include/mgl/mgl.h"
void mgl_vertices_draw(mgl_context *context, const mgl_vertex *vertices, size_t vertex_count, mgl_primitive_type primitive_type, mgl_vec2f position) {
@@ -6,11 +7,14 @@ void mgl_vertices_draw(mgl_context *context, const mgl_vertex *vertices, size_t
return;
context->gl.glPushMatrix();
- context->gl.glTranslatef(position.x, position.y, 0.0f);
- context->gl.glMatrixMode(GL_TEXTURE);
- context->gl.glLoadIdentity();
+ if(!mgl_texture_current_texture()) {
+ context->gl.glMatrixMode(GL_TEXTURE);
+ context->gl.glLoadIdentity();
+ }
+
context->gl.glMatrixMode(GL_MODELVIEW);
+ context->gl.glTranslatef(position.x, position.y, 0.0f);
context->gl.glVertexPointer(2, GL_FLOAT, sizeof(mgl_vertex), (void*)&vertices[0].position);
context->gl.glTexCoordPointer(2, GL_FLOAT, sizeof(mgl_vertex), (void*)&vertices[0].texcoords);