summaryrefslogtreecommitdiffstats
path: root/libdimension/gl.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2011-12-06 00:56:37 -0500
committerTavian Barnes <tavianator@gmail.com>2011-12-06 15:48:25 -0500
commit5eac8b795c5a44469b749ecb4cf7a68038055b5b (patch)
treebb1f7dd640884f3eb1fa6d1377478536371fb99a /libdimension/gl.c
parent7db5342a36341b061a8785a3b349cf0fcad69ebf (diff)
downloaddimension-5eac8b795c5a44469b749ecb4cf7a68038055b5b.tar.xz
Add physics test.
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;