1. Summary
  2. Files
  3. Support
  4. Report Spam
  5. Create account
  6. Log in

root/branches/v0.8.0.0/Projects/Axiom/RenderSystems/OpenGL/GLGpuProgram.cs @ 2940

Revision 2940, 5.3 KB (checked in by borrillis, 17 months ago)

Brand new build system for final release.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1#region LGPL License
2
3/*
4Axiom Graphics Engine Library
5Copyright © 2003-2011 Axiom Project Team
6
7The overall design, and a majority of the core engine and rendering code
8contained within this library is a derivative of the open source Object Oriented
9Graphics Engine OGRE, which can be found at http://ogre.sourceforge.net. 
10Many thanks to the OGRE team for maintaining such a high quality project.
11
12This library is free software; you can redistribute it and/or
13modify it under the terms of the GNU Lesser General Public
14License as published by the Free Software Foundation; either
15version 2.1 of the License, or (at your option) any later version.
16
17This library is distributed in the hope that it will be useful,
18but WITHOUT ANY WARRANTY; without even the implied warranty of
19MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20Lesser General Public License for more details.
21
22You should have received a copy of the GNU Lesser General Public
23License along with this library; if not, write to the Free Software
24Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25*/
26
27#endregion
28
29#region SVN Version Information
30
31// <file>
32//     <license see="http://axiom3d.net/wiki/index.php/license.txt"/>
33//     <id value="$Id$"/>
34// </file>
35
36#endregion SVN Version Information
37
38#region Namespace Declarations
39
40using System;
41
42using Axiom.Core;
43using Axiom.Graphics;
44
45using Tao.OpenGl;
46
47using System.Diagnostics;
48
49using ResourceHandle = System.UInt64;
50
51#endregion Namespace Declarations
52
53namespace Axiom.RenderSystems.OpenGL
54{
55        /// <summary>
56        ///     Specialization of vertex/fragment programs for OpenGL.
57        /// </summary>
58        public class GLGpuProgram : GpuProgram
59        {
60                #region Fields
61
62                /// <summary>
63                ///    Internal OpenGL id assigned to this program.
64                /// </summary>
65                protected int programId;
66
67                /// <summary>
68                ///    Type of this program (vertex or fragment).
69                /// </summary>
70                protected int programType;
71
72                /// <summary>
73                ///     For use internally to store temp values for passing constants, etc.
74                /// </summary>
75                protected float[] tempProgramFloats = new float[4];
76
77                #endregion Fields
78
79                #region Constructors
80
81                /// <summary>
82                ///     Constructor.
83                /// </summary>
84                /// <param name="name">Name of the program.</param>
85                /// <param name="type">Type of program (vertex or fragment).</param>
86                /// <param name="syntaxCode">Syntax code (i.e. arbvp1, etc).</param>
87                internal GLGpuProgram( ResourceManager parent, string name, ResourceHandle handle, string group, bool isManual, IManualResourceLoader loader )
88                        : base( parent, name, handle, group, isManual, loader ) {}
89
90                #endregion Constructors
91
92                #region GpuProgram Methods
93
94                /// <summary>
95                ///     Called when a program needs to be bound.
96                /// </summary>
97                virtual public void Bind()
98                {
99                        // do nothing
100                }
101
102                /// <summary>
103                ///     Called when a program needs to be unbound.
104                /// </summary>
105                virtual public void Unbind()
106                {
107                        // do nothing
108                }
109
110                /// <summary>
111                ///     Called to create the program from source.
112                /// </summary>
113                protected override void LoadFromSource()
114                {
115                        // do nothing
116                }
117
118                /// <summary>
119                ///     Called when a program needs to bind the supplied parameters.
120                /// </summary>
121                /// <param name="parms"></param>
122                virtual public void BindParameters( GpuProgramParameters parms )
123                {
124                        // do nothing
125                }
126
127                /// <summary>
128                /// Bind just the pass iteration parameters
129                /// </summary>
130                /// <param name="parms"></param>
131                virtual public void BindProgramPassIterationParameters( GpuProgramParameters parms )
132                {
133                        // do nothing
134                }
135
136                #endregion GpuProgram Methods
137
138                #region Properties
139
140                /// <summary>
141                ///    Access to the internal program id.
142                /// </summary>
143                public int ProgramID { get { return programId; } }
144
145                /// <summary>
146                ///    Gets the program type (GL_VERTEX_PROGRAM_ARB, GL_FRAGMENT_PROGRAM_ARB, etc);
147                /// </summary>
148                public int GLProgramType { get { return programType; } }
149
150                public override int SamplerCount
151                {
152                        get
153                        {
154                                //TODO: SamplerCount is not implimented
155                                return 0;
156                        }
157                }
158
159                #endregion Properties
160
161                internal bool IsAttributeValid( VertexElementSemantic semantic )
162                {
163                        switch( semantic )
164                        {
165                                case VertexElementSemantic.Diffuse:
166                                case VertexElementSemantic.Normal:
167                                case VertexElementSemantic.Position:
168                                case VertexElementSemantic.Specular:
169                                case VertexElementSemantic.TexCoords:
170                                default:
171                                        Debug.Assert( false, "Shouldn't be calling this for normal attributes" );
172                                        break;
173                                case VertexElementSemantic.Binormal:
174                                case VertexElementSemantic.BlendIndices:
175                                case VertexElementSemantic.BlendWeights:
176                                case VertexElementSemantic.Tangent:
177                                        return true;
178                        }
179                        return false; // keeps compiler happy
180                }
181
182                internal int AttributeIndex( VertexElementSemantic semantic )
183                {
184                        switch( semantic )
185                        {
186                                case VertexElementSemantic.Diffuse:
187                                case VertexElementSemantic.Normal:
188                                case VertexElementSemantic.Position:
189                                case VertexElementSemantic.Specular:
190                                case VertexElementSemantic.TexCoords:
191                                default:
192                                        Debug.Assert( false, "Shouldn't be calling this for normal attributes" );
193                                        break;
194                                case VertexElementSemantic.Binormal:
195                                        return 7;
196                                case VertexElementSemantic.BlendIndices:
197                                        return 1;
198                                case VertexElementSemantic.BlendWeights:
199                                        return 14;
200                                case VertexElementSemantic.Tangent:
201                                        return 15;
202                        }
203                        return 0; // keeps compiler happy
204                }
205        }
206}
Note: See TracBrowser for help on using the browser.