X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=include%2Fishaders.h;h=f588c287440e2e1c91355920729e98ca86ae76a9;hb=184fba9ab5ad3111f50c25b70b79d4103943f1f2;hp=49ddf46b401f647b6030f31e4d7fbb341841ea01;hpb=12b372f89ce109a4db9d510884fbe7d05af79870;p=xonotic%2Fnetradiant.git diff --git a/include/ishaders.h b/include/ishaders.h index 49ddf46b..f588c287 100644 --- a/include/ishaders.h +++ b/include/ishaders.h @@ -1,43 +1,44 @@ /* -Copyright (C) 1999-2006 Id Software, Inc. and contributors. -For a list of contributors, see the accompanying CONTRIBUTORS file. + Copyright (C) 1999-2006 Id Software, Inc. and contributors. + For a list of contributors, see the accompanying CONTRIBUTORS file. -This file is part of GtkRadiant. + 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 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. + 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 -*/ + 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 + */ -#if !defined(INCLUDED_ISHADERS_H) +#if !defined( INCLUDED_ISHADERS_H ) #define INCLUDED_ISHADERS_H #include "generic/constant.h" +#include "generic/callback.h" enum { - QER_TRANS = 1 << 0, - QER_NOCARVE = 1 << 1, - QER_NODRAW = 1 << 2, - QER_NONSOLID = 1 << 3, - QER_WATER = 1 << 4, - QER_LAVA = 1 << 5, - QER_FOG = 1 << 6, - QER_ALPHATEST = 1 << 7, - QER_CULL = 1 << 8, - QER_AREAPORTAL = 1 << 9, - QER_CLIP = 1 << 10, - QER_BOTCLIP = 1 << 11, + QER_TRANS = 1 << 0, + QER_NOCARVE = 1 << 1, + QER_NODRAW = 1 << 2, + QER_NONSOLID = 1 << 3, + QER_WATER = 1 << 4, + QER_LAVA = 1 << 5, + QER_FOG = 1 << 6, + QER_ALPHATEST = 1 << 7, + QER_CULL = 1 << 8, + QER_AREAPORTAL = 1 << 9, + QER_CLIP = 1 << 10, + QER_BOTCLIP = 1 << 11, }; struct qtexture_t; @@ -62,114 +63,109 @@ const BlendFactor BLEND_SRC_ALPHA_SATURATE = 10; class BlendFunc { public: - BlendFunc(BlendFactor src, BlendFactor dst) : m_src(src), m_dst(dst) - { - } - BlendFactor m_src; - BlendFactor m_dst; +BlendFunc( BlendFactor src, BlendFactor dst ) : m_src( src ), m_dst( dst ){ +} +BlendFactor m_src; +BlendFactor m_dst; }; class ShaderLayer { public: - virtual qtexture_t* texture() const = 0; - virtual BlendFunc blendFunc() const = 0; - virtual bool clampToBorder() const = 0; - virtual float alphaTest() const = 0; +virtual qtexture_t* texture() const = 0; +virtual BlendFunc blendFunc() const = 0; +virtual bool clampToBorder() const = 0; +virtual float alphaTest() const = 0; }; -template -class Callback1; -typedef Callback1 ShaderLayerCallback; - +typedef Callback ShaderLayerCallback; class IShader { public: - enum EAlphaFunc - { - eAlways, - eEqual, - eLess, - eGreater, - eLEqual, - eGEqual, - }; - enum ECull - { - eCullNone, - eCullBack, - }; - // Increment the number of references to this object - virtual void IncRef() = 0; - // Decrement the reference count - virtual void DecRef() = 0; - // get/set the qtexture_t* Radiant uses to represent this shader object - virtual qtexture_t* getTexture() const = 0; - virtual qtexture_t* getDiffuse() const = 0; - virtual qtexture_t* getBump() const = 0; - virtual qtexture_t* getSpecular() const = 0; - // get shader name - virtual const char* getName() const = 0; - virtual bool IsInUse() const = 0; - virtual void SetInUse(bool bInUse) = 0; - // get the editor flags (QER_NOCARVE QER_TRANS) - virtual int getFlags() const = 0; - // get the transparency value - virtual float getTrans() const = 0; - // test if it's a true shader, or a default shader created to wrap around a texture - virtual bool IsDefault() const = 0; - // get the alphaFunc - virtual void getAlphaFunc(EAlphaFunc *func, float *ref) = 0; - virtual BlendFunc getBlendFunc() const = 0; - // get the cull type - virtual ECull getCull() = 0; - // get shader file name (ie the file where this one is defined) - virtual const char* getShaderFileName() const = 0; - - virtual const ShaderLayer* firstLayer() const = 0; - virtual void forEachLayer(const ShaderLayerCallback& layer) const = 0; - - virtual qtexture_t* lightFalloffImage() const = 0; +enum EAlphaFunc +{ + eAlways, + eEqual, + eLess, + eGreater, + eLEqual, + eGEqual, +}; +enum ECull +{ + eCullNone, + eCullBack, +}; +// Increment the number of references to this object +virtual void IncRef() = 0; +// Decrement the reference count +virtual void DecRef() = 0; +// get/set the qtexture_t* Radiant uses to represent this shader object +virtual qtexture_t* getTexture() const = 0; +virtual qtexture_t* getDiffuse() const = 0; +virtual qtexture_t* getBump() const = 0; +virtual qtexture_t* getSpecular() const = 0; +// get shader name +virtual const char* getName() const = 0; +virtual bool IsInUse() const = 0; +virtual void SetInUse( bool bInUse ) = 0; +// get the editor flags (QER_NOCARVE QER_TRANS) +virtual int getFlags() const = 0; +// get the transparency value +virtual float getTrans() const = 0; +// test if it's a true shader, or a default shader created to wrap around a texture +virtual bool IsDefault() const = 0; +// get the alphaFunc +virtual void getAlphaFunc( EAlphaFunc *func, float *ref ) = 0; +virtual BlendFunc getBlendFunc() const = 0; +// get the cull type +virtual ECull getCull() = 0; +// get shader file name (ie the file where this one is defined) +virtual const char* getShaderFileName() const = 0; + +virtual const ShaderLayer* firstLayer() const = 0; +virtual void forEachLayer( const ShaderLayerCallback& layer ) const = 0; + +virtual qtexture_t* lightFalloffImage() const = 0; }; -class Callback; typedef struct _GSList GSList; -typedef Callback1 ShaderNameCallback; +typedef Callback ShaderNameCallback; class ModuleObserver; class ShaderSystem { public: - INTEGER_CONSTANT(Version, 1); - STRING_CONSTANT(Name, "shaders"); - // NOTE: shader and texture names used must be full path. - // Shaders usable as textures have prefix equal to getTexturePrefix() +INTEGER_CONSTANT( Version, 1 ); +STRING_CONSTANT( Name, "shaders" ); +// NOTE: shader and texture names used must be full path. +// Shaders usable as textures have prefix equal to getTexturePrefix() - virtual void realise() = 0; - virtual void unrealise() = 0; - virtual void refresh() = 0; - // activate the shader for a given name and return it - // will return the default shader if name is not found - virtual IShader* getShaderForName(const char* name) = 0; +virtual void realise() = 0; +virtual void unrealise() = 0; +virtual void refresh() = 0; +// activate the shader for a given name and return it +// will return the default shader if name is not found +virtual IShader* getShaderForName( const char* name ) = 0; - virtual void foreachShaderName(const ShaderNameCallback& callback) = 0; +virtual void foreachShaderName( const ShaderNameCallback& callback ) = 0; - // iterate over the list of active shaders - virtual void beginActiveShadersIterator() = 0; - virtual bool endActiveShadersIterator() = 0; - virtual IShader* dereferenceActiveShadersIterator() = 0; - virtual void incrementActiveShadersIterator() = 0; +// iterate over the list of active shaders +virtual void beginActiveShadersIterator() = 0; +virtual bool endActiveShadersIterator() = 0; +virtual IShader* dereferenceActiveShadersIterator() = 0; +virtual void incrementActiveShadersIterator() = 0; - virtual void setActiveShadersChangedNotify(const Callback& notify) = 0; +virtual void setActiveShadersChangedNotify( const Callback& notify ) = 0; - virtual void attach(ModuleObserver& observer) = 0; - virtual void detach(ModuleObserver& observer) = 0; +virtual void attach( ModuleObserver& observer ) = 0; +virtual void detach( ModuleObserver& observer ) = 0; - virtual void setLightingEnabled(bool enabled) = 0; +virtual void setLightingEnabled( bool enabled ) = 0; - virtual const char* getTexturePrefix() const = 0; +virtual const char* getTexturePrefix() const = 0; }; #include "modulesystem.h" @@ -182,12 +178,10 @@ template class GlobalModuleRef; typedef GlobalModuleRef GlobalShadersModuleRef; -inline ShaderSystem& GlobalShaderSystem() -{ - return GlobalShadersModule::getTable(); +inline ShaderSystem& GlobalShaderSystem(){ + return GlobalShadersModule::getTable(); } - #define QERApp_Shader_ForName GlobalShaderSystem().getShaderForName #define QERApp_ActiveShaders_IteratorBegin GlobalShaderSystem().beginActiveShadersIterator #define QERApp_ActiveShaders_IteratorAtEnd GlobalShaderSystem().endActiveShadersIterator