root/OpenSceneGraph/trunk/examples/osgwidgetinput/osgwidgetinput.cpp @ 13771

Revision 12292, 1.7 kB (checked in by robert, 4 years ago)

Ran svn propset -R svn:eol-style native . on the OpenSceneGraph

  • Property svn:eol-style set to native
Line 
1// -*-c++-*- osgWidget - Code by: Jeremy Moles (cubicool) 2007-2008
2// $Id: osgwidgetinput.cpp 50 2008-05-06 05:06:36Z cubicool $
3
4#include <osgDB/ReadFile>
5#include <osgDB/WriteFile>
6#include <osgViewer/ViewerEventHandlers>
7#include <osgWidget/WindowManager>
8#include <osgWidget/Box>
9#include <osgWidget/Input>
10#include <osgWidget/ViewerEventHandlers>
11
12const unsigned int MASK_2D = 0xF0000000;
13
14int main(int argc, char** argv) {
15    osgViewer::Viewer viewer;
16
17    osgWidget::WindowManager* wm = new osgWidget::WindowManager(
18        &viewer,
19        1280.0f,
20        1024.0f,
21        MASK_2D,
22        osgWidget::WindowManager::WM_PICK_DEBUG
23    );
24   
25    osgWidget::Box*   box   = new osgWidget::Box("vbox", osgWidget::Box::VERTICAL);
26    osgWidget::Input* input = new osgWidget::Input("input", "", 50);
27
28    input->setFont("fonts/VeraMono.ttf");
29    input->setFontColor(0.0f, 0.0f, 0.0f, 1.0f);
30    input->setFontSize(15);
31    input->setYOffset(input->calculateBestYOffset("y"));
32    input->setSize(400.0f, input->getText()->getCharacterHeight());
33
34    box->addWidget(input);
35    box->setOrigin(200.0f, 200.0f);
36
37    wm->addChild(box);
38
39    viewer.setUpViewInWindow(
40        50,
41        50,
42        static_cast<int>(wm->getWidth()),
43        static_cast<int>(wm->getHeight())
44    );
45
46    osg::Camera* camera = wm->createParentOrthoCamera();
47
48    viewer.addEventHandler(new osgWidget::MouseHandler(wm));
49    viewer.addEventHandler(new osgWidget::KeyboardHandler(wm));
50    viewer.addEventHandler(new osgWidget::ResizeHandler(wm, camera));
51    viewer.addEventHandler(new osgWidget::CameraSwitchHandler(wm, camera));
52    viewer.addEventHandler(new osgViewer::WindowSizeHandler());
53
54    wm->resizeAllWindows();
55
56    viewer.setSceneData(camera);
57
58    return viewer.run();
59}
Note: See TracBrowser for help on using the browser.