コード例 #1
0
		public DepthBuffer CreateDepthBufferFor( RenderTarget renderTarget )
		{
			GLES2DepthBuffer retVal = null;

			//Only FBO & ppbuffer support different depth buffers, so everything
			//else creates dummy (empty containers

			GLES2FrameBufferObject fbo = null;
			fbo = (GLES2FrameBufferObject) 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
				GLenum depthFormat = GLenum.None, stencilFormat = GLenum.None;
				( this.rttManager as GLES2FBOManager ).GetBestDepthStencil( fbo.Format, ref depthFormat, ref stencilFormat );
				var depthBuffer = new GLES2RenderBuffer( depthFormat, fbo.Width, fbo.Height, fbo.FSAA );

				GLES2RenderBuffer stencilBuffer = depthBuffer;
				if ( stencilBuffer != null )
				{
					stencilBuffer = new GLES2RenderBuffer( stencilFormat, fbo.Width, fbo.Height, fbo.FSAA );
				}

				//No "custom-quality" multisample for now in GL
				retVal = new GLES2DepthBuffer( 0, this, this.currentContext, depthBuffer, stencilBuffer, fbo.Width, fbo.Height, fbo.FSAA, 0, false );
			}
			return retVal;
		}
コード例 #2
0
		public override RenderWindow CreateRenderWindow( string name, int width, int height, bool isFullScreen, Collections.NamedParameterList miscParams )
		{
			if ( renderTargets.ContainsKey( name ) )
			{
				throw new AxiomException( "NativeWindowType with name " + name + " already exists" );
			}
			// Log a message
			var ss = new StringBuilder();
			ss.Append( "GLES2RenderSystem.CreateRenderWindow \"" + name + "\"," + width + "x" + height + " " );

			if ( isFullScreen )
			{
				ss.Append( "fullscreen " );
			}
			else
			{
				ss.Append( "windowed" );
			}

			if ( miscParams != null && miscParams.Count > 0 )
			{
				ss.Append( " misParams: " );
				foreach ( var it in miscParams )
				{
					ss.Append( it.Key + "=" + it.Value.ToString() + " " );
				}

				LogManager.Instance.Write( ss.ToString() );
			}

			//Create the window

			RenderWindow win = this.glSupport.NewWindow( name, width, height, isFullScreen, miscParams );
			AttachRenderTarget( win );

			if ( this.glInitialized == false )
			{
				this.InitializeContext( win );
				var tokens = this.glSupport.GLVersion.Split( '.' );
				if ( tokens.Length > 0 )
				{
					if ( tokens[ 0 ] != "UNKOWN" && tokens[ 0 ] != "OpenGL" )
					{
						driverVersion.Major = int.Parse( tokens[ 0 ] );
						if ( tokens.Length > 1 )
						{
							driverVersion.Minor = int.Parse( tokens[ 1 ] );
						}
						if ( tokens.Length > 2 )
						{
							driverVersion.Release = int.Parse( tokens[ 2 ] );
						}
					}
					else
					{
						driverVersion.Major = 0;
						driverVersion.Minor = 0;
						driverVersion.Release = 0;
					}
				}
				driverVersion.Build = 0;

				//Initialize GL after the first window has been created
				//Ogre TODO: fire this from emulation options and don't duplicate Real and Current capabilities
				realCapabilities = this.CreateRenderSystemCapabilities();

				//use real capabilities if custom capabilities are not availabe
				if ( useCustomCapabilities == false )
				{
					currentCapabilities = realCapabilities;
				}

				FireEvent( "RenderSystemCapabilitiesCreated" );

				this.InitializeFromRenderSystemCapabilities( currentCapabilities, win );

				//Initialize the main context
				this.OneTimeContextInitialization();
				if ( this.currentContext != null )
				{
					this.currentContext.IsInitialized = true;
				}
			}

			if ( win.DepthBufferPool != PoolId.NoDepth )
			{
				//Unlike D3D9, OGL doesn't allow sharing the main depth buffer, so keep them seperate.
				//Only Copy does, but Copy means only one depth buffer...
				var windowContext = (GLES2Context) win[ "GLCONTEXT" ];
				var depthBuffer = new GLES2DepthBuffer( PoolId.Default, this, windowContext, null, null, win.Width, win.Height, win.FSAA, 0, true );

				depthBufferPool[ depthBuffer.PoolId ].Add( depthBuffer );
				win.AttachDepthBuffer( depthBuffer );
			}
			return win;
		}