Hi Vic,

I'm making a game/simulation-engine as a learning project and I want it to be able to 
display windows of different sizes. For example when it starts you get a menu in a small 
window and when you click "start" in the menu another window open up in full 
screen in which you can navigate around the 'game world' and when you exit that you get 
back to the small window with the menu.

OK, that clarifies your usage. Thanks for the explanation.

I have tested using only the viewer but it does not seem to give me much control 
over the window. Using viewer->setUpViewInWindow(x, y, w, h) a window appears 
but how can I remove the frame around it if I want to have a custom GUI including 
minimize and close buttons inside it instead?

The way to do that would be to create a graphics context using

  osg::GraphicsContext::createGraphicsContext(traits);

You set up the osg::GraphicsContext::Traits structure to fit what you want your window to look like. For example:

  osg::ref_ptr<osg::GraphicsContext::Traits> traits =
      new osg::GraphicsContext::Traits;
  traits->x = 0;    // In screen space, so it's the top-left corner
  traits->y = 0;
  traits->width = width;
  traits->height = height;
  traits->windowDecoration = false;    // Removes the window's border

  osg::GraphicsContext* gc =
      osg::GraphicsContext::createGraphicsContext(traits.get());

See the osg::GraphicsContext::Traits class for the list of the parameters you can change.

http://www.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a00279.html
http://www.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a00275.html

To set the screen's fullscreen resolution, you can't just set your traits structure, because that just specifies the size of the graphics context. So if for example you create a 1024x768 context, without window decoration, but your Windows screen resolution is 1280x1024, you'll just see a borderless window that takes up part of your screen - the screen's resolution won't change to fit it. For that, you need to go through the WindowingSystemInterface which you get by calling

  osg::GraphicsContext::getWindowingSystemInterface();

and then calling setScreenResolution() on that. Remember to save the previous screen resolution at startup and re-set it before exiting.

http://www.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a00280.html

Using these interfaces, you can keep your code 100% portable since OSG will automatically choose the right GraphicsWindow* subclass for you (Win32 on Win32, X11 on Linux, Carbon on MacOS X) through the static createGraphicsContext() and getWindowingSystemInterface() calls.

In your case, according to your explanation above, I expect you'd want to create a first graphics context for your menu system, do what you need there, then when the game starts you'd destroy it and create a new graphics context for the game.

Hope this helps,

J-S
--
______________________________________________________
Jean-Sebastien Guay    [email protected]
                               http://www.cm-labs.com/
                        http://whitestar02.webhop.org/
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to