| 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 | { |
| 39 | ImageModuleRef m_bitmapModule; |
| 40 | public: |
| 41 | ShadersDependencies() : |
| 42 | //m_bitmapModule( "bmp" ){ |
| 43 | m_bitmapModule( "png" ){ |
| 44 | } |
| 45 | ImageModuleRef& getBitmapModule(){ |
| 46 | return m_bitmapModule; |
| 47 | } |
| 48 | }; |
| 49 | |
| 50 | class ShadersQ3API |
| 51 | { |
| 52 | ShaderSystem* m_shadersq3; |
| 53 | public: |
| 54 | typedef ShaderSystem Type; |
| 55 | STRING_CONSTANT( Name, "quake3" ); |
| 56 | |
| 57 | ShadersQ3API( ShadersDependencies& dependencies ){ |
| 58 | g_shadersExtension = "shader"; |
| 59 | g_shadersDirectory = "scripts/"; |
| 60 | g_bitmapModule = dependencies.getBitmapModule().getTable(); |
| 61 | Shaders_Construct(); |
| 62 | m_shadersq3 = &GetShaderSystem(); |
| 63 | } |
| 64 | ~ShadersQ3API(){ |
| 65 | Shaders_Destroy(); |
| 66 | } |
| 67 | ShaderSystem* getTable(){ |
| 68 | return m_shadersq3; |
| 69 | } |
| 70 | }; |
| 71 | |
| 72 | typedef SingletonModule<ShadersQ3API, ShadersDependencies, DependenciesAPIConstructor<ShadersQ3API, ShadersDependencies> > ShadersQ3Module; |
| 73 | |
| 74 | ShadersQ3Module g_ShadersQ3Module; |
| 75 | |
| 76 | |
| 77 | class ShadersDoom3API |
| 78 | { |
| 79 | ShaderSystem* m_shadersdoom3; |
| 80 | public: |
| 81 | typedef ShaderSystem Type; |
| 82 | STRING_CONSTANT( Name, "doom3" ); |
| 83 | |
| 84 | ShadersDoom3API( ShadersDependencies& dependencies ){ |
| 85 | g_shadersExtension = "mtr"; |
| 86 | g_shadersDirectory = "materials/"; |
| 87 | g_enableDefaultShaders = false; |
| 88 | g_shaderLanguage = SHADERLANGUAGE_DOOM3; |
| 89 | g_useShaderList = false; |
| 90 | g_bitmapModule = dependencies.getBitmapModule().getTable(); |
| 91 | Shaders_Construct(); |
| 92 | m_shadersdoom3 = &GetShaderSystem(); |
| 93 | } |
| 94 | ~ShadersDoom3API(){ |
| 95 | Shaders_Destroy(); |
| 96 | } |
| 97 | ShaderSystem* getTable(){ |
| 98 | return m_shadersdoom3; |
| 99 | } |
| 100 | }; |
| 101 | |
| 102 | typedef SingletonModule<ShadersDoom3API, ShadersDependencies, DependenciesAPIConstructor<ShadersDoom3API, ShadersDependencies> > ShadersDoom3Module; |
| 103 | |
| 104 | ShadersDoom3Module g_ShadersDoom3Module; |
| 105 | |
| 106 | |
| 107 | class ShadersQuake4API |
| 108 | { |
| 109 | ShaderSystem* m_shadersquake4; |
| 110 | public: |
| 111 | typedef ShaderSystem Type; |
| 112 | STRING_CONSTANT( Name, "quake4" ); |
| 113 | |
| 114 | ShadersQuake4API( ShadersDependencies& dependencies ){ |
| 115 | g_shadersExtension = "mtr"; |
| 116 | g_shadersDirectory = "materials/"; |
| 117 | g_enableDefaultShaders = false; |
| 118 | g_shaderLanguage = SHADERLANGUAGE_QUAKE4; |
| 119 | g_useShaderList = false; |
| 120 | g_bitmapModule = dependencies.getBitmapModule().getTable(); |
| 121 | Shaders_Construct(); |
| 122 | m_shadersquake4 = &GetShaderSystem(); |
| 123 | } |
| 124 | ~ShadersQuake4API(){ |
| 125 | Shaders_Destroy(); |
| 126 | } |
| 127 | ShaderSystem* getTable(){ |
| 128 | return m_shadersquake4; |
| 129 | } |
| 130 | }; |
| 131 | |
| 132 | typedef SingletonModule<ShadersQuake4API, ShadersDependencies, DependenciesAPIConstructor<ShadersQuake4API, ShadersDependencies> > ShadersQuake4Module; |
| 133 | |
| 134 | ShadersQuake4Module g_ShadersQuake4Module; |
| 135 | |
| 136 | |
| 137 | |
| 138 | extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules( ModuleServer& server ){ |
| 139 | initialiseModule( server ); |
| 140 | |
| 141 | g_ShadersQ3Module.selfRegister(); |
| 142 | g_ShadersDoom3Module.selfRegister(); |
| 143 | g_ShadersQuake4Module.selfRegister(); |
| 144 | } |