irender.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #if !defined(INCLUDED_IRENDER_H)
00023 #define INCLUDED_IRENDER_H
00024
00025 #include <string>
00026 #include "generic/constant.h"
00027 #include "generic/callbackfwd.h"
00028
00029
00030
00031
00032 const unsigned int RENDER_DEFAULT = 0;
00033 const unsigned int RENDER_LINESTIPPLE = 1 << 0;
00034 const unsigned int RENDER_ALPHATEST = 1 << 4;
00035 const unsigned int RENDER_DEPTHTEST = 1 << 5;
00036 const unsigned int RENDER_DEPTHWRITE = 1 << 6;
00037 const unsigned int RENDER_COLOURWRITE = 1 << 7;
00038 const unsigned int RENDER_CULLFACE = 1 << 8;
00039 const unsigned int RENDER_SCALED = 1 << 9;
00040 const unsigned int RENDER_SMOOTH = 1 << 10;
00041 const unsigned int RENDER_LIGHTING = 1 << 12;
00042 const unsigned int RENDER_BLEND = 1 << 13;
00043 const unsigned int RENDER_FILL = 1 << 15;
00044 const unsigned int RENDER_COLOURARRAY = 1 << 16;
00045 const unsigned int RENDER_COLOURCHANGE = 1 << 17;
00046 const unsigned int RENDER_TEXTURE = 1 << 18;
00047 const unsigned int RENDER_SCREEN = 1 << 21;
00048 const unsigned int RENDER_OVERRIDE = 1 << 22;
00049 typedef unsigned int RenderStateFlags;
00050
00051 class AABB;
00052 class Matrix4;
00053
00054 template<typename Element> class BasicVector3;
00055 typedef BasicVector3<float> Vector3;
00056
00057 class Shader;
00058
00063 class RendererLight
00064 {
00065 public:
00066 virtual ~RendererLight ()
00067 {
00068 }
00069 virtual Shader* getShader () const = 0;
00070 virtual const Vector3& colour () const = 0;
00071 };
00072
00089 class LightCullable
00090 {
00091 public:
00092 virtual ~LightCullable ()
00093 {
00094 }
00095 virtual void insertLight (const RendererLight& light)
00096 {
00097 }
00098 virtual void clearLights ()
00099 {
00100 }
00101 };
00102
00103 class Renderable;
00104 typedef Callback1<const Renderable&> RenderableCallback;
00105
00106 typedef Callback1<const RendererLight&> RendererLightCallback;
00107
00108 class LightList
00109 {
00110 public:
00111 virtual ~LightList ()
00112 {
00113 }
00114 virtual void evaluateLights () const = 0;
00115 virtual void lightsChanged () const = 0;
00116 virtual void forEachLight (const RendererLightCallback& callback) const = 0;
00117 };
00118
00119 const int c_attr_TexCoord0 = 1;
00120 const int c_attr_Tangent = 3;
00121 const int c_attr_Binormal = 4;
00122
00135 class OpenGLRenderable
00136 {
00137 public:
00138 virtual ~OpenGLRenderable ()
00139 {
00140 }
00145 virtual void render (RenderStateFlags state) const = 0;
00146 };
00147
00148 class Matrix4;
00149 struct qtexture_t;
00150 class ModuleObserver;
00151
00152 #include "math/Vector3.h"
00153
00163 class Shader
00164 {
00165 public:
00166 virtual ~Shader ()
00167 {
00168 }
00169 virtual void addRenderable (const OpenGLRenderable& renderable, const Matrix4& modelview,
00170 const LightList* lights = 0) = 0;
00171 virtual void incrementUsed () = 0;
00172 virtual void decrementUsed () = 0;
00173 virtual void attach (ModuleObserver& observer) = 0;
00174 virtual void detach (ModuleObserver& observer) = 0;
00175 virtual qtexture_t& getTexture () const = 0;
00176 virtual unsigned int getFlags () const = 0;
00177 };
00178
00179 class ShaderCache
00180 {
00181 public:
00182 INTEGER_CONSTANT(Version, 1);
00183 STRING_CONSTANT(Name, "renderstate");
00184
00185 virtual ~ShaderCache ()
00186 {
00187 }
00188
00200 virtual Shader* capture (const std::string& name) = 0;
00201
00209 virtual void release (const std::string& name) = 0;
00210
00212 virtual void render (RenderStateFlags globalstate, const Matrix4& modelview, const Matrix4& projection,
00213 const Vector3& viewer = Vector3(0, 0, 0)) = 0;
00214
00215 virtual void realise () = 0;
00216 virtual void unrealise () = 0;
00217
00218 virtual const LightList& attach (LightCullable& cullable) = 0;
00219 virtual void detach (LightCullable& cullable) = 0;
00220 virtual void changed (LightCullable& cullable) = 0;
00221 virtual void attach (RendererLight& light) = 0;
00222 virtual void detach (RendererLight& light) = 0;
00223 virtual void changed (RendererLight& light) = 0;
00224
00225 virtual void attachRenderable (const Renderable& renderable) = 0;
00226 virtual void detachRenderable (const Renderable& renderable) = 0;
00227 virtual void forEachRenderable (const RenderableCallback& callback) const = 0;
00228 };
00229
00230 #include "modulesystem.h"
00231
00232 template<typename Type>
00233 class GlobalModule;
00234 typedef GlobalModule<ShaderCache> GlobalShaderCacheModule;
00235
00236 template<typename Type>
00237 class GlobalModuleRef;
00238 typedef GlobalModuleRef<ShaderCache> GlobalShaderCacheModuleRef;
00239
00240 inline ShaderCache& GlobalShaderCache ()
00241 {
00242 return GlobalShaderCacheModule::getTable();
00243 }
00244
00245 #endif