Hi Adrian,
Adrian Egli OpenSceneGraph (3D) schrieb:
may i do something wrong, or the osgViewer for Carbon is not right, i don't
know. The result should looking like "Bild 3". the "Bild 1" and "Bild 2" are
wrong, or current state of the integration. (Bild 1 : osg default when
window not moved, Bild 2 after bild moved)
I am not sure if your usage-scenario is currently doable with
GraphicsWindowCarbon. You want to attach a HIView (or what it is called
in Carbon) , which is part of a window to the osgViewer::Viewer.
GraphicWindowCarbon owns whole windows, it takes all the place, it eats
all the events, so other ui-items get lost. It is not designed to handle
only a view.
The current implementation of GraphicsWindowCarbon does not process any
events, if it gets a "foreign" window. If you want to install the
eventhandlers, with a foreign window, set
m_windowData->setInstallEventHandler(true);
This may not work for your settings, because GraphicsWindowCarbon
installs several event handlers to catch Application-Quit etc.
Perhaps it is the best way to implement your own native
GraphicsContext-implementation for the plugin-usage or use a
GraphicsWindowEmbedded and do the handling of the AGLContext yourself.
Hope that helps,
Stephan
(P.S. I am attaching a working example using an external window with
GraphicsWindowCarbon)
//
// main.c
// cefixTemplate
//
// Created by Stephan Huber on 26.11.06.
// Copyright __MyCompanyName__ 2006. All rights reserved.
//
#include <osgViewer/api/Carbon/GraphicsWindowCarbon>
#include <osgViewer/Viewer>
#include <osg/ShapeDrawable>
int main(int argc, char* argv[])
{
// create the window:
Rect titleRect = {100,100, 600, 800};
OSStatus err = 0;
WindowRef windowPtr;
WindowAttributes attr = (kWindowStandardDocumentAttributes |
kWindowStandardHandlerAttribute) & ~kWindowResizableAttribute;
err = CreateNewWindow(kDocumentWindowClass, attr, &titleRect,
&windowPtr);
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new
osg::GraphicsContext::Traits;
// Init the Windata Variable that holds the handle for the Window to
display OSG in.
osg::ref_ptr<osgViewer::GraphicsWindowCarbon::WindowData> m_windowData
= new osgViewer::GraphicsWindowCarbon::WindowData(windowPtr);
m_windowData->setInstallEventHandler(true);
// Setup the traits parameters
traits->x = titleRect.left;
traits->y = titleRect.top;
traits->width = abs(titleRect.right - titleRect.left);
traits->height = abs(titleRect.bottom - titleRect.top);
osg::notify(osg::ALWAYS) << "SIZE=" << traits->width << " x " <<
traits->height << std::endl;
traits->windowDecoration = false;
traits->doubleBuffer = true;
traits->sharedContext = NULL;
traits->setInheritedWindowPixelFormat = false;//true;
traits->inheritedWindowData = m_windowData.get();
// Create the Graphics Context
osg::GraphicsContext* gc =
osg::GraphicsContext::createGraphicsContext(traits.get());
// Init a new Camera (Master for this View)
osg::Camera* camera = new osg::Camera;
// Assign Graphics Context to the Camera
camera->setGraphicsContext(gc);
// Set the viewport for the Camera
camera->setViewport(new osg::Viewport(0,0, traits->width,
traits->height));
// Add the Camera to the Viewer
osg::ref_ptr<osgViewer::Viewer> m_osg_simple_viewer = new
osgViewer::Viewer();
m_osg_simple_viewer->addSlave(camera);
m_osg_simple_viewer->setCamera(camera);
osg::Group* g = new osg::Group();
osg::Geode* geode = new osg::Geode();
geode->addDrawable(new osg::ShapeDrawable(new osg::Box()));
g->addChild(geode);
m_osg_simple_viewer->setSceneData(geode);
m_osg_simple_viewer->realize();
m_osg_simple_viewer->run();
return 0;
}
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org