public override void UnbindGpuProgram( GpuProgramType type ) { if ( type == GpuProgramType.Vertex && this.currentVertexProgram != null ) { activeVertexGpuProgramParameters = null; this.currentVertexProgram.UnbindProgram(); this.currentVertexProgram = null; } else if ( type == GpuProgramType.Fragment && this.currentFragmentProgram != null ) { activeFragmentGpuProgramParameters = null; this.currentFragmentProgram.UnbindProgram(); this.currentFragmentProgram = null; } base.UnbindGpuProgram( type ); }
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; }
public override void BindGpuProgram( GpuProgram program ) { if ( program == null ) { throw new AxiomException( "Null program bound." ); } var glprg = program as GLES2GpuProgram; // Unbind previous gpu program first. // // Note: // 1. Even if both previous and current are the same object, we can't // bypass re-bind completely since the object itself may be modified. // But we can bypass unbind based on the assumption that object // internally GL program type shouldn't be changed after it has // been created. The behavior of bind to a GL program type twice // should be same as unbind and rebind that GL program type, even // for different objects. // 2. We also assumed that the program's type (vertex or fragment) should // not be changed during it's in using. If not, the following switch // statement will confuse GL state completely, and we can't fix it // here. To fix this case, we must coding the program implementation // itself, if type is changing (during load/unload, etc), and it's in use, // unbind and notify render system to correct for its state. // switch ( glprg.Type ) { case GpuProgramType.Vertex: if ( this.currentVertexProgram != glprg ) { if ( this.currentVertexProgram != null ) { this.currentVertexProgram.UnbindProgram(); } this.currentVertexProgram = glprg; } break; case GpuProgramType.Fragment: if ( this.currentFragmentProgram != glprg ) { if ( this.currentFragmentProgram != null ) { this.currentFragmentProgram.UnbindProgram(); } this.currentFragmentProgram = glprg; } break; case GpuProgramType.Geometry: default: break; } glprg.BindProgram(); base.BindGpuProgram( program ); }