]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - plugins/shaders/plugin.cpp
Merge remote branch 'icculus/master'
[xonotic/netradiant.git] / plugins / shaders / plugin.cpp
1 /*
2 Copyright (C) 2001-2006, William Joseph.
3 All Rights Reserved.
4
5 This file is part of GtkRadiant.
6
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20 */
21
22 #include "plugin.h"
23
24 #include "ishaders.h"
25 #include "ifilesystem.h"
26 #include "itextures.h"
27 #include "iscriplib.h"
28 #include "qerplugin.h"
29
30 #include "string/string.h"
31 #include "modulesystem/singletonmodule.h"
32
33 #include "shaders.h"
34
35 class ShadersDependencies :
36   public GlobalFileSystemModuleRef,
37   public GlobalTexturesModuleRef,
38   public GlobalScripLibModuleRef,
39   public GlobalRadiantModuleRef
40 {
41   ImageModuleRef m_bitmapModule;
42 public:
43   ShadersDependencies() :
44     m_bitmapModule("bmp")
45   {
46   }
47   ImageModuleRef& getBitmapModule()
48   {
49     return m_bitmapModule;
50   }
51 };
52
53 class ShadersQ3API
54 {
55   ShaderSystem* m_shadersq3;
56 public:
57   typedef ShaderSystem Type;
58   STRING_CONSTANT(Name, "quake3");
59
60   ShadersQ3API(ShadersDependencies& dependencies)
61   {
62     g_shadersExtension = "shader";
63     g_shadersDirectory = "scripts/";
64     g_bitmapModule = dependencies.getBitmapModule().getTable();
65     Shaders_Construct();
66     m_shadersq3 = &GetShaderSystem();
67   }
68   ~ShadersQ3API()
69   {
70     Shaders_Destroy();
71   }
72   ShaderSystem* getTable()
73   {
74     return m_shadersq3;
75   }
76 };
77
78 typedef SingletonModule<ShadersQ3API, ShadersDependencies, DependenciesAPIConstructor<ShadersQ3API, ShadersDependencies> > ShadersQ3Module;
79
80 ShadersQ3Module g_ShadersQ3Module;
81
82
83 class ShadersDoom3API
84 {
85   ShaderSystem* m_shadersdoom3;
86 public:
87   typedef ShaderSystem Type;
88   STRING_CONSTANT(Name, "doom3");
89
90   ShadersDoom3API(ShadersDependencies& dependencies)
91   {
92     g_shadersExtension = "mtr";
93     g_shadersDirectory = "materials/";
94     g_enableDefaultShaders = false;
95     g_shaderLanguage = SHADERLANGUAGE_DOOM3;
96     g_useShaderList = false;
97     g_bitmapModule = dependencies.getBitmapModule().getTable();
98     Shaders_Construct();
99     m_shadersdoom3 = &GetShaderSystem();
100   }
101   ~ShadersDoom3API()
102   {
103     Shaders_Destroy();
104   }
105   ShaderSystem* getTable()
106   {
107     return m_shadersdoom3;
108   }
109 };
110
111 typedef SingletonModule<ShadersDoom3API, ShadersDependencies, DependenciesAPIConstructor<ShadersDoom3API, ShadersDependencies> > ShadersDoom3Module;
112
113 ShadersDoom3Module g_ShadersDoom3Module;
114
115
116 class ShadersQuake4API
117 {
118   ShaderSystem* m_shadersquake4;
119 public:
120   typedef ShaderSystem Type;
121   STRING_CONSTANT(Name, "quake4");
122
123   ShadersQuake4API(ShadersDependencies& dependencies)
124   {
125     g_shadersExtension = "mtr";
126     g_shadersDirectory = "materials/";
127     g_enableDefaultShaders = false;
128     g_shaderLanguage = SHADERLANGUAGE_QUAKE4;
129     g_useShaderList = false;
130     g_bitmapModule = dependencies.getBitmapModule().getTable();
131     Shaders_Construct();
132     m_shadersquake4 = &GetShaderSystem();
133   }
134   ~ShadersQuake4API()
135   {
136     Shaders_Destroy();
137   }
138   ShaderSystem* getTable()
139   {
140     return m_shadersquake4;
141   }
142 };
143
144 typedef SingletonModule<ShadersQuake4API, ShadersDependencies, DependenciesAPIConstructor<ShadersQuake4API, ShadersDependencies> > ShadersQuake4Module;
145
146 ShadersQuake4Module g_ShadersQuake4Module;
147
148
149
150 extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
151 {
152   initialiseModule(server);
153
154   g_ShadersQ3Module.selfRegister();
155   g_ShadersDoom3Module.selfRegister();
156   g_ShadersQuake4Module.selfRegister();
157 }