Specialization of vertex/fragment programs for OpenGL.
Inheritance: Axiom.Graphics.GpuProgram
Exemplo n.º 1
0
		public override void UnbindGpuProgram( GpuProgramType type )
		{
			// store the current program in use for eas unbinding later
			if ( type == GpuProgramType.Vertex && currentVertexProgram != null )
			{
			    activeVertexGpuProgramParameters = null;
				currentVertexProgram.Unbind();
				currentVertexProgram = null;
			}
            else if (type == GpuProgramType.Geometry && currentGeometryProgram != null)
            {
                activeGeometryGpuProgramParameters = null;
                currentGeometryProgram.Unbind();
                currentGeometryProgram = null;
            }
			else if ( type == GpuProgramType.Fragment && currentFragmentProgram != null )
			{
                activeFragmentGpuProgramParameters = null;
				currentFragmentProgram.Unbind();
				currentFragmentProgram = null;
			}

		    base.UnbindGpuProgram( type );
		}
        /// <summary>
        ///    Binds the specified GpuProgram to the future rendering operations.
        /// </summary>
        /// <param name="program"></param>
        public override void BindGpuProgram(GpuProgram program)
        {
            GLGpuProgram glProgram = (GLGpuProgram)program;

            glProgram.Bind();

            // store the current program in use for eas unbinding later
            if(glProgram.Type == GpuProgramType.Vertex) {
                currentVertexProgram = glProgram;
            }
            else {
                currentFragmentProgram = glProgram;
            }
        }
Exemplo n.º 3
0
		public override void BindGpuProgram( GpuProgram program )
		{
			var glProgram = (GLGpuProgram)program;

            // 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 maybe 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 difference 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 inuse,
            //     unbind and notify render system to correct for its state.
            //
            switch (glProgram.Type)
            {
                case GpuProgramType.Vertex:
                    if (currentVertexProgram != glProgram)
                    {
                        if (currentVertexProgram != null)
                            currentVertexProgram.Unbind();
                        currentVertexProgram = glProgram;
                    }
                    break;

                case GpuProgramType.Fragment:
                    if (currentFragmentProgram != glProgram)
                    {
                        if (currentFragmentProgram != null)
                            currentFragmentProgram.Unbind();
                        currentFragmentProgram = glProgram;
                    }
                    break;
                case GpuProgramType.Geometry:
                    if (currentGeometryProgram != glProgram)
                    {
                        if (currentGeometryProgram != null)
                            currentGeometryProgram.Unbind();
                        currentGeometryProgram = glProgram;
                    }
                    break;
            }

			glProgram.Bind();

		    base.BindGpuProgram( program );
		}
 /// <summary>
 ///    Unbinds programs of the specified type.
 /// </summary>
 /// <param name="type"></param>
 public override void UnbindGpuProgram(GpuProgramType type)
 {
     // store the current program in use for eas unbinding later
     if(type == GpuProgramType.Vertex && currentVertexProgram != null) {
         currentVertexProgram.Unbind();
         currentVertexProgram = null;
     }
     else if(type == GpuProgramType.Fragment && currentFragmentProgram != null) {
         currentFragmentProgram.Unbind();
         currentFragmentProgram = null;
     }
 }