SuperTuxKart
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
IrrDriver Class Reference

class that creates the irrLicht device and offers higher-level ways to manage the 3D scene More...

#include <irr_driver.hpp>

Inheritance diagram for IrrDriver:
Inheritance graph
[legend]

Classes

struct  BloomData
 
class  VideoMode
 A simple class to store video resolutions. More...
 

Public Member Functions

video::SColorf getAmbientLight () const
 
void doScreenShot ()
 Requess a screenshot from irrlicht, and save it in a file.
 
 IrrDriver ()
 The constructor creates the irrlicht device.
 
 ~IrrDriver ()
 Destructor - removes the irrlicht device.
 
void initDevice ()
 This creates the actualy OpenGL device.
 
void reset ()
 Called before a race is started, after all cameras are set up.
 
void setMaxTextureSize ()
 
void unsetMaxTextureSize ()
 
void getOpenGLData (std::string *vendor, std::string *renderer, std::string *version)
 
void increaseObjectCount ()
 
core::array< video::IRenderTarget > & getMainSetup ()
 
void updateConfigIfRelevant ()
 If the position of the window should be remembered, store it in the config file.
 
core::recti getSplitscreenWindow (int WindowNum)
 
void setAllMaterialFlags (scene::IMesh *mesh) const
 Sets the material flags in this mesh depending on the settings in material_manager.
 
scene::IAnimatedMesh * getAnimatedMesh (const std::string &name)
 Loads an animated mesh and returns a pointer to it.
 
scene::IMesh * getMesh (const std::string &name)
 Loads a non-animated mesh and returns a pointer to it.
 
void displayFPS ()
 Displays the FPS on the screen.
 
void displayStoryModeTimer ()
 Displays the timer for Story Mode on the screen.
 
bool OnEvent (const irr::SEvent &event)
 This is not really used to process events, it's only used to shut down irrLicht's chatty logging until the event handler is ready to take the task.
 
void setAmbientLight (const video::SColorf &light, bool force_SH_computation=true)
 Sets the ambient light.
 
video::ITexture * getTexture (FileManager::AssetType type, const std::string &filename)
 Loads a texture from a file and returns the texture object.
 
video::ITexture * getTexture (const std::string &filename)
 Loads a texture from a file and returns the texture object.
 
void grabAllTextures (const scene::IMesh *mesh)
 Appends a pointer to each texture used in this mesh to the vector.
 
void dropAllTextures (const scene::IMesh *mesh)
 Appends a pointer to each texture used in this mesh to the vector.
 
scene::IMesh * createQuadMesh (const video::SMaterial *material=NULL, bool create_one_quad=false)
 Creates a quad mesh with a given material.
 
scene::IMesh * createTexturedQuadMesh (const video::SMaterial *material, const double w, const double h)
 Creates a quad mesh buffer with a given width and height (z coordinate is 0).
 
scene::ISceneNode * addWaterNode (scene::IMesh *mesh, scene::IMesh **welded, float wave_height, float wave_speed, float wave_length)
 Converts the mesh into a water scene node.
 
scene::IMeshSceneNode * addOctTree (scene::IMesh *mesh)
 Adds a mesh that will be optimised using an oct tree.
 
scene::ISceneNode * addSphere (float radius, const video::SColor &color=video::SColor(128, 255, 255, 255))
 Adds a sphere with a given radius and color.
 
scene::ISceneNode * addMesh (scene::IMesh *mesh, const std::string &debug_name, scene::ISceneNode *parent=NULL, std::shared_ptr< GE::GERenderInfo > render_info=nullptr)
 Adds a static mesh to scene.
 
PerCameraNodeaddPerCameraNode (scene::ISceneNode *node, scene::ICameraSceneNode *cam, scene::ISceneNode *parent=NULL)
 
scene::ISceneNode * addBillboard (const core::dimension2d< f32 > size, const std::string &tex_name, scene::ISceneNode *parent=NULL)
 Adds a billboard node to scene.
 
scene::IParticleSystemSceneNode * addParticleNode (bool default_emitter=true)
 Adds a particle scene node.
 
scene::ISceneNode * addSkyBox (const std::vector< video::ITexture * > &texture_names, const std::vector< video::ITexture * > &spherical_harmonics_textures)
 Adds a skybox using.
 
void suppressSkyBox ()
 
void removeNode (scene::ISceneNode *node)
 Removes a scene node from the scene.
 
