~karl-qdh/nux/nux.gtkentry-wrapper

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/*
 * Copyright 2010 Inalogic Inc.
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License version 3, as
 * published by the  Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
 * PURPOSE.  See the applicable version of the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of both the GNU Lesser General Public
 * License version 3 along with this program.  If not, see
 * <http://www.gnu.org/licenses/>
 *
 * Authored by: Jay Taoko <jaytaoko@inalogic.com>
 *
 */


#include "NuxCore/NuxCore.h"
#include "GLResource.h"
#include "GLShader.h"
#include "GLShaderParameter.h"

namespace nux
{
// //-----------------------------------------------------------------------------
// void AddShaderDefinition(std::vector<ShaderDefinition>& Definitions,const TCHAR* Name,const TCHAR* Format,...)
// {
//     TCHAR	DefinitionText[1024];
//     GET_VARARGS(DefinitionText, NUX_ARRAY_COUNT(DefinitionText), NUX_ARRAY_COUNT(DefinitionText)-1,Format);
//
//     ShaderDefinition	Definition;
//     Definition.Name = Name;
//     Definition.Value = DefinitionText;
//     Definitions.push_back(Definition);
// }
//
// //-----------------------------------------------------------------------------
// bool ExtractShaderString3(const NString &ShaderToken, const NString &ShaderSource, NString &RetSource, NString& ShaderPreprocessorDefines)
// {
//     unsigned int lineStart = 0;
//     unsigned int lineCount = 1;
//     bool startTokenFound = false;
//     int shaderStringStart =0;
//     int shaderStartLine   =1;
//
//
//     //Loop for all characters in the string
//     if(ShaderToken != TEXT(""))
//     {
//         int i;
//         for(i = 0; i< ShaderSource.Length(); i++)
//         {
//             //Check if the starting character '[' (open bracket) is found at the beginning of the line
//             // i counts the characters in the file. lineStart is equal to i at the beginning of the line.
//             if((TCharStringNCompare(&ShaderSource[i],TEXT("["), 1) == 0) && (lineStart == i))
//             {
//                 if(!startTokenFound)
//                 {
//                     //Test for the start token
//                     if(ShaderSource.FindFirstOccurence(ShaderToken) == i)
//                     {
//                         // Found the shader token
//                         shaderStringStart = i + ShaderToken.Length();
//                         startTokenFound = true;
//
//                         //Set what line the shader was found on
//                         shaderStartLine = lineCount;
//                     }
//                 }
//                 else
//                 {
//                     //Break where the end token was found
//                     break;
//                 }
//             }
//
//             //If the character is equal to the new line character,
//             // The next character must be on the new line
//             if((TCharStringNCompare(&ShaderSource[i], TEXT("\r"), 1) == 0) || (TCharStringNCompare(&ShaderSource[i], TEXT("\n"), 1) == 0))
//             {
//                 lineStart = i+1;
//             }
//
//             //Count the new lines
//             if(TCharStringNCompare(&ShaderSource[i], TEXT("\n"), 1) == 0)
//             {
//                 lineCount++;
//             }
//         }
//
//         //If the string was not found, return false
//         if(!startTokenFound || shaderStringStart >= i)
//         {
//             return false;
//         }
//
//         //Assign the return string
//         RetSource = ShaderSource.GetSubString(shaderStringStart, i - shaderStringStart);
//
//         //Add the line directive to the shader source. See the documentation for GLSL #line directive.
//         // GLSL spec: The #version directive must occur in a shader before anything else, except for comments and white space.
//         int Pos = RetSource.FindFirstOccurence(TEXT("#version"));
//         while(RetSource[Pos] != TEXT('\n'))
//         {
//             if(RetSource[Pos] == 0)
//                 break;
//             ++Pos;
//         }
//         if(RetSource[Pos] != 0)
//             ++Pos;
//
//         int EndOfLinePosition = 0;
//         unsigned int LinePosition = 0;
//         while((EndOfLinePosition = RetSource.FindNextOccurence(TEXT('\n'), EndOfLinePosition)) < Pos-1)
//         {
//             ++EndOfLinePosition;
//             ++LinePosition;
//         }
//
//         RetSource.Insert(Pos, NString::Printf(TEXT("#line %u\n"), LinePosition + shaderStartLine));
//
//         // Insert the preprocessor definitions before the #line directive
//         if(ShaderPreprocessorDefines.Length())
//             RetSource.Insert(Pos, ShaderPreprocessorDefines + NString(TEXT('\n')));
//
//         return true;
//     }
//     else
//     {
//         // We are not searching for a start token. Return the whole source.
//         RetSource = ShaderSource;
//         return true;
//     }
// }
//
// void InsertPreProcessorDefinitions(const NString &ShaderSource, NString &RetSource, NString& ShaderPreprocessorDefines)
// {
//     RetSource = ShaderSource;
//
//     if(ShaderPreprocessorDefines.Length() == 0)
//         return;
//
//     // GLSL spec: The #version directive must occur in a shader before anything else, except for comments and white space.
//     int Pos = RetSource.FindFirstOccurence(TEXT("#version"));
//     if(Pos != -1)
//     {
//         Pos = RetSource.FindNextOccurence(TEXT('\n'), Pos);
//         if(Pos == -1)
//         {
//             // this is most likely an incorrect shader
//             Pos = RetSource.Size();
//             RetSource.Insert(Pos, NString(TEXT('\n')));
//             Pos = RetSource.Size();
//         }
//         else
//         {
//             // Skip character \n
//             Pos++;
//         }
//     }
//     else
//     {
//         Pos = 0;
//     }
//
//     if(ShaderPreprocessorDefines.Length())
//         RetSource.Insert(Pos, ShaderPreprocessorDefines + NString(TEXT('\n')));
// }
}