2012-04-03 20:44:46 +02:00
|
|
|
/* Copyright (C) 2012 Wildfire Games.
|
2009-04-18 19:00:33 +02:00
|
|
|
* This file is part of 0 A.D.
|
|
|
|
*
|
|
|
|
* 0 A.D. 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.
|
|
|
|
*
|
|
|
|
* 0 A.D. 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 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2009-04-18 19:51:05 +02:00
|
|
|
/*
|
|
|
|
* higher level interface on top of OpenGL to render basic objects:
|
|
|
|
* terrain, models, sprites, particles etc.
|
2007-05-07 18:33:24 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#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"
|
2011-03-26 21:17:21 +01:00
|
|
|
#include "graphics/ShaderProgram.h"
|
2006-09-26 03:44:20 +02:00
|
|
|
#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;
|
2012-04-03 20:44:46 +02:00
|
|
|
class CShaderDefines;
|
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;
|
2010-09-10 23:02:10 +02:00
|
|
|
class CTextureManager;
|
2011-03-26 21:17:21 +01:00
|
|
|
class CShaderManager;
|
2011-04-03 21:15:15 +02:00
|
|
|
class CParticleManager;
|
2012-04-03 20:44:46 +02:00
|
|
|
class CMaterialManager;
|
2004-05-30 02:46:58 +02:00
|
|
|
|
|
|
|
// rendering modes
|
|
|
|
enum ERenderMode { WIREFRAME, SOLID, EDGED_FACES };
|
|
|
|
|
2011-07-13 01:48:05 +02:00
|
|
|
// transparency modes
|
|
|
|
enum ETransparentMode { TRANSPARENT, TRANSPARENT_OPAQUE, TRANSPARENT_BLEND };
|
|
|
|
|
2004-05-30 02:46:58 +02:00
|
|
|
// access to sole renderer object
|
|
|
|
#define g_Renderer CRenderer::GetSingleton()
|
|
|
|
|
2011-07-13 01:48:05 +02:00
|
|
|
struct SScreenRect
|
|
|
|
{
|
|
|
|
GLint x1, y1, x2, y2;
|
|
|
|
};
|
|
|
|
|
2004-05-30 02:46:58 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// 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 Option {
|
|
|
|
OPT_NOVBO,
|
|
|
|
OPT_SHADOWS,
|
2006-05-17 05:53:54 +02:00
|
|
|
OPT_FANCYWATER,
|
2011-07-13 01:48:05 +02:00
|
|
|
OPT_SHADOWPCF
|
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
|
|
|
|
2011-03-26 21:17:21 +01:00
|
|
|
// Use new ARB/GLSL system
|
|
|
|
RP_SHADER
|
2005-10-05 18:42:09 +02:00
|
|
|
};
|
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
|
2011-04-29 14:26:31 +02:00
|
|
|
void Reset() { memset(this, 0, sizeof(*this)); }
|
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;
|
2011-07-13 01:48:05 +02:00
|
|
|
// number of water triangles drawn
|
|
|
|
size_t m_WaterTris;
|
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;
|
2011-07-30 02:56:45 +02:00
|
|
|
// number of overlay triangles drawn
|
|
|
|
size_t m_OverlayTris;
|
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;
|
2011-04-29 14:26:31 +02:00
|
|
|
// number of particles
|
|
|
|
size_t m_Particles;
|
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;
|
|
|
|
bool m_Shadows;
|
2006-05-17 05:53:54 +02:00
|
|
|
bool m_FancyWater;
|
2005-10-25 03:43:07 +02:00
|
|
|
RenderPath m_RenderPath;
|
2011-03-07 01:34:03 +01:00
|
|
|
bool m_ShadowAlphaFix;
|
2011-03-26 21:17:21 +01:00
|
|
|
bool m_ARBProgramShadow;
|
2011-07-13 01:48:05 +02:00
|
|
|
bool m_ShadowPCF;
|
2012-01-29 02:22:22 +01:00
|
|
|
bool m_PreferGLSL;
|
2012-04-10 23:03:22 +02:00
|
|
|
bool m_ForceAlphaTest;
|
2012-04-12 17:43:59 +02:00
|
|
|
bool m_GPUSkinning;
|
2005-10-25 03:43:07 +02:00
|
|
|
} m_Options;
|
|
|
|
|
2006-02-11 19:04:32 +01:00
|
|
|
struct Caps {
|
|
|
|
bool m_VBO;
|
2011-03-26 21:17:21 +01:00
|
|
|
bool m_ARBProgram;
|
|
|
|
bool m_ARBProgramShadow;
|
2006-02-11 19:04:32 +01:00
|
|
|
bool m_VertexShader;
|
2010-03-21 15:18:15 +01:00
|
|
|
bool m_FragmentShader;
|
2011-02-03 02:12:24 +01:00
|
|
|
bool m_Shadows;
|
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
|
2010-06-03 21:07:59 +02:00
|
|
|
bool Open(int width,int height);
|
2004-05-30 02:46:58 +02:00
|
|
|
|
|
|
|
// 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;
|
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
|
|
|
|
2011-03-26 21:17:21 +01:00
|
|
|
// trigger a reload of shaders (when parameters they depend on have changed)
|
|
|
|
void MakeShadersDirty();
|
|
|
|
|
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.
|
|
|
|
*/
|
2011-04-05 22:32:03 +02:00
|
|
|
void RenderScene(Scene& scene);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the scene that is currently being rendered.
|
|
|
|
* Only valid when the renderer is in a RenderScene call.
|
|
|
|
*/
|
|
|
|
Scene& GetScene();
|
2004-05-30 02:46:58 +02:00
|
|
|
|
2011-01-29 17:31:48 +01:00
|
|
|
/**
|
|
|
|
* Render text overlays on top of the scene.
|
|
|
|
* Assumes the caller has set up the GL environment for orthographic rendering
|
|
|
|
* with texturing and blending.
|
|
|
|
*/
|
|
|
|
void RenderTextOverlays();
|
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; }
|
|
|
|
|
2011-01-29 17:31:48 +01:00
|
|
|
// debugging
|
|
|
|
void SetDisplayTerrainPriorities(bool enabled) { m_DisplayTerrainPriorities = enabled; }
|
|
|
|
|
2004-06-07 21:53:58 +02:00
|
|
|
// bind a GL texture object to active unit
|
2011-07-15 15:22:48 +02:00
|
|
|
void BindTexture(int unit, unsigned int tex);
|
2004-05-30 02:46:58 +02:00
|
|
|
|
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
|
2011-04-29 14:26:31 +02:00
|
|
|
Stats& GetStats() { return m_Stats; }
|
2004-05-30 02:46:58 +02:00
|
|
|
|
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; }
|
2012-03-19 22:10:14 +01:00
|
|
|
// replace the current view camera
|
|
|
|
void SetViewCamera(const CCamera& camera) { m_ViewCamera = camera; }
|
|
|
|
|
2006-01-22 20:12:30 +01:00
|
|
|
// return the current cull camera
|
|
|
|
const CCamera& GetCullCamera() const { return m_CullCamera; }
|
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; }
|
|
|
|
|
2010-09-10 23:02:10 +02:00
|
|
|
CTextureManager& GetTextureManager();
|
|
|
|
|
2011-03-26 21:17:21 +01:00
|
|
|
CShaderManager& GetShaderManager();
|
|
|
|
|
2011-04-03 21:15:15 +02:00
|
|
|
CParticleManager& GetParticleManager();
|
|
|
|
|
2012-04-03 20:44:46 +02:00
|
|
|
CMaterialManager& GetMaterialManager();
|
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; }
|
|
|
|
|
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;
|
2011-03-13 20:22:05 +01:00
|
|
|
friend class CDecalRData;
|
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;
|
2012-04-03 20:44:46 +02:00
|
|
|
friend class ShaderModelVertexRenderer;
|
2005-10-30 02:22:22 +02:00
|
|
|
friend class InstancingModelRenderer;
|
2011-03-26 21:17:21 +01:00
|
|
|
friend class ShaderInstancingModelRenderer;
|
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_GetRenderPath(JSContext*);
|
|
|
|
void JSI_SetRenderPath(JSContext* ctx, jsval newval);
|
2006-02-16 00:50:24 +01:00
|
|
|
jsval JSI_GetDepthTextureBits(JSContext*);
|
|
|
|
void JSI_SetDepthTextureBits(JSContext* ctx, jsval newval);
|
2011-03-26 21:17:21 +01:00
|
|
|
jsval JSI_GetShadows(JSContext*);
|
|
|
|
void JSI_SetShadows(JSContext* ctx, jsval newval);
|
2011-03-07 01:34:03 +01:00
|
|
|
jsval JSI_GetShadowAlphaFix(JSContext*);
|
|
|
|
void JSI_SetShadowAlphaFix(JSContext* ctx, jsval newval);
|
2011-07-13 01:48:05 +02:00
|
|
|
jsval JSI_GetShadowPCF(JSContext*);
|
|
|
|
void JSI_SetShadowPCF(JSContext* ctx, jsval newval);
|
2012-01-29 02:22:22 +01:00
|
|
|
jsval JSI_GetPreferGLSL(JSContext*);
|
|
|
|
void JSI_SetPreferGLSL(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);
|
2010-01-09 20:20:14 +01:00
|
|
|
void Submit(SOverlayLine* overlay);
|
2011-07-30 02:56:45 +02:00
|
|
|
void Submit(SOverlayTexturedLine* overlay);
|
2010-10-02 14:41:29 +02:00
|
|
|
void Submit(SOverlaySprite* overlay);
|
2011-03-13 20:22:05 +01:00
|
|
|
void Submit(CModelDecal* decal);
|
2011-04-03 21:15:15 +02:00
|
|
|
void Submit(CParticleEmitter* emitter);
|
2006-09-24 13:25:11 +02:00
|
|
|
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
|
2012-04-03 20:44:46 +02:00
|
|
|
void RenderPatches(const CShaderDefines& context, const CFrustum* frustum = 0);
|
2004-05-30 02:46:58 +02:00
|
|
|
|
|
|
|
// model rendering stuff
|
2012-04-03 20:44:46 +02:00
|
|
|
void RenderModels(const CShaderDefines& context, const CFrustum* frustum = 0);
|
|
|
|
void RenderTransparentModels(const CShaderDefines& context, ETransparentMode transparentMode, const CFrustum* frustum = 0);
|
2004-05-30 02:46:58 +02:00
|
|
|
|
2012-04-03 20:44:46 +02:00
|
|
|
void RenderSilhouettes(const CShaderDefines& context);
|
2011-03-18 17:57:54 +01:00
|
|
|
|
2011-04-03 21:15:15 +02:00
|
|
|
void RenderParticles();
|
|
|
|
|
2004-05-30 02:46:58 +02:00
|
|
|
// shadow rendering stuff
|
2012-04-03 20:44:46 +02:00
|
|
|
void RenderShadowMap(const CShaderDefines& context);
|
2004-05-30 02:46:58 +02:00
|
|
|
|
2006-05-28 04:13:32 +02:00
|
|
|
// render water reflection and refraction textures
|
2012-04-03 20:44:46 +02:00
|
|
|
SScreenRect RenderReflections(const CShaderDefines& context, const CBoundingBoxAligned& scissor);
|
|
|
|
SScreenRect RenderRefractions(const CShaderDefines& context, const CBoundingBoxAligned& scissor);
|
2006-05-28 04:13:32 +02:00
|
|
|
|
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
|
2011-07-13 01:48:05 +02:00
|
|
|
void SetObliqueFrustumClipping(const CVector4D& clipPlane);
|
2006-05-28 04:13:32 +02:00
|
|
|
|
2011-03-26 21:17:21 +01:00
|
|
|
void ReloadShaders();
|
|
|
|
|
2011-01-29 17:31:48 +01:00
|
|
|
// hotloading
|
2011-05-03 14:38:42 +02:00
|
|
|
static Status ReloadChangedFileCB(void* param, const VfsPath& path);
|
2011-01-29 17:31:48 +01:00
|
|
|
|
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
|
2010-06-03 21:07:59 +02:00
|
|
|
int m_Height;
|
2004-05-30 02:46:58 +02:00
|
|
|
// 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;
|
|
|
|
|
2011-04-05 22:32:03 +02:00
|
|
|
// only valid inside a call to RenderScene
|
|
|
|
Scene* m_CurrentScene;
|
|
|
|
|
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;
|
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;
|
|
|
|
|
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;
|
|
|
|
|
2011-01-29 17:31:48 +01:00
|
|
|
/**
|
|
|
|
* Enable rendering of terrain tile priority text overlay, for debugging.
|
|
|
|
*/
|
|
|
|
bool m_DisplayTerrainPriorities;
|
|
|
|
|
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;
|
2004-05-30 02:46:58 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|