From dbab279df7ffcf5dd55128a1bc44ea52d7584859 Mon Sep 17 00:00:00 2001 From: Morten Hustveit Date: Fri, 12 Dec 2014 15:32:34 -0800 Subject: main_glut.c: Restrict raster position to inside of target window --- main_glut.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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); -- cgit v1.2.3