GLSLGpuProgram.cs :  » Game » RealmForge » Axiom » RenderSystems » OpenGL » GLSL » 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 » GLSL » GLSLGpuProgram.cs
using System;
using Axiom.Graphics;

namespace Axiom.RenderSystems.OpenGL.GLSL{
  /// <summary>
  ///    GLSL low level compiled shader object - this class is used to get at the linked program object 
  ///    and provide an interface for GLRenderSystem calls.  GLSL does not provide access to the
  ///    low level code of the shader so this class is really just a dummy place holder.
  ///    GLSL uses a program object to represent the active vertex and fragment programs used
  ///    but Axiom materials maintain seperate instances of the active vertex and fragment programs
  ///    which creates a small problem for GLSL integration.  The GLSLGpuProgram class provides the
  ///    interface between the GLSLLinkProgramManager , GLRenderSystem, and the active GLSLProgram
  ///    instances.
  /// </summary>
  public class GLSLGpuProgram : GLGpuProgram {
    #region Fields

    /// <summary>
    ///    GL Handle for the shader object.
    /// </summary>
    protected GLSLProgram glslProgram;

    /// <summary>
    ///    Keep track of the number of vertex shaders created.
    /// </summary>
    protected static int vertexShaderCount;
    /// <summary>
    ///    Keep track of the number of fragment shaders created.
    /// </summary>
    protected static int fragmentShaderCount;

    #endregion Fields

    #region Constructor

    public GLSLGpuProgram(GLSLProgram parent) : base(parent.Name, parent.Type, "glsl") {
      // store off the reference to the parent program
      glslProgram = parent;

      if(parent.Type == GpuProgramType.Vertex) {
        programId = ++vertexShaderCount;
      }
      else {
        programId = ++fragmentShaderCount;
      }

      // there is nothing to load
      loadFromFile = false;
    }

    #endregion Constructor

    #region Properties

    /// <summary>
    ///    Gets the GLSLProgram for the shader object.
    /// </summary>
    public GLSLProgram GLSLProgram {
      get {
        return glslProgram;
      }
    }
  
    #endregion Properties

    #region Resource Implementation

    public override void Load() {
      isLoaded = true;
    }

    public override void Unload() {
      // nothing to unload
    }

    #endregion Resource Implementation

    #region GpuProgram Implementation

    public override void Bind() {
      // tell the Link Program Manager what shader is to become active
      if(type == GpuProgramType.Vertex) {
        GLSLLinkProgramManager.Instance.SetActiveVertexShader(this);
      }
      else {
        GLSLLinkProgramManager.Instance.SetActiveFragmentShader(this);
      }
    }

    public override void BindParameters(GpuProgramParameters parameters) {
      // activate the link program object
      GLSLLinkProgram linkProgram = GLSLLinkProgramManager.Instance.ActiveLinkProgram;

      // pass on parameters from params to program object uniforms
      linkProgram.UpdateUniforms(parameters);
    }

    /// <summary>
    /// 
    /// </summary>
    protected override void LoadFromSource() {
      // nothing to load
    }

    public override void Unbind() {
      // tell the Link Program Manager what shader is to become inactive
      if(type == GpuProgramType.Vertex) {
        GLSLLinkProgramManager.Instance.SetActiveVertexShader(null);
      }
      else {
        GLSLLinkProgramManager.Instance.SetActiveFragmentShader(null);
      }
    }

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