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

Alessandro Terenzi a.terenzi at gmail.com
Wed Apr 20 08:39:44 PDT 2011


Hi Stephan,
thank you for your suggestion. I tried to create windata by passing the
app's window, set the traits to what I need, but I get 'noise' in the window
area outside the intended viewer's view.

Instead, if I pass a custom UIView object then the viewer's view is created
as described earlier (and no noise in the window's area not covered by the
view). But in this case the viewer's view is not added to the window's
subviews, and it is not added even to the UIView I passed when creating the
windata object. Instead it is added to the parent of the UIView object I
intended to use. Now, I can try to think about a way to safely get a
reference to the view object created by OSG, it could be useful to have a
way(method) to do it straight from OSG's APIs. What do you think?

Cheers.
Alessandro


On Wed, Apr 20, 2011 at 2:12 PM, Stephan Maximilian Huber <
ratzfatz at digitalmind.de> wrote:

> 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
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20110420/c1782847/attachment-0004.htm>


More information about the osg-users mailing list