From Stephan Hunber, "* now you can create a transparent opengl-view (see GraphicWindowIOS::WindowData)
* changes of the view's bound are reported via osg's event-system more reliably "
This commit is contained in:
parent
4a0ce866c0
commit
d200ef90a7
@ -120,7 +120,7 @@ typedef std::map<void*, unsigned int> TouchPointsIdMapping;
|
||||
- (void)setGraphicsWindow: (osgViewer::GraphicsWindowIOS*) win;
|
||||
- (osgViewer::GraphicsWindowIOS*) getGraphicsWindow;
|
||||
- (void)setOpenGLContext: (EAGLContext*) context;
|
||||
|
||||
- (void)updateDimensions;
|
||||
- (BOOL)createFramebuffer;
|
||||
- (void)destroyFramebuffer;
|
||||
- (void)swapBuffers;
|
||||
@ -267,7 +267,11 @@ typedef std::map<void*, unsigned int> TouchPointsIdMapping;
|
||||
// Get the layer
|
||||
CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
|
||||
|
||||
eaglLayer.opaque = YES;//need to look into this, can't remember why it's here, i.e. do I set it to no for alphaed window?
|
||||
osgViewer::GraphicsWindowIOS::WindowData* win_data(NULL);
|
||||
if (_win->getTraits()->inheritedWindowData.valid())
|
||||
win_data = dynamic_cast<osgViewer::GraphicsWindowIOS::WindowData*>(_win->getTraits()->inheritedWindowData.get());
|
||||
|
||||
eaglLayer.opaque = win_data ? !win_data->getCreateTransparentView() : YES ;
|
||||
if(_win->getTraits()->alpha > 0)
|
||||
{
|
||||
//create layer with alpha channel RGBA8
|
||||
@ -298,14 +302,36 @@ typedef std::map<void*, unsigned int> TouchPointsIdMapping;
|
||||
}
|
||||
|
||||
- (void)layoutSubviews {
|
||||
/*
|
||||
[EAGLContext setCurrentContext:_context];
|
||||
[self destroyFramebuffer];
|
||||
[self createFramebuffer];
|
||||
*/
|
||||
[super layoutSubviews];
|
||||
[self updateDimensions];
|
||||
}
|
||||
|
||||
|
||||
- (void) setFrame:(CGRect)frame
|
||||
{
|
||||
[super setFrame:frame];
|
||||
[self updateDimensions];
|
||||
}
|
||||
|
||||
|
||||
- (void) updateDimensions
|
||||
{
|
||||
if (_win)
|
||||
{
|
||||
CGRect frame = self.bounds;
|
||||
osg::Vec2 pointOrigin = osg::Vec2(frame.origin.x,frame.origin.y);
|
||||
osg::Vec2 pointSize = osg::Vec2(frame.size.width,frame.size.height);
|
||||
osg::Vec2 pixelOrigin = [(GraphicsWindowIOSGLView*)(self) convertPointToPixel:pointOrigin];
|
||||
osg::Vec2 pixelSize = [(GraphicsWindowIOSGLView*)(self) convertPointToPixel:pointSize];
|
||||
|
||||
OSG_INFO << "updateDimensions, resize to "
|
||||
<< pixelOrigin.x() << " " << pixelOrigin.y() << " "
|
||||
<< pixelSize.x() << " " << pixelSize.y()
|
||||
<< std::endl;
|
||||
_win->resized(pixelOrigin.x(), pixelOrigin.y(), pixelSize.x(), pixelSize.y());
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)createFramebuffer {
|
||||
|
||||
_msaaFramebuffer = _msaaRenderBuffer = 0;
|
||||
@ -368,6 +394,12 @@ typedef std::map<void*, unsigned int> TouchPointsIdMapping;
|
||||
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT24_OES, _backingWidth, _backingHeight);
|
||||
}
|
||||
|
||||
#if defined(GL_DEPTH_COMPONENT32_OES)
|
||||
else if(_win->getTraits()->depth == 32){
|
||||
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT32_OES, _backingWidth, _backingHeight);
|
||||
}
|
||||
#endif
|
||||
|
||||
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, _depthRenderbuffer);
|
||||
}
|
||||
|
||||
@ -657,20 +689,7 @@ typedef std::map<void*, unsigned int> TouchPointsIdMapping;
|
||||
|
||||
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
|
||||
{
|
||||
osgViewer::GraphicsWindowIOS* win = [(GraphicsWindowIOSGLView*)(self.view) getGraphicsWindow];
|
||||
if (win) {
|
||||
CGRect frame = self.view.bounds;
|
||||
osg::Vec2 pointOrigin = osg::Vec2(frame.origin.x,frame.origin.y);
|
||||
osg::Vec2 pointSize = osg::Vec2(frame.size.width,frame.size.height);
|
||||
osg::Vec2 pixelOrigin = [(GraphicsWindowIOSGLView*)(self.view) convertPointToPixel:pointOrigin];
|
||||
osg::Vec2 pixelSize = [(GraphicsWindowIOSGLView*)(self.view) convertPointToPixel:pointSize];
|
||||
OSG_INFO << "willAnimateRotationToInterfaceOrientation, resize to "
|
||||
<< pixelOrigin.x() << " " << pixelOrigin.y() << " "
|
||||
<< pixelSize.x() << " " << pixelSize.y()
|
||||
<< std::endl;
|
||||
win->resized(pixelOrigin.x(), pixelOrigin.y(), pixelSize.x(), pixelSize.y());
|
||||
}
|
||||
|
||||
[(GraphicsWindowIOSGLView*)(self.view) updateDimensions];
|
||||
}
|
||||
|
||||
|
||||
@ -852,11 +871,14 @@ bool GraphicsWindowIOS::realizeImplementation()
|
||||
|
||||
// Attach view to window
|
||||
[_window addSubview: _view];
|
||||
if ([_window isKindOfClass:[UIWindow class]])
|
||||
_window.rootViewController = _viewController;
|
||||
[theView release];
|
||||
|
||||
//if we own the window also make it visible
|
||||
if (_ownsWindow)
|
||||
{
|
||||
|
||||
//show window
|
||||
[_window makeKeyAndVisible];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user