summaryrefslogtreecommitdiffstats
path: root/libdimension/gl.c
diff options
context:
space:
mode:
Diffstat (limited to 'libdimension/gl.c')
-rw-r--r--libdimension/gl.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/libdimension/gl.c b/libdimension/gl.c
index 1250307..396205b 100644
--- a/libdimension/gl.c
+++ b/libdimension/gl.c
@@ -40,8 +40,8 @@ dmnsn_gl_optimize_canvas(dmnsn_canvas *canvas)
int
dmnsn_gl_write_canvas(const dmnsn_canvas *canvas)
{
- GLushort *pixels; /* Array of 16-bit ints in RGBA order */
- GLushort *pixel;
+ GLubyte *pixels; /* Array of 8-bit ints in RGBA order */
+ GLubyte *pixel;
dmnsn_color color;
size_t width = canvas->width;
@@ -50,13 +50,13 @@ dmnsn_gl_write_canvas(const dmnsn_canvas *canvas)
/* Check if we can optimize this */
DMNSN_ARRAY_FOREACH (dmnsn_canvas_optimizer *, i, canvas->optimizers) {
if (i->optimizer_fn == dmnsn_rgba16_optimizer_fn) {
- glDrawPixels(width, height, GL_RGBA, GL_UNSIGNED_SHORT, i->ptr);
+ glDrawPixels(width, height, GL_RGBA, GL_UNSIGNED_BYTE, i->ptr);
return glGetError() == GL_NO_ERROR ? 0 : 1;
}
}
/* We couldn't, so transform the canvas to RGB now */
- pixels = dmnsn_malloc(4*width*height*sizeof(GLushort));
+ pixels = dmnsn_malloc(4*width*height*sizeof(GLubyte));
for (size_t y = 0; y < height; ++y) {
for (size_t x = 0; x < width; ++x) {
@@ -67,14 +67,14 @@ dmnsn_gl_write_canvas(const dmnsn_canvas *canvas)
color = dmnsn_color_to_sRGB(color);
color = dmnsn_color_saturate(color);
- pixel[0] = lround(color.R*UINT16_MAX);
- pixel[1] = lround(color.G*UINT16_MAX);
- pixel[2] = lround(color.B*UINT16_MAX);
- pixel[3] = lround(color.trans*UINT16_MAX);
+ pixel[0] = lround(color.R*UINT8_MAX);
+ pixel[1] = lround(color.G*UINT8_MAX);
+ pixel[2] = lround(color.B*UINT8_MAX);
+ pixel[3] = lround(color.trans*UINT8_MAX);
}
}
- glDrawPixels(width, height, GL_RGBA, GL_UNSIGNED_SHORT, pixels);
+ glDrawPixels(width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
dmnsn_free(pixels);
return glGetError() == GL_NO_ERROR ? 0 : 1;