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

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

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

  • Property svn:eol-style set to native
RevLine 
[8588]1// -*-c++-*- osgWidget - Code by: Jeremy Moles (cubicool) 2007-2008
2// $Id: osgwidgetinput.cpp 50 2008-05-06 05:06:36Z cubicool $
3
[9289]4#include <osgDB/ReadFile>
[8588]5#include <osgDB/WriteFile>
[9289]6#include <osgViewer/ViewerEventHandlers>
[8588]7#include <osgWidget/WindowManager>
8#include <osgWidget/Box>
9#include <osgWidget/Input>
[9289]10#include <osgWidget/ViewerEventHandlers>
[8588]11
12const unsigned int MASK_2D = 0xF0000000;
13
14int main(int argc, char** argv) {
[8600]15    osgViewer::Viewer viewer;
[8588]16
[8600]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);
[9289]26    osgWidget::Input* input = new osgWidget::Input("input", "", 50);
[8588]27
[9289]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());
[8588]33
[9289]34    box->addWidget(input);
35    box->setOrigin(200.0f, 200.0f);
[8588]36
[9289]37    wm->addChild(box);
[8588]38
[9289]39    viewer.setUpViewInWindow(
40        50,
41        50,
42        static_cast<int>(wm->getWidth()),
43        static_cast<int>(wm->getHeight())
44    );
[8588]45
[9289]46    osg::Camera* camera = wm->createParentOrthoCamera();
[8588]47
[9289]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());
[8588]53
[9289]54    wm->resizeAllWindows();
[8588]55
[9289]56    viewer.setSceneData(camera);
[8588]57
[9289]58    return viewer.run();
[8588]59}
Note: See TracBrowser for help on using the browser.