19 #ifndef HEADER_IRR_DRIVER_HPP
20 #define HEADER_IRR_DRIVER_HPP
30 #include "graphics/abstract_renderer.hpp"
31 #include "graphics/gl_headers.hpp"
32 #include "graphics/wind.hpp"
33 #include "io/file_manager.hpp"
34 #include "utils/aligned_array.hpp"
35 #include "utils/no_copy.hpp"
36 #include "utils/ptr_vector.hpp"
37 #include "utils/vec3.hpp"
43 #include <dimension2d.h>
44 #include <position2d.h>
47 #include <IEventReceiver.h>
52 class SPDynamicDrawCall;
58 namespace scene {
class ISceneManager;
class IMesh;
class IAnimatedMeshSceneNode;
class IAnimatedMesh;
59 class IMeshSceneNode;
class IParticleSystemSceneNode;
class ICameraSceneNode;
class ILightSceneNode;
60 class CLensFlareSceneNode; }
61 namespace gui {
class IGUIEnvironment;
class IGUIFont; }
62 namespace video {
struct IRenderTarget;
class ITexture;
class IVideoDriver;
68 enum TypeRTT :
unsigned int;
75 namespace GE {
class GERenderInfo; }
104 core::dimension2du m_actual_screen_size;
107 core::array<video::IRenderTarget>
m_mrt;
110 core::matrix4
m_ViewMatrix, m_InvViewMatrix, m_ProjMatrix, m_InvProjMatrix, m_ProjViewMatrix, m_InvProjViewMatrix;
121 enum {RES_CHANGE_NONE, RES_CHANGE_YES, RES_CHANGE_CANCEL,
122 RES_CHANGE_SAME, RES_CHANGE_YES_WARN, RES_CHANGE_SAME_FULL} m_resolution_changing;
133 VideoMode(
int w,
int h) {m_width=w; m_height=h; }
134 int getWidth()
const {
return m_width; }
135 int getHeight()
const {
return m_height; }
139 scene::ISceneNode * node;
143 video::SColorf getAmbientLight()
const;
148 int m_screen_orientation;
149 std::vector<VideoMode> m_modes;
151 void setupViewports();
162 void applyResolutionSettings(
bool recreate_device);
163 void createListOfVideoModes();
165 bool m_request_screenshot;
170 bool m_boundingboxesviz;
172 bool m_render_nw_debug;
178 unsigned m_last_light_bucket_distance;
179 unsigned m_skinning_joint;
182 core::vector3df m_sun_direction;
183 video::SColorf m_suncolor;
186 std::vector<LightNode *> m_lights;
188 std::vector<BloomData> m_forcedbloom;
190 std::vector<scene::ISceneNode *> m_background;
195 irr::ELOG_LEVEL m_logger_level;
198 std::vector<irr::scene::IAnimatedMeshSceneNode*> m_debug_meshes;
201 void updateDisplace(
float dt);
211 void setMaxTextureSize();
212 void unsetMaxTextureSize();
213 void getOpenGLData(std::string *vendor, std::string *renderer,
214 std::string *version);
216 void increaseObjectCount();
217 core::array<video::IRenderTarget> &getMainSetup();
218 void updateConfigIfRelevant();
219 core::recti getSplitscreenWindow(
int window_num);
220 void setAllMaterialFlags(scene::IMesh *mesh)
const;
221 scene::IAnimatedMesh *getAnimatedMesh(
const std::string &name);
222 scene::IMesh *getMesh(
const std::string &name);
224 void displayStoryModeTimer();
225 bool OnEvent(
const irr::SEvent &event);
226 void setAmbientLight(
const video::SColorf &light,
227 bool force_SH_computation =
true);
229 const std::string &filename);
230 video::ITexture *getTexture(
const std::string &filename);
231 void grabAllTextures(
const scene::IMesh *mesh);
232 void dropAllTextures(
const scene::IMesh *mesh);
233 scene::IMesh *createQuadMesh(
const video::SMaterial *material=NULL,
234 bool create_one_quad=
false);
235 scene::IMesh *createTexturedQuadMesh(
const video::SMaterial *material,
236 const double w,
const double h);
237 scene::ISceneNode *addWaterNode(scene::IMesh *mesh, scene::IMesh **welded,
239 float wave_speed,
float wave_length);
240 scene::IMeshSceneNode*addOctTree(scene::IMesh *mesh);
241 scene::ISceneNode* addSphere(
float radius,
242 const video::SColor &color=video::SColor(128, 255, 255, 255));
243 scene::ISceneNode* addMesh(scene::IMesh *mesh,
244 const std::string& debug_name,
245 scene::ISceneNode *parent = NULL,
246 std::shared_ptr<GE::GERenderInfo> render_info =
nullptr);
248 scene::ICameraSceneNode* cam,
249 scene::ISceneNode *parent = NULL);
250 scene::ISceneNode *addBillboard(
const core::dimension2d< f32 > size,
251 const std::string& tex_name,
252 scene::ISceneNode* parent=NULL);
253 scene::IParticleSystemSceneNode
254 *addParticleNode(
bool default_emitter=
true);
255 scene::ISceneNode *addSkyBox(
const std::vector<video::ITexture*> &texture_names,
256 const std::vector<video::ITexture*> &spherical_harmonics_textures);
257 void suppressSkyBox();
258 void removeNode(scene::ISceneNode *node);
259 void removeMeshFromCache(scene::IMesh *mesh);
260 void removeTexture(video::ITexture *t);
261 scene::IAnimatedMeshSceneNode
262 *addAnimatedMesh(scene::IAnimatedMesh *mesh,
263 const std::string& debug_name,
264 scene::ISceneNode* parent = NULL,
265 std::shared_ptr<GE::GERenderInfo> render_info =
nullptr);
266 scene::ICameraSceneNode
267 *addCameraSceneNode();
269 void removeCameraSceneNode(scene::ICameraSceneNode *camera);
270 void removeCamera(
Camera *camera);
271 void update(
float dt,
bool loading=
false);
273 void changeResolution(
const int w,
const int h,
const bool fullscreen);
275 void cancelResChange();
277 bool moveWindow(
int x,
int y);
281 void setLastLightBucketDistance(
unsigned d) { m_last_light_bucket_distance = d; }
282 void setSkinningJoint(
unsigned d) { m_skinning_joint = d; }
283 bool isPointerShown()
const {
return m_pointer_shown; }
284 core::position2di getMouseLocation();
286 void printRenderStats();
287 void requestScreenshot();
288 class GPUTimer &getGPUTimer(
unsigned);
289 const char* getGPUQueryPhaseName(
unsigned);
292 std::unique_ptr<RenderTarget> createRenderTarget(
const irr::core::dimension2du &dimension,
293 const std::string &name);
302 m_clear_color = color;
310 const core::dimension2d<u32>& getFrameSize()
const;
322 gui::IGUIEnvironment *
getGUI()
const {
return m_gui_env; }
326 unsigned int getRealTime();
329 void giveBoost(
unsigned int cam_index) { m_renderer->giveBoost(cam_index);}
331 inline core::vector3df getWind() {
return m_wind->getWind();}
337 const core::vector3df& getSunDirection()
const {
return m_sun_direction; };
339 void setSunDirection(
const core::vector3df &SunPos)
341 m_sun_direction = SunPos;
344 video::SColorf getSunColor()
const {
return m_suncolor; }
346 void setSunColor(
const video::SColorf &col)
351 GLuint getRenderTargetTexture(TypeRTT which);
352 GLuint getDepthStencilTexture();
354 void resetDebugModes();
356 void toggleSSAOViz() { m_ssaoviz = !m_ssaoviz; }
358 bool getSSAOViz() {
return m_ssaoviz; }
360 void toggleShadowViz() { m_shadowviz = !m_shadowviz; }
362 bool getShadowViz() {
return m_shadowviz; }
364 void toggleBoundingBoxesViz() { m_boundingboxesviz = !m_boundingboxesviz; }
366 void toggleRenderNetworkDebug() { m_render_nw_debug = !m_render_nw_debug; }
368 bool getRenderNetworkDebug()
const {
return m_render_nw_debug; }
370 void renderNetworkDebug();
372 bool getBoundingBoxesViz() {
return m_boundingboxesviz; }
374 int getSceneComplexity() {
return m_scene_complexity; }
376 void resetSceneComplexity() { m_scene_complexity = 0; }
378 void addSceneComplexity(
int complexity)
380 if (complexity > 1) m_scene_complexity += (complexity - 1);
383 float getLODMultiplier() {
return m_lod_multiplier; }
385 void setLODMultiplier(
float multiplier) { m_lod_multiplier = multiplier; }
387 bool isRecording()
const {
return m_recording; }
389 void setRecording(
bool val);
391 std::vector<LightNode *> getLights() {
return m_lights; }
393 void addGlowingNode(scene::ISceneNode *n,
float r = 1.0f,
float g = 1.0f,
396 m_renderer->addGlowingNode(n, r, g, b);
399 void clearGlowingNodes() { m_renderer->clearGlowingNodes(); }
401 void addForcedBloomNode(scene::ISceneNode *n,
float power = 1)
407 m_forcedbloom.push_back(dat);
410 void clearForcedBloom() { m_forcedbloom.clear(); }
412 const std::vector<BloomData> &getForcedBloom()
const
414 return m_forcedbloom;
417 void clearBackgroundNodes() { m_background.clear(); }
419 void addBackgroundNode(scene::ISceneNode *
const n)
421 m_background.push_back(n);
424 scene::ISceneNode *addLight(
const core::vector3df &pos,
float energy,
425 float radius,
float r,
float g,
float b,
427 scene::ISceneNode* parent = NULL);
434 void cleanSunInterposer();
435 void createSunInterposer();
437 void setViewMatrix(core::matrix4 matrix)
439 m_ViewMatrix = matrix; matrix.getInverse(m_InvViewMatrix);
442 const core::matrix4 &getViewMatrix()
const {
return m_ViewMatrix; }
444 const core::matrix4 &getInvViewMatrix()
const {
return m_InvViewMatrix; }
446 void setProjMatrix(core::matrix4 matrix)
448 m_ProjMatrix = matrix; matrix.getInverse(m_InvProjMatrix);
451 const core::matrix4 &getProjMatrix()
const {
return m_ProjMatrix; }
453 const core::matrix4 &getInvProjMatrix()
const {
return m_InvProjMatrix; }
455 void genProjViewMatrix()
457 m_ProjViewMatrix = m_ProjMatrix * m_ViewMatrix;
458 m_InvProjViewMatrix = m_ProjViewMatrix;
459 m_InvProjViewMatrix.makeInverse();
462 const core::matrix4 &getProjViewMatrix()
const {
return m_ProjViewMatrix; }
464 const core::matrix4 &getInvProjViewMatrix()
const
466 return m_InvProjViewMatrix;
469 const core::vector2df &getCurrentScreenSize()
const
471 return m_renderer->getCurrentScreenSize();
474 const core::dimension2du getActualScreenSize()
const
476 return m_actual_screen_size;
479 float getSSAORadius()
const
481 return m_ssao_radius;
485 void setSSAORadius(
float v)
491 float getSSAOK()
const
497 void setSSAOK(
float v)
503 float getSSAOSigma()
const
509 void setSSAOSigma(
float v)
514 std::vector<scene::IAnimatedMeshSceneNode*> getDebugMeshes()
516 return m_debug_meshes;
519 void clearDebugMesh() { m_debug_meshes.clear(); }
522 void addDebugMesh(scene::IAnimatedMeshSceneNode *node)
524 m_debug_meshes.push_back(node);
529 void onUnloadWorld();
531 void updateSplitAndLightcoordRangeFromComputeShaders(
size_t width,
534 void uploadLightingData();
535 void sameRestart() { m_resolution_changing = RES_CHANGE_SAME; }
538 void fullRestart() { m_resolution_changing = RES_CHANGE_SAME_FULL; }
540 u32 getDefaultFramebuffer()
const;
542 void handleWindowResize();
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:62
Virtual base class for the renderer.
Definition: abstract_renderer.hpp:60
This is the base class for all cameras.
Definition: camera.hpp:49
AssetType
The various asset types (and directories) STK might request.
Definition: file_manager.hpp:63
Definition: frame_buffer.hpp:33
Definition: glwrap.hpp:56
A simple class to store video resolutions.
Definition: irr_driver.hpp:128
class that creates the irrLicht device and offers higher-level ways to manage the 3D scene
Definition: irr_driver.hpp:86
AbstractRenderer * m_renderer
Renderer.
Definition: irr_driver.hpp:99
int m_scene_complexity
Store if the scene is complex (based on polycount, etc)
Definition: irr_driver.hpp:157
Wind * m_wind
Wind.
Definition: irr_driver.hpp:102
const std::vector< VideoMode > & getVideoModes() const
Returns a list of all video modes supports by the graphics card.
Definition: irr_driver.hpp:307
core::array< video::IRenderTarget > m_mrt
The main MRT setup.
Definition: irr_driver.hpp:107
void setClearbackBufferColor(irr::video::SColor color)
Sets the color to use when clearing the back buffer.
Definition: irr_driver.hpp:300
irr::video::SColor m_clear_color
Background colour to reset a buffer.
Definition: irr_driver.hpp:175
void fullRestart()
Used when we don't want a changed resolution prompt but need to reinit things that sameRestart doesn'...
Definition: irr_driver.hpp:538
core::matrix4 m_ViewMatrix
Matrixes used in several places stored here to avoid recomputation.
Definition: irr_driver.hpp:110
gui::IGUIEnvironment * m_gui_env
Irrlicht gui environment.
Definition: irr_driver.hpp:93
const SHCoefficients * getSHCoefficients()
Returns a pointer to the spherical harmonics coefficients.
Definition: irr_driver.hpp:335
gui::IGUIEnvironment * getGUI() const
Returns the gui environment, used to add widgets to a screen.
Definition: irr_driver.hpp:322
const irr::video::SColor & getClearColor() const
Returns the color to clear the back buffer.
Definition: irr_driver.hpp:297
gui::IGUIFont * m_race_font
Irrlicht race font.
Definition: irr_driver.hpp:97
void giveBoost(unsigned int cam_index)
Use motion blur for a short time.
Definition: irr_driver.hpp:329
video::IVideoDriver * m_video_driver
Irrlicht video driver.
Definition: irr_driver.hpp:95
video::IVideoDriver * getVideoDriver() const
Returns the irrlicht video driver.
Definition: irr_driver.hpp:316
scene::ISceneManager * m_scene_manager
Irrlicht scene manager.
Definition: irr_driver.hpp:91
scene::ISceneManager * getSceneManager() const
Returns the irrlicht scene manager.
Definition: irr_driver.hpp:319
IrrlichtDevice * getDevice() const
Returns the irrlicht device.
Definition: irr_driver.hpp:313
float m_lod_multiplier
Used for auto-LoD adjustment in low-complexity scenes.
Definition: irr_driver.hpp:159
bool m_pointer_shown
Whether the mouse cursor is currently shown.
Definition: irr_driver.hpp:154
IrrlichtDevice * m_device
The irrlicht device.
Definition: irr_driver.hpp:89
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:26
manages smoke particle effects
Definition: per_camera_node.hpp:46
Definition: render_target.hpp:42
Definition: sp_dynamic_draw_call.hpp:42
Definition: irr_driver.hpp:138
Definition: spherical_harmonics.hpp:33