summaryrefslogtreecommitdiff
path: root/platform/gl/gl-main.c
diff options
context:
space:
mode:
Diffstat (limited to 'platform/gl/gl-main.c')
-rw-r--r--platform/gl/gl-main.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/platform/gl/gl-main.c b/platform/gl/gl-main.c
index 07b8cc4e..ff080d1b 100644
--- a/platform/gl/gl-main.c
+++ b/platform/gl/gl-main.c
@@ -228,7 +228,7 @@ void texture_from_pixmap(struct texture *tex, fz_pixmap *pix)
if (tex->w > max_texture_size || tex->h > max_texture_size)
fz_warn(ctx, "texture size (%d x %d) exceeds implementation limit (%d)", tex->w, tex->h, max_texture_size);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex->w, tex->h, 0, GL_RGB, GL_UNSIGNED_BYTE, pix->samples);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex->w, tex->h, 0, pix->n == 4 ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, pix->samples);
tex->s = 1;
tex->t = 1;
}
@@ -240,7 +240,7 @@ void texture_from_pixmap(struct texture *tex, fz_pixmap *pix)
fz_warn(ctx, "texture size (%d x %d) exceeds implementation limit (%d)", w2, h2, max_texture_size);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w2, h2, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, tex->w, tex->h, GL_RGB, GL_UNSIGNED_BYTE, pix->samples);
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, tex->w, tex->h, pix->n == 4 ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, pix->samples);
tex->s = (float)tex->w / w2;
tex->t = (float)tex->h / h2;
}