Show
Ignore:
Timestamp:
06/02/07 17:31:21 (8 years ago)
Author:
robert
Message:

Added osgViewer::GraphicsWindowEmbedded? and ported GLUT, SDL and WX examples across from SimpleViewer? to Viewer.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgviewerSDL/osgviewerSDL.cpp

    r6813 r6815  
    44// Derived from osgGLUTsimple.cpp and osgkeyboardmouse.cpp 
    55 
    6 #include <osgViewer/SimpleViewer> 
     6#include <osgViewer/Viewer> 
     7#include <osgViewer/StatsHandler> 
    78#include <osgGA/TrackballManipulator> 
    89#include <osgDB/ReadFile> 
     
    105106    SDL_EnableUNICODE(1); 
    106107     
    107     osgViewer::SimpleViewer viewer; 
    108     viewer.setSceneData(loadedModel.get()); 
    109     viewer.setCameraManipulator(new osgGA::TrackballManipulator); 
    110  
    111108    // If we used 0 to set the fields, query the values so we can pass it to osgViewer 
    112109    windowWidth = screen->w; 
    113110    windowHeight = screen->h; 
    114     viewer.getEventQueue()->windowResize(0, 0, windowWidth, windowHeight ); 
     111    osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> gw = new osgViewer::GraphicsWindowEmbedded(0,0,windowWidth,windowHeight); 
     112     
     113    osgViewer::Viewer viewer; 
     114    viewer.getCamera()->setGraphicsContext(gw.get()); 
     115    viewer.getCamera()->setViewport(new osg::Viewport(0,0,windowWidth,windowHeight)); 
     116    viewer.setSceneData(loadedModel.get()); 
     117    viewer.setCameraManipulator(new osgGA::TrackballManipulator); 
     118    viewer.addEventHandler(new osgViewer::StatsHandler); 
     119    viewer.setThreadingModel(osgViewer::Viewer::SingleThreaded); 
     120    viewer.realize(); 
    115121 
    116122    bool done = false; 
     
    122128        { 
    123129            // pass the SDL event into the viewers event queue 
    124             convertEvent(event, *viewer.getEventQueue()); 
     130            convertEvent(event, *(gw->getEventQueue())); 
    125131 
    126132            switch (event.type) { 
     133 
     134                case SDL_VIDEORESIZE: 
     135                    gw->resized(0, 0, event.resize.w, event.resize.h ); 
     136                    break; 
    127137 
    128138                case SDL_KEYUP: 
    129139 
    130140                    if (event.key.keysym.sym==SDLK_ESCAPE) done = true; 
    131                     if (event.key.keysym.sym=='f') SDL_WM_ToggleFullScreen(screen); 
     141                    if (event.key.keysym.sym=='f')  
     142                    { 
     143                        SDL_WM_ToggleFullScreen(screen); 
     144                        gw->resized(0, 0, screen->w, screen->h ); 
     145                    } 
    132146 
    133147                    break;