|
本帖最后由 oirrm 于 2014-6-17 23:39 编辑
- #include "stdafx.h"
- #include <osgDB/ReadFile>
- #include <osgDB/WriteFile>
- #include <osgViewer/ViewerEventHandlers>
- #include <osgWidget/WindowManager>
- #include <osgWidget/Box>
- #include <osgWidget/Input>
- #include <osgWidget/ViewerEventHandlers>
- #pragma comment( lib, "osgd.lib")
- #pragma comment( lib, "osgViewerd.lib")
- #pragma comment( lib, "osgDBd.lib")
- #pragma comment( lib, "OpenThreadsd.lib")
- #pragma comment( lib, "osgUtild.lib")
- #pragma comment( lib, "osgGAd.lib")
- #pragma comment( lib, "osgTextd.lib")
- #pragma comment( lib, "osgSimd.lib")
- #pragma comment( lib, "osgWidgetd.lib")
- const unsigned int MASK_2D = 0xF0000000;
- int main(int argc, char** argv) {
- osgViewer::Viewer viewer;
- osgWidget::WindowManager* wm = new osgWidget::WindowManager(
- &viewer,
- 1280.0f,
- 1024.0f,
- MASK_2D,
- osgWidget::WindowManager::WM_PICK_DEBUG
- );
-
- osgWidget::Box* box = new osgWidget::Box("vbox", osgWidget::Box::VERTICAL);
- osgWidget::Input* input = new osgWidget::Input("input", "", 50);
- input->setFont("fonts/VeraMono.ttf");
- input->setFontColor(0.0f, 0.0f, 0.0f, 1.0f);
- input->setFontSize(15);
- input->setYOffset(input->calculateBestYOffset("y"));
- input->setSize(400.0f, input->getText()->getCharacterHeight());
- box->addWidget(input);
- box->setOrigin(200.0f, 200.0f);
- wm->addChild(box);
- viewer.setUpViewInWindow(
- 50,
- 50,
- static_cast<int>(wm->getWidth()),
- static_cast<int>(wm->getHeight())
- );
- osg::Camera* camera = wm->createParentOrthoCamera();
- viewer.addEventHandler(new osgWidget::MouseHandler(wm));
- viewer.addEventHandler(new osgWidget::KeyboardHandler(wm));
- viewer.addEventHandler(new osgWidget::ResizeHandler(wm, camera));
- viewer.addEventHandler(new osgWidget::CameraSwitchHandler(wm, camera));
- viewer.addEventHandler(new osgViewer::WindowSizeHandler());
- wm->resizeAllWindows();
- viewer.setSceneData(camera);
- return viewer.run();
- }
复制代码 |
|