/
Doom3ShaderSystem.cpp
768 lines (595 loc) · 21.1 KB
/
Doom3ShaderSystem.cpp
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
#include "Doom3ShaderSystem.h"
#include "ShaderFileLoader.h"
#include "MaterialSourceGenerator.h"
#include "i18n.h"
#include "iradiant.h"
#include "iregistry.h"
#include "ifilesystem.h"
#include "ifiletypes.h"
#include "ipreferencesystem.h"
#include "imainframe.h"
#include "ieventmanager.h"
#include "iradiant.h"
#include "igame.h"
#include "iarchive.h"
#include "xmlutil/Node.h"
#include "xmlutil/MissingXMLNodeException.h"
#include "ShaderDefinition.h"
#include "ShaderExpression.h"
#include "debugging/ScopedDebugTimer.h"
#include "module/StaticModule.h"
#include "os/file.h"
#include "os/path.h"
#include "decl/SpliceHelper.h"
#include "stream/TemporaryOutputStream.h"
#include "string/predicate.h"
#include "string/replace.h"
#include "materials/ParseLib.h"
#include "parser/DefBlockTokeniser.h"
#include <functional>
namespace
{
const char* TEXTURE_PREFIX = "textures/";
const char* MISSING_BASEPATH_NODE =
"Failed to find \"/game/filesystem/shaders/basepath\" node \
in game descriptor";
const char* MISSING_EXTENSION_NODE =
"Failed to find \"/game/filesystem/shaders/extension\" node \
in game descriptor";
// Default image maps for optional material stages
const std::string IMAGE_FLAT = "_flat.bmp";
const std::string IMAGE_BLACK = "_black.bmp";
inline std::string getBitmapsPath()
{
return module::GlobalModuleRegistry().getApplicationContext().getBitmapsPath();
}
}
namespace shaders
{
// Constructor
Doom3ShaderSystem::Doom3ShaderSystem() :
_defLoader(std::bind(&Doom3ShaderSystem::loadMaterialFiles, this)),
_enableActiveUpdates(true),
_realised(false)
{}
void Doom3ShaderSystem::construct()
{
_library = std::make_shared<ShaderLibrary>();
_textureManager = std::make_shared<GLTextureManager>();
// Register this class as VFS observer
GlobalFileSystem().addObserver(*this);
}
void Doom3ShaderSystem::destroy()
{
// De-register this class as VFS Observer
GlobalFileSystem().removeObserver(*this);
// Free the shaders if we're in realised state
if (_realised)
{
freeShaders();
}
// Don't destroy the GLTextureManager, it's called from
// the CShader destructors.
}
ShaderLibraryPtr Doom3ShaderSystem::loadMaterialFiles()
{
// Get the shaders path and extension from the XML game file
xml::NodeList nlShaderPath =
GlobalGameManager().currentGame()->getLocalXPath("/filesystem/shaders/basepath");
if (nlShaderPath.empty())
throw xml::MissingXMLNodeException(MISSING_BASEPATH_NODE);
xml::NodeList nlShaderExt =
GlobalGameManager().currentGame()->getLocalXPath("/filesystem/shaders/extension");
if (nlShaderExt.empty())
throw xml::MissingXMLNodeException(MISSING_EXTENSION_NODE);
// Load the shader files from the VFS
std::string sPath = nlShaderPath[0].getContent();
if (!string::ends_with(sPath, "/"))
sPath += "/";
std::string extension = nlShaderExt[0].getContent();
ShaderLibraryPtr library = std::make_shared<ShaderLibrary>();
// Load each file from the global filesystem
{
ScopedDebugTimer timer("ShaderFiles parsed: ");
ShaderFileLoader<ShaderLibrary> loader(GlobalFileSystem(), *library,
sPath, extension);
loader.parseFiles();
}
rMessage() << library->getNumDefinitions() << " shader definitions found." << std::endl;
return library;
}
void Doom3ShaderSystem::realise()
{
if (!_realised)
{
// Start loading defs
_defLoader.start();
_signalDefsLoaded.emit();
_realised = true;
}
}
void Doom3ShaderSystem::unrealise()
{
if (_realised)
{
_signalDefsUnloaded.emit();
freeShaders();
_realised = false;
}
}
void Doom3ShaderSystem::ensureDefsLoaded()
{
// To avoid assigning the pointer everytime, check if the library is empty
if (_library->getNumDefinitions() == 0)
{
_library = _defLoader.get();
}
}
void Doom3ShaderSystem::onFileSystemInitialise()
{
realise();
}
void Doom3ShaderSystem::onFileSystemShutdown()
{
unrealise();
}
void Doom3ShaderSystem::freeShaders() {
_library->clear();
_defLoader.reset();
_textureManager->checkBindings();
activeShadersChangedNotify();
}
void Doom3ShaderSystem::refresh() {
unrealise();
realise();
}
// Is the shader system realised
bool Doom3ShaderSystem::isRealised()
{
// Don't report true until we have at least some definitions loaded
return _realised && _library->getNumDefinitions() > 0;
}
sigc::signal<void>& Doom3ShaderSystem::signal_DefsLoaded()
{
return _signalDefsLoaded;
}
sigc::signal<void>& Doom3ShaderSystem::signal_DefsUnloaded()
{
return _signalDefsUnloaded;
}
// Return a shader by name
MaterialPtr Doom3ShaderSystem::getMaterial(const std::string& name)
{
ensureDefsLoaded();
CShaderPtr shader = _library->findShader(name);
return shader;
}
bool Doom3ShaderSystem::materialExists(const std::string& name)
{
ensureDefsLoaded();
return _library->definitionExists(name);
}
bool Doom3ShaderSystem::materialCanBeModified(const std::string& name)
{
ensureDefsLoaded();
if (!_library->definitionExists(name))
{
return false;
}
const auto& def = _library->getDefinition(name);
return def.file.name.empty() || def.file.getIsPhysicalFile();
}
void Doom3ShaderSystem::foreachShaderName(const ShaderNameCallback& callback)
{
ensureDefsLoaded();
// Pass the call to the Library
_library->foreachShaderName(callback);
}
void Doom3ShaderSystem::setLightingEnabled(bool enabled)
{
ensureDefsLoaded();
if (CShader::m_lightingEnabled != enabled)
{
// First unrealise the lighting of all shaders
_library->foreachShader([](const CShaderPtr& shader)
{
shader->unrealiseLighting();
});
// Set the global (greebo: Does this really need to be done this way?)
CShader::m_lightingEnabled = enabled;
// Now realise the lighting of all shaders
_library->foreachShader([](const CShaderPtr& shader)
{
shader->realiseLighting();
});
}
}
const char* Doom3ShaderSystem::getTexturePrefix() const
{
return TEXTURE_PREFIX;
}
GLTextureManager& Doom3ShaderSystem::getTextureManager()
{
return *_textureManager;
}
// Get default textures
TexturePtr Doom3ShaderSystem::getDefaultInteractionTexture(IShaderLayer::Type type)
{
TexturePtr defaultTex;
// Look up based on layer type
switch (type)
{
case IShaderLayer::DIFFUSE:
case IShaderLayer::SPECULAR:
defaultTex = _textureManager->getBinding(getBitmapsPath() + IMAGE_BLACK);
break;
case IShaderLayer::BUMP:
defaultTex = _textureManager->getBinding(getBitmapsPath() + IMAGE_FLAT);
break;
default:
break;
}
return defaultTex;
}
sigc::signal<void> Doom3ShaderSystem::signal_activeShadersChanged() const
{
return _signalActiveShadersChanged;
}
void Doom3ShaderSystem::activeShadersChangedNotify()
{
if (_enableActiveUpdates)
{
_signalActiveShadersChanged.emit();
}
}
void Doom3ShaderSystem::foreachMaterial(const std::function<void(const MaterialPtr&)>& func)
{
ensureDefsLoaded();
_library->foreachShader(func);
}
TexturePtr Doom3ShaderSystem::loadTextureFromFile(const std::string& filename)
{
// Remove any unused Textures before allocating new ones.
_textureManager->checkBindings();
// Get the binding (i.e. load the texture)
return _textureManager->getBinding(filename);
}
sigc::signal<void, const std::string&>& Doom3ShaderSystem::signal_materialCreated()
{
return _sigMaterialCreated;
}
sigc::signal<void, const std::string&, const std::string&>& Doom3ShaderSystem::signal_materialRenamed()
{
return _sigMaterialRenamed;
}
sigc::signal<void, const std::string&>& Doom3ShaderSystem::signal_materialRemoved()
{
return _sigMaterialRemoved;
}
IShaderExpression::Ptr Doom3ShaderSystem::createShaderExpressionFromString(const std::string& exprStr)
{
return ShaderExpression::createFromString(exprStr);
}
std::string Doom3ShaderSystem::ensureNonConflictingName(const std::string& name)
{
auto candidate = name;
auto i = 0;
while (_library->definitionExists(candidate))
{
candidate += fmt::format("{0:02d}", ++i);
}
return candidate;
}
MaterialPtr Doom3ShaderSystem::createEmptyMaterial(const std::string& name)
{
auto candidate = ensureNonConflictingName(name);
// Create a new template/definition
auto shaderTemplate = std::make_shared<ShaderTemplate>(candidate, "");
ShaderDefinition def{ shaderTemplate, vfs::FileInfo("", "", vfs::Visibility::HIDDEN) };
_library->addDefinition(candidate, def);
auto material = _library->findShader(candidate);
material->setIsModified();
_sigMaterialCreated.emit(candidate);
return material;
}
bool Doom3ShaderSystem::renameMaterial(const std::string& oldName, const std::string& newName)
{
if (oldName == newName)
{
rWarning() << "Cannot rename, the new name is no different" << std::endl;
return false;
}
if (!_library->definitionExists(oldName))
{
rWarning() << "Cannot rename non-existent material " << oldName << std::endl;
return false;
}
if (_library->definitionExists(newName))
{
rWarning() << "Cannot rename material to " << newName << " since this name is already in use" << std::endl;
return false;
}
_library->renameDefinition(oldName, newName);
_sigMaterialRenamed(oldName, newName);
return true;
}
void Doom3ShaderSystem::removeMaterial(const std::string& name)
{
if (!_library->definitionExists(name))
{
rWarning() << "Cannot remove non-existent material " << name << std::endl;
return;
}
_library->removeDefinition(name);
_sigMaterialRemoved.emit(name);
}
MaterialPtr Doom3ShaderSystem::createDefaultMaterial(const std::string& name)
{
return std::make_shared<CShader>(name, _library->getEmptyDefinition(), true);
}
MaterialPtr Doom3ShaderSystem::copyMaterial(const std::string& nameOfOriginal, const std::string& nameOfCopy)
{
if (nameOfCopy.empty())
{
rWarning() << "Cannot copy, the new name must not be empty" << std::endl;
return MaterialPtr();
}
auto candidate = ensureNonConflictingName(nameOfCopy);
if (!_library->definitionExists(nameOfOriginal))
{
rWarning() << "Cannot copy non-existent material " << nameOfOriginal << std::endl;
return MaterialPtr();
}
_library->copyDefinition(nameOfOriginal, candidate);
_sigMaterialCreated.emit(candidate);
auto material = _library->findShader(candidate);
material->setIsModified();
material->setShaderFileName("");
return material;
}
void Doom3ShaderSystem::saveMaterial(const std::string& name)
{
ensureDefsLoaded();
auto material = _library->findShader(name);
if (!material->isModified())
{
rMessage() << "Material is not modified, nothing to save." << std::endl;
return;
}
if (!materialCanBeModified(material->getName()))
{
throw std::runtime_error("Cannot save this material, it's read-only.");
}
if (material->getShaderFileInfo().fullPath().empty())
{
throw std::runtime_error("No file path set on this material, cannot save.");
}
// Construct the output path for this material
fs::path outputPath = GlobalGameManager().getModPath();
if (outputPath.empty())
{
outputPath = GlobalGameManager().getUserEnginePath();
}
outputPath /= material->getShaderFileInfo().fullPath();
auto outputDir = os::getContainingDir(outputPath.string());
if (!os::fileOrDirExists(outputDir))
{
rMessage() << "Creating mod materials path: " << outputDir << std::endl;
fs::create_directories(outputDir);
}
rMessage() << "Saving material " << material->getName() << " to " << outputPath << std::endl;
stream::TemporaryOutputStream tempStream(outputPath);
std::string tempString;
auto& stream = tempStream.getStream();
// If a previous file exists, open it for reading and filter out the material def we'll be writing
if (fs::exists(outputPath))
{
std::ifstream inheritStream(outputPath);
if (!inheritStream.is_open())
{
throw std::runtime_error(
fmt::format(_("Cannot open file for reading: {0}"), outputPath.string()));
}
// Write the file to the output stream, up to the point the material def should be written to
std::regex pattern(getDeclNamePatternForMaterialName(material->getName()));
decl::SpliceHelper::PipeStreamUntilInsertionPoint(inheritStream, stream, pattern);
if (inheritStream.eof())
{
// Material declaration was not found in the inherited stream, write our comment
stream << std::endl << std::endl;
MaterialSourceGenerator::WriteMaterialGenerationComment(stream);
}
// We're at the insertion point (which might as well be EOF of the inheritStream)
// Write the name, curly braces and block contents
MaterialSourceGenerator::WriteFullMaterialToStream(stream, material);
stream << inheritStream.rdbuf();
inheritStream.close();
}
else
{
// File is empty, just write the comment and the declaration
MaterialSourceGenerator::WriteMaterialGenerationComment(stream);
MaterialSourceGenerator::WriteFullMaterialToStream(stream, material);
}
tempStream.closeAndReplaceTargetFile();
// Store the modifications in our actual template and un-mark the file
material->commitModifications();
// Update the template in our library
_library->replaceDefinition(material->getName(), ShaderDefinition{ material->getTemplate(), material->getShaderFileInfo() });
}
ITableDefinition::Ptr Doom3ShaderSystem::getTable(const std::string& name)
{
ensureDefsLoaded();
return _library->getTableForName(name);
}
const std::string& Doom3ShaderSystem::getName() const
{
static std::string _name(MODULE_SHADERSYSTEM);
return _name;
}
const StringSet& Doom3ShaderSystem::getDependencies() const
{
static StringSet _dependencies;
if (_dependencies.empty())
{
_dependencies.insert(MODULE_VIRTUALFILESYSTEM);
_dependencies.insert(MODULE_XMLREGISTRY);
_dependencies.insert(MODULE_GAMEMANAGER);
_dependencies.insert(MODULE_FILETYPES);
}
return _dependencies;
}
void Doom3ShaderSystem::initialiseModule(const IApplicationContext& ctx)
{
rMessage() << getName() << "::initialiseModule called" << std::endl;
construct();
realise();
#if 0
testShaderExpressionParsing();
#endif
// Register the mtr file extension
GlobalFiletypes().registerPattern("material", FileTypePattern(_("Material File"), "mtr", "*.mtr"));
}
// Horrible evil macro to avoid assertion failures if expr is NULL
#define GET_EXPR_OR_RETURN expr = createShaderExpressionFromString(exprStr);\
if (!expr) return;
void Doom3ShaderSystem::testShaderExpressionParsing()
{
// Test a few things
std::string exprStr = "3";
IShaderExpression::Ptr expr;
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "3+4";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "(3+4)";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "(4.2)";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "3+5+6";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "3+(5+6)";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "3 * 3+5";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "3+3*5";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "(3+3)*5";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "(3+3*7)-5";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "3-3*5";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "blinktable[0]";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "blinktable[1]";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "blinktable[0.3]";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "blinksnaptable[0.3]";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "xianjittertable[0]";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "xianjittertable[time]";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "3-3*xianjittertable[2]";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "3+xianjittertable[3]*7";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "(3+xianjittertable[3])*7";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "2.3 % 2";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "2.0 % 0.5";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "2 == 2";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "1 == 2";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "1 != 2";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "1.2 != 1.2";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "1.2 == 1.2*3";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "1.2*3 == 1.2*3";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "3 == 3 && 1 != 0";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "1 != 1 || 3 == 3";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "4 == 3 || 1 != 0";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "time";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(2) << std::endl;
exprStr = "-3 + 5";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "3 * -5";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "3 * -5 + 4";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "3 + -5 * 4";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "3 * 5 * -6";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
exprStr = "decalFade[(time - Parm3)/(parm4 - parm3)]";
GET_EXPR_OR_RETURN;
rMessage() << "Expression " << exprStr << ": " << expr->getValue(0) << std::endl;
}
void Doom3ShaderSystem::shutdownModule()
{
rMessage() << "Doom3ShaderSystem::shutdownModule called" << std::endl;
destroy();
unrealise();
}
// Accessor function encapsulating the static shadersystem instance
Doom3ShaderSystemPtr GetShaderSystem()
{
// Acquire the moduleptr from the module registry
RegisterableModulePtr modulePtr(module::GlobalModuleRegistry().getModule(MODULE_SHADERSYSTEM));
// static_cast it onto our shadersystem type
return std::static_pointer_cast<Doom3ShaderSystem>(modulePtr);
}
GLTextureManager& GetTextureManager()
{
return GetShaderSystem()->getTextureManager();
}
// Static module instance
module::StaticModule<Doom3ShaderSystem> d3ShaderSystemModule;
} // namespace shaders