worldspawn/plugins/shaders/plugin.cpp

93 lines
2.2 KiB
C++
Raw Normal View History

2020-11-17 03:16:16 -08:00
/*
Copyright (C) 2001-2006, William Joseph.
All Rights Reserved.
This file is part of GtkRadiant.
GtkRadiant is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GtkRadiant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "ishaders.h"
#include "ifilesystem.h"
#include "itextures.h"
#include "iscriplib.h"
#include "qerplugin.h"
#include "string/string.h"
#include "modulesystem/singletonmodule.h"
#include "shaders.h"
class ShadersDependencies :
public GlobalFileSystemModuleRef,
public GlobalTexturesModuleRef,
public GlobalScripLibModuleRef,
public GlobalRadiantModuleRef {
2021-08-04 13:23:18 -07:00
ImageModuleRef m_bitmapModule;
2020-11-17 03:16:16 -08:00
public:
2021-08-04 13:23:18 -07:00
ShadersDependencies() :
m_bitmapModule("tga")
{
}
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
ImageModuleRef &getBitmapModule()
{
return m_bitmapModule;
}
2020-11-17 03:16:16 -08:00
};
class MaterialAPI {
2021-08-04 13:23:18 -07:00
ShaderSystem *m_shadersq3;
2020-11-17 03:16:16 -08:00
public:
2021-08-04 13:23:18 -07:00
typedef ShaderSystem Type;
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
STRING_CONSTANT(Name, "mat");
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
MaterialAPI(ShadersDependencies &dependencies)
{
g_shadersExtension = "mat";
g_shadersDirectory = "textures/";
g_enableDefaultShaders = false;
g_useShaderList = false;
g_bitmapModule = dependencies.getBitmapModule().getTable();
Shaders_Construct();
m_shadersq3 = &GetShaderSystem();
}
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
~MaterialAPI()
{
Shaders_Destroy();
}
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
ShaderSystem *getTable()
{
return m_shadersq3;
}
2020-11-17 03:16:16 -08:00
};
typedef SingletonModule<MaterialAPI, ShadersDependencies, DependenciesAPIConstructor<MaterialAPI, ShadersDependencies> > MaterialModule;
MaterialModule g_MaterialModule;
2021-06-02 01:49:27 -07:00
extern "C" void
#ifdef _WIN32
__declspec(dllexport)
#else
__attribute__((visibility("default")))
#endif
Radiant_RegisterModules(ModuleServer &server)
2020-11-17 03:16:16 -08:00
{
initialiseModule(server);
g_MaterialModule.selfRegister();
}