void removeMeshFromCache (scene::IMesh *mesh)
 Removes a mesh from the mesh cache, freeing the memory.
 
void removeTexture (video::ITexture *t)
 Removes a texture from irrlicht's texture cache.
 
scene::IAnimatedMeshSceneNode * addAnimatedMesh (scene::IAnimatedMesh *mesh, const std::string &debug_name, scene::ISceneNode *parent=NULL, std::shared_ptr< GE::GERenderInfo > render_info=nullptr)
 Adds an animated mesh to the scene.
 
scene::ICameraSceneNode * addCameraSceneNode ()
 Adds a camera to the scene.
 
CameraaddCamera (unsigned int index, AbstractKart *kart)
 
void removeCameraSceneNode (scene::ICameraSceneNode *camera)
 Removes a camera.
 
void removeCamera (Camera *camera)
 
void update (float dt, bool loading=false)
 Update, called once per frame.
 
void changeResolution (const int w, const int h, const bool fullscreen)
 Call to change resolution.
 
void cancelResChange ()
 Call this to roll back to the previous resolution if a resolution switch attempt goes bad.
 
bool moveWindow (int x, int y)
 Moves the STK main window to coordinates (x,y)
 
void showPointer ()
 
void hidePointer ()
 
void setLastLightBucketDistance (unsigned d)
 
void setSkinningJoint (unsigned d)
 
bool isPointerShown () const
 
core::position2di getMouseLocation ()
 
void printRenderStats ()
 Prints statistics about rendering, e.g.
 
void requestScreenshot ()
 
class GPUTimergetGPUTimer (unsigned)
 
const char * getGPUQueryPhaseName (unsigned)
 
std::unique_ptr< RenderTargetcreateRenderTarget (const irr::core::dimension2du &dimension, const std::string &name)
 
const irr::video::SColor & getClearColor () const
 Returns the color to clear the back buffer.
 
void setClearbackBufferColor (irr::video::SColor color)
 Sets the color to use when clearing the back buffer.
 
const std::vector< VideoMode > & getVideoModes () const
 Returns a list of all video modes supports by the graphics card.
 
const core::dimension2d< u32 > & getFrameSize () const
 Returns the frame size.
 
IrrlichtDevice * getDevice () const
 Returns the irrlicht device.
 
video::IVideoDriver * getVideoDriver () const
 Returns the irrlicht video driver.
 
scene::ISceneManager * getSceneManager () const
 Returns the irrlicht scene manager.
 
gui::IGUIEnvironment * getGUI () const
 Returns the gui environment, used to add widgets to a screen.
 
unsigned int getRealTime ()
 Returns the current real time, which might not be 0 at start of the application.
 
void giveBoost (unsigned int cam_index)
 Use motion blur for a short time.
 
core::vector3df getWind ()
 
const SHCoefficientsgetSHCoefficients ()
 Returns a pointer to the spherical harmonics coefficients.
 
const core::vector3df & getSunDirection () const
 
void setSunDirection (const core::vector3df &SunPos)
 
video::SColorf getSunColor () const
 
void setSunColor (const video::SColorf &col)
 
GLuint getRenderTargetTexture (TypeRTT which)
 
GLuint getDepthStencilTexture ()
 
void resetDebugModes ()
 
void toggleSSAOViz ()
 
bool getSSAOViz ()
 
void toggleShadowViz ()
 
bool getShadowViz ()
 
void toggleBoundingBoxesViz ()
 
void toggleRenderNetworkDebug ()
 
bool getRenderNetworkDebug () const
 
void renderNetworkDebug ()
 
bool getBoundingBoxesViz ()
 
int getSceneComplexity ()
 
void resetSceneComplexity ()
 
void addSceneComplexity (int complexity)
 
bool isRecording () const
 
void setRecording (bool val)
 
std::vector< LightNode * > getLights ()
 
void addGlowingNode (scene::ISceneNode *n, float r=1.0f, float g=1.0f, float b=1.0f)
 
void clearGlowingNodes ()
 
void addForcedBloomNode (scene::ISceneNode *n, float power=1)
 
void clearForcedBloom ()
 
const std::vector< BloomData > & getForcedBloom () const
 
void clearBackgroundNodes ()
 
void addBackgroundNode (scene::ISceneNode *const n)
 
scene::ISceneNode * addLight (const core::vector3df &pos, float energy, float radius, float r, float g, float b, bool sun_=false, scene::ISceneNode *parent=NULL)
 
