23 #include "precompiled.h"
29 #include <boost/algorithm/string.hpp>
94 const std::vector<ProfileColumn>&
GetColumns();
138 return "Renderer statistics";
159 return "# draw calls";
160 sprintf_s(buf,
sizeof(buf),
"%lu", (
unsigned long)
Stats.m_DrawCalls);
165 return "# terrain tris";
166 sprintf_s(buf,
sizeof(buf),
"%lu", (
unsigned long)
Stats.m_TerrainTris);
171 return "# water tris";
172 sprintf_s(buf,
sizeof(buf),
"%lu", (
unsigned long)
Stats.m_WaterTris);
177 return "# model tris";
178 sprintf_s(buf,
sizeof(buf),
"%lu", (
unsigned long)
Stats.m_ModelTris);
183 return "# overlay tris";
184 sprintf_s(buf,
sizeof(buf),
"%lu", (
unsigned long)
Stats.m_OverlayTris);
189 return "# blend splats";
190 sprintf_s(buf,
sizeof(buf),
"%lu", (
unsigned long)
Stats.m_BlendSplats);
195 return "# particles";
196 sprintf_s(buf,
sizeof(buf),
"%lu", (
unsigned long)
Stats.m_Particles);
201 return "VB bytes reserved";
207 return "VB bytes allocated";
213 return "shader effects loaded";
214 sprintf_s(buf,
sizeof(buf),
"%lu", (
unsigned long)
g_Renderer.GetShaderManager().GetNumEffectsLoaded());
334 #warning TODO: fix CRenderer camera handling for GLES (do not use global matrixes)
336 glMatrixMode(GL_PROJECTION);
337 glLoadMatrixf(&proj.
_11);
339 glMatrixMode(GL_MODELVIEW);
340 glLoadMatrixf(&view.
_11);
355 contextSkinned.
Add(str_USE_INSTANCING, str_1);
356 contextSkinned.
Add(str_USE_GPU_SKINNING, str_1);
363 contextUnskinned.
Add(str_USE_INSTANCING, str_1);
376 contextSkinned.
Add(str_USE_INSTANCING, str_1);
377 contextSkinned.
Add(str_USE_GPU_SKINNING, str_1);
384 contextUnskinned.
Add(str_USE_INSTANCING, str_1);
454 CStr skystring =
"0 0 0";
511 if (0 ==
ogl_HaveExtensions(0,
"GL_ARB_vertex_program",
"GL_ARB_fragment_program", NULL))
518 if (0 ==
ogl_HaveExtensions(0,
"GL_ARB_shader_objects",
"GL_ARB_shading_language_100", NULL))
529 if (0 ==
ogl_HaveExtensions(0,
"GL_ARB_shadow",
"GL_ARB_depth_texture",
"GL_EXT_framebuffer_object", NULL))
542 defines.
Add(str_SYS_HAS_ARB, str_1);
545 defines.
Add(str_SYS_HAS_GLSL, str_1);
548 defines.
Add(str_SYS_PREFER_GLSL, str_1);
621 glPixelStorei(GL_PACK_ALIGNMENT,1);
622 glPixelStorei(GL_UNPACK_ALIGNMENT,1);
625 glDepthFunc(GL_LEQUAL);
626 glEnable(GL_DEPTH_TEST);
629 glEnable(GL_CULL_FACE);
632 glGetIntegerv(GL_DEPTH_BITS,&bits);
633 LOGMESSAGE(L
"CRenderer::Open: depth bits %d",bits);
634 glGetIntegerv(GL_STENCIL_BITS,&bits);
635 LOGMESSAGE(L
"CRenderer::Open: stencil bits %d",bits);
636 glGetIntegerv(GL_ALPHA_BITS,&bits);
637 LOGMESSAGE(L
"CRenderer::Open: alpha bits %d",bits);
719 debug_warn(L
"CRenderer::SetOptionBool: unknown option");
758 debug_warn(L
"CRenderer::GetOptionBool: unknown option");
791 LOGWARNING(L
"Falling back to fixed function\n");
813 default:
return "(invalid)";
821 if (name ==
"shader")
823 if (name ==
"default")
826 LOGWARNING(L
"Unknown render path name '%hs', assuming 'default'", name.c_str());
873 glCullFace(GL_FRONT);
874 glEnable(GL_CULL_FACE);
880 contextCast.
Add(str_MODE_SHADOWCAST, str_1);
888 PROFILE(
"render transparent models");
890 glDisable(GL_CULL_FACE);
892 glEnable(GL_CULL_FACE);
904 bool filtered =
false;
914 #warning TODO: implement wireface/edged rendering mode GLES
919 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
934 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
940 glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
943 pglActiveTextureARB(GL_TEXTURE0);
944 glDisable(GL_TEXTURE_2D);
945 glColor3f(0.5f, 0.5f, 1.0f);
960 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
994 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
1003 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
1008 contextWireframe.
Add(str_MODE_WIREFRAME, str_1);
1010 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
1011 glDisable(GL_TEXTURE_2D);
1015 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
1036 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
1042 glDisable(GL_CULL_FACE);
1045 contextOpaque.
Add(str_ALPHABLEND_PASS_OPAQUE, str_1);
1048 contextBlend.
Add(str_ALPHABLEND_PASS_BLEND, str_1);
1057 glEnable(GL_CULL_FACE);
1063 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
1068 contextWireframe.
Add(str_MODE_WIREFRAME, str_1);
1070 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
1071 glDisable(GL_TEXTURE_2D);
1075 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
1100 q.
X = (
sgn(camPlane.
X) - matrix[8]/matrix[11]) / matrix[0];
1101 q.
Y = (
sgn(camPlane.
Y) - matrix[9]/matrix[11]) / matrix[5];
1102 q.
Z = 1.0f/matrix[11];
1103 q.
W = (1.0f - matrix[10]/matrix[11]) / matrix[14];
1106 CVector4D c = camPlane * (2.0f * matrix[11] / camPlane.
Dot(q));
1111 matrix[10] = c.
Z - matrix[11];
1160 screenScissor.
x1 = (GLint)floor((scissor[0].
X*0.5f+0.5f)*vp.
m_Width);
1161 screenScissor.
y1 = (GLint)floor((scissor[0].
Y*0.5f+0.5f)*vp.
m_Height);
1162 screenScissor.
x2 = (GLint)ceil((scissor[1].
X*0.5f+0.5f)*vp.
m_Width);
1163 screenScissor.
y2 = (GLint)ceil((scissor[1].
Y*0.5f+0.5f)*vp.
m_Height);
1165 if (screenScissor.
x1 < screenScissor.
x2 && screenScissor.
y1 < screenScissor.
y2)
1167 glEnable(GL_SCISSOR_TEST);
1168 glScissor(screenScissor.
x1, screenScissor.
y1, screenScissor.
x2 - screenScissor.
x1, screenScissor.
y2 - screenScissor.
y1);
1170 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
1184 glFrontFace(GL_CCW);
1186 glDisable(GL_SCISSOR_TEST);
1189 pglActiveTextureARB(GL_TEXTURE0);
1190 glEnable(GL_TEXTURE_2D);
1192 glCopyTexSubImage2D(GL_TEXTURE_2D, 0,
1193 screenScissor.
x1, screenScissor.
y1,
1194 screenScissor.
x1, screenScissor.
y1,
1195 screenScissor.
x2 - screenScissor.
x1, screenScissor.
y2 - screenScissor.
y1);
1202 return screenScissor;
1244 screenScissor.
x1 = (GLint)floor((scissor[0].
X*0.5f+0.5f)*vp.
m_Width);
1245 screenScissor.
y1 = (GLint)floor((scissor[0].
Y*0.5f+0.5f)*vp.
m_Height);
1246 screenScissor.
x2 = (GLint)ceil((scissor[1].
X*0.5f+0.5f)*vp.
m_Width);
1247 screenScissor.
y2 = (GLint)ceil((scissor[1].
Y*0.5f+0.5f)*vp.
m_Height);
1248 if (screenScissor.
x1 < screenScissor.
x2 && screenScissor.
y1 < screenScissor.
y2)
1250 glEnable(GL_SCISSOR_TEST);
1251 glScissor(screenScissor.
x1, screenScissor.
y1, screenScissor.
x2 - screenScissor.
x1, screenScissor.
y2 - screenScissor.
y1);
1253 glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
1254 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
1264 glDisable(GL_SCISSOR_TEST);
1267 pglActiveTextureARB(GL_TEXTURE0);
1268 glEnable(GL_TEXTURE_2D);
1270 glCopyTexSubImage2D(GL_TEXTURE_2D, 0,
1271 screenScissor.
x1, screenScissor.
y1,
1272 screenScissor.
x1, screenScissor.
y1,
1273 screenScissor.
x2 - screenScissor.
x1, screenScissor.
y2 - screenScissor.
y1);
1280 return screenScissor;
1289 contextOccluder.
Add(str_MODE_SILHOUETTEOCCLUDER, str_1);
1292 contextDisplay.
Add(str_MODE_SILHOUETTEDISPLAY, str_1);
1301 float silhouetteAlpha = 0.75f;
1306 silhouetteAlpha = 1.f;
1308 glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
1310 glColorMask(0, 0, 0, 0);
1320 glCullFace(GL_FRONT);
1322 glCullFace(GL_BACK);
1326 PROFILE(
"render model occluders");
1331 PROFILE(
"render transparent occluders");
1335 glDepthFunc(GL_GEQUAL);
1336 glColorMask(1, 1, 1, 1);
1339 if (silhouetteAlpha == 1.f)
1352 glBlendFunc(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA);
1353 pglBlendColorEXT(0, 0, 0, silhouetteAlpha);
1355 glEnable(GL_STENCIL_TEST);
1356 glStencilFunc(GL_NOTEQUAL, 1, (GLuint)-1);
1357 glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
1372 glDepthFunc(GL_LEQUAL);
1373 if (silhouetteAlpha == 1.f)
1379 glDisable(GL_BLEND);
1380 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1381 pglBlendColorEXT(0, 0, 0, 0);
1382 glDisable(GL_STENCIL_TEST);
1399 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
1401 glDisable(GL_TEXTURE_2D);
1402 glColor3f(0.0f, 0.5f, 0.0f);
1407 shaderTech->BeginPass();
1409 shader->Uniform(str_color, 0.0f, 1.0f, 0.0f, 1.0f);
1414 shaderTech->EndPass();
1416 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
1464 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
1481 dirty.
x1 = std::min(reflectionScissor.
x1, refractionScissor.
x1);
1482 dirty.
y1 = std::min(reflectionScissor.
y1, refractionScissor.
y1);
1483 dirty.
x2 = std::max(reflectionScissor.
x2, refractionScissor.
x2);
1484 dirty.
y2 = std::max(reflectionScissor.
y2, refractionScissor.
y2);
1489 dirty.
x1 = refractionScissor.
x1;
1490 dirty.
y1 = refractionScissor.
y1;
1491 dirty.
x2 = refractionScissor.
x2;
1492 dirty.
y2 = refractionScissor.
y2;
1497 dirty.
x1 = reflectionScissor.
x1;
1498 dirty.
y1 = reflectionScissor.
y1;
1499 dirty.
x2 = reflectionScissor.
x2;
1500 dirty.
y2 = reflectionScissor.
y2;
1502 if (dirty.
x1 < dirty.
x2 && dirty.
y1 < dirty.
y2)
1504 glEnable(GL_SCISSOR_TEST);
1505 glScissor(dirty.
x1, dirty.
y1, dirty.
x2 - dirty.
x1, dirty.
y2 - dirty.
y1);
1507 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
1508 glDisable(GL_SCISSOR_TEST);
1583 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
1626 ONCE(
LOGERROR(L
"CRenderer::EndFrame: GL errors occurred"));
1639 #warning TODO: implement CRenderer::DisplayFrustum for GLES
1642 glDisable(GL_CULL_FACE);
1643 glDisable(GL_TEXTURE_2D);
1646 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1647 glColor4ub(255,255,255,64);
1649 glDisable(GL_BLEND);
1651 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
1652 glColor3ub(255,255,255);
1654 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
1656 glEnable(GL_CULL_FACE);
1737 bool requiresSkinning = (model->
GetModelDef()->GetNumBones() != 0);
1741 if (requiresSkinning)
1748 if (requiresSkinning)
1785 pglActiveTextureARB(GL_TEXTURE0+unit);
1787 glBindTexture(GL_TEXTURE_2D, tex);
1790 glEnable(GL_TEXTURE_2D);
1792 glDisable(GL_TEXTURE_2D);
1805 const wchar_t*
const key = L
"(alpha map composite)";
1819 VfsPath path(L
"art/textures/terrain/alphamaps/standard");
1824 L
"blendedgecorner.png",
1825 L
"blendedgetwocorners.png",
1826 L
"blendfourcorners.png",
1827 L
"blendtwooppositecorners.png",
1828 L
"blendlshapecorner.png",
1829 L
"blendtwocorners.png",
1831 L
"blendtwoedges.png",
1832 L
"blendthreecorners.png",
1849 size_t this_width = 0, this_height = 0, this_bpp = 0;
1851 if(this_width != this_height)
1860 else if(base != this_width || bpp != this_bpp)
1867 size_t tile_w = 2+base+2;
1870 shared_ptr<u8> data;
1879 size_t srcstep = bpp/8;
1882 u8* dst = data.get() + (i*tile_w);
1885 for (
size_t j = 0; j < base; j++)
1892 for (
size_t k = 0; k < base; k++)
1899 *dst++ = *(src-srcstep);
1900 *dst++ = *(src-srcstep);
1903 dst += total_w-tile_w;
1960 if (boost::algorithm::starts_with(path.
string(), L
"art/textures/terrain/alphamaps/"))
CParticleManager particleManager
Particle manager.
void SetOpenGLCamera(const CCamera &camera)
Load the OpenGL projection and modelview matrices and the viewport according to the given camera...
void RenderSky()
RenderSky: Render the sky.
void Translate(float x, float y, float z)
void Add(CStrIntern name, CStrIntern value)
Add a name and associated value to the map of defines.
Handle ogl_tex_find(const VfsPath &pathname)
Find and return an existing texture object, if it has already been loaded and is still in memory...
void CallModelRenderers(const CShaderDefines &context, int flags)
Renders all non-alpha-blended models with the given context.
ERenderMode m_TerrainRenderMode
void SetObliqueFrustumClipping(const CVector4D &clipPlane)
WaterManager waterManager
Water manager.
ModelRendererPtr TranspUnskinned
const CVector3D & GetSunDir() const
void SetClearColor(SColor4ub color)
Class CRendererStatsTable: Implementation of AbstractProfileTable to display the renderer stats in-ga...
void RenderOutlines(bool filtered=false)
RenderOutlines: Render the outline of patches as lines.
void RenderWater(const CShaderDefines &context, ShadowMap *shadow)
RenderWater: Render water for all patches that have been submitted this frame.
#define UNUSED(param)
mark a function parameter as unused and avoid the corresponding compiler warning. ...
Line-based overlay, with world-space coordinates, rendered in the world potentially behind other obje...
void MakeDirty(ssize_t i0, ssize_t j0, ssize_t i1, ssize_t j1, int dirtyFlags)
void RenderBounds(CShaderProgramPtr &shader)
Render bounding boxes for all the submitted emitters.
CStr GetTitle()
GetTitle: Longer, explanatory text (can be dynamic).
CTimeManager & GetTimeManager()
void PrepareForRendering()
PrepareForRendering: Prepare internal data structures like vertex buffers for rendering.
ModelRendererPtr TranspSkinned
void SetupFrame(const CCamera &camera, const CVector3D &lightdir)
SetupFrame: Configure light space for the given camera and light direction, create the shadow texture...
virtual const CBoundingBoxAligned GetWorldBoundsRec()
Returns world space bounds of this object and all child objects.
void RenderParticles(bool solidColor=false)
Render all the submitted particles.
CRendererStatsTable(const CRenderer::Stats &st)
Handle ogl_tex_wrap(Tex *t, const PIVFS &vfs, const VfsPath &pathname, size_t flags)
Make the Tex object ready for use as an OpenGL texture and return a handle to it. ...
Status ogl_tex_free(Handle &ht)
Release this texture reference.
void AddShadowedBound(const CBoundingBoxAligned &bounds)
AddShadowedBound: Add the bounding box of an object that has to be shadowed.
Class AbstractProfileTable: Profile table data model.
size_t m_RefractionTextureSize
CVertexBufferManager g_VBMan
friend class InstancingModelRenderer
Class OverlayRenderer: Render various bits of data that overlay the game world (selection circles...
void FilterModels(CModelFilter &filter, int passed, int flags=0)
Filters all non-alpha-blended models.
bool Filter(CModel *model)
ShadowMap shadow
Shadow map.
static const uintptr_t maxSectorSize
void Resize(int width, int height)
static void RenderOverlaysBeforeWater()
Draw all ITerrainOverlay objects that exist and that should be drawn before water.
#define CFG_GET_VAL(name, type, destination)
const std::string & GetLightingModel() const
size_t GetNumberRows()
GetNumberRows.
static void RenderOverlaysAfterWater()
Draw all ITerrainOverlay objects that exist and that should be drawn after water. ...
void EndFrame()
Reset the list of submitted overlays.
static RenderPath GetRenderPathByName(const CStr &name)
bool ShadersDirty
true if shaders need to be reloaded
indicates the image is 8bpp greyscale.
void RenderTerrainShader(const CShaderDefines &context, ShadowMap *shadow, bool filtered=false)
Render textured terrain, as with RenderTerrain, but using shaders instead of multitexturing.
const CFrustum & GetFrustum() const
bool IsBoxVisible(const CVector3D &position, const CBoundingBoxAligned &bounds) const
CVector3D Transform(const CVector3D &vector) const
size_t m_ReflectionTextureSize
const std::vector< ProfileColumn > & GetColumns()
GetColumnDescriptions.
shared_ptr< CShaderTechnique > CShaderTechniquePtr
CMatrix3D GetTranspose() const
CStr GetName()
GetName: Short descriptive name of this table (should be static).
Billboard sprite overlay, with world-space coordinates, rendered on top of all other objects...
CCamera m_CullCamera
m_CullCamera: determines the frustum for culling and shadowmap calculations
void RecomputeSystemShaderDefines()
Implementation of ModelRenderer that loads the appropriate shaders for rendering each model...
void SetSceneCamera(const CCamera &viewCamera, const CCamera &cullCamera)
Set up the camera used for rendering the next scene; this includes setting OpenGL state like viewport...
#define RENDERDATA_UPDATE_COLOR
CModelCuller(const CFrustum &frustum)
void SetViewport(const SViewPort &)
GLuint m_RefractionTexture
void RenderTerrain(bool filtered=false)
RenderTerrain: Render textured terrain (including blends between different terrain types)...
Class ShadowMap: Maintain the shadow map texture and perform necessary OpenGL setup, including matrix calculations.
ModelVertexRendererPtr VertexGPUSkinningShader
virtual CLOSTexture & GetLOSTexture()=0
Return the LOS texture to be used for rendering this scene.
CMaterialManager materialManager
Material manager.
CShaderDefines m_SystemShaderDefines
void Submit(SOverlayLine *overlay)
Add a line overlay for rendering in this frame.
int sprintf_s(char *buf, size_t max_chars, const char *fmt,...) PRINTF_ARGS(3)
void RenderTransparentModels(const CShaderDefines &context, ETransparentMode transparentMode, const CFrustum *frustum=0)
CMatrix3D m_ReflectionMatrix
bool m_DisplayTerrainPriorities
Enable rendering of terrain tile priority text overlay, for debugging.
bool ParseString(const CStr8 &Value, float DefaultAlpha)
Public API for simulation system.
static CStr GetRenderPathName(RenderPath rp)
SColor4ub AsSColor4ub() const
ModelRendererPtr NormalSkinned
AbstractProfileTable * GetChild(size_t row)
GetChild: Return a row's child table if the child is expandable.
CCamera m_ViewCamera
m_ViewCamera: determines the eye position for rendering
void EndFrame()
Reset the list of submitted overlays.
SkyManager * m_SkyManager
m_SkyManager: the SkyManager object used for sky textures and settings
CRendererInternals * m
Private data that is not needed by inline functions.
const CFrustum & m_Frustum
CTerrain * GetTerrain()
Get the pointer to the terrain object.
Status ogl_tex_bind(Handle ht, size_t unit)
Bind texture to the specified unit in preparation for using it in rendering.
Texture manager with asynchronous loading and automatic DDS conversion/compression.
bool m_DisplayFrustum
m_DisplayFrustum: Render the cull frustum and other data that may be interesting to evaluate culling ...
void RenderPatches(bool filtered=false)
RenderPatches: Render all patches un-textured as polygons.
CPostprocManager postprocManager
Postprocessing effect manager.
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
Handle m_hCompositeAlphaMap
T round_up_to_pow2(T x)
round up to next larger power of two.
GLint ogl_max_tex_units
[pixels]
CMaterialManager & GetMaterialManager()
TerrainRenderer terrainRenderer
Terrain renderer.
Textured line overlay, with world-space coordinates, rendered in the world onto the terrain...
void RenderPriorities()
Render priority text for all submitted patches, for debugging.
bool CullPatches(const CFrustum *frustum)
CullPatches: Culls patches and decals against a frustum, and stores the results in a special filtered...
struct CRendererInternals::Models Model
CTimeManager timeManager
Time manager.
void UnregisterFileReloadFunc(FileReloadFunc func, void *obj)
delete a callback function registered with RegisterFileReloadFunc (removes any with the same func and...
ModelVertexRendererPtr VertexInstancingShader
void RenderDebugTexture()
Visualize shadow map texture to help in debugging.
void RegisterFileReloadFunc(FileReloadFunc func, void *obj)
register a callback function to be called by ReloadChangedFiles
shared_ptr< ModelRenderer > ModelRendererPtr
Status ogl_tex_set_wrap(Handle ht, GLint wrap_s, GLint wrap_t)
Override default wrap mode (GL_REPEAT) for this texture.
CMatrix3D m_RefractionMatrix
CTextureManager textureManager
Texture manager.
void PrepareForRendering(const CShaderDefines &context)
Prepare internal data structures for rendering.
float m_ShadowZBias
m_ShadowZBias: Z bias used when rendering shadows into a depth texture.
bool GetOptionBool(enum Option opt) const
shared_ptr< ModelVertexRenderer > ModelVertexRendererPtr
const String & string() const
#define ONCE(ONCE_code__)
execute the code passed as a parameter only the first time this is reached.
friend struct CRendererInternals
void Initialize()
Performs one-time initialization.
std::vector< ProfileColumn > columnDescriptions
Column descriptions.
void SetSimulation(CSimulation2 *simulation)
Set simulation context for rendering purposes.
virtual void ValidatePosition()
Ensure that both the transformation and the bone matrices are correct for this model and all its prop...
int m_ShadowMapSize
m_ShadowMapSize: Size of shadow map, or 0 for default.
void Scale(float x_scale, float y_scale, float z_scale)
void EndFrame()
EndFrame: Remove all patches from the list of submitted patches.
CShaderManager shaderManager
Shader manager.
CGame * g_Game
Globally accessible pointer to the CGame object.
void FilterTranspModels(CModelFilter &filter, int passed, int flags=0)
Filters all alpha-blended models.
void ClipFrustum(const CPlane &clipPlane)
CMatrix3D & GetProjection()
#define MODELFLAG_FILTERED
i64 Status
Error handling system.
void CallTranspModelRenderers(const CShaderDefines &context, int flags)
Renders all alpha-blended models with the given context.
static Status ReloadChangedFileCB(void *param, const VfsPath &path)
i64 Handle
`handle' representing a reference to a resource (sound, texture, etc.)
void Submit(CPatch *patch)
Submit a terrain patch that is part of the scene.
#define MODELFLAG_CASTSHADOWS
T bits(T num, size_t lo_idx, size_t hi_idx)
extract the value of bits hi_idx:lo_idx within num
void Submit(CParticleEmitter *emitter)
Add an emitter for rendering in this frame.
RenderPath GetRenderPath() const
stores all data describing an image.
SScreenRect RenderReflections(const CShaderDefines &context, const CBoundingBoxAligned &scissor)
void Submit(CPatch *patch)
Submit: Add a patch for rendering in this frame.
float Dot(const CVector4D &a) const
Handle ogl_tex_load(const PIVFS &vfs, const VfsPath &pathname, size_t flags)
Load and return a handle to the texture.
void SetViewPort(const SViewPort &viewport)
bool IsOpen
true if CRenderer::Open has been called
CTextureManager & GetTextureManager()
A RenderModifier that sets uniforms and textures appropriately for rendering models.
float GetNearPlane() const
void BeginRender()
BeginRender: Set OpenGL state for rendering into the shadow map texture.
void RenderSilhouettes(const CShaderDefines &context)
Represents a mapping of name strings to value strings, for use with #if and #ifdef and similar condit...
TerrainRenderer & GetTerrainRenderer()
struct CRenderer::@49 m_AlphaMapCoords[NumAlphaMaps]
#define MODELFLAG_SILHOUETTE_DISPLAY
NONCOPYABLE(CRendererInternals)
void RenderForegroundOverlays(const CCamera &viewCamera)
Render all the submitted overlays that should appear on top of everything in the world.
Struct CRendererInternals: Truly hide data that is supposed to be hidden in this structure so it won'...
Rectangular single-quad terrain overlay, in world space coordinates.
void UpdateFrustum(const CBoundingBoxAligned &scissor=CBoundingBoxAligned(CVector3D(-1.0f,-1.0f,-1.0f), CVector3D(1.0f, 1.0f, 1.0f)))
void ReleaseRenderOutput()
CRendererStatsTable profileTable
Table to display renderer stats in-game via profile system.
WaterManager * m_WaterManager
m_WaterManager: the WaterManager object used for water textures and settings (e.g.
CShaderManager & GetShaderManager()
const SViewPort & GetViewPort() const
bool WillRenderFancyWater()
Returns true if fancy water shaders will be used (i.e.
bool ogl_HaveExtension(const char *ext)
check if an extension is supported by the OpenGL implementation.
OverlayRenderer overlayRenderer
Overlay renderer.
static Status AllocateAligned(shared_ptr< T > &p, size_t size, size_t alignment=cacheLineSize)
void RenderDebugBounds()
Visualize shadow mapping calculations to help in debugging and optimal shadow map usage...
GLuint m_ReflectionTexture
bool Open(int width, int height)
size_t GetBytesReserved()
ModelRendererPtr NormalUnskinned
LitRenderModifierPtr ModShader
Scene & GetScene()
Return the scene that is currently being rendered.
Status ogl_tex_set_filter(Handle ht, GLint filter)
Override default filter (see ogl_tex_set_defaults) for this texture.
Status ogl_tex_get_data(Handle ht, u8 **p)
Retrieve pixel data of the texture.
CParticleManager & GetParticleManager()
void SetScaling(float x_scale, float y_scale, float z_scale)
void GetInverse(CMatrix3D &dst) const
NONCOPYABLE(CRendererStatsTable)
Struct ProfileColumn: Describes one column of an AbstractProfileTable.
void RenderShadowMap(const CShaderDefines &context)
This interface describes a scene to the renderer.
void RenderOverlaysAfterWater()
Render all the submitted overlays that are embedded in the world (i.e.
void SubmitNonRecursive(CModel *model)
Submit a model that is part of the scene, without submitting attached models.
void RecreateTexture()
RecreateTexture: Destroy the current shadow texture and force creation of a new one.
CMatrix3D GetViewProjection() const
shared_ptr< LitRenderModifier > LitRenderModifierPtr
ERenderMode m_ModelRenderMode
Status tex_wrap(size_t w, size_t h, size_t bpp, size_t flags, const shared_ptr< u8 > &data, size_t ofs, Tex *t)
store the given image data into a Tex object; this will be as if it had been loaded via tex_load...
#define DEBUG_DISPLAY_ERROR(description)
void SetRenderPath(RenderPath rp)
SkyManager skyManager
Sky manager.
Class TerrainRenderer: Render everything related to the terrain, especially patches and water...
float GetFarPlane() const
CWorld * GetWorld()
Get the pointer to the game world object.
void SetOptionBool(enum Option opt, bool value)
void ogl_WarnIfError()
raise a warning (break into the debugger) if an OpenGL error is pending.
#define PROFILE3_GPU(name)
#define debug_warn(expr)
display the error dialog with the given text.
void RenderScene(Scene &scene)
Render the given scene immediately.
const CModelDefPtr & GetModelDef()
CShaderDefines globalContext
void Render(int intermediates=0) const
Render: Renders the camera's frustum in world space.
CStr GetCellText(size_t row, size_t col)
GetCellText.
void RenderModels(const CShaderDefines &context, const CFrustum *frustum=0)
CMaterial & GetMaterial()
SScreenRect RenderRefractions(const CShaderDefines &context, const CBoundingBoxAligned &scissor)
#define MODELFLAG_SILHOUETTE_OCCLUDER
const CBoundingBoxAligned & GetWorldBounds()
Returns the world-space axis-aligned bounds of this object.
size_t GetBytesAllocated()
friend class ShaderModelVertexRenderer
void CaptureRenderOutput()
CBoundingBoxAligned ScissorWater(const CMatrix3D &viewproj)
Calculate a scissor rectangle for the visible water patches.
void EndRender()
EndRender: Finish rendering into the shadow map.
const CRenderer::Stats & Stats
Reference to the renderer singleton's stats.
void RenderOverlaysBeforeWater()
Render all the submitted overlays that are embedded in the world (i.e.
bool m_SkipSubmit
m_SkipSubmit: Disable the actual submission of rendering commands to OpenGL.
shared_ptr< CShaderProgram > CShaderProgramPtr
void PrepareForRendering()
Prepare internal data structures for rendering.
ModelVertexRendererPtr VertexRendererShader
void RenderTextOverlays()
Render text overlays on top of the scene.
void SetProjection(float nearp, float farp, float fov)
void SetSimulation(CSimulation2 *simulation)
Set the simulation context for this frame.
Shader manager: loads and caches shader programs.
virtual void EnumerateObjects(const CFrustum &frustum, SceneCollector *c)=0
Send all objects that can be seen when rendering the given frustum to the scene collector.
void RenderSubmit(SceneCollector &collector, const CFrustum &frustum)
void BindTexture(int unit, unsigned int tex)
Status ogl_tex_upload(const Handle ht, GLenum fmt_ovr, int q_flags_ovr, GLint int_fmt_ovr)
Upload texture to OpenGL.
struct CRenderer::Options m_Options
void RenderPatches(const CShaderDefines &context, const CFrustum *frustum=0)
CPostprocManager & GetPostprocManager()
#define RETURN_STATUS_IF_ERR(expression)
Class WaterManager: Maintain water settings and textures.
Status ogl_tex_get_size(Handle ht, size_t *w, size_t *h, size_t *bpp)
Retrieve dimensions and bit depth of the texture.
const char * ogl_HaveExtensions(int dummy,...)
check if a list of extensions are all supported (as determined by ogl_HaveExtension).
ParticleRenderer particleRenderer
Particle renderer.
Class SkyManager: Maintain sky settings and textures, and render the sky.