2014-06-06 18:04:00 +02:00
|
|
|
#ifndef _GAMERENDERER_HPP_
|
|
|
|
#define _GAMERENDERER_HPP_
|
2016-04-10 19:48:38 +02:00
|
|
|
#include <rw/defines.hpp>
|
2013-07-03 10:46:07 +02:00
|
|
|
|
2015-03-30 03:45:58 +02:00
|
|
|
class Logger;
|
|
|
|
|
2016-04-07 02:13:46 +02:00
|
|
|
#include <gl/gl_core_3_3.h>
|
|
|
|
|
2013-07-04 03:40:47 +02:00
|
|
|
#include <memory>
|
2013-12-20 14:43:12 +01:00
|
|
|
#include <vector>
|
2013-07-03 10:46:07 +02:00
|
|
|
|
2013-12-20 15:03:32 +01:00
|
|
|
#include <render/ViewCamera.hpp>
|
2013-07-02 09:53:23 +02:00
|
|
|
|
2014-08-22 15:29:46 +02:00
|
|
|
#include <render/OpenGLRenderer.hpp>
|
2015-01-25 18:54:31 +01:00
|
|
|
#include "MapRenderer.hpp"
|
2015-02-07 23:55:06 +01:00
|
|
|
#include "TextRenderer.hpp"
|
2015-03-28 14:42:29 +01:00
|
|
|
#include "WaterRenderer.hpp"
|
2014-08-22 15:29:46 +02:00
|
|
|
|
2013-07-04 03:40:47 +02:00
|
|
|
class Model;
|
2014-02-09 04:14:43 +01:00
|
|
|
class ModelFrame;
|
2013-12-20 17:02:46 +01:00
|
|
|
class GameWorld;
|
2014-02-28 12:23:51 +01:00
|
|
|
class GameObject;
|
2014-07-04 22:06:56 +02:00
|
|
|
|
2015-01-23 18:18:16 +01:00
|
|
|
class AreaIndicatorInfo;
|
|
|
|
|
2014-07-20 22:21:51 +02:00
|
|
|
/// @todo migrate to some other way of rendering each object type.
|
2014-07-01 23:00:45 +02:00
|
|
|
class CharacterObject;
|
|
|
|
class VehicleObject;
|
|
|
|
class InstanceObject;
|
2014-07-04 22:06:56 +02:00
|
|
|
class PickupObject;
|
2014-07-20 22:21:51 +02:00
|
|
|
class ProjectileObject;
|
2014-07-30 14:44:25 +02:00
|
|
|
class CutsceneObject;
|
2014-07-04 22:06:56 +02:00
|
|
|
|
2013-09-11 01:26:13 +02:00
|
|
|
class Animator;
|
2014-06-29 23:14:46 +02:00
|
|
|
class InventoryItem;
|
2013-07-22 05:39:58 +02:00
|
|
|
|
2014-08-22 15:29:46 +02:00
|
|
|
class Renderer;
|
|
|
|
|
2014-02-13 11:55:11 +01:00
|
|
|
/**
|
2014-07-09 06:04:48 +02:00
|
|
|
* @brief Implements high level drawing logic and low level draw commands
|
|
|
|
*
|
|
|
|
* Rendering of object types is handled by drawWorld, calling the respective
|
|
|
|
* render function for each object.
|
2014-02-13 11:55:11 +01:00
|
|
|
*/
|
2014-06-06 18:04:00 +02:00
|
|
|
class GameRenderer
|
2013-07-02 09:53:23 +02:00
|
|
|
{
|
2015-04-27 04:55:18 +02:00
|
|
|
/** Game data to use for rendering */
|
|
|
|
GameData* data;
|
|
|
|
|
2015-03-30 03:45:58 +02:00
|
|
|
/** Logger to output messages */
|
|
|
|
Logger* logger;
|
2014-08-22 15:29:46 +02:00
|
|
|
|
|
|
|
/** The low-level drawing interface to use */
|
|
|
|
Renderer* renderer;
|
2013-12-20 14:43:12 +01:00
|
|
|
|
2014-08-22 15:29:46 +02:00
|
|
|
/** Stores data for deferring transparent objects */
|
2013-12-20 14:43:12 +01:00
|
|
|
struct RQueueEntry {
|
|
|
|
Model* model;
|
|
|
|
size_t g;
|
|
|
|
size_t sg;
|
|
|
|
glm::mat4 matrix;
|
2014-08-22 15:29:46 +02:00
|
|
|
Renderer::DrawParameters dp;
|
2014-02-28 12:23:51 +01:00
|
|
|
GameObject* object;
|
2013-12-20 14:43:12 +01:00
|
|
|
};
|
|
|
|
|
2014-07-09 06:04:48 +02:00
|
|
|
/**
|
|
|
|
* @brief renders a model's frame.
|
|
|
|
* @param m
|
|
|
|
* @param f
|
|
|
|
* @param matrix
|
|
|
|
* @param object
|
|
|
|
* @param queueTransparent abort the draw if the frame contains transparent materials
|
|
|
|
* @return True if the frame was drawn, false if it should be queued
|
|
|
|
*/
|
2014-08-02 22:34:48 +02:00
|
|
|
bool renderFrame(Model* m, ModelFrame* f, const glm::mat4& matrix, GameObject* object, float opacity, bool queueTransparent = true);
|
2014-08-22 15:29:46 +02:00
|
|
|
|
2014-07-09 06:04:48 +02:00
|
|
|
/** Transparent objects are queued into this list */
|
2013-12-20 14:43:12 +01:00
|
|
|
std::vector<RQueueEntry> transparentDrawQueue;
|
2013-07-24 01:42:50 +02:00
|
|
|
|
2015-04-27 04:55:18 +02:00
|
|
|
// Temporary variables used during rendering
|
2014-06-02 05:58:41 +02:00
|
|
|
float _renderAlpha;
|
2015-04-27 04:55:18 +02:00
|
|
|
GameWorld* _renderWorld;
|
2014-06-02 05:58:41 +02:00
|
|
|
|
2014-08-03 14:37:11 +02:00
|
|
|
/** Internal non-descript VAOs */
|
|
|
|
GLuint vao, debugVAO;
|
|
|
|
|
2014-08-12 22:15:26 +02:00
|
|
|
/** Camera values passed to renderWorld() */
|
|
|
|
ViewCamera _camera;
|
2015-03-28 14:42:29 +01:00
|
|
|
|
|
|
|
GLuint framebufferName;
|
|
|
|
GLuint fbTextures[2];
|
|
|
|
GLuint fbRenderBuffers[1];
|
|
|
|
Renderer::ShaderProgram* postProg;
|
2014-08-12 22:15:26 +02:00
|
|
|
|
2013-07-02 09:53:23 +02:00
|
|
|
public:
|
|
|
|
|
2015-04-27 04:55:18 +02:00
|
|
|
GameRenderer(Logger* log, GameData* data);
|
2015-03-28 14:42:29 +01:00
|
|
|
~GameRenderer();
|
2013-07-02 09:53:23 +02:00
|
|
|
|
2014-07-09 06:04:48 +02:00
|
|
|
/** Number of culling events */
|
2013-07-02 10:58:01 +02:00
|
|
|
size_t culled;
|
2013-07-03 10:46:07 +02:00
|
|
|
|
2014-07-09 06:04:48 +02:00
|
|
|
/** @todo Clean up all these shader program and location variables */
|
2014-08-22 15:29:46 +02:00
|
|
|
Renderer::ShaderProgram* worldProg;
|
|
|
|
Renderer::ShaderProgram* skyProg;
|
2015-01-23 18:18:16 +01:00
|
|
|
Renderer::ShaderProgram* particleProg;
|
2014-08-22 15:29:46 +02:00
|
|
|
|
2014-07-28 03:27:55 +02:00
|
|
|
GLuint ssRectProgram;
|
|
|
|
GLint ssRectTexture, ssRectColour, ssRectSize, ssRectOffset;
|
2014-07-09 03:06:59 +02:00
|
|
|
|
2014-06-08 20:04:47 +02:00
|
|
|
GLuint skydomeVBO, skydomeIBO, debugVBO;
|
2013-07-30 17:59:44 +02:00
|
|
|
GLuint debugTex;
|
2014-08-22 15:29:46 +02:00
|
|
|
|
|
|
|
DrawBuffer skyDbuff;
|
|
|
|
GeometryBuffer skyGbuff;
|
2013-07-04 12:43:28 +02:00
|
|
|
|
2015-01-23 18:18:16 +01:00
|
|
|
DrawBuffer cylinderBuffer;
|
|
|
|
GeometryBuffer cylinderGeometry;
|
2015-04-27 04:55:18 +02:00
|
|
|
|
|
|
|
GameData* getData() const { return data; }
|
|
|
|
|
2013-07-30 17:59:44 +02:00
|
|
|
/**
|
2014-08-12 22:15:26 +02:00
|
|
|
* Renders the world using the parameters of the passed Camera.
|
|
|
|
* Note: The camera's near and far planes are overriden by weather effects.
|
2014-07-09 06:04:48 +02:00
|
|
|
*
|
|
|
|
* - draws all objects (instances, vehicles etc.)
|
|
|
|
* - draws particles
|
|
|
|
* - draws water surfaces
|
|
|
|
* - draws the skybox
|
2013-07-30 17:59:44 +02:00
|
|
|
*/
|
2015-04-27 04:55:18 +02:00
|
|
|
void renderWorld(GameWorld* world, const ViewCamera &camera, float alpha);
|
2013-07-30 17:59:44 +02:00
|
|
|
|
2014-07-09 06:04:48 +02:00
|
|
|
/**
|
|
|
|
* @brief draws a CharacterObject and any item they are holding.
|
|
|
|
* @param pedestrian the character to render
|
|
|
|
*/
|
2014-07-01 23:00:45 +02:00
|
|
|
void renderPedestrian(CharacterObject* pedestrian);
|
2014-07-09 06:04:48 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief draws a VehicleObject and it's wheels.
|
|
|
|
* @param vehicle vehicle to render
|
|
|
|
*/
|
2014-07-01 23:00:45 +02:00
|
|
|
void renderVehicle(VehicleObject* vehicle);
|
2014-07-09 06:04:48 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief draw part of the world.
|
|
|
|
*/
|
2014-07-01 23:00:45 +02:00
|
|
|
void renderInstance(InstanceObject* instance);
|
2014-07-09 06:04:48 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief draws a pickup with it's model
|
|
|
|
* @param pickup
|
|
|
|
* @todo corona rendering, with tint.
|
|
|
|
*/
|
2014-07-04 22:06:56 +02:00
|
|
|
void renderPickup(PickupObject* pickup);
|
2014-07-01 23:00:45 +02:00
|
|
|
|
2014-07-20 22:21:51 +02:00
|
|
|
void renderProjectile(ProjectileObject* projectile);
|
|
|
|
|
2014-07-30 14:44:25 +02:00
|
|
|
void renderCutsceneObject(CutsceneObject *cutscene);
|
|
|
|
|
2014-06-01 18:41:09 +02:00
|
|
|
void renderWheel(Model*, const glm::mat4& matrix, const std::string& name);
|
2013-07-24 01:42:50 +02:00
|
|
|
|
2014-06-29 23:14:46 +02:00
|
|
|
void renderItem(InventoryItem* item, const glm::mat4& modelMatrix);
|
2015-03-06 17:55:46 +01:00
|
|
|
|
2014-07-09 06:04:48 +02:00
|
|
|
/**
|
2015-03-06 17:55:46 +01:00
|
|
|
* Renders the effects (Particles, Lighttrails etc)
|
2014-07-09 06:04:48 +02:00
|
|
|
*/
|
2015-04-27 04:55:18 +02:00
|
|
|
void renderEffects(GameWorld* world);
|
2014-07-09 03:06:59 +02:00
|
|
|
|
2014-07-27 01:38:01 +02:00
|
|
|
/**
|
|
|
|
* @brief Draws the current on screen text.
|
|
|
|
*/
|
|
|
|
void drawOnScreenText();
|
|
|
|
|
2016-04-10 19:48:38 +02:00
|
|
|
/**
|
|
|
|
* @brief Draws a texture on the screen
|
|
|
|
*/
|
|
|
|
void drawTexture(TextureData* texture, glm::vec4 extents);
|
|
|
|
|
2014-02-13 11:55:11 +01:00
|
|
|
/**
|
|
|
|
* Renders a model (who'd have thought)
|
|
|
|
*/
|
2014-02-28 12:23:51 +01:00
|
|
|
void renderModel(Model*, const glm::mat4& modelMatrix, GameObject* = nullptr, Animator* animator = nullptr);
|
2013-07-30 17:59:44 +02:00
|
|
|
|
2014-08-02 22:34:48 +02:00
|
|
|
void renderGeometry(Model*, size_t geom, const glm::mat4& modelMatrix, float opacity, GameObject* = nullptr);
|
2015-01-23 18:18:16 +01:00
|
|
|
|
|
|
|
/** Renders the area indicator */
|
|
|
|
void renderAreaIndicator(const AreaIndicatorInfo* info);
|
2014-08-02 22:34:48 +02:00
|
|
|
|
2014-07-09 06:04:48 +02:00
|
|
|
/** method for rendering AI debug information */
|
2014-08-01 23:03:00 +02:00
|
|
|
void renderPaths();
|
|
|
|
|
|
|
|
/** Increases cinematic value */
|
|
|
|
void renderLetterbox();
|
2014-06-17 22:46:54 +02:00
|
|
|
|
2015-04-13 02:48:29 +02:00
|
|
|
void setupRender();
|
|
|
|
void renderPostProcess();
|
|
|
|
|
2014-09-19 01:10:05 +02:00
|
|
|
Renderer* getRenderer()
|
|
|
|
{
|
|
|
|
return renderer;
|
|
|
|
}
|
2015-01-25 18:54:31 +01:00
|
|
|
|
2015-03-28 14:42:29 +01:00
|
|
|
void setViewport(int w, int h);
|
|
|
|
|
2015-01-25 18:54:31 +01:00
|
|
|
MapRenderer map;
|
2015-03-28 14:42:29 +01:00
|
|
|
WaterRenderer water;
|
2015-02-07 23:55:06 +01:00
|
|
|
TextRenderer text;
|
2015-04-10 00:54:56 +02:00
|
|
|
|
2015-04-12 20:47:47 +02:00
|
|
|
// Profiling data
|
|
|
|
Renderer::ProfileInfo profObjects;
|
|
|
|
Renderer::ProfileInfo profSky;
|
|
|
|
Renderer::ProfileInfo profWater;
|
|
|
|
Renderer::ProfileInfo profEffects;
|
2013-07-02 09:53:23 +02:00
|
|
|
};
|
|
|
|
|
2013-07-22 05:39:58 +02:00
|
|
|
#endif
|