void clearLights ()
 
SP::SPDynamicDrawCallgetSunInterposer ()
 
void cleanSunInterposer ()
 
void createSunInterposer ()
 
void setViewMatrix (core::matrix4 matrix)
 
const core::matrix4 & getViewMatrix () const
 
const core::matrix4 & getInvViewMatrix () const
 
void setProjMatrix (core::matrix4 matrix)
 
const core::matrix4 & getProjMatrix () const
 
const core::matrix4 & getInvProjMatrix () const
 
void genProjViewMatrix ()
 
const core::matrix4 & getProjViewMatrix () const
 
const core::matrix4 & getInvProjViewMatrix () const
 
const core::vector2df & getCurrentScreenSize () const
 
const core::dimension2du getActualScreenSize () const
 
float getSSAORadius () const
 
void setSSAORadius (float v)
 
float getSSAOK () const
 
void setSSAOK (float v)
 
float getSSAOSigma () const
 
void setSSAOSigma (float v)
 
void onLoadWorld ()
 
void onUnloadWorld ()
 
void updateSplitAndLightcoordRangeFromComputeShaders (size_t width, size_t height)
 
void uploadLightingData ()
 
void sameRestart ()
 
u32 getDefaultFramebuffer () const
 
void handleWindowResize ()
 

Private Types

enum  {
  RES_CHANGE_NONE , RES_CHANGE_YES , RES_CHANGE_CANCEL , RES_CHANGE_SAME ,
  RES_CHANGE_YES_WARN
}
 Flag to indicate if a resolution change is pending (which will be acted upon in the next update). More...
 

Private Member Functions

void setupViewports ()
 
void applyResolutionSettings (bool recreate_device)
 Internal method that applies the resolution in user settings.
 
void createListOfVideoModes ()
 Gets a list of supported video modes from the irrlicht device.
 
void resizeWindow ()
 

Private Attributes

IrrlichtDevice * m_device
 The irrlicht device.
 
scene::ISceneManager * m_scene_manager
 Irrlicht scene manager.
 
gui::IGUIEnvironment * m_gui_env
 Irrlicht gui environment.
 
video::IVideoDriver * m_video_driver
 Irrlicht video driver.
 
gui::IGUIFont * m_race_font
 Irrlicht race font.
 
AbstractRendererm_renderer
 Renderer.
 
Windm_wind
 Wind.
 
core::dimension2du m_actual_screen_size
 
core::array< video::IRenderTarget > m_mrt
 The main MRT setup.
 
core::matrix4 m_ViewMatrix
 Matrixes used in several places stored here to avoid recomputation.
 
core::matrix4 m_InvViewMatrix
 
core::matrix4 m_ProjMatrix
 
core::matrix4 m_InvProjMatrix
 
core::matrix4 m_ProjViewMatrix
 
core::matrix4 m_InvProjViewMatrix
 
enum IrrDriver:: { ... }  m_resolution_changing
 Flag to indicate if a resolution change is pending (which will be acted upon in the next update).
 
int m_screen_orientation
 
std::vector< VideoModem_modes
 
bool m_pointer_shown
 Whether the mouse cursor is currently shown.
 
int m_scene_complexity
 Store if the scene is complex (based on polycount, etc)
 
bool m_request_screenshot
 
bool m_ssaoviz
 
bool m_shadowviz
 
bool m_lightviz
 
bool m_boundingboxesviz
 
bool m_recording
 
bool m_render_nw_debug
 
irr::video::SColor m_clear_color
 Background colour to reset a buffer.
 
unsigned m_last_light_bucket_distance
 
unsigned m_skinning_joint
 
SP::SPDynamicDrawCallm_sun_interposer
 
core::vector3df m_sun_direction
 
video::SColorf m_suncolor
 
std::vector< LightNode * > m_lights
 
std::vector< BloomDatam_forcedbloom
 
std::vector< scene::ISceneNode * > m_background
 
float m_ssao_radius
 
float m_ssao_k
 
float m_ssao_sigma
 
irr::ELOG_LEVEL m_logger_level
 

Detailed Description

class that creates the irrLicht device and offers higher-level ways to manage the 3D scene

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private

Flag to indicate if a resolution change is pending (which will be acted upon in the next update).

