[osg-users] iOS: how to draw into a UIView object instead of app's window?

Stephan Maximilian Huber ratzfatz at digitalmind.de
Wed Apr 20 05:12:28 PDT 2011


Hi Alessandro,

I think you are entering unknown territory, nobody has tried what you
are trying to do ;-)

The current implementation creates an UIView and attaches it to the
window, so perhaps you can get it to work via:

osg::ref_ptr<osg::Referenced> windata = new osgViewer::GraphicsWindowIOS::
> WindowData(my_window); // my_window holds the UIWindow

set the x/y width/height of the GraphicsContext::Traits to the bounds of
the view, you want to create.

After creation of the GraphicsWindow the view is added to my_window,
perhaps you can get it via [my_window subviews].


HTH,
Stephan





Am 20.04.11 13:00, schrieb Alessandro Terenzi:
> Hi,
> 
> I'm trying to modify the osgviewer example for iOS in order to be able to
> draw into a specified UIView object rather than to the application's
> window.
> 
> 
> Basically I created a custom ViewController with a couple of views, one of
> which occupies a small area of the main window. Then, once the controller's
> views have been loaded, I setup OSG as shown in the osgviewer example, but
> instead of doing:
> 
> 
> osg::ref_ptr<osg::Referenced> windata = new osgViewer::GraphicsWindowIOS::
> WindowData(window);
> 
> 
> I do this:
> 
> 
> osg::ref_ptr<osg::Referenced> windata = new osgViewer::GraphicsWindowIOS::
> WindowData(my_OsgView);
> 
> 
> where my_OsgView is a UIView object. But this is not working, I get the
> osgviewer's view on screen but not where I expect: the viewer's view seems
> to have the same size of the UIView object (and this is OK) but it is
> displayed away from the UIView itself...I guess that the viewer's view is
> created has a 'child' of my UIView object but I expected that the viewer's
> view actually 'became' my UIView object. In other words it seems that
> another view is created instead of just using the one I created with
> Interface Builder.
> 
> 
> What is the correct way to draw in a generic UIView instead of the
> application's window?
> 
> 
> Thanks.
> 
> Alessandro
> 
> 
> 
> 
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




More information about the osg-users mailing list