X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=examples%2Fhelloworld.cpp;h=8c530df5dc560ea54ce85158a541d5a7a9f9ccdd;hb=aa9b8db38efb9e97460c76e27cecc4d1591b23e5;hp=4f85964d9d2c45e28aa90bae843237d92d657d47;hpb=467e235bb1f647b618763280ca2a1ce13dcdbd72;p=libs%2Fgltk.git diff --git a/examples/helloworld.cpp b/examples/helloworld.cpp index 4f85964..8c530df 100644 --- a/examples/helloworld.cpp +++ b/examples/helloworld.cpp @@ -6,7 +6,9 @@ Demonstrates some of the most common widget types. #include #include #include +#include #include +#include #include #include #include @@ -20,8 +22,10 @@ using namespace Msp; class HelloWorld: public Msp::RegisteredApplication { 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 @@ -57,28 +63,30 @@ HelloWorld::HelloWorld(int, char **): GLtk::Label *lbl; // Prompts can be displayed with Labels - panel->add(*(lbl = new GLtk::Label("Type your name below:"))); + panel->add(*(lbl = new GLtk::Label("Type your name:"))); lbl->set_geometry(GLtk::Geometry(10, 130, 140, 20)); // The user can type text into an Entry panel->add(*(ent_name = new GLtk::Entry)); - ent_name->set_geometry(GLtk::Geometry(10, 110, 140, 20)); + ent_name->set_geometry(GLtk::Geometry(10, 100, 140, 27)); GLtk::Button *btn; // Buttons can be wired to cause things to happen panel->add(*(btn = new GLtk::Button("Hello"))); - btn->set_geometry(GLtk::Geometry(10, 85, 140, 20)); + btn->set_geometry(GLtk::Geometry(10, 68, 140, 27)); btn->signal_clicked.connect(sigc::mem_fun(this, &HelloWorld::show_hello)); // Another label for displaying some information panel->add(*(lbl_hello = new GLtk::Label)); - lbl_hello->set_geometry(GLtk::Geometry(10, 65, 140, 20)); + lbl_hello->set_geometry(GLtk::Geometry(10, 42, 140, 20)); // The user might want to exit the program (*gasp*) panel->add(*(btn = new GLtk::Button("Exit"))); - btn->set_geometry(GLtk::Geometry(50, 10, 100, 20)); + 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