2011-01-20 16:56:30 +01:00
|
|
|
// ==============================================================
|
|
|
|
// This file is part of Glest (www.glest.org)
|
|
|
|
//
|
2011-12-14 08:40:48 +01:00
|
|
|
// Copyright (C) 2001-2008 Martiño Figueroa
|
2011-01-20 16:56:30 +01:00
|
|
|
//
|
|
|
|
// You can redistribute this code 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
|
|
|
|
// ==============================================================
|
|
|
|
|
|
|
|
#ifndef _GLEST_GAME_RENDERER_H_
|
|
|
|
#define _GLEST_GAME_RENDERER_H_
|
|
|
|
|
2012-04-20 03:04:05 +02:00
|
|
|
#ifdef WIN32
|
|
|
|
#include <winsock2.h>
|
|
|
|
#include <winsock.h>
|
|
|
|
#endif
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
#include "vec.h"
|
|
|
|
#include "math_util.h"
|
|
|
|
#include "model.h"
|
|
|
|
#include "particle.h"
|
|
|
|
#include "pixmap.h"
|
|
|
|
#include "font.h"
|
|
|
|
#include "matrix.h"
|
|
|
|
#include "selection.h"
|
|
|
|
#include "components.h"
|
|
|
|
#include "texture.h"
|
|
|
|
#include "model_manager.h"
|
|
|
|
#include "graphics_factory_gl.h"
|
|
|
|
#include "font_manager.h"
|
|
|
|
#include "camera.h"
|
|
|
|
#include <vector>
|
|
|
|
#include "model_renderer.h"
|
|
|
|
#include "model.h"
|
|
|
|
#include "graphics_interface.h"
|
|
|
|
#include "base_renderer.h"
|
|
|
|
#include "simple_threads.h"
|
2012-05-23 21:59:52 +02:00
|
|
|
#include "video_player.h"
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
#ifdef DEBUG_RENDERING_ENABLED
|
|
|
|
# define IF_DEBUG_EDITION(x) x
|
|
|
|
# include "debug_renderer.h"
|
|
|
|
#else
|
|
|
|
# define IF_DEBUG_EDITION(x)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "leak_dumper.h"
|
|
|
|
|
2011-02-06 08:01:54 +01:00
|
|
|
enum DebugUILevelType {
|
|
|
|
debugui_fps = 0x01,
|
|
|
|
debugui_unit_titles = 0x02
|
|
|
|
};
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
namespace Glest{ namespace Game{
|
|
|
|
|
|
|
|
using namespace Shared::Graphics;
|
|
|
|
using namespace Shared::PlatformCommon;
|
|
|
|
|
2011-01-21 23:41:05 +01:00
|
|
|
//non shared classes
|
|
|
|
class Config;
|
|
|
|
class Game;
|
2011-12-02 17:07:59 +01:00
|
|
|
class GameCamera;
|
2011-01-21 23:41:05 +01:00
|
|
|
class MainMenu;
|
|
|
|
class Console;
|
|
|
|
class MenuBackground;
|
|
|
|
class ChatManager;
|
|
|
|
class Object;
|
|
|
|
class ConsoleLineInfo;
|
|
|
|
class SurfaceCell;
|
2012-03-13 02:34:14 +01:00
|
|
|
class Program;
|
2011-01-20 16:56:30 +01:00
|
|
|
// =====================================================
|
|
|
|
// class MeshCallbackTeamColor
|
|
|
|
// =====================================================
|
|
|
|
|
2011-12-02 17:07:59 +01:00
|
|
|
class MeshCallbackTeamColor: public MeshCallback {
|
2011-01-20 16:56:30 +01:00
|
|
|
private:
|
|
|
|
const Texture *teamTexture;
|
|
|
|
|
|
|
|
public:
|
2011-12-02 17:07:59 +01:00
|
|
|
MeshCallbackTeamColor() : MeshCallback() {
|
|
|
|
teamTexture = NULL;
|
|
|
|
}
|
2011-01-20 16:56:30 +01:00
|
|
|
void setTeamTexture(const Texture *teamTexture) {this->teamTexture= teamTexture;}
|
|
|
|
virtual void execute(const Mesh *mesh);
|
|
|
|
|
|
|
|
static bool noTeamColors;
|
|
|
|
};
|
|
|
|
|
|
|
|
// ===========================================================
|
|
|
|
// class Renderer
|
|
|
|
//
|
|
|
|
/// OpenGL renderer, uses the shared library
|
|
|
|
// ===========================================================
|
|
|
|
|
|
|
|
class VisibleQuadContainerCache {
|
|
|
|
protected:
|
|
|
|
|
2012-04-17 17:25:31 +02:00
|
|
|
inline void CopyAll(const VisibleQuadContainerCache &obj) {
|
2011-01-20 16:56:30 +01:00
|
|
|
cacheFrame = obj.cacheFrame;
|
|
|
|
visibleObjectList = obj.visibleObjectList;
|
|
|
|
visibleUnitList = obj.visibleUnitList;
|
|
|
|
visibleQuadUnitList = obj.visibleQuadUnitList;
|
2012-06-22 06:58:44 +02:00
|
|
|
visibleQuadUnitBuildList = obj.visibleQuadUnitBuildList;
|
2011-01-20 16:56:30 +01:00
|
|
|
visibleScaledCellList = obj.visibleScaledCellList;
|
2012-06-12 22:37:00 +02:00
|
|
|
visibleScaledCellToScreenPosList = obj.visibleScaledCellToScreenPosList;
|
2011-01-20 16:56:30 +01:00
|
|
|
lastVisibleQuad = obj.lastVisibleQuad;
|
2011-11-30 06:57:14 +01:00
|
|
|
frustumData = obj.frustumData;
|
|
|
|
proj = obj.proj;
|
|
|
|
modl = obj.modl;
|
2011-12-02 17:07:59 +01:00
|
|
|
frustumDataCache = obj.frustumDataCache;
|
2011-01-20 16:56:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2012-04-17 17:25:31 +02:00
|
|
|
inline VisibleQuadContainerCache() {
|
2011-01-20 16:56:30 +01:00
|
|
|
cacheFrame = 0;
|
2013-02-11 23:51:36 +01:00
|
|
|
clearFrustumData();
|
2011-01-20 16:56:30 +01:00
|
|
|
clearCacheData();
|
|
|
|
}
|
2012-04-17 17:25:31 +02:00
|
|
|
inline VisibleQuadContainerCache(const VisibleQuadContainerCache &obj) {
|
2011-01-20 16:56:30 +01:00
|
|
|
CopyAll(obj);
|
|
|
|
}
|
2012-04-17 17:25:31 +02:00
|
|
|
inline VisibleQuadContainerCache & operator=(const VisibleQuadContainerCache &obj) {
|
2011-01-20 16:56:30 +01:00
|
|
|
CopyAll(obj);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2012-04-17 17:25:31 +02:00
|
|
|
inline void clearCacheData() {
|
2011-01-20 16:56:30 +01:00
|
|
|
clearVolatileCacheData();
|
|
|
|
clearNonVolatileCacheData();
|
|
|
|
}
|
2012-04-17 17:25:31 +02:00
|
|
|
inline void clearVolatileCacheData() {
|
2011-01-20 16:56:30 +01:00
|
|
|
visibleUnitList.clear();
|
|
|
|
visibleQuadUnitList.clear();
|
2012-06-22 06:58:44 +02:00
|
|
|
visibleQuadUnitBuildList.clear();
|
2011-01-20 16:56:30 +01:00
|
|
|
//inVisibleUnitList.clear();
|
2011-11-23 09:00:09 +01:00
|
|
|
|
|
|
|
visibleUnitList.reserve(500);
|
|
|
|
visibleQuadUnitList.reserve(500);
|
2012-06-22 06:58:44 +02:00
|
|
|
visibleQuadUnitBuildList.reserve(100);
|
2011-01-20 16:56:30 +01:00
|
|
|
}
|
2012-04-17 17:25:31 +02:00
|
|
|
inline void clearNonVolatileCacheData() {
|
2011-01-20 16:56:30 +01:00
|
|
|
visibleObjectList.clear();
|
|
|
|
visibleScaledCellList.clear();
|
2012-06-12 22:37:00 +02:00
|
|
|
visibleScaledCellToScreenPosList.clear();
|
2011-11-23 09:00:09 +01:00
|
|
|
|
|
|
|
visibleObjectList.reserve(500);
|
|
|
|
visibleScaledCellList.reserve(500);
|
2011-01-20 16:56:30 +01:00
|
|
|
}
|
2013-02-11 23:51:36 +01:00
|
|
|
inline void clearFrustumData() {
|
2011-11-30 08:13:17 +01:00
|
|
|
frustumData = vector<vector<float> >(6,vector<float>(4,0));
|
|
|
|
proj = vector<float>(16,0);
|
|
|
|
modl = vector<float>(16,0);
|
2011-11-30 22:27:03 +01:00
|
|
|
frustumDataCache.clear();
|
2011-11-30 07:58:26 +01:00
|
|
|
}
|
2011-01-20 16:56:30 +01:00
|
|
|
int cacheFrame;
|
|
|
|
Quad2i lastVisibleQuad;
|
|
|
|
std::vector<Object *> visibleObjectList;
|
|
|
|
std::vector<Unit *> visibleQuadUnitList;
|
2012-06-22 15:30:15 +02:00
|
|
|
std::vector<UnitBuildInfo> visibleQuadUnitBuildList;
|
2011-01-20 16:56:30 +01:00
|
|
|
std::vector<Unit *> visibleUnitList;
|
|
|
|
std::vector<Vec2i> visibleScaledCellList;
|
2012-06-12 22:37:00 +02:00
|
|
|
std::map<Vec2i,Vec3f> visibleScaledCellToScreenPosList;
|
2011-11-30 06:57:14 +01:00
|
|
|
|
|
|
|
static bool enableFrustumCalcs;
|
|
|
|
vector<vector<float> > frustumData;
|
|
|
|
vector<float> proj;
|
|
|
|
vector<float> modl;
|
2011-11-30 22:27:03 +01:00
|
|
|
map<pair<vector<float>,vector<float> >, vector<vector<float> > > frustumDataCache;
|
2011-11-30 06:57:14 +01:00
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
};
|
|
|
|
|
2011-01-21 23:41:05 +01:00
|
|
|
class VisibleQuadContainerVBOCache {
|
|
|
|
public:
|
|
|
|
// Vertex Buffer Object Names
|
|
|
|
bool hasBuiltVBOs;
|
|
|
|
uint32 m_nVBOVertices; // Vertex VBO Name
|
2011-02-05 06:07:05 +01:00
|
|
|
uint32 m_nVBOFowTexCoords; // Texture Coordinate VBO Name for fog of war texture coords
|
|
|
|
uint32 m_nVBOSurfaceTexCoords; // Texture Coordinate VBO Name for surface texture coords
|
2011-01-21 23:41:05 +01:00
|
|
|
uint32 m_nVBONormals; // Normal VBO Name
|
|
|
|
//uint32 m_nVBOIndexes; // Indexes VBO Name
|
|
|
|
};
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
|
2012-03-04 00:59:44 +01:00
|
|
|
class Renderer : public RendererInterface,
|
|
|
|
public BaseRenderer,
|
|
|
|
// This is for screen saver thread
|
2012-05-23 21:59:52 +02:00
|
|
|
public SimpleTaskCallbackInterface,
|
|
|
|
public VideoLoadingCallbackInterface {
|
2011-01-20 16:56:30 +01:00
|
|
|
public:
|
|
|
|
//progress bar
|
|
|
|
static const int maxProgressBar;
|
|
|
|
static const Vec4f progressBarBack1;
|
|
|
|
static const Vec4f progressBarBack2;
|
|
|
|
static const Vec4f progressBarFront1;
|
|
|
|
static const Vec4f progressBarFront2;
|
|
|
|
|
|
|
|
//sun and moon
|
|
|
|
static const float sunDist;
|
|
|
|
static const float moonDist;
|
|
|
|
static const float lightAmbFactor;
|
|
|
|
|
|
|
|
//mouse
|
|
|
|
static const int maxMouse2dAnim;
|
|
|
|
|
|
|
|
//texture units
|
|
|
|
static const GLenum baseTexUnit;
|
|
|
|
static const GLenum fowTexUnit;
|
|
|
|
static const GLenum shadowTexUnit;
|
|
|
|
|
|
|
|
//selection
|
|
|
|
static const float selectionCircleRadius;
|
|
|
|
static const float magicCircleRadius;
|
|
|
|
|
|
|
|
//perspective values
|
|
|
|
static const float perspFov;
|
|
|
|
static const float perspNearPlane;
|
2011-05-02 00:48:44 +02:00
|
|
|
static float perspFarPlane;
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
//default values
|
|
|
|
static const float ambFactor;
|
|
|
|
static const Vec4f defSpecularColor;
|
|
|
|
static const Vec4f defDiffuseColor;
|
|
|
|
static const Vec4f defAmbientColor;
|
|
|
|
static const Vec4f defColor;
|
|
|
|
static const Vec4f fowColor;
|
|
|
|
|
|
|
|
//light
|
|
|
|
static const float maxLightDist;
|
|
|
|
|
2011-06-10 05:09:19 +02:00
|
|
|
static bool renderText3DEnabled;
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
public:
|
|
|
|
enum Shadows {
|
|
|
|
sDisabled,
|
|
|
|
sProjected,
|
|
|
|
sShadowMapping,
|
|
|
|
|
|
|
|
sCount
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
2011-06-10 05:09:19 +02:00
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
//config
|
|
|
|
int maxLights;
|
|
|
|
bool photoMode;
|
|
|
|
int shadowTextureSize;
|
|
|
|
int shadowFrameSkip;
|
2013-09-22 02:51:47 +02:00
|
|
|
float shadowIntensity;
|
2011-01-20 16:56:30 +01:00
|
|
|
bool focusArrows;
|
|
|
|
bool textures3D;
|
|
|
|
Shadows shadows;
|
|
|
|
int maxConsoleLines;
|
|
|
|
|
|
|
|
//game
|
|
|
|
const Game *game;
|
2011-12-02 17:07:59 +01:00
|
|
|
GameCamera *gameCamera;
|
2011-01-20 16:56:30 +01:00
|
|
|
const MainMenu *menu;
|
2012-03-13 02:34:14 +01:00
|
|
|
Program *program;
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
//misc
|
|
|
|
int triangleCount;
|
|
|
|
int pointCount;
|
|
|
|
Quad2i visibleQuad;
|
2011-08-30 20:28:30 +02:00
|
|
|
Quad2i visibleQuadFromCamera;
|
2011-01-20 16:56:30 +01:00
|
|
|
Vec4f nearestLightPos;
|
|
|
|
VisibleQuadContainerCache quadCache;
|
2011-12-13 02:30:52 +01:00
|
|
|
VisibleQuadContainerCache quadCacheSelection;
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
//renderers
|
|
|
|
ModelRenderer *modelRenderer;
|
|
|
|
TextRenderer2D *textRenderer;
|
2011-06-08 09:18:06 +02:00
|
|
|
TextRenderer3D *textRenderer3D;
|
2011-01-20 16:56:30 +01:00
|
|
|
ParticleRenderer *particleRenderer;
|
|
|
|
|
|
|
|
//texture managers
|
|
|
|
ModelManager *modelManager[rsCount];
|
|
|
|
TextureManager *textureManager[rsCount];
|
|
|
|
FontManager *fontManager[rsCount];
|
|
|
|
ParticleManager *particleManager[rsCount];
|
|
|
|
|
|
|
|
//state lists
|
2012-05-24 08:16:54 +02:00
|
|
|
//GLuint list3d;
|
|
|
|
//bool list3dValid;
|
|
|
|
//GLuint list2d;
|
|
|
|
//bool list2dValid;
|
|
|
|
//GLuint list3dMenu;
|
|
|
|
//bool list3dMenuValid;
|
|
|
|
//GLuint *customlist3dMenu;
|
2012-05-28 18:51:56 +02:00
|
|
|
//const MainMenu *mm3d;
|
2012-05-24 08:16:54 +02:00
|
|
|
const MainMenu *custom_mm3d;
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
//shadows
|
|
|
|
GLuint shadowMapHandle;
|
2011-10-22 21:45:05 +02:00
|
|
|
bool shadowMapHandleValid;
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
Matrix4f shadowMapMatrix;
|
|
|
|
int shadowMapFrame;
|
|
|
|
|
|
|
|
//water
|
2010-03-13 22:10:45 +01:00
|
|
|
float waterAnim;
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
bool allowRenderUnitTitles;
|
|
|
|
//std::vector<std::pair<Unit *,Vec3f> > renderUnitTitleList;
|
|
|
|
std::vector<Unit *> visibleFrameUnitList;
|
2011-04-18 18:51:30 +02:00
|
|
|
string visibleFrameUnitListCameraKey;
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
bool no2DMouseRendering;
|
|
|
|
bool showDebugUI;
|
2011-02-06 08:01:54 +01:00
|
|
|
int showDebugUILevel;
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
int lastRenderFps;
|
|
|
|
float smoothedRenderFps;
|
|
|
|
bool shadowsOffDueToMinRender;
|
|
|
|
|
2012-03-14 08:23:41 +01:00
|
|
|
std::vector<std::pair<ParticleSystem *, ResourceScope> > deferredParticleSystems;
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
SimpleTaskThread *saveScreenShotThread;
|
|
|
|
Mutex saveScreenShotThreadAccessor;
|
|
|
|
std::list<std::pair<string,Pixmap2D *> > saveScreenQueue;
|
|
|
|
|
2012-06-22 15:30:15 +02:00
|
|
|
std::map<Vec3f,Vec3f> worldToScreenPosCache;
|
2011-01-20 16:56:30 +01:00
|
|
|
|
2011-12-02 23:04:02 +01:00
|
|
|
//bool masterserverMode;
|
2011-09-27 07:29:57 +02:00
|
|
|
|
2011-02-05 06:07:05 +01:00
|
|
|
std::map<uint32,VisibleQuadContainerVBOCache > mapSurfaceVBOCache;
|
2011-02-04 07:34:32 +01:00
|
|
|
|
|
|
|
class SurfaceData {
|
|
|
|
public:
|
2012-04-17 17:25:31 +02:00
|
|
|
inline SurfaceData() {
|
2011-09-01 01:10:43 +02:00
|
|
|
uniqueId=0;
|
|
|
|
bufferCount=0;
|
|
|
|
textureHandle=0;
|
|
|
|
}
|
2011-02-05 06:07:05 +01:00
|
|
|
static uint32 nextUniqueId;
|
|
|
|
uint32 uniqueId;
|
|
|
|
int bufferCount;
|
2011-02-04 07:34:32 +01:00
|
|
|
int textureHandle;
|
|
|
|
vector<Vec2f> texCoords;
|
|
|
|
vector<Vec2f> texCoordsSurface;
|
|
|
|
vector<Vec3f> vertices;
|
|
|
|
vector<Vec3f> normals;
|
|
|
|
};
|
|
|
|
|
2011-02-05 06:07:05 +01:00
|
|
|
VisibleQuadContainerVBOCache * GetSurfaceVBOs(SurfaceData *cellData);
|
|
|
|
void ReleaseSurfaceVBOs();
|
|
|
|
std::map<string,std::pair<Chrono, std::vector<SurfaceData> > > mapSurfaceData;
|
2011-03-28 23:04:47 +02:00
|
|
|
static bool rendererEnded;
|
2011-07-08 18:45:55 +02:00
|
|
|
|
|
|
|
class MapRenderer {
|
|
|
|
public:
|
2012-04-17 17:25:31 +02:00
|
|
|
inline MapRenderer(): map(NULL) {}
|
|
|
|
inline ~MapRenderer() { destroy(); }
|
2011-07-10 07:42:11 +02:00
|
|
|
void render(const Map* map,float coordStep,VisibleQuadContainerCache &qCache);
|
|
|
|
void renderVisibleLayers(const Map* map,float coordStep,VisibleQuadContainerCache &qCache);
|
2011-07-08 18:45:55 +02:00
|
|
|
void destroy();
|
|
|
|
private:
|
|
|
|
void load(float coordStep);
|
2011-07-10 07:42:11 +02:00
|
|
|
void loadVisibleLayers(float coordStep,VisibleQuadContainerCache &qCache);
|
|
|
|
|
2011-07-08 18:45:55 +02:00
|
|
|
const Map* map;
|
|
|
|
struct Layer {
|
2012-04-17 17:25:31 +02:00
|
|
|
inline Layer(int th):
|
2011-07-08 18:45:55 +02:00
|
|
|
vbo_vertices(0), vbo_normals(0),
|
|
|
|
vbo_fowTexCoords(0), vbo_surfTexCoords(0),
|
|
|
|
vbo_indices(0), indexCount(0),
|
2012-09-22 22:13:57 +02:00
|
|
|
textureHandle(th),textureCRC(0) {}
|
2013-02-09 07:57:05 +01:00
|
|
|
|
|
|
|
inline Layer & operator=(Layer &obj) {
|
|
|
|
this->vertices = obj.vertices;
|
|
|
|
this->normals = obj.normals;
|
|
|
|
this->fowTexCoords = obj.fowTexCoords;
|
|
|
|
this->surfTexCoords = obj.surfTexCoords;
|
|
|
|
this->indices = obj.indices;
|
|
|
|
this->cellToIndicesMap = obj.cellToIndicesMap;
|
|
|
|
this->rowsToRenderCache = obj.rowsToRenderCache;
|
|
|
|
this->vbo_vertices = obj.vbo_vertices;
|
|
|
|
this->vbo_normals = obj.vbo_normals;
|
|
|
|
this->vbo_fowTexCoords = obj.vbo_fowTexCoords;
|
|
|
|
this->vbo_surfTexCoords = obj.vbo_surfTexCoords;
|
|
|
|
this->vbo_indices = obj.vbo_indices;
|
|
|
|
this->indexCount = obj.indexCount;
|
|
|
|
this->textureHandle = obj.textureHandle;
|
|
|
|
this->texturePath = obj.texturePath;
|
|
|
|
this->textureCRC = obj.textureCRC;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2011-07-08 18:45:55 +02:00
|
|
|
~Layer();
|
2011-07-10 07:42:11 +02:00
|
|
|
void load_vbos(bool vboEnabled);
|
|
|
|
void render(VisibleQuadContainerCache &qCache);
|
|
|
|
void renderVisibleLayer();
|
|
|
|
|
2011-07-08 18:45:55 +02:00
|
|
|
std::vector<Vec3f> vertices, normals;
|
|
|
|
std::vector<Vec2f> fowTexCoords, surfTexCoords;
|
|
|
|
std::vector<GLuint> indices;
|
2011-07-10 07:42:11 +02:00
|
|
|
std::map<Vec2i, int> cellToIndicesMap;
|
|
|
|
std::map<Quad2i, vector<pair<int,int> > > rowsToRenderCache;
|
|
|
|
|
2011-07-08 18:45:55 +02:00
|
|
|
GLuint vbo_vertices, vbo_normals,
|
|
|
|
vbo_fowTexCoords, vbo_surfTexCoords,
|
|
|
|
vbo_indices;
|
|
|
|
int indexCount;
|
2013-02-09 07:57:05 +01:00
|
|
|
int textureHandle;
|
2011-07-10 07:42:11 +02:00
|
|
|
string texturePath;
|
2012-07-07 04:46:57 +02:00
|
|
|
uint32 textureCRC;
|
2011-07-08 18:45:55 +02:00
|
|
|
};
|
|
|
|
typedef std::vector<Layer*> Layers;
|
|
|
|
Layers layers;
|
2011-07-10 07:42:11 +02:00
|
|
|
Quad2i lastVisibleQuad;
|
2011-07-08 18:45:55 +02:00
|
|
|
} mapRenderer;
|
2011-11-30 06:57:14 +01:00
|
|
|
|
2011-11-30 17:51:51 +01:00
|
|
|
bool ExtractFrustum(VisibleQuadContainerCache &quadCacheItem);
|
2011-11-30 06:57:14 +01:00
|
|
|
bool PointInFrustum(vector<vector<float> > &frustum, float x, float y, float z );
|
2011-12-13 02:30:52 +01:00
|
|
|
bool SphereInFrustum(vector<vector<float> > &frustum, float x, float y, float z, float radius);
|
2011-11-30 06:57:14 +01:00
|
|
|
bool CubeInFrustum(vector<vector<float> > &frustum, float x, float y, float z, float size );
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
private:
|
2011-12-02 23:04:02 +01:00
|
|
|
Renderer();
|
2011-01-20 16:56:30 +01:00
|
|
|
~Renderer();
|
|
|
|
|
|
|
|
public:
|
2011-12-02 23:04:02 +01:00
|
|
|
static Renderer &getInstance();
|
2011-03-28 23:04:47 +02:00
|
|
|
static bool isEnded();
|
2011-12-02 23:04:02 +01:00
|
|
|
//bool isMasterserverMode() const { return masterserverMode; }
|
2011-01-20 16:56:30 +01:00
|
|
|
|
2012-03-14 08:23:41 +01:00
|
|
|
void addToDeferredParticleSystemList(std::pair<ParticleSystem *, ResourceScope> deferredParticleSystem);
|
|
|
|
void manageDeferredParticleSystems();
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
void reinitAll();
|
|
|
|
|
|
|
|
//init
|
|
|
|
void init();
|
2011-12-02 17:07:59 +01:00
|
|
|
void initGame(const Game *game, GameCamera *gameCamera);
|
2011-01-20 16:56:30 +01:00
|
|
|
void initMenu(const MainMenu *mm);
|
|
|
|
void reset3d();
|
|
|
|
void reset2d();
|
|
|
|
void reset3dMenu();
|
|
|
|
|
|
|
|
//end
|
|
|
|
void end();
|
2011-10-06 20:04:59 +02:00
|
|
|
void endScenario();
|
2011-01-20 16:56:30 +01:00
|
|
|
void endMenu();
|
2011-10-22 21:45:05 +02:00
|
|
|
void endGame(bool isFinalEnd);
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
//get
|
2012-04-17 17:25:31 +02:00
|
|
|
inline int getTriangleCount() const {return triangleCount;}
|
|
|
|
inline int getPointCount() const {return pointCount;}
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
//misc
|
|
|
|
void reloadResources();
|
|
|
|
|
|
|
|
//engine interface
|
|
|
|
void initTexture(ResourceScope rs, Texture *texture);
|
|
|
|
void endTexture(ResourceScope rs, Texture *texture,bool mustExistInList=false);
|
|
|
|
void endLastTexture(ResourceScope rs, bool mustExistInList=false);
|
|
|
|
|
|
|
|
Model *newModel(ResourceScope rs);
|
|
|
|
void endModel(ResourceScope rs, Model *model, bool mustExistInList=false);
|
|
|
|
void endLastModel(ResourceScope rs, bool mustExistInList=false);
|
|
|
|
|
|
|
|
Texture2D *newTexture2D(ResourceScope rs);
|
|
|
|
Texture3D *newTexture3D(ResourceScope rs);
|
|
|
|
Font2D *newFont(ResourceScope rs);
|
2011-06-08 09:18:06 +02:00
|
|
|
Font3D *newFont3D(ResourceScope rs);
|
2012-09-22 22:13:57 +02:00
|
|
|
void endFont(Shared::Graphics::Font *font, ResourceScope rs, bool mustExistInList=false);
|
2011-10-25 20:39:11 +02:00
|
|
|
void resetFontManager(ResourceScope rs);
|
2011-06-08 09:18:06 +02:00
|
|
|
|
2012-04-17 17:25:31 +02:00
|
|
|
inline TextRenderer2D *getTextRenderer() const {return textRenderer;}
|
|
|
|
inline TextRenderer3D *getTextRenderer3D() const {return textRenderer3D;}
|
2011-06-10 05:09:19 +02:00
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
void manageParticleSystem(ParticleSystem *particleSystem, ResourceScope rs);
|
|
|
|
void cleanupParticleSystems(vector<ParticleSystem *> &particleSystems,ResourceScope rs);
|
|
|
|
void cleanupUnitParticleSystems(vector<UnitParticleSystem *> &particleSystems,ResourceScope rs);
|
|
|
|
bool validateParticleSystemStillExists(ParticleSystem * particleSystem,ResourceScope rs) const;
|
2013-09-24 05:44:15 +02:00
|
|
|
void removeParticleSystemsForParticleOwner(ParticleOwner * particleOwner,ResourceScope rs);
|
2011-01-20 16:56:30 +01:00
|
|
|
void updateParticleManager(ResourceScope rs,int renderFps=-1);
|
|
|
|
void renderParticleManager(ResourceScope rs);
|
|
|
|
void swapBuffers();
|
|
|
|
|
|
|
|
//lights and camera
|
|
|
|
void setupLighting();
|
2012-08-13 23:46:27 +02:00
|
|
|
void setupLightingForRotatedModel();
|
2011-01-20 16:56:30 +01:00
|
|
|
void loadGameCameraMatrix();
|
|
|
|
void loadCameraMatrix(const Camera *camera);
|
|
|
|
void computeVisibleQuad();
|
|
|
|
|
|
|
|
//basic rendering
|
|
|
|
void renderMouse2d(int mouseX, int mouseY, int anim, float fade= 0.f);
|
|
|
|
void renderMouse3d();
|
2012-06-22 06:58:44 +02:00
|
|
|
|
2012-06-22 15:30:15 +02:00
|
|
|
void renderGhostModel(const UnitType *building, const Vec2i pos,CardinalDir facing,Vec4f *forceColor=NULL);
|
2012-06-22 06:58:44 +02:00
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
void renderBackground(const Texture2D *texture);
|
|
|
|
void renderTextureQuad(int x, int y, int w, int h, const Texture2D *texture, float alpha=1.f,const Vec3f *color=NULL);
|
2011-04-15 01:13:44 +02:00
|
|
|
void renderConsole(const Console *console, const bool showAll=false, const bool showMenuConsole=false, int overrideMaxConsoleLines=-1);
|
2011-06-10 05:09:19 +02:00
|
|
|
void renderConsoleLine3D(int lineIndex, int xPosition, int yPosition, int lineHeight, Font3D* font, string stringToHightlight, const ConsoleLineInfo *lineInfo);
|
2011-06-06 23:38:25 +02:00
|
|
|
void renderConsoleLine(int lineIndex, int xPosition, int yPosition, int lineHeight, Font2D* font, string stringToHightlight, const ConsoleLineInfo *lineInfo);
|
2011-06-10 05:09:19 +02:00
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
void renderChatManager(const ChatManager *chatManager);
|
2012-08-15 16:37:27 +02:00
|
|
|
void renderClock();
|
2013-11-11 02:42:27 +01:00
|
|
|
void renderPerformanceStats();
|
2011-01-20 16:56:30 +01:00
|
|
|
void renderResourceStatus();
|
|
|
|
void renderSelectionQuad();
|
2011-06-06 23:38:25 +02:00
|
|
|
void renderText(const string &text, Font2D *font, float alpha, int x, int y, bool centered= false);
|
|
|
|
void renderText(const string &text, Font2D *font, const Vec3f &color, int x, int y, bool centered= false);
|
|
|
|
void renderText(const string &text, Font2D *font, const Vec4f &color, int x, int y, bool centered=false);
|
|
|
|
void renderTextShadow(const string &text, Font2D *font,const Vec4f &color, int x, int y, bool centered= false);
|
2011-01-20 16:56:30 +01:00
|
|
|
|
2011-06-08 09:18:06 +02:00
|
|
|
void renderText3D(const string &text, Font3D *font, float alpha, int x, int y, bool centered);
|
|
|
|
void renderText3D(const string &text, Font3D *font, const Vec3f &color, int x, int y, bool centered);
|
|
|
|
void renderText3D(const string &text, Font3D *font, const Vec4f &color, int x, int y, bool centered);
|
2011-06-10 05:09:19 +02:00
|
|
|
void renderTextShadow3D(const string &text, Font3D *font,const Vec4f &color, int x, int y, bool centered=false);
|
2012-09-27 08:12:53 +02:00
|
|
|
void renderProgressBar3D(int size, int x, int y, Font3D *font, int customWidth=-1, string prefixLabel="", bool centeredText=true,int customHeight=-1);
|
2011-06-08 09:18:06 +02:00
|
|
|
|
2011-07-02 03:56:06 +02:00
|
|
|
Vec2f getCentered3DPos(const string &text, Font3D *font, Vec2f &pos, int w, int h, bool centeredW, bool centeredH);
|
2012-07-26 17:26:59 +02:00
|
|
|
void renderTextBoundingBox3D(const string &text, Font3D *font, const Vec4f &color, int x, int y, int w, int h, bool centeredW, bool centeredH, bool editModeEnabled, int maxEditWidth, int maxEditRenderWidth);
|
|
|
|
void renderTextBoundingBox3D(const string &text, Font3D *font, const Vec3f &color, int x, int y, int w, int h, bool centeredW, bool centeredH, bool editModeEnabled,int maxEditWidth, int maxEditRenderWidth);
|
|
|
|
void renderTextBoundingBox3D(const string &text, Font3D *font, float alpha, int x, int y, int w, int h, bool centeredW, bool centeredH, bool editModeEnabled,int maxEditWidth, int maxEditRenderWidth);
|
2012-07-26 08:27:00 +02:00
|
|
|
|
2012-07-26 17:26:59 +02:00
|
|
|
void renderTextSurroundingBox(int x, int y, int w, int h,int maxEditWidth, int maxEditRenderWidth);
|
2011-06-12 07:54:54 +02:00
|
|
|
|
|
|
|
void beginRenderToTexture(Texture2D **renderToTexture);
|
|
|
|
void endRenderToTexture(Texture2D **renderToTexture);
|
2011-06-11 10:52:49 +02:00
|
|
|
|
2011-07-01 04:50:20 +02:00
|
|
|
void renderFPSWhenEnabled(int lastFps);
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
//components
|
2011-06-06 23:38:25 +02:00
|
|
|
void renderLabel(GraphicLabel *label);
|
|
|
|
void renderLabel(GraphicLabel *label,const Vec3f *color);
|
|
|
|
void renderLabel(GraphicLabel *label,const Vec4f *color);
|
|
|
|
void renderButton(GraphicButton *button,const Vec4f *fontColorOverride=NULL,bool *lightedOverride=NULL);
|
2011-01-20 16:56:30 +01:00
|
|
|
void renderCheckBox(const GraphicCheckBox *box);
|
|
|
|
void renderLine(const GraphicLine *line);
|
|
|
|
void renderScrollBar(const GraphicScrollBar *sb);
|
2011-06-06 23:38:25 +02:00
|
|
|
void renderListBox(GraphicListBox *listBox);
|
|
|
|
void renderMessageBox(GraphicMessageBox *listBox);
|
2011-09-21 08:51:28 +02:00
|
|
|
void renderPopupMenu(PopupMenu *menu);
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
//complex rendering
|
|
|
|
void renderSurface(const int renderFps);
|
|
|
|
void renderObjects(const int renderFps);
|
|
|
|
|
|
|
|
void renderWater();
|
|
|
|
void renderUnits(const int renderFps);
|
2012-06-22 06:58:44 +02:00
|
|
|
void renderUnitsToBuild(const int renderFps);
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
void renderSelectionEffects();
|
|
|
|
void renderWaterEffects();
|
2011-06-09 02:59:03 +02:00
|
|
|
void renderHud();
|
2011-01-20 16:56:30 +01:00
|
|
|
void renderMinimap();
|
|
|
|
void renderDisplay();
|
|
|
|
void renderMenuBackground(const MenuBackground *menuBackground);
|
|
|
|
void renderMapPreview(const MapPreview *map, bool renderAll, int screenX, int screenY,Texture2D **renderToTexture=NULL);
|
2011-10-12 07:24:30 +02:00
|
|
|
void renderMenuBackground(Camera *camera, float fade, Model *mainModel, vector<Model *> characterModels,const Vec3f characterPosition, float anim);
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
//computing
|
2012-06-12 22:37:00 +02:00
|
|
|
bool computePosition(const Vec2i &screenPos, Vec2i &worldPos,bool exactCoords=false);
|
2011-02-13 15:35:17 +01:00
|
|
|
void computeSelected(Selection::UnitContainer &units, const Object *&obj, const bool withObjectSelection, const Vec2i &posDown, const Vec2i &posUp);
|
2011-12-14 03:25:14 +01:00
|
|
|
void selectUsingColorPicking(Selection::UnitContainer &units, const Object *&obj,const bool withObjectSelection,const Vec2i &posDown, const Vec2i &posUp);
|
|
|
|
void selectUsingSelectionBuffer(Selection::UnitContainer &units,const Object *&obj, const bool withObjectSelection,const Vec2i &posDown, const Vec2i &posUp);
|
|
|
|
void selectUsingFrustumSelection(Selection::UnitContainer &units,const Object *&obj, const bool withObjectSelection,const Vec2i &posDown, const Vec2i &posUp);
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
//gl wrap
|
|
|
|
string getGlInfo();
|
|
|
|
string getGlMoreInfo();
|
|
|
|
void autoConfig();
|
|
|
|
|
|
|
|
//clear
|
|
|
|
void clearBuffers();
|
|
|
|
void clearZBuffer();
|
|
|
|
|
|
|
|
//shadows
|
|
|
|
void renderShadowsToTexture(const int renderFps);
|
|
|
|
|
|
|
|
//misc
|
|
|
|
void loadConfig();
|
2012-03-17 12:26:39 +01:00
|
|
|
void saveScreen(const string &path,int w=0, int h=0);
|
2012-04-17 17:25:31 +02:00
|
|
|
inline Quad2i getVisibleQuad() const {return visibleQuad;}
|
|
|
|
inline Quad2i getVisibleQuadFromCamera() const {return visibleQuadFromCamera;}
|
2011-07-07 00:02:38 +02:00
|
|
|
void renderTeamColorPlane();
|
2012-10-13 09:33:33 +02:00
|
|
|
void renderSpecialHighlightUnits(std::map<int,HighlightSpecialUnitInfo> unitHighlightList);
|
2011-07-07 00:02:38 +02:00
|
|
|
void renderTeamColorCircle();
|
2012-09-11 23:16:24 +02:00
|
|
|
void renderMorphEffects();
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
//static
|
|
|
|
static Shadows strToShadows(const string &s);
|
|
|
|
static string shadowsToStr(Shadows shadows);
|
|
|
|
|
2012-04-17 17:25:31 +02:00
|
|
|
inline const Game * getGame() { return game; }
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
void setAllowRenderUnitTitles(bool value);
|
2012-04-17 17:25:31 +02:00
|
|
|
inline bool getAllowRenderUnitTitles() { return allowRenderUnitTitles; }
|
2011-01-20 16:56:30 +01:00
|
|
|
void renderUnitTitles(Font2D *font, Vec3f color);
|
2011-07-01 09:46:18 +02:00
|
|
|
void renderUnitTitles3D(Font3D *font, Vec3f color);
|
2011-01-20 16:56:30 +01:00
|
|
|
Vec3f computeScreenPosition(const Vec3f &worldPos);
|
|
|
|
|
|
|
|
void setPhotoMode(bool value) { photoMode = value; }
|
|
|
|
|
2012-04-17 17:25:31 +02:00
|
|
|
inline bool getNo2DMouseRendering() const { return no2DMouseRendering; }
|
2011-01-20 16:56:30 +01:00
|
|
|
void setNo2DMouseRendering(bool value) { no2DMouseRendering = value; }
|
|
|
|
|
2012-04-17 17:25:31 +02:00
|
|
|
inline bool getShowDebugUI() const { return showDebugUI; }
|
2011-01-20 16:56:30 +01:00
|
|
|
void setShowDebugUI(bool value) { showDebugUI = value; }
|
|
|
|
|
2012-04-17 17:25:31 +02:00
|
|
|
inline int getShowDebugUILevel() const { return showDebugUILevel; }
|
2011-02-06 08:01:54 +01:00
|
|
|
void setShowDebugUILevel(int value) { showDebugUILevel=value; }
|
|
|
|
void cycleShowDebugUILevel();
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
void setLastRenderFps(int value);
|
2012-04-17 17:25:31 +02:00
|
|
|
inline int getLastRenderFps() const { return lastRenderFps;}
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
VisibleQuadContainerCache & getQuadCache(bool updateOnDirtyFrame=true,bool forceNew=false);
|
2012-06-12 22:37:00 +02:00
|
|
|
std::pair<bool,Vec3f> posInCellQuadCache(Vec2i pos);
|
|
|
|
Vec3f getMarkedCellScreenPosQuadCache(Vec2i pos);
|
|
|
|
void updateMarkedCellScreenPosQuadCache(Vec2i pos);
|
|
|
|
void forceQuadCacheUpdate();
|
2012-09-20 06:10:34 +02:00
|
|
|
void renderVisibleMarkedCells(bool renderTextHint=false,int x=-1, int y=-1);
|
2012-06-12 22:37:00 +02:00
|
|
|
void renderMarkedCellsOnMinimap();
|
|
|
|
|
2012-07-13 23:50:34 +02:00
|
|
|
void renderHighlightedCellsOnMinimap();
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
void removeObjectFromQuadCache(const Object *o);
|
|
|
|
void removeUnitFromQuadCache(const Unit *unit);
|
|
|
|
|
|
|
|
uint64 getCurrentPixelByteCount(ResourceScope rs=rsGame) const;
|
|
|
|
unsigned int getSaveScreenQueueSize();
|
|
|
|
|
2011-01-04 09:44:00 +01:00
|
|
|
Texture2D *saveScreenToTexture(int x, int y, int width, int height);
|
|
|
|
|
2011-04-20 07:24:11 +02:00
|
|
|
void renderProgressBar(int size, int x, int y, Font2D *font,int customWidth=-1, string prefixLabel="", bool centeredText=true);
|
2011-01-20 16:56:30 +01:00
|
|
|
|
2012-09-25 09:05:52 +02:00
|
|
|
static Texture2D * findTexture(string logoFilename);
|
2011-03-22 03:02:54 +01:00
|
|
|
static Texture2D * preloadTexture(string logoFilename);
|
2013-11-02 12:04:52 +01:00
|
|
|
inline int getCachedSurfaceDataSize() const { return (int)mapSurfaceData.size(); }
|
2011-01-26 10:09:59 +01:00
|
|
|
|
2012-05-24 08:16:54 +02:00
|
|
|
//void setCustom3dMenuList(GLuint *customlist3dMenu) { this->customlist3dMenu = customlist3dMenu; }
|
|
|
|
//inline GLuint * getCustom3dMenuList() const { return this->customlist3dMenu; }
|
|
|
|
void setCustom3dMenu(const MainMenu *mm) { this->custom_mm3d = mm; }
|
|
|
|
const MainMenu * getCustom3dMenu() { return this->custom_mm3d; }
|
2011-10-05 05:42:29 +02:00
|
|
|
|
2011-10-12 07:24:30 +02:00
|
|
|
void init3dListMenu(const MainMenu *mm);
|
|
|
|
|
2012-03-13 02:34:14 +01:00
|
|
|
void setProgram(Program *program) { this->program = program; }
|
|
|
|
|
2012-05-23 21:59:52 +02:00
|
|
|
void setupRenderForVideo();
|
|
|
|
virtual void renderVideoLoading(int progressPercent);
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
private:
|
|
|
|
//private misc
|
|
|
|
float computeSunAngle(float time);
|
|
|
|
float computeMoonAngle(float time);
|
|
|
|
Vec4f computeSunPos(float time);
|
|
|
|
Vec4f computeMoonPos(float time);
|
2012-05-12 02:01:05 +02:00
|
|
|
inline Vec4f computeWaterColor(float waterLevel, float cellHeight) {
|
|
|
|
const float waterFactor= 1.5f;
|
|
|
|
return Vec4f(1.f, 1.f, 1.f, clamp((waterLevel-cellHeight) * waterFactor, 0.f, 1.f));
|
|
|
|
}
|
2011-01-20 16:56:30 +01:00
|
|
|
void checkExtension(const string &extension, const string &msg);
|
|
|
|
|
|
|
|
//selection render
|
2011-12-13 02:30:52 +01:00
|
|
|
vector<Object *> renderObjectsFast(bool renderingShadows = false, bool resourceOnly = false, bool colorPickingSelection = false);
|
|
|
|
vector<Unit *> renderUnitsFast(bool renderingShadows = false, bool colorPickingSelection = false);
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
//gl requirements
|
|
|
|
void checkGlCaps();
|
|
|
|
void checkGlOptionalCaps();
|
|
|
|
|
|
|
|
//gl init
|
|
|
|
void init3dList();
|
|
|
|
void init2dList();
|
|
|
|
|
|
|
|
//misc
|
|
|
|
void loadProjectionMatrix();
|
|
|
|
void enableProjectiveTexturing();
|
|
|
|
|
|
|
|
//private aux drawing
|
2011-07-07 00:02:38 +02:00
|
|
|
void renderSelectionCircle(Vec3f v, int size, float radius, float thickness=0.2f);
|
|
|
|
void renderTeamColorEffect(Vec3f &v, int heigth, int size, Vec3f color, const Texture2D *texture);
|
2011-01-20 16:56:30 +01:00
|
|
|
void renderArrow(const Vec3f &pos1, const Vec3f &pos2, const Vec3f &color, float width);
|
|
|
|
void renderTile(const Vec2i &pos);
|
|
|
|
void renderQuad(int x, int y, int w, int h, const Texture2D *texture);
|
|
|
|
|
2013-11-07 19:39:08 +01:00
|
|
|
void simpleTask(BaseThread *callingThread,void *userdata);
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
//static
|
|
|
|
static Texture2D::Filter strToTextureFilter(const string &s);
|
2011-02-12 08:34:32 +01:00
|
|
|
void cleanupScreenshotThread();
|
|
|
|
|
2012-05-24 08:16:54 +02:00
|
|
|
void render2dMenuSetup();
|
|
|
|
void render3dSetup();
|
|
|
|
void render3dMenuSetup(const MainMenu *mm);
|
2011-01-20 16:56:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}} //end namespace
|
|
|
|
|
|
|
|
#endif
|