public override DepthBuffer CreateDepthBufferFor( RenderTarget renderTarget ) { GLDepthBuffer retVal = null; //Only FBO & pbuffer support different depth buffers, so everything //else creates dummy (empty) containers //retVal = mRTTManager->_createDepthBufferFor( renderTarget ); var fbo = (GLFrameBufferObject)renderTarget["FBO"]; if( fbo != null ) { //Presence of an FBO means the manager is an FBO Manager, that's why it's safe to downcast //Find best depth & stencil format suited for the RT's format int depthFormat; int stencilFormat; ((GLFBORTTManager)(rttManager)).GetBestDepthStencil( fbo.Format, out depthFormat, out stencilFormat ); var depthBuffer = new GLRenderBuffer( depthFormat, fbo.Width, fbo.Height, fbo.FSAA ); var stencilBuffer = depthBuffer; if( depthFormat != Gl.GL_DEPTH24_STENCIL8_EXT && stencilBuffer != null ) /* Gl.GL_NONE */ { stencilBuffer = new GLRenderBuffer( stencilFormat, fbo.Width, fbo.Height, fbo.FSAA ); } //No "custom-quality" multisample for now in GL retVal = new GLDepthBuffer( 0, this, _currentContext, depthBuffer, stencilBuffer, fbo.Width, fbo.Height, fbo.FSAA, 0, false ); } return retVal; }
public override RenderWindow CreateRenderWindow( string name, int width, int height, bool isFullscreen, NamedParameterList miscParams ) { if ( renderTargets.ContainsKey( name ) ) { throw new Exception( String.Format( "Window with the name '{0}' already exists.", name ) ); } // Log a message var msg = new StringBuilder(); msg.AppendFormat( "GLRenderSystem.CreateRenderWindow \"{0}\", {1}x{2} {3} ", name, width, height, isFullscreen ? "fullscreen" : "windowed" ); if ( miscParams != null ) { msg.Append( "miscParams: " ); foreach ( var param in miscParams ) { msg.AppendFormat( " {0} = {1} ", param.Key, param.Value ); } LogManager.Instance.Write( msg.ToString() ); } // create the window var window = this._glSupport.NewWindow( name, width, height, isFullscreen, miscParams ); // add the new render target AttachRenderTarget( window ); if ( !this._glInitialised ) { InitializeContext( window ); var _glSupportVersion = this._glSupport.Version.Split( new[] { ' ' } )[ 0 ]; var tokens = _glSupportVersion.Split( new[] { '.' } ); if ( tokens.Length != 0 ) { driverVersion.Major = Int32.Parse( tokens[ 0 ] ); if ( tokens.Length > 1 ) { driverVersion.Minor = Int32.Parse( tokens[ 1 ] ); } if ( tokens.Length > 2 ) { driverVersion.Release = Int32.Parse( tokens[ 2 ] ); } } driverVersion.Build = 0; // Initialise GL after the first window has been created // TODO: fire this from emulation options, and don't duplicate Real and Current capabilities realCapabilities = CreateRenderSystemCapabilities(); // use real capabilities if custom capabilities are not available if ( !useCustomCapabilities ) { currentCapabilities = realCapabilities; } FireEvent( "RenderSystemCapabilitiesCreated" ); InitializeFromRenderSystemCapabilities( currentCapabilities, window ); // Initialise the main context OneTimeContextInitialization(); if ( this._currentContext != null ) { this._currentContext.Initialized = true; } } if ( window.DepthBufferPool != PoolId.NoDepth ) { //Unlike D3D9, OGL doesn't allow sharing the main depth buffer, so keep them separate. //Only Copy does, but Copy means only one depth buffer... var windowContext = (GLContext)window[ "GLCONTEXT" ]; var depthBuffer = new GLDepthBuffer( PoolId.Default, this, windowContext, null, null, window.Width, window.Height, window.FSAA, 0, true ); depthBufferPool[ depthBuffer.PoolId ].Add( depthBuffer ); window.AttachDepthBuffer( depthBuffer ); } return window; }
public override RenderWindow CreateRenderWindow(string name, int width, int height, bool isFullscreen, NamedParameterList miscParams) { if (renderTargets.ContainsKey(name)) { throw new Exception(String.Format("Window with the name '{0}' already exists.", name)); } // Log a message var msg = new StringBuilder(); msg.AppendFormat("GLRenderSystem.CreateRenderWindow \"{0}\", {1}x{2} {3} ", name, width, height, isFullscreen ? "fullscreen" : "windowed"); if (miscParams != null) { msg.Append("miscParams: "); foreach (var param in miscParams) { msg.AppendFormat(" {0} = {1} ", param.Key, param.Value); } LogManager.Instance.Write(msg.ToString()); } // create the window var window = this._glSupport.NewWindow(name, width, height, isFullscreen, miscParams); // add the new render target AttachRenderTarget(window); if (!this._glInitialised) { InitializeContext(window); var _glSupportVersion = this._glSupport.Version.Split(new[] { ' ' })[0]; var tokens = _glSupportVersion.Split(new[] { '.' }); if (tokens.Length != 0) { driverVersion.Major = Int32.Parse(tokens[0]); if (tokens.Length > 1) { driverVersion.Minor = Int32.Parse(tokens[1]); } if (tokens.Length > 2) { driverVersion.Release = Int32.Parse(tokens[2]); } } driverVersion.Build = 0; // Initialise GL after the first window has been created // TODO: fire this from emulation options, and don't duplicate Real and Current capabilities realCapabilities = CreateRenderSystemCapabilities(); // use real capabilities if custom capabilities are not available if (!useCustomCapabilities) { currentCapabilities = realCapabilities; } FireEvent("RenderSystemCapabilitiesCreated"); InitializeFromRenderSystemCapabilities(currentCapabilities, window); // Initialise the main context OneTimeContextInitialization(); if (this._currentContext != null) { this._currentContext.Initialized = true; } } if (window.DepthBufferPool != PoolId.NoDepth) { //Unlike D3D9, OGL doesn't allow sharing the main depth buffer, so keep them separate. //Only Copy does, but Copy means only one depth buffer... var windowContext = (GLContext)window["GLCONTEXT"]; var depthBuffer = new GLDepthBuffer(PoolId.Default, this, windowContext, null, null, window.Width, window.Height, window.FSAA, 0, true); depthBufferPool[depthBuffer.PoolId].Add(depthBuffer); window.AttachDepthBuffer(depthBuffer); } return(window); }