]> git.tdb.fi Git - libs/gltk.git/blobdiff - examples/helloworld.cpp
Adjust things to conform to changes in other libraries
[libs/gltk.git] / examples / helloworld.cpp
index 0eb9811a780bbeeb8b0e217f028ce87d94f09f81..8c530df5dc560ea54ce85158a541d5a7a9f9ccdd 100644 (file)
@@ -6,7 +6,9 @@ Demonstrates some of the most common widget types.
 #include <msp/core/application.h>
 #include <msp/graphics/simplewindow.h>
 #include <msp/gl/blend.h>
+#include <msp/gl/device.h>
 #include <msp/gl/matrix.h>
+#include <msp/gl/windowview.h>
 #include <msp/gltk/button.h>
 #include <msp/gltk/entry.h>
 #include <msp/gltk/label.h>
@@ -20,8 +22,10 @@ using namespace Msp;
 class HelloWorld: public Msp::RegisteredApplication<HelloWorld>
 {
 private:
-       // An OpenGL window to display our widgets in
-       Graphics::SimpleGLWindow wnd;
+       // A window and graphics device to display our widgets in
+       Graphics::SimpleWindow wnd;
+       GL::Device gl_dev;
+       GL::WindowView view;
 
        // GLtk resources and widgets
        GLtk::Resources res;
@@ -39,6 +43,8 @@ private:
 
 HelloWorld::HelloWorld(int, char **):
        wnd(200, 200),
+       gl_dev(wnd),
+       view(wnd),
        // Load resources.  This must be done before the root widget is created.
        res("basic.skin"),
        // A Root receives input from a Graphics::Window and passes it on
@@ -79,6 +85,8 @@ HelloWorld::HelloWorld(int, char **):
        btn->set_geometry(GLtk::Geometry(50, 10, 100, 27));
        btn->signal_clicked.connect(sigc::bind(sigc::mem_fun(this, &HelloWorld::exit), 0));
 
+       view.set_content(&root);
+
        // Done with setting things up, show the window!
        wnd.show();
 }
@@ -87,17 +95,7 @@ HelloWorld::HelloWorld(int, char **):
 void HelloWorld::tick()
 {
        wnd.tick();
-
-       // Set up an orthogonal projection matching the root widget
-       GL::MatrixStack::projection() = GL::Matrix::ortho_bottomleft(200, 200);
-       GL::MatrixStack::modelview() = GL::Matrix();
-
-       // Font rendering requires blending
-       GL::Bind bind_blend(GL::Blend::alpha());
-
-       root.render();
-
-       wnd.swap_buffers();
+       view.render();
 }
 
 // Displays a greeting to the user