From 5eac8b795c5a44469b749ecb4cf7a68038055b5b Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Tue, 6 Dec 2011 00:56:37 -0500 Subject: Add physics test. --- libdimension/gl.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'libdimension/gl.c') 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; -- cgit v1.2.3