ATIFragmentShaderGpuProgram.cs :  » Game » RealmForge » Axiom » RenderSystems » OpenGL » ATI » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Game » RealmForge 
RealmForge » Axiom » RenderSystems » OpenGL » ATI » ATIFragmentShaderGpuProgram.cs
using System;
using Axiom.Graphics;
using Axiom.RenderSystems.OpenGL;
using Tao.OpenGl;

namespace Axiom.RenderSystems.OpenGL.ATI{
  /// <summary>
  /// Summary description for ATIFragmentShaderGpuProgram.
  /// </summary>
  public class ATIFragmentShaderGpuProgram : GLGpuProgram {
    public ATIFragmentShaderGpuProgram(string name, GpuProgramType type, string syntaxCode)
            : base(name, type, syntaxCode) {

            programType = Gl.GL_FRAGMENT_SHADER_ATI;
            programId = Gl.glGenFragmentShadersATI(1);
    }

        #region Implementation of GpuProgram

        protected override void LoadFromSource() {
            PixelShader assembler = new PixelShader();

            //bool testError = assembler.RunTests();

            bool error = !assembler.Compile(source);

            if(!error) {
                Gl.glBindFragmentShaderATI(programId);
                Gl.glBeginFragmentShaderATI();

                // Compile and issue shader commands
                error = !assembler.BindAllMachineInstToFragmentShader();

                Gl.glEndFragmentShaderATI();
            }
            else {
            }
        }

        public override void Unload() {
            base.Unload ();

            // delete the fragment shader for good
            Gl.glDeleteFragmentShaderATI(programId);
        }


        #endregion Implementation of GpuProgram

        #region Implementation of GLGpuProgram

        public override void Bind() {
            Gl.glEnable(programType);
            Gl.glBindFragmentShaderATI(programId);
        }

        public override void BindParameters(GpuProgramParameters parms) {
            // program constants done internally by compiler for local
            if(parms.HasFloatConstants) {
        for(int index = 0; index < parms.FloatConstantCount; index++) {
          GpuProgramParameters.FloatConstantEntry entry = parms.GetFloatConstant(index);

          if(entry.isSet) {
            // send the params 4 at a time
            Gl.glSetFragmentShaderConstantATI(Gl.GL_CON_0_ATI + index, entry.val);
          }
        }
            }   
        }

        public override void Unbind() {
            Gl.glDisable(programType);
        }

        #endregion Implementation of GLGpuProgram
  }

    /// <summary>
    /// 
    /// </summary>
    public class ATIFragmentShaderFactory : IOpenGLGpuProgramFactory {
        #region IOpenGLGpuProgramFactory Members

        public GLGpuProgram Create(string name, Axiom.Graphics.GpuProgramType type, string syntaxCode) {
            // creates and returns a new ATI fragment shader implementation
            return new ATIFragmentShaderGpuProgram(name, type, syntaxCode);
        }

        #endregion

    }

}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.