2007-05-07 18:33:24 +02:00
|
|
|
/**
|
|
|
|
* =========================================================================
|
|
|
|
* File : Renderer.h
|
|
|
|
* Project : 0 A.D.
|
|
|
|
* Description : higher level interface on top of OpenGL to render basic
|
|
|
|
* objects: terrain, models, sprites, particles etc.
|
|
|
|
* =========================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef INCLUDED_RENDERER
|
|
|
|
#define INCLUDED_RENDERER
|
2004-05-30 02:46:58 +02:00
|
|
|
|
2006-06-02 04:10:27 +02:00
|
|
|
#include "graphics/Camera.h"
|
2008-07-19 02:36:42 +02:00
|
|
|
#include "graphics/SColor.h"
|
2006-09-26 03:44:20 +02:00
|
|
|
#include "lib/ogl.h"
|
|
|
|
#include "lib/res/handle.h"
|
2006-06-02 04:10:27 +02:00
|
|
|
#include "ps/Singleton.h"
|
2005-10-10 16:15:28 +02:00
|
|
|
#include "scripting/ScriptableObject.h"
|
|
|
|
|
2006-09-24 13:25:11 +02:00
|
|
|
#include "renderer/Scene.h"
|
2005-10-25 03:43:07 +02:00
|
|
|
|
2004-05-30 02:46:58 +02:00
|
|
|
// necessary declarations
|
|
|
|
class CPatch;
|
|
|
|
class CMaterial;
|
2005-10-25 03:43:07 +02:00
|
|
|
class CModel;
|
2004-05-30 02:46:58 +02:00
|
|
|
class CLightEnv;
|
|
|
|
class CTexture;
|
2005-10-25 03:43:07 +02:00
|
|
|
|
2005-10-05 18:42:09 +02:00
|
|
|
class RenderPathVertexShader;
|
2006-01-07 02:04:26 +01:00
|
|
|
class WaterManager;
|
2006-05-16 06:41:37 +02:00
|
|
|
class SkyManager;
|
2004-05-30 02:46:58 +02:00
|
|
|
|
|
|
|
// rendering modes
|
|
|
|
enum ERenderMode { WIREFRAME, SOLID, EDGED_FACES };
|
|
|
|
|
|
|
|
// stream flags
|
2005-10-02 23:11:11 +02:00
|
|
|
#define STREAM_POS 0x01
|
|
|
|
#define STREAM_NORMAL 0x02
|
|
|
|
#define STREAM_COLOR 0x04
|
|
|
|
#define STREAM_UV0 0x08
|
|
|
|
#define STREAM_UV1 0x10
|
|
|
|
#define STREAM_UV2 0x20
|
|
|
|
#define STREAM_UV3 0x40
|
2004-05-30 02:46:58 +02:00
|
|
|
#define STREAM_POSTOUV0 0x80
|
2006-03-26 01:54:20 +01:00
|
|
|
#define STREAM_TEXGENTOUV1 0x100
|
2004-05-30 02:46:58 +02:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// SVertex3D: simple 3D vertex declaration
|
|
|
|
struct SVertex3D
|
|
|
|
{
|
|
|
|
float m_Position[3];
|
|
|
|
float m_TexCoords[2];
|
|
|
|
unsigned int m_Color;
|
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// SVertex2D: simple 2D vertex declaration
|
|
|
|
struct SVertex2D
|
|
|
|
{
|
|
|
|
float m_Position[2];
|
|
|
|
float m_TexCoords[2];
|
|
|
|
unsigned int m_Color;
|
|
|
|
};
|
|
|
|
|
|
|
|
// access to sole renderer object
|
|
|
|
#define g_Renderer CRenderer::GetSingleton()
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// CRenderer: base renderer class - primary interface to the rendering engine
|
2005-11-19 17:15:34 +01:00
|
|
|
struct CRendererInternals;
|
|
|
|
|
2006-09-24 13:25:11 +02:00
|
|
|
class CRenderer :
|
|
|
|
public Singleton<CRenderer>,
|
|
|
|
public CJSObject<CRenderer>,
|
|
|
|
private SceneCollector
|
2004-05-30 02:46:58 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
// various enumerations and renderer related constants
|
|
|
|
enum { NumAlphaMaps=14 };
|
|
|
|
enum { MaxTextureUnits=16 };
|
|
|
|
enum Option {
|
|
|
|
OPT_NOVBO,
|
2006-03-26 19:36:33 +02:00
|
|
|
OPT_NOFRAMEBUFFEROBJECT,
|
2004-05-30 02:46:58 +02:00
|
|
|
OPT_SHADOWS,
|
2006-05-17 05:53:54 +02:00
|
|
|
OPT_FANCYWATER,
|
2004-10-21 17:04:19 +02:00
|
|
|
OPT_LODBIAS
|
2004-05-30 02:46:58 +02:00
|
|
|
};
|
2006-01-07 02:04:26 +01:00
|
|
|
|
2005-10-05 18:42:09 +02:00
|
|
|
enum RenderPath {
|
|
|
|
// If no rendering path is configured explicitly, the renderer
|
|
|
|
// will choose the path when Open() is called.
|
|
|
|
RP_DEFAULT,
|
2006-01-07 02:04:26 +01:00
|
|
|
|
2005-10-05 18:42:09 +02:00
|
|
|
// Classic fixed function.
|
|
|
|
RP_FIXED,
|
2006-01-07 02:04:26 +01:00
|
|
|
|
2005-10-05 18:42:09 +02:00
|
|
|
// Use (GL 2.0) vertex shaders for T&L when possible.
|
|
|
|
RP_VERTEXSHADER
|
|
|
|
};
|
2006-01-07 02:04:26 +01:00
|
|
|
|
2004-05-30 02:46:58 +02:00
|
|
|
// stats class - per frame counts of number of draw calls, poly counts etc
|
|
|
|
struct Stats {
|
|
|
|
// set all stats to zero
|
|
|
|
void Reset() { memset(this,0,sizeof(*this)); }
|
|
|
|
// add given stats to this stats
|
|
|
|
Stats& operator+=(const Stats& rhs) {
|
|
|
|
m_Counter++;
|
|
|
|
m_DrawCalls+=rhs.m_DrawCalls;
|
|
|
|
m_TerrainTris+=rhs.m_TerrainTris;
|
|
|
|
m_ModelTris+=rhs.m_ModelTris;
|
|
|
|
m_BlendSplats+=rhs.m_BlendSplats;
|
|
|
|
return *this;
|
|
|
|
}
|
2006-01-07 02:04:26 +01:00
|
|
|
// count of the number of stats added together
|
2005-08-09 17:55:44 +02:00
|
|
|
size_t m_Counter;
|
2004-05-30 02:46:58 +02:00
|
|
|
// number of draw calls per frame - total DrawElements + Begin/End immediate mode loops
|
2005-08-09 17:55:44 +02:00
|
|
|
size_t m_DrawCalls;
|
2004-05-30 02:46:58 +02:00
|
|
|
// number of terrain triangles drawn
|
2005-08-09 17:55:44 +02:00
|
|
|
size_t m_TerrainTris;
|
2004-05-30 02:46:58 +02:00
|
|
|
// number of (non-transparent) model triangles drawn
|
2005-08-09 17:55:44 +02:00
|
|
|
size_t m_ModelTris;
|
2004-05-30 02:46:58 +02:00
|
|
|
// number of splat passes for alphamapping
|
2005-08-09 17:55:44 +02:00
|
|
|
size_t m_BlendSplats;
|
2004-05-30 02:46:58 +02:00
|
|
|
};
|
|
|
|
|
2006-01-07 02:04:26 +01:00
|
|
|
// renderer options
|
2005-10-25 03:43:07 +02:00
|
|
|
struct Options {
|
|
|
|
bool m_NoVBO;
|
2006-03-26 19:36:33 +02:00
|
|
|
bool m_NoFramebufferObject;
|
2005-10-25 03:43:07 +02:00
|
|
|
bool m_Shadows;
|
2006-05-17 05:53:54 +02:00
|
|
|
bool m_FancyWater;
|
2005-10-25 03:43:07 +02:00
|
|
|
float m_LodBias;
|
|
|
|
RenderPath m_RenderPath;
|
|
|
|
} m_Options;
|
|
|
|
|
2006-02-11 19:04:32 +01:00
|
|
|
struct Caps {
|
|
|
|
bool m_VBO;
|
|
|
|
bool m_TextureBorderClamp;
|
|
|
|
bool m_GenerateMipmaps;
|
|
|
|
bool m_VertexShader;
|
|
|
|
bool m_DepthTextureShadows;
|
2006-03-26 19:36:33 +02:00
|
|
|
bool m_FramebufferObject;
|
2006-02-11 19:04:32 +01:00
|
|
|
};
|
|
|
|
|
2004-05-30 02:46:58 +02:00
|
|
|
public:
|
|
|
|
// constructor, destructor
|
|
|
|
CRenderer();
|
|
|
|
~CRenderer();
|
|
|
|
|
|
|
|
// open up the renderer: performs any necessary initialisation
|
|
|
|
bool Open(int width,int height,int depth);
|
|
|
|
|
|
|
|
// resize renderer view
|
|
|
|
void Resize(int width,int height);
|
2006-01-07 02:04:26 +01:00
|
|
|
|
|
|
|
// set/get boolean renderer option
|
2004-05-30 02:46:58 +02:00
|
|
|
void SetOptionBool(enum Option opt,bool value);
|
|
|
|
bool GetOptionBool(enum Option opt) const;
|
2006-01-07 02:04:26 +01:00
|
|
|
// set/get RGBA color renderer option
|
2006-09-26 03:44:20 +02:00
|
|
|
// void SetOptionColor(enum Option opt,const RGBAColor& value);
|
2004-10-21 17:04:19 +02:00
|
|
|
void SetOptionFloat(enum Option opt, float val);
|
2006-09-26 03:44:20 +02:00
|
|
|
// const RGBAColor& GetOptionColor(enum Option opt) const;
|
2005-10-05 18:42:09 +02:00
|
|
|
void SetRenderPath(RenderPath rp);
|
|
|
|
RenderPath GetRenderPath() const { return m_Options.m_RenderPath; }
|
|
|
|
static CStr GetRenderPathName(RenderPath rp);
|
2006-07-20 16:37:58 +02:00
|
|
|
static RenderPath GetRenderPathByName(const CStr& name);
|
2006-01-07 02:04:26 +01:00
|
|
|
|
2004-05-30 02:46:58 +02:00
|
|
|
// return view width
|
|
|
|
int GetWidth() const { return m_Width; }
|
|
|
|
// return view height
|
|
|
|
int GetHeight() const { return m_Height; }
|
|
|
|
// return view aspect ratio
|
|
|
|
float GetAspect() const { return float(m_Width)/float(m_Height); }
|
|
|
|
|
|
|
|
// signal frame start
|
|
|
|
void BeginFrame();
|
2006-01-22 20:12:30 +01:00
|
|
|
// signal frame end
|
2004-05-30 02:46:58 +02:00
|
|
|
void EndFrame();
|
|
|
|
|
|
|
|
// set color used to clear screen in BeginFrame()
|
2008-07-19 02:36:42 +02:00
|
|
|
void SetClearColor(SColor4ub color);
|
2004-05-30 02:46:58 +02:00
|
|
|
|
|
|
|
// return current frame counter
|
|
|
|
int GetFrameCounter() const { return m_FrameCounter; }
|
|
|
|
|
2006-01-22 20:12:30 +01:00
|
|
|
/**
|
2006-09-24 13:25:11 +02:00
|
|
|
* Set up the camera used for rendering the next scene; this includes
|
2006-01-22 20:12:30 +01:00
|
|
|
* setting OpenGL state like viewport, projection and modelview matrices.
|
|
|
|
*
|
|
|
|
* @param viewCamera this camera determines the eye position for rendering
|
2006-09-14 22:06:21 +02:00
|
|
|
* @param cullCamera this camera determines the frustum for culling in the renderer and
|
2006-01-22 20:12:30 +01:00
|
|
|
* for shadow calculations
|
|
|
|
*/
|
2006-09-14 22:06:21 +02:00
|
|
|
void SetSceneCamera(const CCamera& viewCamera, const CCamera& cullCamera);
|
2004-05-30 02:46:58 +02:00
|
|
|
|
2004-08-05 15:07:51 +02:00
|
|
|
// set the viewport
|
|
|
|
void SetViewport(const SViewPort &);
|
|
|
|
|
2006-09-24 13:25:11 +02:00
|
|
|
/**
|
|
|
|
* Render the given scene immediately.
|
|
|
|
* @param scene a Scene object describing what should be rendered.
|
|
|
|
*/
|
|
|
|
void RenderScene(Scene* scene);
|
2004-05-30 02:46:58 +02:00
|
|
|
|
2006-01-07 02:04:26 +01:00
|
|
|
// basic primitive rendering operations in 2 and 3D; handy for debugging stuff, but also useful in
|
|
|
|
// editor tools (eg for highlighting specific terrain patches)
|
|
|
|
// note:
|
2004-05-30 02:46:58 +02:00
|
|
|
// * all 3D vertices specified in world space
|
|
|
|
// * primitive operations rendered immediatedly, never batched
|
|
|
|
// * primitives rendered in current material (set via SetMaterial)
|
2006-01-22 20:12:30 +01:00
|
|
|
// void RenderLine(const SVertex2D* vertices);
|
|
|
|
// void RenderLineLoop(int len,const SVertex2D* vertices);
|
|
|
|
// void RenderTri(const SVertex2D* vertices);
|
|
|
|
// void RenderQuad(const SVertex2D* vertices);
|
|
|
|
// void RenderLine(const SVertex3D* vertices);
|
|
|
|
// void RenderLineLoop(int len,const SVertex3D* vertices);
|
|
|
|
// void RenderTri(const SVertex3D* vertices);
|
|
|
|
// void RenderQuad(const SVertex3D* vertices);
|
2004-05-30 02:46:58 +02:00
|
|
|
|
|
|
|
// set the current lighting environment; (note: the passed pointer is just copied to a variable within the renderer,
|
|
|
|
// so the lightenv passed must be scoped such that it is not destructed until after the renderer is no longer rendering)
|
|
|
|
void SetLightEnv(CLightEnv* lightenv) {
|
|
|
|
m_LightEnv=lightenv;
|
|
|
|
}
|
|
|
|
|
|
|
|
// set the mode to render subsequent terrain patches
|
|
|
|
void SetTerrainRenderMode(ERenderMode mode) { m_TerrainRenderMode=mode; }
|
|
|
|
// get the mode to render subsequent terrain patches
|
|
|
|
ERenderMode GetTerrainRenderMode() const { return m_TerrainRenderMode; }
|
|
|
|
|
|
|
|
// set the mode to render subsequent models
|
|
|
|
void SetModelRenderMode(ERenderMode mode) { m_ModelRenderMode=mode; }
|
|
|
|
// get the mode to render subsequent models
|
|
|
|
ERenderMode GetModelRenderMode() const { return m_ModelRenderMode; }
|
|
|
|
|
|
|
|
// try and load the given texture
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
bool LoadTexture(CTexture* texture,int wrapflags);
|
2004-06-11 00:24:03 +02:00
|
|
|
// set the given unit to reference the given texture; pass a null texture to disable texturing on any unit;
|
2004-06-07 21:53:58 +02:00
|
|
|
// active texture unit always set to given unit on exit
|
2004-05-30 02:46:58 +02:00
|
|
|
void SetTexture(int unit,CTexture* texture);
|
2004-06-07 21:53:58 +02:00
|
|
|
// bind a GL texture object to active unit
|
2004-05-30 02:46:58 +02:00
|
|
|
void BindTexture(int unit,GLuint tex);
|
|
|
|
// query transparency of given texture
|
|
|
|
bool IsTextureTransparent(CTexture* texture);
|
|
|
|
|
2005-10-12 06:16:41 +02:00
|
|
|
// load the default set of alphamaps.
|
|
|
|
// return a negative error code if anything along the way fails.
|
|
|
|
// called via delay-load mechanism.
|
2005-05-03 23:36:57 +02:00
|
|
|
int LoadAlphaMaps();
|
2004-12-16 13:41:54 +01:00
|
|
|
void UnloadAlphaMaps();
|
|
|
|
|
2004-05-30 02:46:58 +02:00
|
|
|
// return stats accumulated for current frame
|
|
|
|
const Stats& GetStats() { return m_Stats; }
|
|
|
|
|
2005-10-05 18:42:09 +02:00
|
|
|
// return the current light environment
|
|
|
|
const CLightEnv &GetLightEnv() { return *m_LightEnv; }
|
2006-01-07 02:04:26 +01:00
|
|
|
|
2006-01-22 20:12:30 +01:00
|
|
|
// return the current view camera
|
|
|
|
const CCamera& GetViewCamera() const { return m_ViewCamera; }
|
|
|
|
// return the current cull camera
|
|
|
|
const CCamera& GetCullCamera() const { return m_CullCamera; }
|
2006-01-07 02:04:26 +01:00
|
|
|
|
2006-05-28 04:13:32 +02:00
|
|
|
// get the current OpenGL model-view-projection matrix into the given float[]
|
|
|
|
CMatrix3D GetModelViewProjectionMatrix();
|
|
|
|
|
2006-01-07 02:04:26 +01:00
|
|
|
/**
|
|
|
|
* GetWaterManager: Return the renderer's water manager.
|
|
|
|
*
|
|
|
|
* @return the WaterManager object used by the renderer
|
|
|
|
*/
|
|
|
|
WaterManager* GetWaterManager() { return m_WaterManager; }
|
|
|
|
|
2006-05-16 06:41:37 +02:00
|
|
|
/**
|
2006-06-02 03:01:39 +02:00
|
|
|
* GetSkyManager: Return the renderer's sky manager.
|
2006-05-16 06:41:37 +02:00
|
|
|
*
|
|
|
|
* @return the SkyManager object used by the renderer
|
|
|
|
*/
|
|
|
|
SkyManager* GetSkyManager() { return m_SkyManager; }
|
|
|
|
|
2005-10-25 03:43:07 +02:00
|
|
|
/**
|
|
|
|
* SetFastPlayerColor: Tell the renderer which path to take for
|
|
|
|
* player colored models. Both paths should provide the same visual
|
|
|
|
* quality, however the slow path runs on older hardware using multi-pass.
|
|
|
|
*
|
|
|
|
* @param fast true if the fast path should be used from now on. If fast
|
|
|
|
* is true but the OpenGL implementation does not support it, a warning
|
|
|
|
* is printed and the slow path is used instead.
|
|
|
|
*/
|
|
|
|
void SetFastPlayerColor(bool fast);
|
2006-01-07 02:04:26 +01:00
|
|
|
|
2006-02-11 19:04:32 +01:00
|
|
|
/**
|
|
|
|
* GetCapabilities: Return which OpenGL capabilities are available and enabled.
|
|
|
|
*
|
|
|
|
* @return capabilities structure
|
|
|
|
*/
|
|
|
|
const Caps& GetCapabilities() const { return m_Caps; }
|
|
|
|
|
2006-02-16 00:50:24 +01:00
|
|
|
bool GetDisableCopyShadow() const { return m_DisableCopyShadow; }
|
|
|
|
|
2008-04-06 16:03:23 +02:00
|
|
|
static void ScriptingInit();
|
|
|
|
|
2004-05-30 02:46:58 +02:00
|
|
|
protected:
|
2005-11-19 17:37:50 +01:00
|
|
|
friend struct CRendererInternals;
|
2004-06-11 00:24:03 +02:00
|
|
|
friend class CVertexBuffer;
|
2004-05-30 02:46:58 +02:00
|
|
|
friend class CPatchRData;
|
2005-10-25 03:43:07 +02:00
|
|
|
friend class FixedFunctionModelRenderer;
|
|
|
|
friend class ModelRenderer;
|
2005-11-06 00:15:23 +01:00
|
|
|
friend class PolygonSortModelRenderer;
|
|
|
|
friend class SortModelRenderer;
|
2005-10-05 18:42:09 +02:00
|
|
|
friend class RenderPathVertexShader;
|
2005-10-25 03:43:07 +02:00
|
|
|
friend class HWLightingModelRenderer;
|
2005-10-30 02:22:22 +02:00
|
|
|
friend class InstancingModelRenderer;
|
2006-01-07 02:04:26 +01:00
|
|
|
friend class TerrainRenderer;
|
2004-05-30 02:46:58 +02:00
|
|
|
|
2005-10-10 16:15:28 +02:00
|
|
|
// scripting
|
2006-09-23 14:48:06 +02:00
|
|
|
// TODO: Perhaps we could have a version of AddLocalProperty for function-driven
|
|
|
|
// properties? Then we could hide these function in the private implementation class.
|
2005-10-25 03:43:07 +02:00
|
|
|
jsval JSI_GetFastPlayerColor(JSContext*);
|
|
|
|
void JSI_SetFastPlayerColor(JSContext* ctx, jsval newval);
|
|
|
|
jsval JSI_GetRenderPath(JSContext*);
|
|
|
|
void JSI_SetRenderPath(JSContext* ctx, jsval newval);
|
2006-02-11 19:04:32 +01:00
|
|
|
jsval JSI_GetUseDepthTexture(JSContext*);
|
|
|
|
void JSI_SetUseDepthTexture(JSContext* ctx, jsval newval);
|
2006-02-16 00:50:24 +01:00
|
|
|
jsval JSI_GetDepthTextureBits(JSContext*);
|
|
|
|
void JSI_SetDepthTextureBits(JSContext* ctx, jsval newval);
|
2006-05-17 04:24:17 +02:00
|
|
|
jsval JSI_GetSky(JSContext*);
|
|
|
|
void JSI_SetSky(JSContext* ctx, jsval newval);
|
2006-01-07 02:04:26 +01:00
|
|
|
|
2006-09-24 13:25:11 +02:00
|
|
|
//BEGIN: Implementation of SceneCollector
|
|
|
|
void Submit(CPatch* patch);
|
|
|
|
void SubmitNonRecursive(CModel* model);
|
|
|
|
//END: Implementation of SceneCollector
|
|
|
|
|
|
|
|
// render any batched objects
|
|
|
|
void RenderSubmissions();
|
|
|
|
|
2004-05-30 02:46:58 +02:00
|
|
|
// patch rendering stuff
|
|
|
|
void RenderPatches();
|
|
|
|
|
|
|
|
// model rendering stuff
|
|
|
|
void RenderModels();
|
2005-10-25 03:43:07 +02:00
|
|
|
void RenderTransparentModels();
|
2004-05-30 02:46:58 +02:00
|
|
|
|
|
|
|
// shadow rendering stuff
|
|
|
|
void RenderShadowMap();
|
|
|
|
|
2006-05-28 04:13:32 +02:00
|
|
|
// render water reflection and refraction textures
|
|
|
|
void RenderReflections();
|
|
|
|
void RenderRefractions();
|
|
|
|
|
2006-01-29 18:34:45 +01:00
|
|
|
// debugging
|
|
|
|
void DisplayFrustum();
|
|
|
|
|
2006-05-28 04:13:32 +02:00
|
|
|
// enable oblique frustum clipping with the given clip plane
|
|
|
|
void SetObliqueFrustumClipping(const CVector4D& clipPlane, int sign);
|
|
|
|
|
2004-05-30 02:46:58 +02:00
|
|
|
// RENDERER DATA:
|
2005-11-19 17:15:34 +01:00
|
|
|
/// Private data that is not needed by inline functions
|
|
|
|
CRendererInternals* m;
|
2004-05-30 02:46:58 +02:00
|
|
|
// view width
|
|
|
|
int m_Width;
|
|
|
|
// view height
|
|
|
|
int m_Height;
|
|
|
|
// view depth (bpp)
|
|
|
|
int m_Depth;
|
|
|
|
// frame counter
|
|
|
|
int m_FrameCounter;
|
|
|
|
// current terrain rendering mode
|
|
|
|
ERenderMode m_TerrainRenderMode;
|
|
|
|
// current model rendering mode
|
|
|
|
ERenderMode m_ModelRenderMode;
|
2006-01-22 20:12:30 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* m_ViewCamera: determines the eye position for rendering
|
|
|
|
*
|
|
|
|
* @see CGameView::m_ViewCamera
|
|
|
|
*/
|
|
|
|
CCamera m_ViewCamera;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* m_CullCamera: determines the frustum for culling and shadowmap calculations
|
|
|
|
*
|
|
|
|
* @see CGameView::m_ViewCamera
|
|
|
|
*/
|
|
|
|
CCamera m_CullCamera;
|
|
|
|
|
2004-05-30 02:46:58 +02:00
|
|
|
// color used to clear screen in BeginFrame
|
|
|
|
float m_ClearColor[4];
|
|
|
|
// current lighting setup
|
|
|
|
CLightEnv* m_LightEnv;
|
2005-09-20 00:48:20 +02:00
|
|
|
// ogl_tex handle of composite alpha map (all the alpha maps packed into one texture)
|
|
|
|
Handle m_hCompositeAlphaMap;
|
2004-05-30 02:46:58 +02:00
|
|
|
// coordinates of each (untransformed) alpha map within the packed texture
|
|
|
|
struct {
|
|
|
|
float u0,u1,v0,v1;
|
|
|
|
} m_AlphaMapCoords[NumAlphaMaps];
|
|
|
|
// card capabilities
|
2006-02-11 19:04:32 +01:00
|
|
|
Caps m_Caps;
|
2004-05-30 02:46:58 +02:00
|
|
|
// build card cap bits
|
|
|
|
void EnumCaps();
|
|
|
|
// per-frame renderer stats
|
2004-06-11 00:24:03 +02:00
|
|
|
Stats m_Stats;
|
2004-05-30 02:46:58 +02:00
|
|
|
// active textures on each unit
|
|
|
|
GLuint m_ActiveTextures[MaxTextureUnits];
|
2006-01-07 02:04:26 +01:00
|
|
|
|
2005-10-05 18:42:09 +02:00
|
|
|
// Additional state that is only available when the vertex shader
|
|
|
|
// render path is used (according to m_Options.m_RenderPath)
|
|
|
|
RenderPathVertexShader* m_VertexShader;
|
2005-10-10 16:15:28 +02:00
|
|
|
|
2005-10-25 04:22:22 +02:00
|
|
|
/// If false, use a multipass fallback for player colors.
|
2005-10-12 03:07:01 +02:00
|
|
|
bool m_FastPlayerColor;
|
2006-01-07 02:04:26 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* m_WaterManager: the WaterManager object used for water textures and settings
|
|
|
|
* (e.g. water color, water height)
|
|
|
|
*/
|
|
|
|
WaterManager* m_WaterManager;
|
|
|
|
|
2006-05-16 06:41:37 +02:00
|
|
|
/**
|
|
|
|
* m_SkyManager: the SkyManager object used for sky textures and settings
|
|
|
|
*/
|
|
|
|
SkyManager* m_SkyManager;
|
|
|
|
|
2005-10-25 04:22:22 +02:00
|
|
|
/**
|
|
|
|
* m_SortAllTransparent: If true, all transparent models are
|
|
|
|
* rendered using the TransparencyRenderer which performs sorting.
|
|
|
|
*
|
|
|
|
* Otherwise, transparent models are rendered using the faster
|
|
|
|
* batching renderer when possible.
|
|
|
|
*/
|
|
|
|
bool m_SortAllTransparent;
|
2006-01-07 02:04:26 +01:00
|
|
|
|
2006-01-22 20:12:30 +01:00
|
|
|
/**
|
|
|
|
* m_DisplayFrustum: Render the cull frustum and other data that may be interesting
|
|
|
|
* to evaluate culling and shadow map calculations
|
|
|
|
*
|
|
|
|
* Can be controlled from JS via renderer.displayFrustum
|
|
|
|
*/
|
|
|
|
bool m_DisplayFrustum;
|
|
|
|
|
2006-02-16 00:50:24 +01:00
|
|
|
/**
|
|
|
|
* m_DisableCopyShadow: For debugging purpose:
|
|
|
|
* Disable copying of shadow data into the shadow texture (when EXT_fbo is not available)
|
|
|
|
*/
|
|
|
|
bool m_DisableCopyShadow;
|
|
|
|
|
2006-02-13 15:18:20 +01:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* m_ShadowZBias: Z bias used when rendering shadows into a depth texture.
|
|
|
|
* This can be used to control shadowing artifacts.
|
|
|
|
*
|
|
|
|
* Can be accessed via JS as renderer.shadowZBias
|
|
|
|
* ShadowMap uses this for matrix calculation.
|
|
|
|
*/
|
|
|
|
float m_ShadowZBias;
|
2006-09-23 18:04:54 +02:00
|
|
|
|
2007-02-09 18:04:55 +01:00
|
|
|
/**
|
|
|
|
* m_ShadowMapSize: Size of shadow map, or 0 for default. Typically slow but useful
|
|
|
|
* for high-quality rendering. Changes don't take effect until the shadow map
|
|
|
|
* is regenerated.
|
|
|
|
*
|
|
|
|
* Can be accessed via JS as renderer.shadowMapSize
|
|
|
|
*/
|
|
|
|
int m_ShadowMapSize;
|
|
|
|
|
2006-09-23 18:04:54 +02:00
|
|
|
/**
|
|
|
|
* m_SkipSubmit: Disable the actual submission of rendering commands to OpenGL.
|
|
|
|
* All state setup is still performed as usual.
|
|
|
|
*
|
|
|
|
* Can be accessed via JS as renderer.skipSubmit
|
|
|
|
*/
|
|
|
|
bool m_SkipSubmit;
|
2006-12-05 03:08:52 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* m_RenderTerritories:
|
|
|
|
* Turn territory boundary rendering on or off.
|
|
|
|
*/
|
|
|
|
bool m_RenderTerritories;
|
2004-05-30 02:46:58 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|