diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/graphics/texture.c | 1 | ||||
-rw-r--r-- | src/graphics/vertex.c | 9 |
2 files changed, 6 insertions, 4 deletions
diff --git a/src/graphics/texture.c b/src/graphics/texture.c index 9ea9b12..7d8fdcf 100644 --- a/src/graphics/texture.c +++ b/src/graphics/texture.c @@ -149,6 +149,7 @@ int mgl_texture_resize(mgl_texture *self, int new_width, int new_height, mgl_tex return 0; } +/* TODO: Optimize. Do not set matrix if the current coordinate type was the same as the previous one */ void mgl_texture_use(const mgl_texture *texture) { mgl_context *context = mgl_get_context(); diff --git a/src/graphics/vertex.c b/src/graphics/vertex.c index 110c86d..8e9b5b9 100644 --- a/src/graphics/vertex.c +++ b/src/graphics/vertex.c @@ -1,16 +1,17 @@ #include "../../include/mgl/graphics/vertex.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) { +void mgl_vertices_draw(mgl_context *context, const mgl_vertex *vertices, size_t vertex_count, mgl_primitive_type primitive_type, mgl_vec2f position) { if(vertex_count == 0) return; - context->gl.glMatrixMode(GL_TEXTURE); - context->gl.glLoadIdentity(); - context->gl.glMatrixMode(GL_MODELVIEW); + context->gl.glPushMatrix(); + 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); context->gl.glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(mgl_vertex), (void*)&vertices[0].color); context->gl.glDrawArrays(mgl_primitive_type_to_gl_mode(primitive_type), 0, vertex_count); + + context->gl.glPopMatrix(); } |