aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gl.c1
-rw-r--r--src/graphics/texture.c9
2 files changed, 3 insertions, 7 deletions
diff --git a/src/gl.c b/src/gl.c
index 4d8fb58..f7607c2 100644
--- a/src/gl.c
+++ b/src/gl.c
@@ -87,6 +87,7 @@ int mgl_gl_load(mgl_gl *self) {
{ &self->glGetError, "glGetError" },
{ &self->glGetString, "glGetString" },
{ &self->glGetIntegerv, "glGetIntegerv" },
+ { &self->glPixelStorei, "glPixelStorei" },
{ NULL, NULL }
};
diff --git a/src/graphics/texture.c b/src/graphics/texture.c
index 2387fa7..0ae21cf 100644
--- a/src/graphics/texture.c
+++ b/src/graphics/texture.c
@@ -122,14 +122,9 @@ int mgl_texture_update(mgl_texture *self, const unsigned char *data, int offset_
mgl_context *context = mgl_get_context();
context->gl.glBindTexture(GL_TEXTURE_2D, self->id);
const mgl_texture_format texture_format = mgl_image_format_to_mgl_texture_format(format);
- /* TODO: TODO: Only do one glTexSubImage2D */
-#if 1
- for(int i = 0; i < height; ++i) {
- context->gl.glTexSubImage2D(GL_TEXTURE_2D, 0, offset_x, offset_y + i, width, 1, mgl_texture_format_to_source_opengl_format(texture_format), GL_UNSIGNED_BYTE, data + (i * width));
- }
-#else
+ context->gl.glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
context->gl.glTexSubImage2D(GL_TEXTURE_2D, 0, offset_x, offset_y, width, height, mgl_texture_format_to_source_opengl_format(texture_format), GL_UNSIGNED_BYTE, data);
-#endif
+ context->gl.glPixelStorei(GL_UNPACK_ALIGNMENT, 0);
context->gl.glBindTexture(GL_TEXTURE_2D, 0);
return 0;
}