None means no change, yes means change to new resolution and trigger confirmation dialog. Yes_warn means that the new resolution is unsupported and that the confirmation dialog needs an additional warning message. Same indicates a change of the resolution (back to the original one), but no confirmation dialog.

Constructor & Destructor Documentation

◆ IrrDriver()

IrrDriver::IrrDriver ( )

The constructor creates the irrlicht device.

It first creates a NULL device. This is necessary to handle the Chicken/egg problem with irrlicht: access to the file system is given from the device, but we can't create the device before reading the user_config file (for resolution, fullscreen). So we create a dummy device here to begin with, which is then later (once the real device exists) changed in initDevice().

Member Function Documentation

◆ addAnimatedMesh()

scene::IAnimatedMeshSceneNode * IrrDriver::addAnimatedMesh ( scene::IAnimatedMesh *  mesh,
const std::string &  debug_name,
scene::ISceneNode *  parent = NULL,
std::shared_ptr< GE::GERenderInfo >  render_info = nullptr 
)

Adds an animated mesh to the scene.

Parameters
meshThe animated mesh to add.

◆ addMesh()

scene::ISceneNode * IrrDriver::addMesh ( scene::IMesh *  mesh,
const std::string &  debug_name,
scene::ISceneNode *  parent = NULL,
std::shared_ptr< GE::GERenderInfo >  render_info = nullptr 
)

Adds a static mesh to scene.

This should be used for smaller objects, since the node is not optimised.

Parameters
meshThe mesh to add.

◆ addOctTree()

scene::IMeshSceneNode * IrrDriver::addOctTree ( scene::IMesh *  mesh)

Adds a mesh that will be optimised using an oct tree.

Parameters
meshMesh to add.

◆ addSkyBox()

scene::ISceneNode * IrrDriver::addSkyBox ( const std::vector< video::ITexture * > &  texture,
const std::vector< video::ITexture * > &  spherical_harmonics_textures 
)

Adds a skybox using.

Irrlicht documentation: A skybox is a big cube with 6 textures on it and is drawn around the camera position.

Parameters
topTexture for the top plane of the box.
bottomTexture for the bottom plane of the box.
leftTexture for the left plane of the box.
rightTexture for the right plane of the box.
frontTexture for the front plane of the box.
backTexture for the back plane of the box.

◆ addSphere()

scene::ISceneNode * IrrDriver::addSphere ( float  radius,
const video::SColor &  color = video::SColor(128, 255, 255, 255) 
)

Adds a sphere with a given radius and color.

