Axiom.RenderSystems.OpenGL.GLFBORTTManager.GetBestDepthStencil C# (CSharp) Method

GetBestDepthStencil() public method

Get best depth and stencil supported for given internalFormat
public GetBestDepthStencil ( PixelFormat format, int &depthFormat, int &stencilFormat ) : void
format PixelFormat
depthFormat int
stencilFormat int
return void
		public void GetBestDepthStencil( PixelFormat format, out int depthFormat, out int stencilFormat )
		{
			FormatProperties props = _props[ (int)format ];

			/// Decide what stencil and depth formats to use
			/// [best supported for internal format]
			int bestmode = 0;
			int bestscore = -1;
			for ( int mode = 0; mode < props.Modes.Count; mode++ )
			{
				int desirability = 0;
				/// Find most desirable mode
				/// desirability == 0            if no depth, no stencil
				/// desirability == 1000...2000  if no depth, stencil
				/// desirability == 2000...3000  if depth, no stencil
				/// desirability == 3000+        if depth and stencil
				/// beyond this, the total numer of bits (stencil+depth) is maximised
				if ( props.Modes[ mode ].Stencil != 0 )
					desirability += 1000;
				if ( props.Modes[ mode ].Depth != 0 )
					desirability += 2000;
				if ( _depthBits[ props.Modes[ mode ].Depth ] == 24 ) // Prefer 24 bit for now
					desirability += 500;
				if ( _depthFormats[ props.Modes[ mode ].Depth ] == GL_DEPTH24_STENCIL8_EXT ) // Prefer 24/8 packed
					desirability += 5000;
				desirability += _stencilBits[ props.Modes[ mode ].Stencil ] + _depthBits[ props.Modes[ mode ].Depth ];

				if ( desirability > bestscore )
				{
					bestscore = desirability;
					bestmode = mode;
				}
			}
			depthFormat = _depthFormats[ props.Modes[ bestmode ].Depth ];
			stencilFormat = _stencilFormats[ props.Modes[ bestmode ].Stencil ];
		}