]> git.xonotic.org Git - xonotic/netradiant.git/blob - plugins/shaders/plugin.cpp
reformat code! now the code is only ugly on the *inside*
[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 "ishaders.h"
23 #include "ifilesystem.h"
24 #include "itextures.h"
25 #include "iscriplib.h"
26 #include "qerplugin.h"
27
28 #include "string/string.h"
29 #include "modulesystem/singletonmodule.h"
30
31 #include "shaders.h"
32
33 class ShadersDependencies :
34         public GlobalFileSystemModuleRef,
35         public GlobalTexturesModuleRef,
36         public GlobalScripLibModuleRef,
37         public GlobalRadiantModuleRef {
38     ImageModuleRef m_bitmapModule;
39 public:
40     ShadersDependencies() :
41             m_bitmapModule("png")
42     {
43     }
44
45     ImageModuleRef &getBitmapModule()
46     {
47         return m_bitmapModule;
48     }
49 };
50
51 class ShadersQ3API {
52     ShaderSystem *m_shadersq3;
53 public:
54     typedef ShaderSystem Type;
55
56     STRING_CONSTANT(Name, "quake3");
57
58     ShadersQ3API(ShadersDependencies &dependencies)
59     {
60         g_shadersExtension = "shader";
61         g_shadersDirectory = "scripts/";
62         g_bitmapModule = dependencies.getBitmapModule().getTable();
63         Shaders_Construct();
64         m_shadersq3 = &GetShaderSystem();
65     }
66
67     ~ShadersQ3API()
68     {
69         Shaders_Destroy();
70     }
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     ShaderSystem *m_shadersdoom3;
85 public:
86     typedef ShaderSystem Type;
87
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
102     ~ShadersDoom3API()
103     {
104         Shaders_Destroy();
105     }
106
107     ShaderSystem *getTable()
108     {
109         return m_shadersdoom3;
110     }
111 };
112
113 typedef SingletonModule<ShadersDoom3API, ShadersDependencies, DependenciesAPIConstructor<ShadersDoom3API, ShadersDependencies> > ShadersDoom3Module;
114
115 ShadersDoom3Module g_ShadersDoom3Module;
116
117
118 class ShadersQuake4API {
119     ShaderSystem *m_shadersquake4;
120 public:
121     typedef ShaderSystem Type;
122
123     STRING_CONSTANT(Name, "quake4");
124
125     ShadersQuake4API(ShadersDependencies &dependencies)
126     {
127         g_shadersExtension = "mtr";
128         g_shadersDirectory = "materials/";
129         g_enableDefaultShaders = false;
130         g_shaderLanguage = SHADERLANGUAGE_QUAKE4;
131         g_useShaderList = false;
132         g_bitmapModule = dependencies.getBitmapModule().getTable();
133         Shaders_Construct();
134         m_shadersquake4 = &GetShaderSystem();
135     }
136
137     ~ShadersQuake4API()
138     {
139         Shaders_Destroy();
140     }
141
142     ShaderSystem *getTable()
143     {
144         return m_shadersquake4;
145     }
146 };
147
148 typedef SingletonModule<ShadersQuake4API, ShadersDependencies, DependenciesAPIConstructor<ShadersQuake4API, ShadersDependencies> > ShadersQuake4Module;
149
150 ShadersQuake4Module g_ShadersQuake4Module;
151
152
153 extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer &server)
154 {
155     initialiseModule(server);
156
157     g_ShadersQ3Module.selfRegister();
158     g_ShadersDoom3Module.selfRegister();
159     g_ShadersQuake4Module.selfRegister();
160 }