예제 #1
0
        /// <summary>
        /// </summary>
        /// <param name="poolId"> </param>
        /// <param name="renderSystem"> </param>
        /// <param name="creatorContext"> </param>
        /// <param name="depth"> </param>
        /// <param name="stencil"> </param>
        /// <param name="width"> </param>
        /// <param name="height"> </param>
        /// <param name="fsaa"> </param>
        /// <param name="multiSampleQuality"> </param>
        /// <param name="isManual"> </param>
        public GLES2DepthBuffer(PoolId poolId, GLES2RenderSystem renderSystem, GLES2Context creatorContext, GLES2RenderBuffer depth, GLES2RenderBuffer stencil, int width, int height, int fsaa, int multiSampleQuality, bool isManual)
            : base(poolId, 0, width, height, fsaa, "", isManual)
        {
            this._creatorContext     = creatorContext;
            this._multiSampleQuality = multiSampleQuality;
            this._depthBuffer        = depth;
            this._stencilBuffer      = stencil;
            this._renderSystem       = renderSystem;

            if (this._depthBuffer != null)
            {
                switch (this._depthBuffer.GLFormat)
                {
                case OpenTK.Graphics.ES20.All.DepthComponent16:
                    bitDepth = 16;
                    break;

                case GLenum.DepthComponent24Oes:
                case GLenum.DepthComponent32Oes:
                case GLenum.Depth24Stencil8Oes:                         //Packed depth / stencil
                    bitDepth = 32;
                    break;
                }
            }
        }
예제 #2
0
		/// <summary>
		/// </summary>
		/// <param name="poolId"> </param>
		/// <param name="renderSystem"> </param>
		/// <param name="creatorContext"> </param>
		/// <param name="depth"> </param>
		/// <param name="stencil"> </param>
		/// <param name="width"> </param>
		/// <param name="height"> </param>
		/// <param name="fsaa"> </param>
		/// <param name="multiSampleQuality"> </param>
		/// <param name="isManual"> </param>
		public GLES2DepthBuffer( PoolId poolId, GLES2RenderSystem renderSystem, GLES2Context creatorContext, GLES2RenderBuffer depth, GLES2RenderBuffer stencil, int width, int height, int fsaa, int multiSampleQuality, bool isManual )
			: base( poolId, 0, width, height, fsaa, "", isManual )
		{
			this._creatorContext = creatorContext;
			this._multiSampleQuality = multiSampleQuality;
			this._depthBuffer = depth;
			this._stencilBuffer = stencil;
			this._renderSystem = renderSystem;

			if ( this._depthBuffer != null )
			{
				switch ( this._depthBuffer.GLFormat )
				{
					case OpenTK.Graphics.ES20.All.DepthComponent16:
						bitDepth = 16;
						break;
					case GLenum.DepthComponent24Oes:
					case GLenum.DepthComponent32Oes:
					case GLenum.Depth24Stencil8Oes: //Packed depth / stencil
						bitDepth = 32;
						break;
				}
			}
		}
예제 #3
0
		public GLES2RenderSystem()
		{
			this.depthWrite = true;
			this.stencilMask = 0xFFFFFFFF;
			this.gpuProgramManager = null;
			this.glslESProgramFactory = null;
			this.hardwareBufferManager = null;
			this.rttManager = null;

			int i;

			LogManager.Instance.Write( this.Name + " created." );
			this.renderAttribsBound = new List<int>( 100 );


#if RTSHADER_SYSTEM_BUILD_CORE_SHADERS
			enableFixedPipeline = false;
#endif

			this.CreateGlSupport();

			this.worldMatrix = Matrix4.Identity;
			this.viewMatrix = Matrix4.Identity;

			this.glSupport.AddConfig();

			this.colorWrite[ 0 ] = this.colorWrite[ 1 ] = this.colorWrite[ 2 ] = this.colorWrite[ 3 ] = true;

			for ( i = 0; i < Config.MaxTextureLayers; i++ )
			{
				//Dummy value
				this.textureCoordIndex[ i ] = 99;
				this.textureTypes[ i ] = 0;
			}

			activeRenderTarget = null;
			this.currentContext = null;
			this.mainContext = null;
			this.glInitialized = false;
			this.minFilter = FilterOptions.Linear;
			this.mipFilter = FilterOptions.Point;
			this.currentVertexProgram = null;
			this.currentFragmentProgram = null;
			//todo
			//polygonMode = GL_FILL;
		}
예제 #4
0
		public void InitializeContext( RenderWindow primary )
		{
			//Set main and current context
			this.mainContext = null;
			this.mainContext = (GLES2Context) primary[ "GLCONTEXT" ];
			this.currentContext = this.mainContext;

			//sET PRIMARY CONTEXT AS ACTIVE
			if ( this.currentContext != null )
			{
				this.currentContext.SetCurrent();
			}

			//Setup GLSupport
			this.glSupport.InitializeExtensions();

			LogManager.Instance.Write( "**************************************" );
			LogManager.Instance.Write( "*** OpenGL ES 2.x Renderer Started ***" );
			LogManager.Instance.Write( "**************************************" );
		}
예제 #5
0
		public void SwitchContext( GLES2Context context )
		{
			// Unbind GPU programs and rebind to new context later, because
			// scene manager treat render system as ONE 'context' ONLY, and it
			// cached the GPU programs using state.
			if ( this.currentVertexProgram != null )
			{
				this.currentVertexProgram.UnbindProgram();
			}
			if ( this.currentFragmentProgram != null )
			{
				this.currentFragmentProgram.UnbindProgram();
			}

			//Disable textures
			disabledTexUnitsFrom = 0;

			//It's ready for switching
			if ( this.currentContext != null )
			{
				this.currentContext.EndCurrent();
			}
			this.currentContext = context;
			this.currentContext.SetCurrent();

			//Check if the context has already done one-time initialization
			if ( !this.currentContext.IsInitialized )
			{
				this.OneTimeContextInitialization();
				this.currentContext.IsInitialized = true;
			}

			//Rebind GPU programs to new context
			if ( this.currentVertexProgram != null )
			{
				this.currentVertexProgram.BindProgram();
			}
			if ( this.currentFragmentProgram != null )
			{
				this.currentFragmentProgram.BindProgram();
			}

			// Must reset depth/colour write mask to according with user desired, otherwise,
			// clearFrameBuffer would be wrong because the value we are recorded may be
			// difference with the really state stored in GL context.
			GL.DepthMask( this.depthWrite );
			GL.ColorMask( this.colorWrite[ 0 ], this.colorWrite[ 1 ], this.colorWrite[ 2 ], this.colorWrite[ 3 ] );
			GL.StencilMask( this.stencilMask );
		}
예제 #6
0
		public void UnregisterContext( GLES2Context context )
		{
			if ( this.currentContext == context )
			{
				// Change the context to something else so that a valid context
				// remains active. When this is the main context being unregistered,
				// we set the main context to 0.
				if ( this.currentContext != this.mainContext )
				{
					this.SwitchContext( this.mainContext );
				}
				else
				{
					//No contexts remain
					this.currentContext.EndCurrent();
					this.currentContext = null;
					this.mainContext = null;
				}
			}
		}