Merge lp:~unity-team/nux/nux.gpudevice-cleanup into lp:nux
- nux.gpudevice-cleanup
- Merge into trunk
Proposed by
Jay Taoko
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Michi Henning | ||||
Approved revision: | 677 | ||||
Merged at revision: | 676 | ||||
Proposed branch: | lp:~unity-team/nux/nux.gpudevice-cleanup | ||||
Merge into: | lp:nux | ||||
Diff against target: |
1259 lines (+267/-229) 18 files modified
Nux/Theme.cpp (+20/-17) NuxCore/FileIO.cpp (+9/-9) NuxCore/FileIO.h (+3/-3) NuxGraphics/FontRenderer.cpp (+2/-2) NuxGraphics/GLError.cpp (+2/-0) NuxGraphics/GLRenderStates.cpp (+2/-2) NuxGraphics/GLRenderStates.h (+9/-9) NuxGraphics/GLShaderParameter.h (+2/-2) NuxGraphics/GpuDevice.cpp (+114/-75) NuxGraphics/GpuDevice.h (+22/-32) NuxGraphics/GpuDeviceVertex.cpp (+1/-1) NuxGraphics/GraphicsEngine.cpp (+1/-1) NuxGraphics/GraphicsEngine.h (+3/-3) NuxGraphics/IOpenGLAsmShader.cpp (+9/-9) NuxGraphics/IOpenGLAsmShader.h (+2/-2) NuxGraphics/IOpenGLCgShader.h (+6/-6) NuxGraphics/IOpenGLGLSLShader.cpp (+51/-47) NuxGraphics/IOpenGLGLSLShader.h (+9/-9) |
||||
To merge this branch: | bzr merge lp:~unity-team/nux/nux.gpudevice-cleanup | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Nicolas d'Offay (community) | Approve | ||
Eleni Maria Stea (community) | Approve | ||
Michi Henning (community) | Approve | ||
Review via email:
|
Commit message
* Removing instances of NString.
* Fixed integer to pointer convertion in GpuDevice:
* Fixed bug in Them.cpp: Check that a pointer is NULL before calling UnReference.
* Use proper member variables naming.
* GpuDevice: Changed code for detection of OpenGL minor and minor version.
Description of the change
* Removing instances of NString.
* Fixed integer to pointer convertion in GpuDevice:
* Fixed bug in Them.cpp: Check that a pointer is NULL before calling UnReference.
* Use proper member variables naming.
* GpuDevice: Changed code for detection of OpenGL minor and minor version.
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Michi Henning (michihenning) wrote : | # |
This also fixes Bug #1052765
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Nicolas d'Offay (nicolas-doffay) wrote : | # |
Looks good to land from here.
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'Nux/Theme.cpp' | |||
2 | --- Nux/Theme.cpp 2012-09-26 12:23:04 +0000 | |||
3 | +++ Nux/Theme.cpp 2012-09-30 17:24:22 +0000 | |||
4 | @@ -151,7 +151,10 @@ | |||
5 | 151 | std::list<PainterImage*>::iterator it; | 151 | std::list<PainterImage*>::iterator it; |
6 | 152 | for (it = painter_image_list_.begin(); it != painter_image_list_.end(); it++) | 152 | for (it = painter_image_list_.begin(); it != painter_image_list_.end(); it++) |
7 | 153 | { | 153 | { |
9 | 154 | (*it)->texture->UnReference(); | 154 | if ((*it)->texture) |
10 | 155 | { | ||
11 | 156 | (*it)->texture->UnReference(); | ||
12 | 157 | } | ||
13 | 155 | delete(*it); | 158 | delete(*it); |
14 | 156 | } | 159 | } |
15 | 157 | painter_image_list_.clear(); | 160 | painter_image_list_.clear(); |
16 | @@ -204,8 +207,8 @@ | |||
17 | 204 | { | 207 | { |
18 | 205 | BaseTexture* device_texture; | 208 | BaseTexture* device_texture; |
19 | 206 | 209 | ||
22 | 207 | NString texture_filename = NUX_FIND_RESOURCE_LOCATION_NOFAIL(*value_cursor); | 210 | std::string texture_filename = NUX_FIND_RESOURCE_LOCATION_NOFAIL(*value_cursor); |
23 | 208 | device_texture = theme->Load2DTextureFile(texture_filename.GetTCharPtr()); | 211 | device_texture = theme->Load2DTextureFile(texture_filename.c_str()); |
24 | 209 | 212 | ||
25 | 210 | pimage->texture = device_texture; | 213 | pimage->texture = device_texture; |
26 | 211 | } | 214 | } |
27 | @@ -228,8 +231,8 @@ | |||
28 | 228 | 231 | ||
29 | 229 | void UXTheme::LoadPainterImages() | 232 | void UXTheme::LoadPainterImages() |
30 | 230 | { | 233 | { |
33 | 231 | NString file_search = "Painter.xml"; | 234 | std::string file_search = "Painter.xml"; |
34 | 232 | NString painter_filename = NUX_FIND_RESOURCE_LOCATION_NOFAIL(file_search.GetTCharPtr()); | 235 | std::string painter_filename = NUX_FIND_RESOURCE_LOCATION_NOFAIL(file_search.c_str()); |
35 | 233 | 236 | ||
36 | 234 | if (painter_filename == "") | 237 | if (painter_filename == "") |
37 | 235 | { | 238 | { |
38 | @@ -253,10 +256,10 @@ | |||
39 | 253 | this, | 256 | this, |
40 | 254 | NULL); | 257 | NULL); |
41 | 255 | 258 | ||
44 | 256 | NString str; | 259 | std::string str; |
45 | 257 | LoadFileToString(str, painter_filename.GetTCharPtr()); | 260 | LoadFileToString(str, painter_filename.c_str()); |
46 | 258 | 261 | ||
48 | 259 | if (g_markup_parse_context_parse(context, str.GetTCharPtr(), str.Length(), NULL) == FALSE) | 262 | if (g_markup_parse_context_parse(context, str.c_str(), str.length(), NULL) == FALSE) |
49 | 260 | { | 263 | { |
50 | 261 | nuxCriticalMsg("[GraphicsEngine::LoadPainterImages] Failed to parse data."); | 264 | nuxCriticalMsg("[GraphicsEngine::LoadPainterImages] Failed to parse data."); |
51 | 262 | return; | 265 | return; |
52 | @@ -264,7 +267,7 @@ | |||
53 | 264 | 267 | ||
54 | 265 | #else | 268 | #else |
55 | 266 | 269 | ||
57 | 267 | TiXmlDocument doc(painter_filename.GetTCharPtr()); | 270 | TiXmlDocument doc(painter_filename.c_str()); |
58 | 268 | doc.LoadFile(); | 271 | doc.LoadFile(); |
59 | 269 | 272 | ||
60 | 270 | TiXmlHandle docHandle( &doc ); | 273 | TiXmlHandle docHandle( &doc ); |
61 | @@ -273,12 +276,12 @@ | |||
62 | 273 | 276 | ||
63 | 274 | for (image = data->FirstChildElement(TCHARToUTF8("Image")); image; image = image->NextSiblingElement(TCHARToUTF8("Image"))) | 277 | for (image = data->FirstChildElement(TCHARToUTF8("Image")); image; image = image->NextSiblingElement(TCHARToUTF8("Image"))) |
64 | 275 | { | 278 | { |
66 | 276 | PainterImage *pimage = new PainterImage; | 279 | PainterImage* pimage = new PainterImage; |
67 | 277 | Memset(pimage, 0, sizeof(PainterImage)); | 280 | Memset(pimage, 0, sizeof(PainterImage)); |
68 | 278 | 281 | ||
70 | 279 | NString style = image->Attribute(TCHARToUTF8("style")); | 282 | std::string style = image->Attribute(TCHARToUTF8("style")); |
71 | 280 | 283 | ||
73 | 281 | pimage->style = GetStyleImageRef(style.GetTCharPtr()); | 284 | pimage->style = GetStyleImageRef(style.c_str()); |
74 | 282 | 285 | ||
75 | 283 | // If the attributes border_left, border_right, border_top, border_bottom are not present, assume they are equal to 0; | 286 | // If the attributes border_left, border_right, border_top, border_bottom are not present, assume they are equal to 0; |
76 | 284 | pimage->border_left = pimage->border_right = pimage->border_top = pimage->border_bottom = 0; | 287 | pimage->border_left = pimage->border_right = pimage->border_top = pimage->border_bottom = 0; |
77 | @@ -309,16 +312,16 @@ | |||
78 | 309 | 312 | ||
79 | 310 | if (1) | 313 | if (1) |
80 | 311 | { | 314 | { |
83 | 312 | NString filename = image->Attribute(TCHARToUTF8("Name")); | 315 | std::string filename = image->Attribute(TCHARToUTF8("Name")); |
84 | 313 | NString texture_filename = NUX_FIND_RESOURCE_LOCATION_NOFAIL(filename.GetTCharPtr()); | 316 | std::string texture_filename = NUX_FIND_RESOURCE_LOCATION_NOFAIL(filename.c_str()); |
85 | 314 | pimage->texture = 0; | 317 | pimage->texture = 0; |
86 | 315 | pimage->filename = texture_filename; | 318 | pimage->filename = texture_filename; |
87 | 316 | } | 319 | } |
88 | 317 | else | 320 | else |
89 | 318 | { | 321 | { |
93 | 319 | NString filename = image->Attribute(TCHARToUTF8("Name")); | 322 | std::string filename = image->Attribute(TCHARToUTF8("Name")); |
94 | 320 | NString texture_filename = NUX_FIND_RESOURCE_LOCATION_NOFAIL(filename.GetTCharPtr()); | 323 | std::string texture_filename = NUX_FIND_RESOURCE_LOCATION_NOFAIL(filename.c_str()); |
95 | 321 | pimage->texture = Load2DTextureFile(texture_filename.GetTCharPtr()); | 324 | pimage->texture = Load2DTextureFile(texture_filename.c_str()); |
96 | 322 | } | 325 | } |
97 | 323 | 326 | ||
98 | 324 | painter_image_list_.push_back(pimage); | 327 | painter_image_list_.push_back(pimage); |
99 | 325 | 328 | ||
100 | === modified file 'NuxCore/FileIO.cpp' | |||
101 | --- NuxCore/FileIO.cpp 2011-10-21 22:06:35 +0000 | |||
102 | +++ NuxCore/FileIO.cpp 2012-09-30 17:24:22 +0000 | |||
103 | @@ -229,10 +229,10 @@ | |||
104 | 229 | } | 229 | } |
105 | 230 | 230 | ||
106 | 231 | /*! | 231 | /*! |
108 | 232 | Load a text file to an NString. The file maybe ANSI or Unicode. | 232 | Load a text file to an std::string. The file maybe ANSI or Unicode. |
109 | 233 | The resulting string is TCHAR. | 233 | The resulting string is TCHAR. |
110 | 234 | */ | 234 | */ |
112 | 235 | bool LoadFileToString ( NString &Result, const TCHAR *Filename, NFileManager &FileManager ) | 235 | bool LoadFileToString(std::string &Result, const TCHAR *Filename, NFileManager &FileManager) |
113 | 236 | { | 236 | { |
114 | 237 | NSerializer *Reader = FileManager.CreateFileReader (Filename); | 237 | NSerializer *Reader = FileManager.CreateFileReader (Filename); |
115 | 238 | 238 | ||
116 | @@ -318,9 +318,9 @@ | |||
117 | 318 | /*! | 318 | /*! |
118 | 319 | Save string to File. Attempt to write it as ASCII if possible. If not write as UTF16-BE. | 319 | Save string to File. Attempt to write it as ASCII if possible. If not write as UTF16-BE. |
119 | 320 | */ | 320 | */ |
121 | 321 | bool SaveStringToFile ( const NString &String, const TCHAR *Filename, NFileManager &FileManager ) | 321 | bool SaveStringToFile(const std::string &String, const TCHAR *Filename, NFileManager &FileManager) |
122 | 322 | { | 322 | { |
124 | 323 | if ( !String.Length() ) | 323 | if ( !String.length() ) |
125 | 324 | return 0; | 324 | return 0; |
126 | 325 | 325 | ||
127 | 326 | NSerializer *Ar = FileManager.CreateFileWriter ( Filename ); | 326 | NSerializer *Ar = FileManager.CreateFileWriter ( Filename ); |
128 | @@ -347,20 +347,20 @@ | |||
129 | 347 | 347 | ||
130 | 348 | if ( SaveAsUnicode || (sizeof (TCHAR) == 1) ) | 348 | if ( SaveAsUnicode || (sizeof (TCHAR) == 1) ) |
131 | 349 | { | 349 | { |
134 | 350 | unsigned int s = (unsigned int) String.Length() * sizeof (TCHAR); | 350 | unsigned int s = (unsigned int) String.length() * sizeof (TCHAR); |
135 | 351 | Ar->Serialize ( NUX_CONST_CAST (TCHAR *, String.GetTCharPtr() ), (unsigned int) s); | 351 | Ar->Serialize(NUX_CONST_CAST(TCHAR *, String.c_str()), (unsigned int) s); |
136 | 352 | } | 352 | } |
137 | 353 | else | 353 | else |
138 | 354 | { | 354 | { |
140 | 355 | unsigned int s = (unsigned int) String.Length(); | 355 | unsigned int s = (unsigned int) String.length(); |
141 | 356 | std::vector<ANSICHAR> AnsiBuffer ( (unsigned int) s); | 356 | std::vector<ANSICHAR> AnsiBuffer ( (unsigned int) s); |
142 | 357 | 357 | ||
143 | 358 | // Cast all character down from UTF16 to ANSI | 358 | // Cast all character down from UTF16 to ANSI |
145 | 359 | for (unsigned int i = 0; i < (unsigned int) String.Length(); i++ ) | 359 | for (unsigned int i = 0; i < (unsigned int) String.length(); i++) |
146 | 360 | AnsiBuffer[i] = ConvertTCHARToAnsiChar ( (unsigned int) String[i]); | 360 | AnsiBuffer[i] = ConvertTCHARToAnsiChar ( (unsigned int) String[i]); |
147 | 361 | 361 | ||
148 | 362 | // serialize | 362 | // serialize |
150 | 363 | s = (unsigned int) String.Length(); | 363 | s = (unsigned int) String.length(); |
151 | 364 | Ar->Serialize ( NUX_CONST_CAST (ANSICHAR *, &AnsiBuffer[0]), s); | 364 | Ar->Serialize ( NUX_CONST_CAST (ANSICHAR *, &AnsiBuffer[0]), s); |
152 | 365 | } | 365 | } |
153 | 366 | 366 | ||
154 | 367 | 367 | ||
155 | === modified file 'NuxCore/FileIO.h' | |||
156 | --- NuxCore/FileIO.h 2011-04-06 21:54:09 +0000 | |||
157 | +++ NuxCore/FileIO.h 2012-09-30 17:24:22 +0000 | |||
158 | @@ -29,9 +29,9 @@ | |||
159 | 29 | bool LoadFileToArray ( std::vector<BYTE>& Result, const TCHAR *Filename, NFileManager &FileManager = GFileManager ); | 29 | bool LoadFileToArray ( std::vector<BYTE>& Result, const TCHAR *Filename, NFileManager &FileManager = GFileManager ); |
160 | 30 | bool LoadTextFileToAnsiArray ( std::vector<ANSICHAR>& Result, const TCHAR *Filename, NFileManager &FileManager = GFileManager ); | 30 | bool LoadTextFileToAnsiArray ( std::vector<ANSICHAR>& Result, const TCHAR *Filename, NFileManager &FileManager = GFileManager ); |
161 | 31 | bool LoadTextFileToUnicodeArray ( std::vector<UNICHAR>& Result, const TCHAR *Filename, NFileManager &FileManager = GFileManager ); | 31 | bool LoadTextFileToUnicodeArray ( std::vector<UNICHAR>& Result, const TCHAR *Filename, NFileManager &FileManager = GFileManager ); |
165 | 32 | bool LoadFileToString ( NString &Result, const TCHAR *Filename, NFileManager &FileManager = GFileManager ); | 32 | bool LoadFileToString(std::string &Result, const TCHAR *Filename, NFileManager &FileManager = GFileManager ); |
166 | 33 | bool SaveArrayToFile ( const std::vector<BYTE>& Array, const TCHAR *Filename, NFileManager &FileManager = GFileManager ); | 33 | bool SaveArrayToFile(const std::vector<BYTE>& Array, const TCHAR *Filename, NFileManager &FileManager = GFileManager ); |
167 | 34 | bool SaveStringToFile ( const NString &String, const TCHAR *Filename, NFileManager &FileManager = GFileManager ); | 34 | bool SaveStringToFile(const std::string &String, const TCHAR *Filename, NFileManager &FileManager = GFileManager ); |
168 | 35 | 35 | ||
169 | 36 | } | 36 | } |
170 | 37 | 37 | ||
171 | 38 | 38 | ||
172 | === modified file 'NuxGraphics/FontRenderer.cpp' | |||
173 | --- NuxGraphics/FontRenderer.cpp 2012-08-27 09:09:21 +0000 | |||
174 | +++ NuxGraphics/FontRenderer.cpp 2012-09-30 17:24:22 +0000 | |||
175 | @@ -179,7 +179,7 @@ | |||
176 | 179 | if (NumCharacter == 0) | 179 | if (NumCharacter == 0) |
177 | 180 | NumChar = str_len; | 180 | NumChar = str_len; |
178 | 181 | else | 181 | else |
180 | 182 | NumChar = std::min(str_len, NumCharacter); | 182 | NumChar = std::min<int>(str_len, NumCharacter); |
181 | 183 | 183 | ||
182 | 184 | strBBox.width = Font->GetStringWidth(str, NumChar); | 184 | strBBox.width = Font->GetStringWidth(str, NumChar); |
183 | 185 | strBBox.height = Font->GetLineHeight(); | 185 | strBBox.height = Font->GetLineHeight(); |
184 | @@ -323,7 +323,7 @@ | |||
185 | 323 | nuxAssertMsg(StartCharacter >= 0, "[FontRenderer::RenderText] Incorrect value for StartCharacter."); | 323 | nuxAssertMsg(StartCharacter >= 0, "[FontRenderer::RenderText] Incorrect value for StartCharacter."); |
186 | 324 | nuxAssertMsg(StartCharacter <= StrLength, "[FontRenderer::RenderText] Incorrect value for StartCharacter."); | 324 | nuxAssertMsg(StartCharacter <= StrLength, "[FontRenderer::RenderText] Incorrect value for StartCharacter."); |
187 | 325 | 325 | ||
189 | 326 | int NumCharToDraw = std::min(StrLength - StartCharacter, NumCharacters); | 326 | int NumCharToDraw = std::min<int>(StrLength - StartCharacter, NumCharacters); |
190 | 327 | 327 | ||
191 | 328 | if (NumCharToDraw <= 0) | 328 | if (NumCharToDraw <= 0) |
192 | 329 | return 0; | 329 | return 0; |
193 | 330 | 330 | ||
194 | === modified file 'NuxGraphics/GLError.cpp' | |||
195 | --- NuxGraphics/GLError.cpp 2012-09-17 09:55:43 +0000 | |||
196 | +++ NuxGraphics/GLError.cpp 2012-09-30 17:24:22 +0000 | |||
197 | @@ -83,8 +83,10 @@ | |||
198 | 83 | if (logger.IsWarningEnabled() && !error_msg.empty()) | 83 | if (logger.IsWarningEnabled() && !error_msg.empty()) |
199 | 84 | { | 84 | { |
200 | 85 | std::string stacktrace; | 85 | std::string stacktrace; |
201 | 86 | #if defined(NUX_OS_LINUX) | ||
202 | 86 | if (debug_glerror_stack()) | 87 | if (debug_glerror_stack()) |
203 | 87 | stacktrace = "\n" + logging::Backtrace(); | 88 | stacktrace = "\n" + logging::Backtrace(); |
204 | 89 | #endif | ||
205 | 88 | logging::LogStream(logging::Warning, logger.module(), file, line).stream() | 90 | logging::LogStream(logging::Warning, logger.module(), file, line).stream() |
206 | 89 | #ifndef NUX_OPENGLES_20 | 91 | #ifndef NUX_OPENGLES_20 |
207 | 90 | << "[CheckGLError] OpenGL Error " << glErr << " (" << gluErrorString(glErr) << ")" | 92 | << "[CheckGLError] OpenGL Error " << glErr << " (" << gluErrorString(glErr) << ")" |
208 | 91 | 93 | ||
209 | === modified file 'NuxGraphics/GLRenderStates.cpp' | |||
210 | --- NuxGraphics/GLRenderStates.cpp 2012-02-21 06:57:05 +0000 | |||
211 | +++ NuxGraphics/GLRenderStates.cpp 2012-09-30 17:24:22 +0000 | |||
212 | @@ -113,8 +113,8 @@ | |||
213 | 113 | 113 | ||
214 | 114 | GpuRenderStates::GpuRenderStates(GpuBrand board, GpuInfo* info) | 114 | GpuRenderStates::GpuRenderStates(GpuBrand board, GpuInfo* info) |
215 | 115 | { | 115 | { |
218 | 116 | _gpu_brand = board; | 116 | gpu_brand_ = board; |
219 | 117 | _gpu_info = info; | 117 | gpu_info_ = info; |
220 | 118 | Memcpy(&render_state_changes_, &s_StateLUT.default_render_state, sizeof(render_state_changes_)); | 118 | Memcpy(&render_state_changes_, &s_StateLUT.default_render_state, sizeof(render_state_changes_)); |
221 | 119 | } | 119 | } |
222 | 120 | 120 | ||
223 | 121 | 121 | ||
224 | === modified file 'NuxGraphics/GLRenderStates.h' | |||
225 | --- NuxGraphics/GLRenderStates.h 2012-02-21 06:18:24 +0000 | |||
226 | +++ NuxGraphics/GLRenderStates.h 2012-09-30 17:24:22 +0000 | |||
227 | @@ -264,8 +264,8 @@ | |||
228 | 264 | 264 | ||
229 | 265 | private: | 265 | private: |
230 | 266 | 266 | ||
233 | 267 | GpuBrand _gpu_brand; | 267 | GpuBrand gpu_brand_; |
234 | 268 | GpuInfo *_gpu_info; | 268 | GpuInfo* gpu_info_; |
235 | 269 | 269 | ||
236 | 270 | inline void HW__EnableAlphaTest(unsigned int b); | 270 | inline void HW__EnableAlphaTest(unsigned int b); |
237 | 271 | 271 | ||
238 | @@ -963,11 +963,11 @@ | |||
239 | 963 | (BlendOpAlpha_ == GL_MAX), | 963 | (BlendOpAlpha_ == GL_MAX), |
240 | 964 | "Error(HW__SetAlphaBlendOp): Invalid Blend Equation RenderState"); | 964 | "Error(HW__SetAlphaBlendOp): Invalid Blend Equation RenderState"); |
241 | 965 | 965 | ||
243 | 966 | if (_gpu_info->SupportOpenGL20()) | 966 | if (gpu_info_->SupportOpenGL20()) |
244 | 967 | { | 967 | { |
245 | 968 | CHECKGL(glBlendEquationSeparate(BlendOpRGB_, BlendOpAlpha_)); | 968 | CHECKGL(glBlendEquationSeparate(BlendOpRGB_, BlendOpAlpha_)); |
246 | 969 | } | 969 | } |
248 | 970 | else if (_gpu_info->Support_EXT_Blend_Equation_Separate()) | 970 | else if (gpu_info_->Support_EXT_Blend_Equation_Separate()) |
249 | 971 | { | 971 | { |
250 | 972 | CHECKGL(glBlendEquationSeparateEXT(BlendOpRGB_, BlendOpAlpha_)); | 972 | CHECKGL(glBlendEquationSeparateEXT(BlendOpRGB_, BlendOpAlpha_)); |
251 | 973 | } | 973 | } |
252 | @@ -1138,7 +1138,7 @@ | |||
253 | 1138 | { | 1138 | { |
254 | 1139 | if (b) | 1139 | if (b) |
255 | 1140 | { | 1140 | { |
257 | 1141 | if (_gpu_brand == GPU_BRAND_AMD) | 1141 | if (gpu_brand_ == GPU_BRAND_AMD) |
258 | 1142 | { | 1142 | { |
259 | 1143 | CHECKGL(glEnable(GL_STENCIL_TEST)); | 1143 | CHECKGL(glEnable(GL_STENCIL_TEST)); |
260 | 1144 | } | 1144 | } |
261 | @@ -1149,7 +1149,7 @@ | |||
262 | 1149 | } | 1149 | } |
263 | 1150 | else | 1150 | else |
264 | 1151 | { | 1151 | { |
266 | 1152 | if (_gpu_brand == GPU_BRAND_AMD) | 1152 | if (gpu_brand_ == GPU_BRAND_AMD) |
267 | 1153 | { | 1153 | { |
268 | 1154 | CHECKGL(glDisable(GL_STENCIL_TEST)); | 1154 | CHECKGL(glDisable(GL_STENCIL_TEST)); |
269 | 1155 | } | 1155 | } |
270 | @@ -1215,7 +1215,7 @@ | |||
271 | 1215 | (Func_ == GL_ALWAYS), | 1215 | (Func_ == GL_ALWAYS), |
272 | 1216 | "Error(HW__SetBackFaceStencilFunc): Invalid Stencil Function RenderState"); | 1216 | "Error(HW__SetBackFaceStencilFunc): Invalid Stencil Function RenderState"); |
273 | 1217 | 1217 | ||
275 | 1218 | if (_gpu_brand == GPU_BRAND_AMD) | 1218 | if (gpu_brand_ == GPU_BRAND_AMD) |
276 | 1219 | { | 1219 | { |
277 | 1220 | CHECKGL(glStencilFuncSeparateATI(Func_/*Front function*/, Func_/*Back function*/, Ref_, Mask_)); // incorrect | 1220 | CHECKGL(glStencilFuncSeparateATI(Func_/*Front function*/, Func_/*Back function*/, Ref_, Mask_)); // incorrect |
278 | 1221 | } | 1221 | } |
279 | @@ -1268,7 +1268,7 @@ | |||
280 | 1268 | (ZPassOp_ == GL_INVERT), | 1268 | (ZPassOp_ == GL_INVERT), |
281 | 1269 | "Error(HW__SetFrontFaceStencilOp): Invalid ZPassOp RenderState"); | 1269 | "Error(HW__SetFrontFaceStencilOp): Invalid ZPassOp RenderState"); |
282 | 1270 | 1270 | ||
284 | 1271 | if (_gpu_brand == GPU_BRAND_AMD) | 1271 | if (gpu_brand_ == GPU_BRAND_AMD) |
285 | 1272 | { | 1272 | { |
286 | 1273 | CHECKGL(glStencilOpSeparateATI(GL_FRONT, FailOp_, ZFailOp_, ZPassOp_)); | 1273 | CHECKGL(glStencilOpSeparateATI(GL_FRONT, FailOp_, ZFailOp_, ZPassOp_)); |
287 | 1274 | } | 1274 | } |
288 | @@ -1321,7 +1321,7 @@ | |||
289 | 1321 | (ZPassOp_ == GL_INVERT), | 1321 | (ZPassOp_ == GL_INVERT), |
290 | 1322 | "Error(HW__SetBackFaceStencilOp): Invalid ZPassOp RenderState"); | 1322 | "Error(HW__SetBackFaceStencilOp): Invalid ZPassOp RenderState"); |
291 | 1323 | 1323 | ||
293 | 1324 | if (_gpu_brand == GPU_BRAND_AMD) | 1324 | if (gpu_brand_ == GPU_BRAND_AMD) |
294 | 1325 | { | 1325 | { |
295 | 1326 | CHECKGL(glStencilOpSeparateATI(GL_BACK, FailOp_, ZFailOp_, ZPassOp_)); | 1326 | CHECKGL(glStencilOpSeparateATI(GL_BACK, FailOp_, ZFailOp_, ZPassOp_)); |
296 | 1327 | } | 1327 | } |
297 | 1328 | 1328 | ||
298 | === modified file 'NuxGraphics/GLShaderParameter.h' | |||
299 | --- NuxGraphics/GLShaderParameter.h 2011-10-19 20:32:38 +0000 | |||
300 | +++ NuxGraphics/GLShaderParameter.h 2012-09-30 17:24:22 +0000 | |||
301 | @@ -50,8 +50,8 @@ | |||
302 | 50 | { | 50 | { |
303 | 51 | public: | 51 | public: |
304 | 52 | int m_Index; // Register m_Index / Attribute m_Index | 52 | int m_Index; // Register m_Index / Attribute m_Index |
307 | 53 | eShaderParameterType m_ShaderParameterType; | 53 | eShaderParameterType m_ShaderParameterType; |
308 | 54 | NString m_Name; | 54 | std::string m_Name; |
309 | 55 | bool m_bIsOptional; | 55 | bool m_bIsOptional; |
310 | 56 | bool m_bIsStatic; | 56 | bool m_bIsStatic; |
311 | 57 | bool bStaticSet; | 57 | bool bStaticSet; |
312 | 58 | 58 | ||
313 | === modified file 'NuxGraphics/GpuDevice.cpp' | |||
314 | --- NuxGraphics/GpuDevice.cpp 2012-09-19 04:53:45 +0000 | |||
315 | +++ NuxGraphics/GpuDevice.cpp 2012-09-30 17:24:22 +0000 | |||
316 | @@ -32,6 +32,8 @@ | |||
317 | 32 | #include "GLTemplatePrimitiveBuffer.h" | 32 | #include "GLTemplatePrimitiveBuffer.h" |
318 | 33 | #include "GraphicsEngine.h" | 33 | #include "GraphicsEngine.h" |
319 | 34 | 34 | ||
320 | 35 | #include <algorithm> | ||
321 | 36 | |||
322 | 35 | namespace nux | 37 | namespace nux |
323 | 36 | { | 38 | { |
324 | 37 | #if (NUX_ENABLE_CG_SHADERS) | 39 | #if (NUX_ENABLE_CG_SHADERS) |
325 | @@ -299,11 +301,14 @@ | |||
326 | 299 | bool opengl_es_20) | 301 | bool opengl_es_20) |
327 | 300 | #endif | 302 | #endif |
328 | 301 | #endif | 303 | #endif |
329 | 304 | : opengl_major_(0) | ||
330 | 305 | , opengl_minor_(0) | ||
331 | 306 | , use_pixel_buffer_object_(false) | ||
332 | 307 | , pixel_store_alignment_(4) | ||
333 | 308 | , gpu_render_states_(NULL) | ||
334 | 309 | , gpu_info_(NULL) | ||
335 | 302 | { | 310 | { |
340 | 303 | _PixelStoreAlignment = 4; | 311 | gpu_brand_ = GPU_VENDOR_UNKNOWN; |
337 | 304 | _UsePixelBufferObject = false; | ||
338 | 305 | _gpu_info = NULL; | ||
339 | 306 | _gpu_brand = GPU_VENDOR_UNKNOWN; | ||
341 | 307 | 312 | ||
342 | 308 | #ifndef NUX_OPENGLES_20 | 313 | #ifndef NUX_OPENGLES_20 |
343 | 309 | // OpenGL extension initialization | 314 | // OpenGL extension initialization |
344 | @@ -328,35 +333,70 @@ | |||
345 | 328 | #endif | 333 | #endif |
346 | 329 | 334 | ||
347 | 330 | #ifndef NUX_OPENGLES_20 | 335 | #ifndef NUX_OPENGLES_20 |
349 | 331 | _glsl_version_string = ANSI_TO_TCHAR(NUX_REINTERPRET_CAST(const char *, glGetString(GL_VERSION))); | 336 | _openGL_version_string = ANSI_TO_TCHAR(NUX_REINTERPRET_CAST(const char *, glGetString(GL_VERSION))); |
350 | 332 | CHECKGL_MSG(glGetString(GL_VERSION)); | 337 | CHECKGL_MSG(glGetString(GL_VERSION)); |
351 | 333 | 338 | ||
364 | 334 | NString opengl_major; | 339 | // We need OpenGL minor and major version. Before OpenGL 3.0, the version number was reported as a string of format |
365 | 335 | NString opengl_minor; | 340 | // "major.minor". That string has to be parsed to extract the major and minor version numbers. This is not really safe as |
366 | 336 | char split = '.'; | 341 | // we have no guaranty that the version string is has we think it is. Some drivers report a version string like "xx.xx.xx". |
367 | 337 | _glsl_version_string.SplitAtFirstOccurenceOf(split, opengl_major, opengl_minor); | 342 | |
368 | 338 | 343 | // Begin string parsing to extract the major and minor version numbers. | |
369 | 339 | _opengl_major = (char)opengl_major.GetTCharPtr()[0] - '0'; | 344 | std::string opengl_major; |
370 | 340 | _opengl_minor = (char)opengl_minor.GetTCharPtr()[0] - '0'; | 345 | std::string opengl_minor; |
371 | 341 | 346 | std::string split = "."; | |
372 | 342 | if (_opengl_major >= 3) | 347 | |
373 | 343 | { | 348 | size_t pos = 0; |
374 | 344 | CHECKGL(glGetIntegerv(GL_MAJOR_VERSION, &_opengl_major)); | 349 | pos = _openGL_version_string.find(split, pos); |
375 | 345 | CHECKGL(glGetIntegerv(GL_MINOR_VERSION, &_opengl_minor)); | 350 | |
376 | 351 | if (pos != tstring::npos) | ||
377 | 352 | { | ||
378 | 353 | size_t split_string_size = split.length(); | ||
379 | 354 | opengl_major = _openGL_version_string.substr(0, pos); | ||
380 | 355 | opengl_minor = _openGL_version_string.substr(pos + split_string_size, _openGL_version_string.length() - (pos + split_string_size) ); | ||
381 | 356 | } | ||
382 | 357 | |||
383 | 358 | int major_length = opengl_major.length(); | ||
384 | 359 | opengl_major_ = 0; | ||
385 | 360 | int digit_position = 1; | ||
386 | 361 | while (major_length && (opengl_major.c_str()[major_length-1] >= '0') && (opengl_major.c_str()[major_length-1] <= '9')) | ||
387 | 362 | { | ||
388 | 363 | opengl_major_ += (opengl_major.c_str()[major_length-1] - '0') * digit_position; | ||
389 | 364 | |||
390 | 365 | digit_position *= 10; | ||
391 | 366 | --major_length; | ||
392 | 367 | } | ||
393 | 368 | |||
394 | 369 | int minor_length = opengl_minor.length(); | ||
395 | 370 | opengl_minor_ = 0; | ||
396 | 371 | digit_position = 0; | ||
397 | 372 | while (minor_length && (opengl_minor.c_str()[digit_position] >= '0') && (opengl_minor.c_str()[digit_position] <= '9')) | ||
398 | 373 | { | ||
399 | 374 | opengl_minor_ += opengl_minor_ * 10 + (opengl_minor.c_str()[digit_position] - '0'); | ||
400 | 375 | |||
401 | 376 | ++digit_position; | ||
402 | 377 | --minor_length; | ||
403 | 378 | } | ||
404 | 379 | |||
405 | 380 | // End string parsing | ||
406 | 381 | |||
407 | 382 | if (opengl_major_ >= 3) | ||
408 | 383 | { | ||
409 | 384 | CHECKGL(glGetIntegerv(GL_MAJOR_VERSION, &opengl_major_)); | ||
410 | 385 | CHECKGL(glGetIntegerv(GL_MINOR_VERSION, &opengl_minor_)); | ||
411 | 346 | } | 386 | } |
412 | 347 | #else | 387 | #else |
415 | 348 | _opengl_major = 2; | 388 | opengl_major_ = 2; |
416 | 349 | _opengl_minor = 0; | 389 | opengl_minor_ = 0; |
417 | 350 | #endif | 390 | #endif |
418 | 351 | 391 | ||
419 | 352 | #if defined(NUX_OS_WINDOWS) | 392 | #if defined(NUX_OS_WINDOWS) |
420 | 353 | bool opengl_es_context_created = false; | 393 | bool opengl_es_context_created = false; |
422 | 354 | if (((_opengl_major >= 3) && (req_opengl_major >= 3)) || (_opengl_major >= 3) || opengl_es_20) | 394 | if (((opengl_major_ >= 3) && (req_opengl_major >= 3)) || (opengl_major_ >= 3) || opengl_es_20) |
423 | 355 | #elif defined(NUX_OS_LINUX) | 395 | #elif defined(NUX_OS_LINUX) |
424 | 356 | //bool opengl_es_context_created = false; | 396 | //bool opengl_es_context_created = false; |
425 | 357 | if (has_glx_13_support && | 397 | if (has_glx_13_support && |
428 | 358 | (((_opengl_major >= 3) && (req_opengl_major >= 3)) || | 398 | (((opengl_major_ >= 3) && (req_opengl_major >= 3)) || |
429 | 359 | ((_opengl_major >= 3) && opengl_es_20))) | 399 | ((opengl_major_ >= 3) && opengl_es_20))) |
430 | 360 | #endif | 400 | #endif |
431 | 361 | { | 401 | { |
432 | 362 | // Create a new Opengl Rendering Context | 402 | // Create a new Opengl Rendering Context |
433 | @@ -367,22 +407,22 @@ | |||
434 | 367 | if ((OpenGLVersionTable[index].major == req_opengl_major) && | 407 | if ((OpenGLVersionTable[index].major == req_opengl_major) && |
435 | 368 | (OpenGLVersionTable[index].minor == req_opengl_minor)) | 408 | (OpenGLVersionTable[index].minor == req_opengl_minor)) |
436 | 369 | { | 409 | { |
438 | 370 | if (_opengl_major == 1) | 410 | if (opengl_major_ == 1) |
439 | 371 | { | 411 | { |
440 | 372 | if ((req_opengl_major == 1) && (req_opengl_minor >= 0) && (req_opengl_minor <= 5)) | 412 | if ((req_opengl_major == 1) && (req_opengl_minor >= 0) && (req_opengl_minor <= 5)) |
441 | 373 | requested_profile_is_supported = true; | 413 | requested_profile_is_supported = true; |
442 | 374 | } | 414 | } |
444 | 375 | else if (_opengl_major == 2) | 415 | else if (opengl_major_ == 2) |
445 | 376 | { | 416 | { |
446 | 377 | if ((req_opengl_major == 2) && (req_opengl_minor >= 0) && (req_opengl_minor <= 1)) | 417 | if ((req_opengl_major == 2) && (req_opengl_minor >= 0) && (req_opengl_minor <= 1)) |
447 | 378 | requested_profile_is_supported = true; | 418 | requested_profile_is_supported = true; |
448 | 379 | } | 419 | } |
450 | 380 | else if (_opengl_major == 3) | 420 | else if (opengl_major_ == 3) |
451 | 381 | { | 421 | { |
452 | 382 | if ((req_opengl_major == 3) && (req_opengl_minor >= 0) && (req_opengl_minor <= 3)) | 422 | if ((req_opengl_major == 3) && (req_opengl_minor >= 0) && (req_opengl_minor <= 3)) |
453 | 383 | requested_profile_is_supported = true; | 423 | requested_profile_is_supported = true; |
454 | 384 | } | 424 | } |
456 | 385 | else if (_opengl_major == 4) | 425 | else if (opengl_major_ == 4) |
457 | 386 | { | 426 | { |
458 | 387 | if ((req_opengl_major == 4) && (req_opengl_minor >= 0) && (req_opengl_minor <= 1)) | 427 | if ((req_opengl_major == 4) && (req_opengl_minor >= 0) && (req_opengl_minor <= 1)) |
459 | 388 | requested_profile_is_supported = true; | 428 | requested_profile_is_supported = true; |
460 | @@ -528,43 +568,32 @@ | |||
461 | 528 | _openGL_version_string = ANSI_TO_TCHAR(NUX_REINTERPRET_CAST(const char *, glGetString(GL_VERSION))); | 568 | _openGL_version_string = ANSI_TO_TCHAR(NUX_REINTERPRET_CAST(const char *, glGetString(GL_VERSION))); |
462 | 529 | CHECKGL_MSG(glGetString(GL_VERSION)); | 569 | CHECKGL_MSG(glGetString(GL_VERSION)); |
463 | 530 | 570 | ||
501 | 531 | nuxDebugMsg("Gpu Vendor: %s", _board_vendor_string.GetTCharPtr()); | 571 | nuxDebugMsg("Gpu Vendor: %s", _board_vendor_string.c_str()); |
502 | 532 | nuxDebugMsg("Gpu Renderer: %s", _board_renderer_string.GetTCharPtr()); | 572 | nuxDebugMsg("Gpu Renderer: %s", _board_renderer_string.c_str()); |
503 | 533 | nuxDebugMsg("Gpu OpenGL Version: %s", _openGL_version_string.GetTCharPtr()); | 573 | nuxDebugMsg("Gpu OpenGL Version: %s", _openGL_version_string.c_str()); |
504 | 534 | nuxDebugMsg("Gpu OpenGL Major Version: %d", _opengl_major); | 574 | nuxDebugMsg("Gpu OpenGL Major Version: %d", opengl_major_); |
505 | 535 | nuxDebugMsg("Gpu OpenGL Minor Version: %d", _opengl_minor); | 575 | nuxDebugMsg("Gpu OpenGL Minor Version: %d", opengl_minor_); |
506 | 536 | nuxDebugMsg("Gpu GLSL Version: %s", _glsl_version_string.GetTCharPtr()); | 576 | |
507 | 537 | 577 | std::transform(_board_vendor_string.begin(), _board_vendor_string.end(), _board_vendor_string.begin(), ::toupper); | |
508 | 538 | NString TempStr = (const char *) TCharToUpperCase(_board_vendor_string.GetTCharPtr()); | 578 | |
509 | 539 | 579 | if (_board_vendor_string.find("NVIDIA", 0) != tstring::npos) | |
510 | 540 | if (TempStr.FindFirstOccurence("NVIDIA") != tstring::npos) | 580 | { |
511 | 541 | { | 581 | gpu_brand_ = GPU_BRAND_NVIDIA; |
512 | 542 | _gpu_brand = GPU_BRAND_NVIDIA; | 582 | } |
513 | 543 | } | 583 | else if (_board_vendor_string.find("ATI", 0) != tstring::npos) |
514 | 544 | else if (TempStr.FindFirstOccurence("ATI") != tstring::npos) | 584 | { |
515 | 545 | { | 585 | gpu_brand_ = GPU_BRAND_AMD; |
516 | 546 | _gpu_brand = GPU_BRAND_AMD; | 586 | } |
517 | 547 | } | 587 | else if (_board_vendor_string.find("TUNGSTEN", 0) != tstring::npos) |
518 | 548 | else if (TempStr.FindFirstOccurence("TUNGSTEN") != tstring::npos) | 588 | { |
519 | 549 | { | 589 | gpu_brand_ = GPU_BRAND_INTEL; |
520 | 550 | _gpu_brand = GPU_BRAND_INTEL; | 590 | } |
521 | 551 | } | 591 | |
522 | 552 | 592 | use_pixel_buffer_object_ = false; | |
523 | 553 | if (0) | 593 | |
524 | 554 | { | 594 | gpu_info_ = new GpuInfo(); |
525 | 555 | if (GetGPUBrand() == GPU_BRAND_AMD) | 595 | gpu_info_->Setup(); |
526 | 556 | _UsePixelBufferObject = false; | 596 | gpu_render_states_ = new GpuRenderStates(gpu_brand_, gpu_info_); |
490 | 557 | else | ||
491 | 558 | _UsePixelBufferObject = true; | ||
492 | 559 | } | ||
493 | 560 | else | ||
494 | 561 | { | ||
495 | 562 | _UsePixelBufferObject = false; | ||
496 | 563 | } | ||
497 | 564 | |||
498 | 565 | _gpu_info = new GpuInfo(); | ||
499 | 566 | _gpu_info->Setup(); | ||
500 | 567 | _gpu_render_states = new GpuRenderStates(_gpu_brand, _gpu_info); | ||
527 | 568 | 597 | ||
528 | 569 | #if defined(NUX_OS_WINDOWS) | 598 | #if defined(NUX_OS_WINDOWS) |
529 | 570 | OGL_EXT_SWAP_CONTROL = WGLEW_EXT_swap_control ? true : false; | 599 | OGL_EXT_SWAP_CONTROL = WGLEW_EXT_swap_control ? true : false; |
530 | @@ -579,8 +608,8 @@ | |||
531 | 579 | // http://www.opengl.org/resources/features/KilgardTechniques/oglpitfall/ | 608 | // http://www.opengl.org/resources/features/KilgardTechniques/oglpitfall/ |
532 | 580 | // We use a pack /unpack alignment to 1 so we don't have any padding at the end of row. | 609 | // We use a pack /unpack alignment to 1 so we don't have any padding at the end of row. |
533 | 581 | 610 | ||
536 | 582 | CHECKGL(glPixelStorei(GL_UNPACK_ALIGNMENT, _PixelStoreAlignment)); | 611 | CHECKGL(glPixelStorei(GL_UNPACK_ALIGNMENT, pixel_store_alignment_)); |
537 | 583 | CHECKGL(glPixelStorei(GL_PACK_ALIGNMENT, _PixelStoreAlignment)); | 612 | CHECKGL(glPixelStorei(GL_PACK_ALIGNMENT, pixel_store_alignment_)); |
538 | 584 | 613 | ||
539 | 585 | // _DeviceWidth = DeviceWidth; | 614 | // _DeviceWidth = DeviceWidth; |
540 | 586 | // _DeviceHeight = DeviceHeight; | 615 | // _DeviceHeight = DeviceHeight; |
541 | @@ -619,8 +648,8 @@ | |||
542 | 619 | 648 | ||
543 | 620 | GpuDevice::~GpuDevice() | 649 | GpuDevice::~GpuDevice() |
544 | 621 | { | 650 | { |
547 | 622 | NUX_SAFE_DELETE(_gpu_info); | 651 | NUX_SAFE_DELETE(gpu_info_); |
548 | 623 | NUX_SAFE_DELETE(_gpu_render_states); | 652 | NUX_SAFE_DELETE(gpu_render_states_); |
549 | 624 | 653 | ||
550 | 625 | _FrameBufferObject.Release(); | 654 | _FrameBufferObject.Release(); |
551 | 626 | active_framebuffer_object_.Release(); | 655 | active_framebuffer_object_.Release(); |
552 | @@ -656,37 +685,47 @@ | |||
553 | 656 | 685 | ||
554 | 657 | int GpuDevice::GetOpenGLMajorVersion() const | 686 | int GpuDevice::GetOpenGLMajorVersion() const |
555 | 658 | { | 687 | { |
557 | 659 | return _opengl_major; | 688 | return opengl_major_; |
558 | 660 | } | 689 | } |
559 | 661 | 690 | ||
560 | 662 | int GpuDevice::GetOpenGLMinorVersion() const | 691 | int GpuDevice::GetOpenGLMinorVersion() const |
561 | 663 | { | 692 | { |
563 | 664 | return _opengl_minor; | 693 | return opengl_minor_; |
564 | 694 | } | ||
565 | 695 | |||
566 | 696 | unsigned int GpuDevice::GetPixelStoreAlignment() const | ||
567 | 697 | { | ||
568 | 698 | return pixel_store_alignment_; | ||
569 | 699 | } | ||
570 | 700 | |||
571 | 701 | bool GpuDevice::UsePixelBufferObjects() const | ||
572 | 702 | { | ||
573 | 703 | return use_pixel_buffer_object_; | ||
574 | 665 | } | 704 | } |
575 | 666 | 705 | ||
576 | 667 | GpuBrand GpuDevice::GetGPUBrand() const | 706 | GpuBrand GpuDevice::GetGPUBrand() const |
577 | 668 | { | 707 | { |
579 | 669 | return _gpu_brand; | 708 | return gpu_brand_; |
580 | 670 | } | 709 | } |
581 | 671 | 710 | ||
582 | 672 | GpuRenderStates &GpuDevice::GetRenderStates() | 711 | GpuRenderStates &GpuDevice::GetRenderStates() |
583 | 673 | { | 712 | { |
585 | 674 | return *_gpu_render_states; | 713 | return *gpu_render_states_; |
586 | 675 | } | 714 | } |
587 | 676 | 715 | ||
589 | 677 | GpuInfo &GpuDevice::GetGpuInfo() | 716 | const GpuInfo& GpuDevice::GetGpuInfo() const |
590 | 678 | { | 717 | { |
592 | 679 | return *_gpu_info; | 718 | return *gpu_info_; |
593 | 680 | } | 719 | } |
594 | 681 | 720 | ||
595 | 682 | void GpuDevice::ResetRenderStates() | 721 | void GpuDevice::ResetRenderStates() |
596 | 683 | { | 722 | { |
598 | 684 | _gpu_render_states->ResetStateChangeToDefault(); | 723 | gpu_render_states_->ResetStateChangeToDefault(); |
599 | 685 | } | 724 | } |
600 | 686 | 725 | ||
601 | 687 | void GpuDevice::VerifyRenderStates() | 726 | void GpuDevice::VerifyRenderStates() |
602 | 688 | { | 727 | { |
604 | 689 | _gpu_render_states->CheckStateChange(); | 728 | gpu_render_states_->CheckStateChange(); |
605 | 690 | } | 729 | } |
606 | 691 | 730 | ||
607 | 692 | void GpuDevice::InvalidateTextureUnit(int TextureUnitIndex) | 731 | void GpuDevice::InvalidateTextureUnit(int TextureUnitIndex) |
608 | 693 | 732 | ||
609 | === modified file 'NuxGraphics/GpuDevice.h' | |||
610 | --- NuxGraphics/GpuDevice.h 2012-09-17 09:55:43 +0000 | |||
611 | +++ NuxGraphics/GpuDevice.h 2012-09-30 17:24:22 +0000 | |||
612 | @@ -362,11 +362,6 @@ | |||
613 | 362 | //! Setup a NULL texture | 362 | //! Setup a NULL texture |
614 | 363 | void InvalidateTextureUnit(int TextureUnitIndex); | 363 | void InvalidateTextureUnit(int TextureUnitIndex); |
615 | 364 | 364 | ||
616 | 365 | unsigned int GetPixelStoreAlignment() | ||
617 | 366 | { | ||
618 | 367 | return _PixelStoreAlignment; | ||
619 | 368 | } | ||
620 | 369 | |||
621 | 370 | int AllocateUnpackPixelBufferIndex(int *index); | 365 | int AllocateUnpackPixelBufferIndex(int *index); |
622 | 371 | int FreeUnpackPixelBufferIndex(const int index); | 366 | int FreeUnpackPixelBufferIndex(const int index); |
623 | 372 | int BindUnpackPixelBufferIndex(const int index); | 367 | int BindUnpackPixelBufferIndex(const int index); |
624 | @@ -389,6 +384,8 @@ | |||
625 | 389 | //! Restore the backbuffer as the render target. | 384 | //! Restore the backbuffer as the render target. |
626 | 390 | void DeactivateFrameBuffer(); | 385 | void DeactivateFrameBuffer(); |
627 | 391 | 386 | ||
628 | 387 | unsigned int GetPixelStoreAlignment() const; | ||
629 | 388 | |||
630 | 392 | public: | 389 | public: |
631 | 393 | void SetCurrentFrameBufferObject(ObjectPtr<IOpenGLFrameBufferObject> fbo); | 390 | void SetCurrentFrameBufferObject(ObjectPtr<IOpenGLFrameBufferObject> fbo); |
632 | 394 | ObjectPtr<IOpenGLFrameBufferObject> GetCurrentFrameBufferObject(); | 391 | ObjectPtr<IOpenGLFrameBufferObject> GetCurrentFrameBufferObject(); |
633 | @@ -409,10 +406,6 @@ | |||
634 | 409 | bool IsReserved; | 406 | bool IsReserved; |
635 | 410 | }; | 407 | }; |
636 | 411 | 408 | ||
637 | 412 | unsigned int _PixelStoreAlignment; | ||
638 | 413 | |||
639 | 414 | std::vector<PixelBufferObject> _PixelBufferArray; | ||
640 | 415 | |||
641 | 416 | public: | 409 | public: |
642 | 417 | 410 | ||
643 | 418 | #if (NUX_ENABLE_CG_SHADERS) | 411 | #if (NUX_ENABLE_CG_SHADERS) |
644 | @@ -423,16 +416,13 @@ | |||
645 | 423 | CGcontext m_Cgcontext; | 416 | CGcontext m_Cgcontext; |
646 | 424 | #endif | 417 | #endif |
647 | 425 | 418 | ||
652 | 426 | inline bool UsePixelBufferObjects() const | 419 | bool UsePixelBufferObjects() const; |
649 | 427 | { | ||
650 | 428 | return _UsePixelBufferObject; | ||
651 | 429 | } | ||
653 | 430 | 420 | ||
654 | 431 | GpuBrand GetGPUBrand() const; | 421 | GpuBrand GetGPUBrand() const; |
655 | 432 | 422 | ||
657 | 433 | GpuRenderStates &GetRenderStates(); | 423 | GpuRenderStates& GetRenderStates(); |
658 | 434 | 424 | ||
660 | 435 | GpuInfo &GetGpuInfo(); | 425 | const GpuInfo& GetGpuInfo() const; |
661 | 436 | 426 | ||
662 | 437 | void ResetRenderStates(); | 427 | void ResetRenderStates(); |
663 | 438 | 428 | ||
664 | @@ -460,34 +450,34 @@ | |||
665 | 460 | 450 | ||
666 | 461 | bool SUPPORT_GL_ARB_TEXTURE_NON_POWER_OF_TWO() const | 451 | bool SUPPORT_GL_ARB_TEXTURE_NON_POWER_OF_TWO() const |
667 | 462 | { | 452 | { |
669 | 463 | return _gpu_info->Support_ARB_Texture_Non_Power_Of_Two(); | 453 | return gpu_info_->Support_ARB_Texture_Non_Power_Of_Two(); |
670 | 464 | } | 454 | } |
671 | 465 | 455 | ||
672 | 466 | bool SUPPORT_GL_EXT_TEXTURE_RECTANGLE() const | 456 | bool SUPPORT_GL_EXT_TEXTURE_RECTANGLE() const |
673 | 467 | { | 457 | { |
675 | 468 | return _gpu_info->Support_EXT_Texture_Rectangle(); | 458 | return gpu_info_->Support_EXT_Texture_Rectangle(); |
676 | 469 | } | 459 | } |
677 | 470 | 460 | ||
678 | 471 | bool SUPPORT_GL_ARB_TEXTURE_RECTANGLE() const | 461 | bool SUPPORT_GL_ARB_TEXTURE_RECTANGLE() const |
679 | 472 | { | 462 | { |
681 | 473 | return _gpu_info->Support_ARB_Texture_Rectangle(); | 463 | return gpu_info_->Support_ARB_Texture_Rectangle(); |
682 | 474 | } | 464 | } |
683 | 475 | 465 | ||
684 | 476 | private: | 466 | private: |
685 | 477 | 467 | ||
686 | 478 | // | 468 | // |
699 | 479 | int _opengl_major; //!< OpenGL major version. | 469 | int opengl_major_; //!< OpenGL major version. |
700 | 480 | int _opengl_minor; //!< OpenGL minor version. | 470 | int opengl_minor_; //!< OpenGL minor version. |
701 | 481 | int _glsl_version_major; //!< GLSL major version. | 471 | |
702 | 482 | int _glsl_version_minor; //!< GLSL major version. | 472 | std::string _board_vendor_string; //!< GPU vendor sting. |
703 | 483 | 473 | std::string _board_renderer_string; //!< GPU renderer sting. | |
704 | 484 | NString _board_vendor_string; //!< GPU vendor sting. | 474 | std::string _openGL_version_string; //!< OpenGL version string. |
705 | 485 | NString _board_renderer_string; //!< GPU renderer sting. | 475 | GpuBrand gpu_brand_; //!< GPU brand. |
706 | 486 | NString _openGL_version_string; //!< OpenGL version string. | 476 | |
707 | 487 | NString _glsl_version_string; //!< GLSL version string. | 477 | bool use_pixel_buffer_object_; |
708 | 488 | GpuBrand _gpu_brand; //!< GPU brand. | 478 | unsigned int pixel_store_alignment_; |
709 | 489 | 479 | std::vector<PixelBufferObject> _PixelBufferArray; | |
710 | 490 | bool _UsePixelBufferObject; | 480 | |
711 | 491 | 481 | ||
712 | 492 | bool OGL_EXT_SWAP_CONTROL; | 482 | bool OGL_EXT_SWAP_CONTROL; |
713 | 493 | bool GL_ARB_VERTEX_PROGRAM; | 483 | bool GL_ARB_VERTEX_PROGRAM; |
714 | @@ -504,8 +494,8 @@ | |||
715 | 504 | bool GL_ARB_TEXTURE_RECTANGLE; //!< Promoted from GL_EXT_TEXTURE_RECTANGLE to ARB. | 494 | bool GL_ARB_TEXTURE_RECTANGLE; //!< Promoted from GL_EXT_TEXTURE_RECTANGLE to ARB. |
716 | 505 | bool GL_NV_TEXTURE_RECTANGLE; | 495 | bool GL_NV_TEXTURE_RECTANGLE; |
717 | 506 | 496 | ||
720 | 507 | GpuRenderStates *_gpu_render_states; | 497 | GpuRenderStates* gpu_render_states_; |
721 | 508 | GpuInfo *_gpu_info; | 498 | GpuInfo* gpu_info_; |
722 | 509 | 499 | ||
723 | 510 | public: | 500 | public: |
724 | 511 | 501 | ||
725 | 512 | 502 | ||
726 | === modified file 'NuxGraphics/GpuDeviceVertex.cpp' | |||
727 | --- NuxGraphics/GpuDeviceVertex.cpp 2012-09-19 04:53:45 +0000 | |||
728 | +++ NuxGraphics/GpuDeviceVertex.cpp 2012-09-30 17:24:22 +0000 | |||
729 | @@ -160,7 +160,7 @@ | |||
730 | 160 | vtxelement.Type, | 160 | vtxelement.Type, |
731 | 161 | GL_FALSE, | 161 | GL_FALSE, |
732 | 162 | vtxelement.stride_, | 162 | vtxelement.stride_, |
734 | 163 | (void*)vtxelement.Offset)); // TODO: Bug. It doesn't make sense to convert a 4-byte int into an 8-byte pointer. | 163 | (void*)&vtxelement.Offset)); |
735 | 164 | 164 | ||
736 | 165 | VertexDeclaration->_valid_vertex_input[shader_attribute_location] = 1; | 165 | VertexDeclaration->_valid_vertex_input[shader_attribute_location] = 1; |
737 | 166 | ++decl; | 166 | ++decl; |
738 | 167 | 167 | ||
739 | === modified file 'NuxGraphics/GraphicsEngine.cpp' | |||
740 | --- NuxGraphics/GraphicsEngine.cpp 2012-09-17 09:55:43 +0000 | |||
741 | +++ NuxGraphics/GraphicsEngine.cpp 2012-09-30 17:24:22 +0000 | |||
742 | @@ -230,7 +230,7 @@ | |||
743 | 230 | } | 230 | } |
744 | 231 | #endif | 231 | #endif |
745 | 232 | 232 | ||
747 | 233 | GpuInfo& gpu_info = _graphics_display.GetGpuDevice()->GetGpuInfo(); | 233 | const GpuInfo& gpu_info = _graphics_display.GetGpuDevice()->GetGpuInfo(); |
748 | 234 | 234 | ||
749 | 235 | if ((gpu_info.Support_ARB_Vertex_Program() && gpu_info.Support_ARB_Fragment_Program()) | 235 | if ((gpu_info.Support_ARB_Vertex_Program() && gpu_info.Support_ARB_Fragment_Program()) |
750 | 236 | || (gpu_info.Support_ARB_Vertex_Shader() && gpu_info.Support_ARB_Fragment_Shader())) | 236 | || (gpu_info.Support_ARB_Vertex_Shader() && gpu_info.Support_ARB_Fragment_Shader())) |
751 | 237 | 237 | ||
752 | === modified file 'NuxGraphics/GraphicsEngine.h' | |||
753 | --- NuxGraphics/GraphicsEngine.h 2012-09-19 04:53:45 +0000 | |||
754 | +++ NuxGraphics/GraphicsEngine.h 2012-09-30 17:24:22 +0000 | |||
755 | @@ -662,15 +662,15 @@ | |||
756 | 662 | 662 | ||
757 | 663 | GpuRenderStates& GetRenderStates() | 663 | GpuRenderStates& GetRenderStates() |
758 | 664 | { | 664 | { |
760 | 665 | return *_graphics_display.m_DeviceFactory->_gpu_render_states; | 665 | return *_graphics_display.m_DeviceFactory->gpu_render_states_; |
761 | 666 | } | 666 | } |
762 | 667 | void ResetRenderStates() | 667 | void ResetRenderStates() |
763 | 668 | { | 668 | { |
765 | 669 | _graphics_display.m_DeviceFactory->_gpu_render_states->ResetStateChangeToDefault(); | 669 | _graphics_display.m_DeviceFactory->gpu_render_states_->ResetStateChangeToDefault(); |
766 | 670 | } | 670 | } |
767 | 671 | void VerifyRenderStates() | 671 | void VerifyRenderStates() |
768 | 672 | { | 672 | { |
770 | 673 | _graphics_display.m_DeviceFactory->_gpu_render_states->CheckStateChange(); | 673 | _graphics_display.m_DeviceFactory->gpu_render_states_->CheckStateChange(); |
771 | 674 | } | 674 | } |
772 | 675 | 675 | ||
773 | 676 | ObjectPtr<FontTexture> GetFont(); | 676 | ObjectPtr<FontTexture> GetFont(); |
774 | 677 | 677 | ||
775 | === modified file 'NuxGraphics/IOpenGLAsmShader.cpp' | |||
776 | --- NuxGraphics/IOpenGLAsmShader.cpp 2012-08-02 16:29:19 +0000 | |||
777 | +++ NuxGraphics/IOpenGLAsmShader.cpp 2012-09-30 17:24:22 +0000 | |||
778 | @@ -39,7 +39,7 @@ | |||
779 | 39 | NUX_IMPLEMENT_OBJECT_TYPE(IOpenGLAsmPixelShader); | 39 | NUX_IMPLEMENT_OBJECT_TYPE(IOpenGLAsmPixelShader); |
780 | 40 | NUX_IMPLEMENT_OBJECT_TYPE(IOpenGLAsmShaderProgram); | 40 | NUX_IMPLEMENT_OBJECT_TYPE(IOpenGLAsmShaderProgram); |
781 | 41 | 41 | ||
783 | 42 | bool ExtractShaderString3(const NString &ShaderToken, const NString &ShaderSource, NString &RetSource, NString ShaderPreprocessorDefines); | 42 | bool ExtractShaderString3(const std::string& ShaderToken, const std::string& ShaderSource, std::string& RetSource, std::string ShaderPreprocessorDefines); |
784 | 43 | 43 | ||
785 | 44 | IOpenGLAsmShader::IOpenGLAsmShader(std::string const& shader_name, GLint shader_type, OpenGLResourceType ResourceType) | 44 | IOpenGLAsmShader::IOpenGLAsmShader(std::string const& shader_name, GLint shader_type, OpenGLResourceType ResourceType) |
786 | 45 | : IOpenGLResource(ResourceType) | 45 | : IOpenGLResource(ResourceType) |
787 | @@ -113,7 +113,7 @@ | |||
788 | 113 | { | 113 | { |
789 | 114 | } | 114 | } |
790 | 115 | 115 | ||
792 | 116 | IOpenGLAsmShaderProgram::IOpenGLAsmShaderProgram(NString ShaderProgramName) | 116 | IOpenGLAsmShaderProgram::IOpenGLAsmShaderProgram(std::string ShaderProgramName) |
793 | 117 | : IOpenGLResource(RT_GLSL_SHADERPROGRAM) | 117 | : IOpenGLResource(RT_GLSL_SHADERPROGRAM) |
794 | 118 | , _ShaderProgramName(ShaderProgramName) | 118 | , _ShaderProgramName(ShaderProgramName) |
795 | 119 | { | 119 | { |
796 | @@ -131,19 +131,19 @@ | |||
797 | 131 | { | 131 | { |
798 | 132 | nuxAssertMsg(ShaderFileName, "[IOpenGLAsmShaderProgram::LoadIShaderFile] Invalid shader file name."); | 132 | nuxAssertMsg(ShaderFileName, "[IOpenGLAsmShaderProgram::LoadIShaderFile] Invalid shader file name."); |
799 | 133 | NUX_RETURN_IF_NULL(ShaderFileName); | 133 | NUX_RETURN_IF_NULL(ShaderFileName); |
801 | 134 | NString SourceCode; | 134 | std::string SourceCode; |
802 | 135 | LoadFileToString(SourceCode, ShaderFileName); | 135 | LoadFileToString(SourceCode, ShaderFileName); |
803 | 136 | LoadIShader(&SourceCode[0]); | 136 | LoadIShader(&SourceCode[0]); |
804 | 137 | } | 137 | } |
805 | 138 | 138 | ||
807 | 139 | void IOpenGLAsmShaderProgram::LoadIShader(const char *ShaderCode) | 139 | void IOpenGLAsmShaderProgram::LoadIShader(const char* ShaderCode) |
808 | 140 | { | 140 | { |
809 | 141 | nuxAssertMsg(ShaderCode, "[IOpenGLAsmShaderProgram::LoadIShader] Invalid shader code."); | 141 | nuxAssertMsg(ShaderCode, "[IOpenGLAsmShaderProgram::LoadIShader] Invalid shader code."); |
810 | 142 | NUX_RETURN_IF_NULL(ShaderCode); | 142 | NUX_RETURN_IF_NULL(ShaderCode); |
815 | 143 | NString VertexShaderSource; | 143 | std::string VertexShaderSource; |
816 | 144 | ExtractShaderString3("[Vertex Shader]", ShaderCode, VertexShaderSource, NString("")); | 144 | ExtractShaderString3("[Vertex Shader]", ShaderCode, VertexShaderSource, std::string("")); |
817 | 145 | NString PixelShaderSource; | 145 | std::string PixelShaderSource; |
818 | 146 | ExtractShaderString3("[Fragment Shader]", ShaderCode, PixelShaderSource, NString("")); | 146 | ExtractShaderString3("[Fragment Shader]", ShaderCode, PixelShaderSource, std::string("")); |
819 | 147 | 147 | ||
820 | 148 | m_AsmVertexProgram->SetShaderCode(&VertexShaderSource[0]); | 148 | m_AsmVertexProgram->SetShaderCode(&VertexShaderSource[0]); |
821 | 149 | m_AsmFragmentProgram->SetShaderCode(&PixelShaderSource[0]); | 149 | m_AsmFragmentProgram->SetShaderCode(&PixelShaderSource[0]); |
822 | @@ -152,7 +152,7 @@ | |||
823 | 152 | m_AsmFragmentProgram->Compile(); | 152 | m_AsmFragmentProgram->Compile(); |
824 | 153 | } | 153 | } |
825 | 154 | 154 | ||
827 | 155 | void IOpenGLAsmShaderProgram::LoadVertexShader(const char *glslshader) | 155 | void IOpenGLAsmShaderProgram::LoadVertexShader(const char* glslshader) |
828 | 156 | { | 156 | { |
829 | 157 | nuxAssertMsg(glslshader, "[IOpenGLAsmShaderProgram::LoadVertexShader] Invalid shader code."); | 157 | nuxAssertMsg(glslshader, "[IOpenGLAsmShaderProgram::LoadVertexShader] Invalid shader code."); |
830 | 158 | NUX_RETURN_IF_NULL(glslshader); | 158 | NUX_RETURN_IF_NULL(glslshader); |
831 | 159 | 159 | ||
832 | === modified file 'NuxGraphics/IOpenGLAsmShader.h' | |||
833 | --- NuxGraphics/IOpenGLAsmShader.h 2012-08-02 16:29:19 +0000 | |||
834 | +++ NuxGraphics/IOpenGLAsmShader.h 2012-09-30 17:24:22 +0000 | |||
835 | @@ -121,9 +121,9 @@ | |||
836 | 121 | void SetFragmentLocalParameter4fvARB (unsigned int index, const float *params); | 121 | void SetFragmentLocalParameter4fvARB (unsigned int index, const float *params); |
837 | 122 | 122 | ||
838 | 123 | private: | 123 | private: |
840 | 124 | IOpenGLAsmShaderProgram(NString ShaderProgramName = NString("AsmShaderProgram")); | 124 | IOpenGLAsmShaderProgram(std::string ShaderProgramName = std::string("AsmShaderProgram")); |
841 | 125 | std::vector<ObjectPtr<IOpenGLAsmShader> > ShaderObjectList; | 125 | std::vector<ObjectPtr<IOpenGLAsmShader> > ShaderObjectList; |
843 | 126 | NString _ShaderProgramName; | 126 | std::string _ShaderProgramName; |
844 | 127 | 127 | ||
845 | 128 | ObjectPtr<IOpenGLAsmVertexShader> m_AsmVertexProgram; | 128 | ObjectPtr<IOpenGLAsmVertexShader> m_AsmVertexProgram; |
846 | 129 | ObjectPtr<IOpenGLAsmPixelShader> m_AsmFragmentProgram; | 129 | ObjectPtr<IOpenGLAsmPixelShader> m_AsmFragmentProgram; |
847 | 130 | 130 | ||
848 | === modified file 'NuxGraphics/IOpenGLCgShader.h' | |||
849 | --- NuxGraphics/IOpenGLCgShader.h 2011-10-19 20:32:38 +0000 | |||
850 | +++ NuxGraphics/IOpenGLCgShader.h 2012-09-30 17:24:22 +0000 | |||
851 | @@ -33,7 +33,7 @@ | |||
852 | 33 | NUX_DECLARE_OBJECT_TYPE(ICgShader, IOpenGLResource); | 33 | NUX_DECLARE_OBJECT_TYPE(ICgShader, IOpenGLResource); |
853 | 34 | 34 | ||
854 | 35 | public: | 35 | public: |
856 | 36 | ICgShader(NString ShaderName, OpenGLResourceType ResourceType); | 36 | ICgShader(std::string ShaderName, OpenGLResourceType ResourceType); |
857 | 37 | virtual ~ICgShader(); | 37 | virtual ~ICgShader(); |
858 | 38 | 38 | ||
859 | 39 | virtual void CreateProgram(const ANSICHAR *ShaderCode, const ANSICHAR *EntryPoint) = 0; | 39 | virtual void CreateProgram(const ANSICHAR *ShaderCode, const ANSICHAR *EntryPoint) = 0; |
860 | @@ -45,9 +45,9 @@ | |||
861 | 45 | virtual bool IsValid() = 0; | 45 | virtual bool IsValid() = 0; |
862 | 46 | CGparameter GetNamedParameter(const char *parameter); | 46 | CGparameter GetNamedParameter(const char *parameter); |
863 | 47 | 47 | ||
867 | 48 | NString _ShaderName; | 48 | std::string _ShaderName; |
868 | 49 | NString _ShaderCode; | 49 | std::string _ShaderCode; |
869 | 50 | NString _EntryPoint; | 50 | std::string _EntryPoint; |
870 | 51 | CGprogram _CgProgram; | 51 | CGprogram _CgProgram; |
871 | 52 | }; | 52 | }; |
872 | 53 | 53 | ||
873 | @@ -62,7 +62,7 @@ | |||
874 | 62 | virtual bool Compile(); | 62 | virtual bool Compile(); |
875 | 63 | virtual bool IsValid(); | 63 | virtual bool IsValid(); |
876 | 64 | private: | 64 | private: |
878 | 65 | ICgVertexShader(NString ShaderName = NString("VertexProgram")); | 65 | ICgVertexShader(std::string ShaderName = std::string("VertexProgram")); |
879 | 66 | int _ready; | 66 | int _ready; |
880 | 67 | friend class GpuDevice; | 67 | friend class GpuDevice; |
881 | 68 | }; | 68 | }; |
882 | @@ -78,7 +78,7 @@ | |||
883 | 78 | virtual bool Compile(); | 78 | virtual bool Compile(); |
884 | 79 | virtual bool IsValid(); | 79 | virtual bool IsValid(); |
885 | 80 | private: | 80 | private: |
887 | 81 | ICgPixelShader(NString ShaderName = NString("PixelProgram")); | 81 | ICgPixelShader(std::string ShaderName = std::string("PixelProgram")); |
888 | 82 | int _ready; | 82 | int _ready; |
889 | 83 | friend class GpuDevice; | 83 | friend class GpuDevice; |
890 | 84 | }; | 84 | }; |
891 | 85 | 85 | ||
892 | === modified file 'NuxGraphics/IOpenGLGLSLShader.cpp' | |||
893 | --- NuxGraphics/IOpenGLGLSLShader.cpp 2012-02-23 16:30:14 +0000 | |||
894 | +++ NuxGraphics/IOpenGLGLSLShader.cpp 2012-09-30 17:24:22 +0000 | |||
895 | @@ -43,7 +43,7 @@ | |||
896 | 43 | NUX_IMPLEMENT_OBJECT_TYPE(IOpenGLShaderProgram); | 43 | NUX_IMPLEMENT_OBJECT_TYPE(IOpenGLShaderProgram); |
897 | 44 | 44 | ||
898 | 45 | 45 | ||
900 | 46 | bool ExtractShaderString3(const NString &ShaderToken, const NString &ShaderSource, NString &RetSource, NString ShaderPreprocessorDefines) | 46 | bool ExtractShaderString3(const std::string &ShaderToken, const std::string &ShaderSource, std::string &RetSource, std::string ShaderPreprocessorDefines) |
901 | 47 | { | 47 | { |
902 | 48 | size_t lineStart = 0; | 48 | size_t lineStart = 0; |
903 | 49 | size_t lineCount = 1; | 49 | size_t lineCount = 1; |
904 | @@ -57,7 +57,7 @@ | |||
905 | 57 | { | 57 | { |
906 | 58 | size_t i; | 58 | size_t i; |
907 | 59 | 59 | ||
909 | 60 | for (i = 0; i < ShaderSource.Length(); i++) | 60 | for (i = 0; i < ShaderSource.length(); i++) |
910 | 61 | { | 61 | { |
911 | 62 | //Check if the starting character '[' (open bracket) is found at the beginning of the line | 62 | //Check if the starting character '[' (open bracket) is found at the beginning of the line |
912 | 63 | // i counts the characters in the file. lineStart is equal to i at the beginning of the line. | 63 | // i counts the characters in the file. lineStart is equal to i at the beginning of the line. |
913 | @@ -66,10 +66,10 @@ | |||
914 | 66 | if (!startTokenFound) | 66 | if (!startTokenFound) |
915 | 67 | { | 67 | { |
916 | 68 | //Test for the start token | 68 | //Test for the start token |
918 | 69 | if (ShaderSource.FindFirstOccurence(ShaderToken) == i) | 69 | if (ShaderSource.find(ShaderToken, 0) == i) |
919 | 70 | { | 70 | { |
920 | 71 | // Found the shader token | 71 | // Found the shader token |
922 | 72 | shaderStringStart = i + ShaderToken.Length(); | 72 | shaderStringStart = i + ShaderToken.length(); |
923 | 73 | startTokenFound = true; | 73 | startTokenFound = true; |
924 | 74 | 74 | ||
925 | 75 | //Set what line the shader was found on | 75 | //Set what line the shader was found on |
926 | @@ -104,11 +104,11 @@ | |||
927 | 104 | } | 104 | } |
928 | 105 | 105 | ||
929 | 106 | //Assign the return string | 106 | //Assign the return string |
931 | 107 | RetSource = ShaderSource.GetSubString(shaderStringStart, i - shaderStringStart); | 107 | RetSource = ShaderSource.substr(shaderStringStart, i - shaderStringStart); |
932 | 108 | 108 | ||
933 | 109 | //Add the line directive to the shader source. See the documentation for GLSL #line directive. | 109 | //Add the line directive to the shader source. See the documentation for GLSL #line directive. |
934 | 110 | // GLSL spec: The #version directive must occur in a shader before anything else, except for comments and white space. | 110 | // GLSL spec: The #version directive must occur in a shader before anything else, except for comments and white space. |
936 | 111 | size_t Pos = RetSource.FindFirstOccurence("#version"); | 111 | size_t Pos = RetSource.find("#version", 0); |
937 | 112 | 112 | ||
938 | 113 | while (RetSource[Pos] != '\n') | 113 | while (RetSource[Pos] != '\n') |
939 | 114 | { | 114 | { |
940 | @@ -124,17 +124,21 @@ | |||
941 | 124 | size_t EndOfLinePosition = 0; | 124 | size_t EndOfLinePosition = 0; |
942 | 125 | size_t LinePosition = 0; | 125 | size_t LinePosition = 0; |
943 | 126 | 126 | ||
945 | 127 | while ((EndOfLinePosition = RetSource.FindNextOccurence('\n', EndOfLinePosition)) < Pos - 1) | 127 | while ((EndOfLinePosition = RetSource.find('\n', EndOfLinePosition)) < Pos - 1) |
946 | 128 | { | 128 | { |
947 | 129 | ++EndOfLinePosition; | 129 | ++EndOfLinePosition; |
948 | 130 | ++LinePosition; | 130 | ++LinePosition; |
949 | 131 | } | 131 | } |
950 | 132 | 132 | ||
952 | 133 | RetSource.Insert(Pos, NString::Printf("#line %u\n", LinePosition + shaderStartLine)); | 133 | std::ostringstream o_str_stream; |
953 | 134 | o_str_stream << "#line " << LinePosition + shaderStartLine << "\n"; | ||
954 | 135 | std::string line_num_str = o_str_stream.str(); | ||
955 | 136 | |||
956 | 137 | RetSource.insert(Pos, line_num_str); | ||
957 | 134 | 138 | ||
958 | 135 | // Insert the preprocessor definitions before the #line directive | 139 | // Insert the preprocessor definitions before the #line directive |
961 | 136 | if (ShaderPreprocessorDefines.Length()) | 140 | if (ShaderPreprocessorDefines.length()) |
962 | 137 | RetSource.Insert(Pos, ShaderPreprocessorDefines + NString('\n')); | 141 | RetSource.insert(Pos, ShaderPreprocessorDefines + std::string("\n")); |
963 | 138 | 142 | ||
964 | 139 | return true; | 143 | return true; |
965 | 140 | } | 144 | } |
966 | @@ -146,26 +150,26 @@ | |||
967 | 146 | } | 150 | } |
968 | 147 | } | 151 | } |
969 | 148 | 152 | ||
971 | 149 | static void InsertPreProcessorDefinitions(const NString &ShaderSource, NString &RetSource, NString &ShaderPreprocessorDefines) | 153 | static void InsertPreProcessorDefinitions(const std::string &ShaderSource, std::string &RetSource, std::string &ShaderPreprocessorDefines) |
972 | 150 | { | 154 | { |
973 | 151 | RetSource = ShaderSource; | 155 | RetSource = ShaderSource; |
974 | 152 | 156 | ||
976 | 153 | if (ShaderPreprocessorDefines.Length() == 0) | 157 | if (ShaderPreprocessorDefines.length() == 0) |
977 | 154 | return; | 158 | return; |
978 | 155 | 159 | ||
979 | 156 | // GLSL spec: The #version directive must occur in a shader before anything else, except for comments and white space. | 160 | // GLSL spec: The #version directive must occur in a shader before anything else, except for comments and white space. |
981 | 157 | size_t Pos = RetSource.FindFirstOccurence("#version"); | 161 | size_t Pos = RetSource.find("#version", 0); |
982 | 158 | 162 | ||
983 | 159 | if (Pos != tstring::npos) | 163 | if (Pos != tstring::npos) |
984 | 160 | { | 164 | { |
986 | 161 | Pos = RetSource.FindNextOccurence('\n', Pos); | 165 | Pos = RetSource.find('\n', Pos); |
987 | 162 | 166 | ||
988 | 163 | if (Pos == tstring::npos) | 167 | if (Pos == tstring::npos) |
989 | 164 | { | 168 | { |
990 | 165 | // this is most likely an incorrect shader | 169 | // this is most likely an incorrect shader |
994 | 166 | Pos = RetSource.Size(); | 170 | Pos = RetSource.size(); |
995 | 167 | RetSource.Insert(Pos, NString('\n')); | 171 | RetSource.insert(Pos, std::string("\n")); |
996 | 168 | Pos = RetSource.Size(); | 172 | Pos = RetSource.size(); |
997 | 169 | } | 173 | } |
998 | 170 | else | 174 | else |
999 | 171 | { | 175 | { |
1000 | @@ -178,11 +182,11 @@ | |||
1001 | 178 | Pos = 0; | 182 | Pos = 0; |
1002 | 179 | } | 183 | } |
1003 | 180 | 184 | ||
1006 | 181 | if (ShaderPreprocessorDefines.Length()) | 185 | if (ShaderPreprocessorDefines.length()) |
1007 | 182 | RetSource.Insert(Pos, ShaderPreprocessorDefines + NString('\n')); | 186 | RetSource.insert(Pos, ShaderPreprocessorDefines + std::string("\n")); |
1008 | 183 | } | 187 | } |
1009 | 184 | 188 | ||
1011 | 185 | IOpenGLShader::IOpenGLShader(NString ShaderName, OpenGLResourceType ResourceType) | 189 | IOpenGLShader::IOpenGLShader(std::string ShaderName, OpenGLResourceType ResourceType) |
1012 | 186 | : IOpenGLResource(ResourceType) | 190 | : IOpenGLResource(ResourceType) |
1013 | 187 | , _ShaderName(ShaderName) | 191 | , _ShaderName(ShaderName) |
1014 | 188 | { | 192 | { |
1015 | @@ -194,7 +198,7 @@ | |||
1016 | 194 | 198 | ||
1017 | 195 | } | 199 | } |
1018 | 196 | 200 | ||
1020 | 197 | IOpenGLVertexShader::IOpenGLVertexShader(NString ShaderName) | 201 | IOpenGLVertexShader::IOpenGLVertexShader(std::string ShaderName) |
1021 | 198 | : IOpenGLShader(ShaderName, RT_GLSL_VERTEXSHADER) | 202 | : IOpenGLShader(ShaderName, RT_GLSL_VERTEXSHADER) |
1022 | 199 | , m_CompiledAndReady(false) | 203 | , m_CompiledAndReady(false) |
1023 | 200 | { | 204 | { |
1024 | @@ -213,8 +217,8 @@ | |||
1025 | 213 | { | 217 | { |
1026 | 214 | nuxAssertMsg(ShaderCode, "[IOpenGLVertexShader::SetShaderCode] Invalid shader code."); | 218 | nuxAssertMsg(ShaderCode, "[IOpenGLVertexShader::SetShaderCode] Invalid shader code."); |
1027 | 215 | NUX_RETURN_IF_NULL(ShaderCode); | 219 | NUX_RETURN_IF_NULL(ShaderCode); |
1030 | 216 | NString ProcessedShaderSource; | 220 | std::string ProcessedShaderSource; |
1031 | 217 | NString Defines(VtxShaderPreprocessorDefines); | 221 | std::string Defines(VtxShaderPreprocessorDefines); |
1032 | 218 | InsertPreProcessorDefinitions(ShaderCode, ProcessedShaderSource, Defines); | 222 | InsertPreProcessorDefinitions(ShaderCode, ProcessedShaderSource, Defines); |
1033 | 219 | 223 | ||
1034 | 220 | m_CompiledAndReady = false; | 224 | m_CompiledAndReady = false; |
1035 | @@ -223,7 +227,7 @@ | |||
1036 | 223 | 227 | ||
1037 | 224 | bool IOpenGLVertexShader::Compile() | 228 | bool IOpenGLVertexShader::Compile() |
1038 | 225 | { | 229 | { |
1040 | 226 | size_t CodeSize = _ShaderCode.Size(); | 230 | size_t CodeSize = _ShaderCode.size(); |
1041 | 227 | 231 | ||
1042 | 228 | if (CodeSize == 0) | 232 | if (CodeSize == 0) |
1043 | 229 | { | 233 | { |
1044 | @@ -232,7 +236,7 @@ | |||
1045 | 232 | 236 | ||
1046 | 233 | char *ShaderSource = new char[CodeSize+1]; | 237 | char *ShaderSource = new char[CodeSize+1]; |
1047 | 234 | Memset(ShaderSource, 0, CodeSize + 1); | 238 | Memset(ShaderSource, 0, CodeSize + 1); |
1049 | 235 | Memcpy(ShaderSource, _ShaderCode.GetTCharPtr(), CodeSize); | 239 | Memcpy(ShaderSource, _ShaderCode.c_str(), CodeSize); |
1050 | 236 | 240 | ||
1051 | 237 | CHECKGL(glShaderSource(_OpenGLID, 1, (const GLcharARB **) &ShaderSource, NULL)); | 241 | CHECKGL(glShaderSource(_OpenGLID, 1, (const GLcharARB **) &ShaderSource, NULL)); |
1052 | 238 | delete [] ShaderSource; | 242 | delete [] ShaderSource; |
1053 | @@ -272,7 +276,7 @@ | |||
1054 | 272 | return(m_CompiledAndReady ? true : false); | 276 | return(m_CompiledAndReady ? true : false); |
1055 | 273 | } | 277 | } |
1056 | 274 | 278 | ||
1058 | 275 | IOpenGLPixelShader::IOpenGLPixelShader(NString ShaderName) | 279 | IOpenGLPixelShader::IOpenGLPixelShader(std::string ShaderName) |
1059 | 276 | : IOpenGLShader(ShaderName, RT_GLSL_PIXELSHADER) | 280 | : IOpenGLShader(ShaderName, RT_GLSL_PIXELSHADER) |
1060 | 277 | , m_CompiledAndReady(false) | 281 | , m_CompiledAndReady(false) |
1061 | 278 | 282 | ||
1062 | @@ -292,8 +296,8 @@ | |||
1063 | 292 | { | 296 | { |
1064 | 293 | nuxAssertMsg(ShaderCode, "[IOpenGLPixelShader::SetShaderCode] Invalid shader code."); | 297 | nuxAssertMsg(ShaderCode, "[IOpenGLPixelShader::SetShaderCode] Invalid shader code."); |
1065 | 294 | NUX_RETURN_IF_NULL(ShaderCode); | 298 | NUX_RETURN_IF_NULL(ShaderCode); |
1068 | 295 | NString ProcessedShaderSource; | 299 | std::string ProcessedShaderSource; |
1069 | 296 | NString Defines(FrgShaderPreprocessorDefines); | 300 | std::string Defines(FrgShaderPreprocessorDefines); |
1070 | 297 | InsertPreProcessorDefinitions(ShaderCode, ProcessedShaderSource, Defines); | 301 | InsertPreProcessorDefinitions(ShaderCode, ProcessedShaderSource, Defines); |
1071 | 298 | 302 | ||
1072 | 299 | m_CompiledAndReady = false; | 303 | m_CompiledAndReady = false; |
1073 | @@ -303,7 +307,7 @@ | |||
1074 | 303 | bool IOpenGLPixelShader::Compile() | 307 | bool IOpenGLPixelShader::Compile() |
1075 | 304 | { | 308 | { |
1076 | 305 | 309 | ||
1078 | 306 | GLint CodeSize = (GLint) _ShaderCode.Size(); | 310 | GLint CodeSize = (GLint) _ShaderCode.size(); |
1079 | 307 | 311 | ||
1080 | 308 | if (CodeSize == 0) | 312 | if (CodeSize == 0) |
1081 | 309 | { | 313 | { |
1082 | @@ -312,7 +316,7 @@ | |||
1083 | 312 | 316 | ||
1084 | 313 | char *ShaderSource = new char[CodeSize+1]; | 317 | char *ShaderSource = new char[CodeSize+1]; |
1085 | 314 | Memset(ShaderSource, 0, CodeSize + 1); | 318 | Memset(ShaderSource, 0, CodeSize + 1); |
1087 | 315 | Memcpy(ShaderSource, _ShaderCode.m_string.c_str(), CodeSize); | 319 | Memcpy(ShaderSource, _ShaderCode.c_str(), CodeSize); |
1088 | 316 | CHECKGL(glShaderSource(_OpenGLID, 1, (const GLcharARB **) &ShaderSource, &CodeSize)); | 320 | CHECKGL(glShaderSource(_OpenGLID, 1, (const GLcharARB **) &ShaderSource, &CodeSize)); |
1089 | 317 | delete [] ShaderSource; | 321 | delete [] ShaderSource; |
1090 | 318 | 322 | ||
1091 | @@ -354,7 +358,7 @@ | |||
1092 | 354 | } | 358 | } |
1093 | 355 | 359 | ||
1094 | 356 | #if 0 | 360 | #if 0 |
1096 | 357 | IOpenGLGeometryShader::IOpenGLGeometryShader(NString ShaderName) | 361 | IOpenGLGeometryShader::IOpenGLGeometryShader(std::string ShaderName) |
1097 | 358 | : IOpenGLShader(ShaderName, RT_GLSL_GEOMETRYSHADER) | 362 | : IOpenGLShader(ShaderName, RT_GLSL_GEOMETRYSHADER) |
1098 | 359 | , m_CompiledAndReady(false) | 363 | , m_CompiledAndReady(false) |
1099 | 360 | 364 | ||
1100 | @@ -374,8 +378,8 @@ | |||
1101 | 374 | { | 378 | { |
1102 | 375 | nuxAssertMsg(ShaderCode, "[IOpenGLGeometryShader::SetShaderCode] Invalid shader code."); | 379 | nuxAssertMsg(ShaderCode, "[IOpenGLGeometryShader::SetShaderCode] Invalid shader code."); |
1103 | 376 | NUX_RETURN_IF_NULL(ShaderCode); | 380 | NUX_RETURN_IF_NULL(ShaderCode); |
1106 | 377 | NString ProcessedShaderSource; | 381 | std::string ProcessedShaderSource; |
1107 | 378 | NString Defines(GeometryShaderPreprocessorDefines); | 382 | std::string Defines(GeometryShaderPreprocessorDefines); |
1108 | 379 | InsertPreProcessorDefinitions(ShaderCode, ProcessedShaderSource, Defines); | 383 | InsertPreProcessorDefinitions(ShaderCode, ProcessedShaderSource, Defines); |
1109 | 380 | 384 | ||
1110 | 381 | m_CompiledAndReady = false; | 385 | m_CompiledAndReady = false; |
1111 | @@ -449,7 +453,7 @@ | |||
1112 | 449 | } | 453 | } |
1113 | 450 | #endif | 454 | #endif |
1114 | 451 | 455 | ||
1116 | 452 | IOpenGLShaderProgram::IOpenGLShaderProgram(NString ShaderProgramName) | 456 | IOpenGLShaderProgram::IOpenGLShaderProgram(std::string ShaderProgramName) |
1117 | 453 | : IOpenGLResource(RT_GLSL_SHADERPROGRAM) | 457 | : IOpenGLResource(RT_GLSL_SHADERPROGRAM) |
1118 | 454 | , _FirstParameter(0) | 458 | , _FirstParameter(0) |
1119 | 455 | , m_CompiledAndReady(false) | 459 | , m_CompiledAndReady(false) |
1120 | @@ -476,7 +480,7 @@ | |||
1121 | 476 | { | 480 | { |
1122 | 477 | nuxAssertMsg(ShaderFileName, "[IOpenGLShaderProgram::LoadIShaderFile] Invalid shader file name."); | 481 | nuxAssertMsg(ShaderFileName, "[IOpenGLShaderProgram::LoadIShaderFile] Invalid shader file name."); |
1123 | 478 | NUX_RETURN_IF_NULL(ShaderFileName); | 482 | NUX_RETURN_IF_NULL(ShaderFileName); |
1125 | 479 | NString SourceCode; | 483 | std::string SourceCode; |
1126 | 480 | LoadFileToString(SourceCode, ShaderFileName); | 484 | LoadFileToString(SourceCode, ShaderFileName); |
1127 | 481 | LoadIShader(&SourceCode[0], VtxShaderPreprocessorDefines, FrgShaderPreprocessorDefines); | 485 | LoadIShader(&SourceCode[0], VtxShaderPreprocessorDefines, FrgShaderPreprocessorDefines); |
1128 | 482 | } | 486 | } |
1129 | @@ -485,10 +489,10 @@ | |||
1130 | 485 | { | 489 | { |
1131 | 486 | nuxAssertMsg(ShaderCode, "[IOpenGLShaderProgram::LoadIShader] Invalid shader code."); | 490 | nuxAssertMsg(ShaderCode, "[IOpenGLShaderProgram::LoadIShader] Invalid shader code."); |
1132 | 487 | NUX_RETURN_IF_NULL(ShaderCode); | 491 | NUX_RETURN_IF_NULL(ShaderCode); |
1137 | 488 | NString VertexShaderSource; | 492 | std::string VertexShaderSource; |
1138 | 489 | ExtractShaderString3("[Vertex Shader]", ShaderCode, VertexShaderSource, NString(VtxShaderPreprocessorDefines)); | 493 | ExtractShaderString3("[Vertex Shader]", ShaderCode, VertexShaderSource, std::string(VtxShaderPreprocessorDefines)); |
1139 | 490 | NString PixelShaderSource; | 494 | std::string PixelShaderSource; |
1140 | 491 | ExtractShaderString3("[Fragment Shader]", ShaderCode, PixelShaderSource, NString(FrgShaderPreprocessorDefines)); | 495 | ExtractShaderString3("[Fragment Shader]", ShaderCode, PixelShaderSource, std::string(FrgShaderPreprocessorDefines)); |
1141 | 492 | 496 | ||
1142 | 493 | ObjectPtr<IOpenGLVertexShader> vs = GetGraphicsDisplay()->GetGpuDevice()->CreateVertexShader(); //new IOpenGLVertexShader; | 497 | ObjectPtr<IOpenGLVertexShader> vs = GetGraphicsDisplay()->GetGpuDevice()->CreateVertexShader(); //new IOpenGLVertexShader; |
1143 | 494 | ObjectPtr<IOpenGLPixelShader> ps = GetGraphicsDisplay()->GetGpuDevice()->CreatePixelShader(); //new IOpenGLPixelShader; | 498 | ObjectPtr<IOpenGLPixelShader> ps = GetGraphicsDisplay()->GetGpuDevice()->CreatePixelShader(); //new IOpenGLPixelShader; |
1144 | @@ -510,8 +514,8 @@ | |||
1145 | 510 | NUX_RETURN_IF_NULL(glslshader); | 514 | NUX_RETURN_IF_NULL(glslshader); |
1146 | 511 | ObjectPtr<IOpenGLVertexShader> vs = GetGraphicsDisplay()->GetGpuDevice()->CreateVertexShader(); //new IOpenGLVertexShader; | 515 | ObjectPtr<IOpenGLVertexShader> vs = GetGraphicsDisplay()->GetGpuDevice()->CreateVertexShader(); //new IOpenGLVertexShader; |
1147 | 512 | 516 | ||
1150 | 513 | NString ProcessedShaderSource; | 517 | std::string ProcessedShaderSource; |
1151 | 514 | NString Defines(VtxShaderPreprocessorDefines); | 518 | std::string Defines(VtxShaderPreprocessorDefines); |
1152 | 515 | InsertPreProcessorDefinitions(glslshader, ProcessedShaderSource, Defines); | 519 | InsertPreProcessorDefinitions(glslshader, ProcessedShaderSource, Defines); |
1153 | 516 | 520 | ||
1154 | 517 | vs->SetShaderCode(glslshader); | 521 | vs->SetShaderCode(glslshader); |
1155 | @@ -525,8 +529,8 @@ | |||
1156 | 525 | NUX_RETURN_IF_NULL(glslshader); | 529 | NUX_RETURN_IF_NULL(glslshader); |
1157 | 526 | ObjectPtr<IOpenGLPixelShader> ps = GetGraphicsDisplay()->GetGpuDevice()->CreatePixelShader(); //new IOpenGLPixelShader; | 530 | ObjectPtr<IOpenGLPixelShader> ps = GetGraphicsDisplay()->GetGpuDevice()->CreatePixelShader(); //new IOpenGLPixelShader; |
1158 | 527 | 531 | ||
1161 | 528 | NString ProcessedShaderSource; | 532 | std::string ProcessedShaderSource; |
1162 | 529 | NString Defines(FrgShaderPreprocessorDefines); | 533 | std::string Defines(FrgShaderPreprocessorDefines); |
1163 | 530 | InsertPreProcessorDefinitions(glslshader, ProcessedShaderSource, Defines); | 534 | InsertPreProcessorDefinitions(glslshader, ProcessedShaderSource, Defines); |
1164 | 531 | 535 | ||
1165 | 532 | ps->SetShaderCode(glslshader); | 536 | ps->SetShaderCode(glslshader); |
1166 | @@ -607,7 +611,7 @@ | |||
1167 | 607 | { | 611 | { |
1168 | 608 | if (ShaderObjectList[i]->Compile() == false) | 612 | if (ShaderObjectList[i]->Compile() == false) |
1169 | 609 | { | 613 | { |
1171 | 610 | nuxDebugMsg("[IOpenGLShaderProgram::Link] Attached shader %s does not compile with program: %s.", ShaderObjectList[i]->_ShaderName.GetTCharPtr(), _ShaderProgramName.GetTCharPtr()); | 614 | nuxDebugMsg("[IOpenGLShaderProgram::Link] Attached shader %s does not compile with program: %s.", ShaderObjectList[i]->_ShaderName.c_str(), _ShaderProgramName.c_str()); |
1172 | 611 | } | 615 | } |
1173 | 612 | } | 616 | } |
1174 | 613 | 617 | ||
1175 | @@ -793,13 +797,13 @@ | |||
1176 | 793 | 797 | ||
1177 | 794 | while (m_CompiledAndReady && parameter) | 798 | while (m_CompiledAndReady && parameter) |
1178 | 795 | { | 799 | { |
1181 | 796 | int location = glGetUniformLocationARB(_OpenGLID, TCHAR_TO_ANSI(parameter->m_Name.GetTCharPtr())); | 800 | int location = glGetUniformLocationARB(_OpenGLID, TCHAR_TO_ANSI(parameter->m_Name.c_str())); |
1182 | 797 | CHECKGL_MSG( glGetUniformLocationARB(_OpenGLID, TCHAR_TO_ANSI(parameter->m_Name.GetTCharPtr()))); | 801 | CHECKGL_MSG( glGetUniformLocationARB(_OpenGLID, TCHAR_TO_ANSI(parameter->m_Name.c_str()))); |
1183 | 798 | 802 | ||
1184 | 799 | //nuxDebugMsg("[IOpenGLShaderProgram::CheckUniformLocation] Location index: %d", location); | 803 | //nuxDebugMsg("[IOpenGLShaderProgram::CheckUniformLocation] Location index: %d", location); |
1185 | 800 | if (location == -1 && (!parameter->m_bIsOptional)) | 804 | if (location == -1 && (!parameter->m_bIsOptional)) |
1186 | 801 | { | 805 | { |
1188 | 802 | nuxDebugMsg("[IOpenGLShaderProgram::CheckUniformLocation] Couldn't find shader program parameter %s \n", parameter->m_Name.GetTCharPtr()); | 806 | nuxDebugMsg("[IOpenGLShaderProgram::CheckUniformLocation] Couldn't find shader program parameter %s \n", parameter->m_Name.c_str()); |
1189 | 803 | nuxAssert(0); | 807 | nuxAssert(0); |
1190 | 804 | } | 808 | } |
1191 | 805 | 809 | ||
1192 | 806 | 810 | ||
1193 | === modified file 'NuxGraphics/IOpenGLGLSLShader.h' | |||
1194 | --- NuxGraphics/IOpenGLGLSLShader.h 2011-10-19 20:32:38 +0000 | |||
1195 | +++ NuxGraphics/IOpenGLGLSLShader.h 2012-09-30 17:24:22 +0000 | |||
1196 | @@ -28,19 +28,19 @@ | |||
1197 | 28 | 28 | ||
1198 | 29 | class IOpenGLResource; | 29 | class IOpenGLResource; |
1199 | 30 | 30 | ||
1201 | 31 | bool ExtractShaderString3(const NString &ShaderToken, const NString &ShaderSource, NString &RetSource, NString ShaderPreprocessorDefines = NString("")); | 31 | bool ExtractShaderString3(const std::string &ShaderToken, const std::string &ShaderSource, std::string &RetSource, std::string ShaderPreprocessorDefines = std::string("")); |
1202 | 32 | 32 | ||
1203 | 33 | class IOpenGLShader: public IOpenGLResource | 33 | class IOpenGLShader: public IOpenGLResource |
1204 | 34 | { | 34 | { |
1205 | 35 | NUX_DECLARE_OBJECT_TYPE(IOpenGLShader, IOpenGLResource); | 35 | NUX_DECLARE_OBJECT_TYPE(IOpenGLShader, IOpenGLResource); |
1207 | 36 | IOpenGLShader(NString ShaderName, OpenGLResourceType ResourceType); | 36 | IOpenGLShader(std::string ShaderName, OpenGLResourceType ResourceType); |
1208 | 37 | virtual ~IOpenGLShader(); | 37 | virtual ~IOpenGLShader(); |
1209 | 38 | public: | 38 | public: |
1210 | 39 | virtual void SetShaderCode(const ANSICHAR *ShaderCode, const char *ShaderPreprocessorDefines = "") = 0; | 39 | virtual void SetShaderCode(const ANSICHAR *ShaderCode, const char *ShaderPreprocessorDefines = "") = 0; |
1211 | 40 | virtual bool Compile() = 0; | 40 | virtual bool Compile() = 0; |
1212 | 41 | virtual bool IsValid() = 0; | 41 | virtual bool IsValid() = 0; |
1215 | 42 | NString _ShaderName; | 42 | std::string _ShaderName; |
1216 | 43 | NString _ShaderCode; | 43 | std::string _ShaderCode; |
1217 | 44 | }; | 44 | }; |
1218 | 45 | 45 | ||
1219 | 46 | class IOpenGLVertexShader: public IOpenGLShader | 46 | class IOpenGLVertexShader: public IOpenGLShader |
1220 | @@ -52,7 +52,7 @@ | |||
1221 | 52 | virtual bool Compile(); | 52 | virtual bool Compile(); |
1222 | 53 | virtual bool IsValid(); | 53 | virtual bool IsValid(); |
1223 | 54 | private: | 54 | private: |
1225 | 55 | IOpenGLVertexShader(NString ShaderName = NString("Vertex Shader")); | 55 | IOpenGLVertexShader(std::string ShaderName = std::string("Vertex Shader")); |
1226 | 56 | int m_CompiledAndReady; | 56 | int m_CompiledAndReady; |
1227 | 57 | friend class GpuDevice; | 57 | friend class GpuDevice; |
1228 | 58 | }; | 58 | }; |
1229 | @@ -66,7 +66,7 @@ | |||
1230 | 66 | virtual bool Compile(); | 66 | virtual bool Compile(); |
1231 | 67 | virtual bool IsValid(); | 67 | virtual bool IsValid(); |
1232 | 68 | private: | 68 | private: |
1234 | 69 | IOpenGLPixelShader(NString ShaderName = NString("Fragment Shader")); | 69 | IOpenGLPixelShader(std::string ShaderName = std::string("Fragment Shader")); |
1235 | 70 | int m_CompiledAndReady; | 70 | int m_CompiledAndReady; |
1236 | 71 | friend class GpuDevice; | 71 | friend class GpuDevice; |
1237 | 72 | }; | 72 | }; |
1238 | @@ -86,7 +86,7 @@ | |||
1239 | 86 | void SetMaxVertexOutput(int max_vertex_output); | 86 | void SetMaxVertexOutput(int max_vertex_output); |
1240 | 87 | 87 | ||
1241 | 88 | private: | 88 | private: |
1243 | 89 | IOpenGLGeometryShader(NString ShaderName = NString("Geometry Shader")); | 89 | IOpenGLGeometryShader(std::string ShaderName = std::string("Geometry Shader")); |
1244 | 90 | int m_CompiledAndReady; | 90 | int m_CompiledAndReady; |
1245 | 91 | friend class GpuDevice; | 91 | friend class GpuDevice; |
1246 | 92 | }; | 92 | }; |
1247 | @@ -207,11 +207,11 @@ | |||
1248 | 207 | int GetAttributeLocation(const char *AttributeName); | 207 | int GetAttributeLocation(const char *AttributeName); |
1249 | 208 | 208 | ||
1250 | 209 | private: | 209 | private: |
1252 | 210 | IOpenGLShaderProgram(NString ShaderProgramName = NString("ShaderProgram")); | 210 | IOpenGLShaderProgram(std::string ShaderProgramName = std::string("ShaderProgram")); |
1253 | 211 | ShaderAttributeDefinition m_ProgramAttributeDefinition[16/*NUM_VERTEX_SHADER_INPUT_ATTRIBUTE*/]; | 211 | ShaderAttributeDefinition m_ProgramAttributeDefinition[16/*NUM_VERTEX_SHADER_INPUT_ATTRIBUTE*/]; |
1254 | 212 | std::vector<ObjectPtr<IOpenGLShader> > ShaderObjectList; | 212 | std::vector<ObjectPtr<IOpenGLShader> > ShaderObjectList; |
1255 | 213 | bool m_CompiledAndReady; | 213 | bool m_CompiledAndReady; |
1257 | 214 | NString _ShaderProgramName; | 214 | std::string _ShaderProgramName; |
1258 | 215 | friend class GpuDevice; | 215 | friend class GpuDevice; |
1259 | 216 | }; | 216 | }; |
1260 | 217 | 217 |
Looks OK.