Parameters
radiusThe radius of the sphere.
colorThe color to use (default (0,0,0,0)

◆ addWaterNode()

scene::ISceneNode * IrrDriver::addWaterNode ( scene::IMesh *  mesh,
scene::IMesh **  welded,
float  wave_height,
float  wave_speed,
float  wave_length 
)

Converts the mesh into a water scene node.

Parameters
meshThe mesh which is converted into a water scene node.
wave_heightHeight of the water waves.
wave_speedSpeed of the water waves.
wave_lengthLenght of a water wave.

◆ createListOfVideoModes()

void IrrDriver::createListOfVideoModes ( )
private

Gets a list of supported video modes from the irrlicht device.

This data is stored in m_modes.

◆ createQuadMesh()

scene::IMesh * IrrDriver::createQuadMesh ( const video::SMaterial *  material = NULL,
bool  create_one_quad = false 
)

Creates a quad mesh with a given material.

Parameters
materialThe material to use (NULL if no material).
create_one_quadIf true creates one quad in the mesh.

◆ createTexturedQuadMesh()

scene::IMesh * IrrDriver::createTexturedQuadMesh ( const video::SMaterial *  material,
const double  w,
const double  h 
)

Creates a quad mesh buffer with a given width and height (z coordinate is 0).

Parameters
materialThe material to use for this quad.
wWidth of the quad.
hHeight of the quad.

◆ displayStoryModeTimer()

void IrrDriver::displayStoryModeTimer ( )

Displays the timer for Story Mode on the screen.

This can't be done in race or overworld GUIs as the speedrun timer has to be displayed on all screens.

◆ dropAllTextures()

void IrrDriver::dropAllTextures ( const scene::IMesh *  mesh)

Appends a pointer to each texture used in this mesh to the vector.

Parameters
meshThe mesh from which the textures are being determined.
texture_listThe list to which to attach the pointer to.

◆ getAnimatedMesh()

scene::IAnimatedMesh * IrrDriver::getAnimatedMesh ( const std::string &  filename)

Loads an animated mesh and returns a pointer to it.

Parameters
filenameFile to load.

◆ getMesh()

scene::IMesh * IrrDriver::getMesh ( const std::string &  filename)

Loads a non-animated mesh and returns a pointer to it.

Parameters
filenameFile to load.

◆ getRealTime()

unsigned int IrrDriver::getRealTime ( )

Returns the current real time, which might not be 0 at start of the application.

Value in msec.

◆ getTexture() [1/2]

video::ITexture * IrrDriver::getTexture ( const std::string &  filename)

Loads a texture from a file and returns the texture object.

Parameters
filenameFile name of the texture to load.

◆ getTexture() [2/2]

video::ITexture * IrrDriver::getTexture ( FileManager::AssetType  type,
const std::string &  filename 
)

Loads a texture from a file and returns the texture object.

This is just a convenient wrapper which loads the texture from a STK asset directory. It calls the file manager to get the full path, then calls the normal getTexture() function.s

Parameters
typeThe FileManager::AssetType of the texture.
filenameFile name of the texture to load.

◆ grabAllTextures()

void IrrDriver::grabAllTextures ( const scene::IMesh *  mesh)

Appends a pointer to each texture used in this mesh to the vector.

Parameters
meshThe mesh from which the textures are being determined.
texture_listThe list to which to attach the pointer to.

◆ initDevice()

void IrrDriver::initDevice ( )

This creates the actualy OpenGL device.

This is called

◆ moveWindow()

bool IrrDriver::moveWindow ( int  x,
int  y 
)

Moves the STK main window to coordinates (x,y)

Returns
true on success, false on failure (always true on Linux at the moment)

◆ printRenderStats()

void IrrDriver::printRenderStats ( )

Prints statistics about rendering, e.g.

number of drawn and culled triangles etc. Note that printing this information will also slow down STK.

◆ removeCameraSceneNode()

void IrrDriver::removeCameraSceneNode ( scene::ICameraSceneNode *  camera)

Removes a camera.

This can't be done with removeNode() since the camera can be marked as active, meaning a drop will not delete it. While this doesn't really cause a memory leak (the camera is removed the next time a camera is added), it's a bit cleaner and easier to check for memory leaks, since the scene root should now always be empty.

◆ removeMeshFromCache()

void IrrDriver::removeMeshFromCache ( scene::IMesh *  mesh)

Removes a mesh from the mesh cache, freeing the memory.

Parameters
meshThe mesh to remove.

◆ removeNode()

void IrrDriver::removeNode ( scene::ISceneNode *  node)

Removes a scene node from the scene.

Parameters
nodeThe scene node to remove.

◆ removeTexture()

void IrrDriver::removeTexture ( video::ITexture *  t)

Removes a texture from irrlicht's texture cache.

Parameters
tThe texture to remove.

◆ setAllMaterialFlags()

void IrrDriver::setAllMaterialFlags ( scene::IMesh *  mesh) const

Sets the material flags in this mesh depending on the settings in material_manager.

Parameters
meshThe mesh to change the settings in.

◆ setAmbientLight()

void IrrDriver::setAmbientLight ( const video::SColorf &  light,
bool  force_SH_computation = true 
)

Sets the ambient light.

Parameters
lightThe colour of the light to set.
force_SH_computationIf false, do not recompute spherical harmonics coefficient when spherical harmonics textures have been defined

◆ update()

void IrrDriver::update ( float  dt,
bool  is_loading = false 
)

Update, called once per frame.

Parameters
dtTime since last update
is_loadingTrue if the rendering is called during loading of world, in which case world, physics etc must not be accessed/

◆ updateConfigIfRelevant()

void IrrDriver::updateConfigIfRelevant ( )

If the position of the window should be remembered, store it in the config file.

Postcondition
The user config file must still be saved!

Member Data Documentation

◆ m_clear_color

irr::video::SColor IrrDriver::m_clear_color
private

Background colour to reset a buffer.

Can be changed by each track.

◆ 

enum { ... } IrrDriver::m_resolution_changing

Flag to indicate if a resolution change is pending (which will be acted upon in the next update).

None means no change, yes means change to new resolution and trigger confirmation dialog. Yes_warn means that the new resolution is unsupported and that the confirmation dialog needs an additional warning message. Same indicates a change of the resolution (back to the original one), but no confirmation dialog.


The documentation for this class was generated from the following files: