summaryrefslogtreecommitdiff
path: root/main_glut.c
diff options
context:
space:
mode:
authorMorten Hustveit <morten.hustveit@gmail.com>2014-12-12 15:32:34 -0800
committerMorten Hustveit <morten.hustveit@gmail.com>2014-12-12 15:32:34 -0800
commitdbab279df7ffcf5dd55128a1bc44ea52d7584859 (patch)
tree527e41c971620b4a393545e97cb5f7c6cd37cf01 /main_glut.c
parente11fb53429bc923a9b757bba307c6c8f6f0bf7a9 (diff)
main_glut.c: Restrict raster position to inside of target window
Diffstat (limited to 'main_glut.c')
-rw-r--r--main_glut.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/main_glut.c b/main_glut.c
index 1717898..272b17e 100644
--- a/main_glut.c
+++ b/main_glut.c
@@ -34,7 +34,11 @@ display(void) {
unsigned char* buffer = calloc(4, WIDTH * HEIGHT);
trace_scene(time, buffer, threaded);
glClear(GL_COLOR_BUFFER_BIT);
- glRasterPos2d(-(double)WIDTH / viewport_width, -(double)HEIGHT / viewport_height);
+ auto raster_x = -(double)WIDTH / viewport_width;
+ auto raster_y = -(double)HEIGHT / viewport_height;
+ if (raster_x < -1.0) raster_x = -1.0;
+ if (raster_y < -1.0) raster_y = -1.0;
+ glRasterPos2d(raster_x, raster_y);
glDrawPixels(WIDTH, HEIGHT, GL_BGRA, GL_UNSIGNED_BYTE, buffer);
free(buffer);