]> git.tdb.fi Git - libs/gl.git/blobdiff - tools/viewer.cpp
Modernize the demo and tool programs
[libs/gl.git] / tools / viewer.cpp
index d2a384f4e0b2afc112afd7fe3ea62ac3da676237..a1853e922f19485097ee644e80900b76c9913b1f 100644 (file)
 #include <msp/gl/lighting.h>
 #include <msp/gl/mesh.h>
 #include <msp/gl/object.h>
 #include <msp/gl/lighting.h>
 #include <msp/gl/mesh.h>
 #include <msp/gl/object.h>
+#include <msp/gl/pipeline.h>
 #include <msp/gl/renderer.h>
 #include <msp/gl/resources.h>
 #include <msp/gl/simplescene.h>
 #include <msp/gl/technique.h>
 #include <msp/gl/tests.h>
 #include <msp/gl/renderer.h>
 #include <msp/gl/resources.h>
 #include <msp/gl/simplescene.h>
 #include <msp/gl/technique.h>
 #include <msp/gl/tests.h>
+#include <msp/gl/windowview.h>
 #include <msp/input/mouse.h>
 #include <msp/io/print.h>
 #include <msp/time/timestamp.h>
 #include <msp/input/mouse.h>
 #include <msp/io/print.h>
 #include <msp/time/timestamp.h>
@@ -48,6 +50,8 @@ private:
        Graphics::SimpleGLWindow window;
        Input::Mouse mouse;
        Resources resources;
        Graphics::SimpleGLWindow window;
        Input::Mouse mouse;
        Resources resources;
+       GL::WindowView view;
+       GL::Pipeline pipeline;
        GL::Renderable *renderable;
        GL::AnimatedObject *anim_object;
        GL::AnimationPlayer *anim_player;
        GL::Renderable *renderable;
        GL::AnimatedObject *anim_object;
        GL::AnimationPlayer *anim_player;
@@ -86,6 +90,8 @@ private:
 Viewer::Viewer(int argc, char **argv):
        window(1024, 768, false),
        mouse(window),
 Viewer::Viewer(int argc, char **argv):
        window(1024, 768, false),
        mouse(window),
+       view(window, window.get_gl_context()),
+       pipeline(view),
        renderable(0),
        anim_object(0),
        anim_player(0),
        renderable(0),
        anim_object(0),
        anim_player(0),
@@ -177,6 +183,14 @@ Viewer::Viewer(int argc, char **argv):
 
        camera.set_up_direction(GL::Vector3(0, 0, 1));
        update_camera();
 
        camera.set_up_direction(GL::Vector3(0, 0, 1));
        update_camera();
+
+       GL::Pipeline::Pass &pass = pipeline.add_pass(0, *renderable);
+       pass.set_lighting(&lighting);
+       pass.set_depth_test(&GL::DepthTest::lequal());
+       pass.set_blend(&GL::Blend::alpha());
+
+       view.set_content(&pipeline);
+       view.set_camera(&camera);
 }
 
 template<typename T>
 }
 
 template<typename T>
@@ -219,16 +233,7 @@ void Viewer::tick()
        }
 
        window.tick();
        }
 
        window.tick();
-
-       GL::Framebuffer::system().clear(GL::COLOR_BUFFER_BIT|GL::DEPTH_BUFFER_BIT);
-
-       GL::Bind bind_depth(GL::DepthTest::lequal());
-       GL::Bind bind_blend(GL::Blend::alpha());
-       GL::Renderer renderer(&camera);
-       renderer.set_lighting(&lighting);
-       renderable->render(renderer);
-
-       window.swap_buffers();
+       view.render();
 }
 
 void Viewer::button_press(unsigned btn)
 }
 
 void Viewer::button_press(unsigned btn)