[osg-users] Looking for CARBON integration example, like osgviewerMFC

Adrian Egli OpenSceneGraph (3D) 3dhelp at gmail.com
Thu Feb 7 05:50:46 PST 2008


Hi i played around, i don't know why it doesn't work for me. :-(

see code above, but when i enable " aglSetDrawable(m_drawContext,
GetWindowPort(windowPtr));" in the code segment, the window gets attached
once i click onto the menu bar of safari, but no event reach the viewer, but
i can move the window. also the client rec is wrong.

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)

void attachViewer(int instanceID, CGrafPtr grafPtr, WindowPtr windowPtr)  {
        ...
                // Init the GraphicsContext Traits
                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.
                m_windowData = new
osgViewer::GraphicsWindowCarbon::WindowData(windowPtr);


                // Setup the traits parameters

                Rect titleRect;
                GetWindowBounds(windowPtr, kWindowContentRgn, &titleRect);

                traits->x = titleRect.left;
                traits->y = titleRect.top;
                traits->width  = abs(titleRect.right - titleRect.left);
                traits->height = abs(titleRect.bottom - titleRect.top);
                std::cout << "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;

                // 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
                m_osg_simple_viewer->addSlave(camera);
                m_osg_simple_viewer->setCamera(camera);


            m_osg_simple_viewer->realize();


            osgViewer::GraphicsWindowCarbon* gw =
dynamic_cast<osgViewer::GraphicsWindowCarbon*>(gc);
            m_drawContext = gw->getAGLContext();


             //aglSetDrawable(m_drawContext, GetWindowPort(windowPtr));
             ....
}


2008/2/6, Adrian Egli OpenSceneGraph (3D) <3dhelp at gmail.com>:
>
> Hi Stephan,
>
> i will test it tomorrow, today i did some short test, it's hard to say
> whats going wrong. may tomorrow i will be able to say more.
>
> /adegli
>
> 2008/2/6, Stephan Maximilian Huber <ratzfatz at digitalmind.de>:
> >
> > Adrian Egli OpenSceneGraph (3D) schrieb:
> > > ok, it seams that i should retest it myself. but the problem is that i
> > don't
> > > have much knowledge on OS/X. it doesn't attach the osgViewer into the
> > > "context" / window rect of the WindowRef is pointing to.
> > I did some minor tests while implementing GraphicsWindowCarbon, and
> > attaching a graphicsContext to an existing window did work, but perhaps
> > it got broken.
> >
> > Do you have a small example which shows the error?
> >
> > cheers,
> > Stephan
> > _______________________________________________
> > osg-users mailing list
> > osg-users at lists.openscenegraph.org
> >
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> >
>
>
>
> --
> ********************************************
> Adrian Egli




-- 
********************************************
Adrian Egli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080207/cceefbc0/attachment-0001.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Bild 1.jpg
Type: image/jpeg
Size: 36659 bytes
Desc: not available
Url : http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080207/cceefbc0/attachment-0003.jpg 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Bild 2.jpg
Type: image/jpeg
Size: 69553 bytes
Desc: not available
Url : http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080207/cceefbc0/attachment-0004.jpg 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Bild 3.jpg
Type: image/jpeg
Size: 53981 bytes
Desc: not available
Url : http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080207/cceefbc0/attachment-0005.jpg 


More information about the osg-users mailing list