summaryrefslogtreecommitdiff
path: root/main_glut.c
diff options
context:
space:
mode:
authorMorten Hustveit <morten.hustveit@gmail.com>2014-12-02 21:40:41 -0500
committerMorten Hustveit <morten.hustveit@gmail.com>2014-12-02 21:40:41 -0500
commit1d257b2051c94988318706a1070794fc2262bd6b (patch)
tree7a71160cf0e5c038f62043f916d73b83257d4986 /main_glut.c
parent6cee50ceb0d153622b89fb813060419f5985857d (diff)
main_glut.c: Clear window and center animation
Diffstat (limited to 'main_glut.c')
-rw-r--r--main_glut.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/main_glut.c b/main_glut.c
index cf22a73..92e3fdb 100644
--- a/main_glut.c
+++ b/main_glut.c
@@ -5,6 +5,7 @@
#include "ray.h"
static int threaded;
+static int viewport_width, viewport_height;
static int
init(int argc, char **argv, int w, int h) {
@@ -32,6 +33,8 @@ 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);
glDrawPixels(WIDTH, HEIGHT, GL_BGRA, GL_UNSIGNED_BYTE, buffer);
free(buffer);
@@ -40,6 +43,8 @@ display(void) {
static void
reshape(int w, int h) {
+ viewport_width = w;
+ viewport_height = h;
glViewport(0, 0, w, h);
}