fixed crash when passing the -screen argument, due to trying to free the
[vrtris] / src / gamescr.c
index de314ae..0bd7f70 100644 (file)
@@ -1,4 +1,6 @@
+#include "opengl.h"
 #include "screen.h"
+#include "cmesh.h"
 
 static int init(void);
 static void cleanup(void);
@@ -29,14 +31,23 @@ struct game_screen game_screen = {
        wheel
 };
 
+static struct cmesh *blkmesh;
 
 static int init(void)
 {
+       if(!(blkmesh = cmesh_alloc())) {
+               return -1;
+       }
+       if(cmesh_load(blkmesh, "data/noisecube.obj") == -1) {
+               fprintf(stderr, "failed to load block model\n");
+               return -1;
+       }
        return 0;
 }
 
 static void cleanup(void)
 {
+       cmesh_free(blkmesh);
 }
 
 static void start(void)
@@ -53,6 +64,9 @@ static void update(float dt)
 
 static void draw(void)
 {
+       glTranslatef(0, 0, 6);
+
+       cmesh_draw(blkmesh);
 }
 
 static void reshape(int x, int y)