~unity-team/nux/nux-remove-glew-mx

« back to all changes in this revision

Viewing changes to NuxGraphics/GLShader.cpp

  • Committer: Jay Taoko
  • Date: 2011-05-30 02:54:31 UTC
  • mfrom: (353.1.1 nux)
  • Revision ID: jay.taoko@canonical.com-20110530025431-kpqcnbcq3apsfz92
* Object::Dispose() now does the same thing as Object::UnReference()
* Fixed memory leak in UXTheme::Load2DTextureFile
* Mesh Resource manager
    - Fixed mesh Resource manager pipeline
    - See example ProgObjMeshLoader

* Fixed GLSL Shaders in FontRendering.cpp
    - removed global variable USE_ARB_SHADERS and replaced with GraphicsEngine::UsingGLSLCodePath()

* Removing files IniFile.cpp/.h
* Removing files UIColorTheme.cpp/.h

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
namespace nux
29
29
{
30
 
// //-----------------------------------------------------------------------------
31
 
// void AddShaderDefinition(std::vector<ShaderDefinition>& Definitions,const TCHAR* Name,const TCHAR* Format,...)
32
 
// {
33
 
//     TCHAR    DefinitionText[1024];
34
 
//     GET_VARARGS(DefinitionText, NUX_ARRAY_COUNT(DefinitionText), NUX_ARRAY_COUNT(DefinitionText)-1,Format);
35
 
//
36
 
//     ShaderDefinition Definition;
37
 
//     Definition.Name = Name;
38
 
//     Definition.Value = DefinitionText;
39
 
//     Definitions.push_back(Definition);
40
 
// }
41
 
//
42
 
// //-----------------------------------------------------------------------------
43
 
// bool ExtractShaderString3(const NString &ShaderToken, const NString &ShaderSource, NString &RetSource, NString& ShaderPreprocessorDefines)
44
 
// {
45
 
//     unsigned int lineStart = 0;
46
 
//     unsigned int lineCount = 1;
47
 
//     bool startTokenFound = false;
48
 
//     int shaderStringStart =0;
49
 
//     int shaderStartLine   =1;
50
 
//
51
 
//
52
 
//     //Loop for all characters in the string
53
 
//     if(ShaderToken != TEXT(""))
54
 
//     {
55
 
//         int i;
56
 
//         for(i = 0; i< ShaderSource.Length(); i++)
57
 
//         {
58
 
//             //Check if the starting character '[' (open bracket) is found at the beginning of the line
59
 
//             // i counts the characters in the file. lineStart is equal to i at the beginning of the line.
60
 
//             if((TCharStringNCompare(&ShaderSource[i],TEXT("["), 1) == 0) && (lineStart == i))
61
 
//             {
62
 
//                 if(!startTokenFound)
63
 
//                 {
64
 
//                     //Test for the start token
65
 
//                     if(ShaderSource.FindFirstOccurence(ShaderToken) == i)
66
 
//                     {
67
 
//                         // Found the shader token
68
 
//                         shaderStringStart = i + ShaderToken.Length();
69
 
//                         startTokenFound = true;
70
 
//
71
 
//                         //Set what line the shader was found on
72
 
//                         shaderStartLine = lineCount;
73
 
//                     }
74
 
//                 }
75
 
//                 else
76
 
//                 {
77
 
//                     //Break where the end token was found
78
 
//                     break;
79
 
//                 }
80
 
//             }
81
 
//
82
 
//             //If the character is equal to the new line character,
83
 
//             // The next character must be on the new line
84
 
//             if((TCharStringNCompare(&ShaderSource[i], TEXT("\r"), 1) == 0) || (TCharStringNCompare(&ShaderSource[i], TEXT("\n"), 1) == 0))
85
 
//             {
86
 
//                 lineStart = i+1;
87
 
//             }
88
 
//
89
 
//             //Count the new lines
90
 
//             if(TCharStringNCompare(&ShaderSource[i], TEXT("\n"), 1) == 0)
91
 
//             {
92
 
//                 lineCount++;
93
 
//             }
94
 
//         }
95
 
//
96
 
//         //If the string was not found, return false
97
 
//         if(!startTokenFound || shaderStringStart >= i)
98
 
//         {
99
 
//             return false;
100
 
//         }
101
 
//
102
 
//         //Assign the return string
103
 
//         RetSource = ShaderSource.GetSubString(shaderStringStart, i - shaderStringStart);
104
 
//
105
 
//         //Add the line directive to the shader source. See the documentation for GLSL #line directive.
106
 
//         // GLSL spec: The #version directive must occur in a shader before anything else, except for comments and white space.
107
 
//         int Pos = RetSource.FindFirstOccurence(TEXT("#version"));
108
 
//         while(RetSource[Pos] != TEXT('\n'))
109
 
//         {
110
 
//             if(RetSource[Pos] == 0)
111
 
//                 break;
112
 
//             ++Pos;
113
 
//         }
114
 
//         if(RetSource[Pos] != 0)
115
 
//             ++Pos;
116
 
//
117
 
//         int EndOfLinePosition = 0;
118
 
//         unsigned int LinePosition = 0;
119
 
//         while((EndOfLinePosition = RetSource.FindNextOccurence(TEXT('\n'), EndOfLinePosition)) < Pos-1)
120
 
//         {
121
 
//             ++EndOfLinePosition;
122
 
//             ++LinePosition;
123
 
//         }
124
 
//
125
 
//         RetSource.Insert(Pos, NString::Printf(TEXT("#line %u\n"), LinePosition + shaderStartLine));
126
 
//
127
 
//         // Insert the preprocessor definitions before the #line directive
128
 
//         if(ShaderPreprocessorDefines.Length())
129
 
//             RetSource.Insert(Pos, ShaderPreprocessorDefines + NString(TEXT('\n')));
130
 
//
131
 
//         return true;
132
 
//     }
133
 
//     else
134
 
//     {
135
 
//         // We are not searching for a start token. Return the whole source.
136
 
//         RetSource = ShaderSource;
137
 
//         return true;
138
 
//     }
139
 
// }
140
 
//
141
 
// void InsertPreProcessorDefinitions(const NString &ShaderSource, NString &RetSource, NString& ShaderPreprocessorDefines)
142
 
// {
143
 
//     RetSource = ShaderSource;
144
 
//
145
 
//     if(ShaderPreprocessorDefines.Length() == 0)
146
 
//         return;
147
 
//
148
 
//     // GLSL spec: The #version directive must occur in a shader before anything else, except for comments and white space.
149
 
//     int Pos = RetSource.FindFirstOccurence(TEXT("#version"));
150
 
//     if(Pos != -1)
151
 
//     {
152
 
//         Pos = RetSource.FindNextOccurence(TEXT('\n'), Pos);
153
 
//         if(Pos == -1)
154
 
//         {
155
 
//             // this is most likely an incorrect shader
156
 
//             Pos = RetSource.Size();
157
 
//             RetSource.Insert(Pos, NString(TEXT('\n')));
158
 
//             Pos = RetSource.Size();
159
 
//         }
160
 
//         else
161
 
//         {
162
 
//             // Skip character \n
163
 
//             Pos++;
164
 
//         }
165
 
//     }
166
 
//     else
167
 
//     {
168
 
//         Pos = 0;
169
 
//     }
170
 
//
171
 
//     if(ShaderPreprocessorDefines.Length())
172
 
//         RetSource.Insert(Pos, ShaderPreprocessorDefines + NString(TEXT('\n')));
173
 
// }
 
30
 
174
31
}