cyberenv
[vrfileman] / src / app.cc
index f99e034..859e6f2 100644 (file)
@@ -5,8 +5,7 @@
 #include "gmath/gmath.h"
 #include "mesh.h"
 #include "meshgen.h"
-#include "sdr.h"
-#include "texture.h"
+#include "backdrop.h"
 
 int win_width, win_height;
 float win_aspect;
@@ -14,13 +13,10 @@ long time_msec;
 
 static float cam_theta, cam_phi;
 static Mesh *mesh_torus;
-static Texture *tex_grid;
 
 static bool bnstate[16];
 static int prev_x, prev_y;
 
-static unsigned int sdr_grid;
-
 bool app_init(int argc, char **argv)
 {
        if(init_opengl() == -1) {
@@ -43,11 +39,7 @@ bool app_init(int argc, char **argv)
        mesh_torus = new Mesh;
        gen_torus(mesh_torus, 1.0, 0.25, 32, 32);
 
-       if(!(sdr_grid = create_program_load("sdr/grid.v.glsl", "sdr/grid.p.glsl"))) {
-               return false;
-       }
-       if(!(tex_grid = load_texture("data/purple_grid.png"))) {
-               delete tex_grid;
+       if(!init_backdrop()) {
                return false;
        }
 
@@ -56,6 +48,8 @@ bool app_init(int argc, char **argv)
 
 void app_cleanup()
 {
+       delete mesh_torus;
+       cleanup_backdrop();
 }
 
 void app_draw()
@@ -70,27 +64,7 @@ void app_draw()
        glLoadMatrixf(view_mat[0]);
 
        //mesh_torus->draw();
-
-       Mat4 xform;
-       xform.scaling(500.0);
-       glPushMatrix();
-       glMultMatrixf(xform[0]);
-
-       bind_program(sdr_grid);
-       bind_texture(tex_grid);
-
-       glBegin(GL_QUADS);
-       glNormal3f(0, 1, 0);
-       glVertex3f(-1, 0, 1);
-       glVertex3f(1, 0, 1);
-       glVertex3f(1, 0, -1);
-       glVertex3f(-1, 0, -1);
-       glEnd();
-
-       bind_texture(0);
-       bind_program(0);
-
-       glPopMatrix();
+       draw_backdrop();
 
        app_swap_buffers();
        assert(glGetError() == GL_NO_ERROR);