diff --git a/src/achievements/achievement.hpp b/src/achievements/achievement.hpp index b127af293..9f7239d98 100644 --- a/src/achievements/achievement.hpp +++ b/src/achievements/achievement.hpp @@ -35,7 +35,7 @@ class XMLNode; * storage for state information by a generic key-value mapping. The values * are stored as strings, but can be used to store numerical values. E.g. * you can call increase("key", 10) for an achievement, which will convert - * the string to int, add 10, then convert the result back to string for + * the string to int, add 10, then convert the result back to string for * storage. * \ingroup achievements */ @@ -69,7 +69,7 @@ public: virtual void reset(); virtual irr::core::stringw getProgressAsString() const; - void onRaceEnd(); + void onRaceEnd(); void onLapEnd(); // ------------------------------------------------------------------------ /** Returns the id of this achievement. */ @@ -89,4 +89,4 @@ public: return m_progress_map; } // getProgress }; // class Achievement -#endif +#endif \ No newline at end of file diff --git a/src/achievements/achievement_info.cpp b/src/achievements/achievement_info.cpp index 1f90f7200..692bff4bd 100644 --- a/src/achievements/achievement_info.cpp +++ b/src/achievements/achievement_info.cpp @@ -41,7 +41,7 @@ AchievementInfo::AchievementInfo(const XMLNode * input) input->get("description", &m_description ); if (!all) { - Log::error("AchievementInfo", + Log::error("AchievementInfo", "Not all necessary values for achievement defined."); Log::error("AchievementInfo", "ID %d title '%s' description '%s'", m_id, m_title.c_str(), @@ -80,7 +80,7 @@ AchievementInfo::AchievementInfo(const XMLNode * input) m_goal_values[key] = goal; } if (m_goal_values.size() != input->getNumNodes()) - Log::fatal("AchievementInfo", + Log::fatal("AchievementInfo", "Duplicate keys for the entries of a MapAchievement found."); if (m_check_type == AC_ONE_AT_LEAST) @@ -156,7 +156,7 @@ bool AchievementInfo::checkCompletion(Achievement * achievement) const } // ---------------------------------------------------------------------------- int AchievementInfo::getGoalValue(const std::string &key) const -{ +{ std::map::const_iterator it; it = m_goal_values.find(key); if (it != m_goal_values.end()) diff --git a/src/achievements/achievements_manager.cpp b/src/achievements/achievements_manager.cpp index f744a08ee..ec59095cf 100644 --- a/src/achievements/achievements_manager.cpp +++ b/src/achievements/achievements_manager.cpp @@ -74,14 +74,14 @@ AchievementsManager::~AchievementsManager() * information for a single player. * \param node The XML of saved data, or NULL if no saved data exists. */ -AchievementsStatus* +AchievementsStatus* AchievementsManager::createAchievementsStatus(const XMLNode *node) { AchievementsStatus *status = new AchievementsStatus(); // First add all achievements, before restoring the saved data. std::map::const_iterator it; - for (it = m_achievements_info.begin(); + for (it = m_achievements_info.begin(); it != m_achievements_info.end(); ++it) { Achievement * achievement; @@ -98,7 +98,7 @@ AchievementsStatus* // ---------------------------------------------------------------------------- AchievementInfo * AchievementsManager::getAchievementInfo(uint32_t id) const { - std::map::const_iterator info = + std::map::const_iterator info = m_achievements_info.find(id); if (info != m_achievements_info.end()) return info->second; diff --git a/src/achievements/achievements_manager.hpp b/src/achievements/achievements_manager.hpp index a9c8ab90a..d138cb151 100644 --- a/src/achievements/achievements_manager.hpp +++ b/src/achievements/achievements_manager.hpp @@ -76,7 +76,7 @@ public: // ------------------------------------------------------------------------ const std::map & getAllInfo() { - return m_achievements_info; + return m_achievements_info; } // getAllInfo }; // class AchievementsManager diff --git a/src/achievements/achievements_status.cpp b/src/achievements/achievements_status.cpp index f9b311b19..3643b9d52 100644 --- a/src/achievements/achievements_status.cpp +++ b/src/achievements/achievements_status.cpp @@ -140,4 +140,4 @@ void AchievementsStatus::onLapEnd() for (iter = m_achievements.begin(); iter != m_achievements.end(); ++iter) { iter->second->onLapEnd(); } -} // onLapEnd +} // onLapEnd \ No newline at end of file diff --git a/src/achievements/achievements_status.hpp b/src/achievements/achievements_status.hpp index 585be071d..7aa8edefa 100644 --- a/src/achievements/achievements_status.hpp +++ b/src/achievements/achievements_status.hpp @@ -62,7 +62,7 @@ public : void onRaceEnd(); void onLapEnd(); // ------------------------------------------------------------------------ - const std::map& getAllAchievements() + const std::map& getAllAchievements() { return m_achievements; } diff --git a/src/addons/addon.cpp b/src/addons/addon.cpp index d70c862bf..924facdd1 100644 --- a/src/addons/addon.cpp +++ b/src/addons/addon.cpp @@ -179,7 +179,7 @@ bool Addon::testIncluded(const std::string &min_ver, const std::string &max_ver) } // ---------------------------------------------------------------------------- -/** +/** * \brief Filter the add-on with a list of words. * \param words A list of words separated by ' '. * \return true if the add-on contains one of the words, otherwise false. @@ -194,25 +194,25 @@ bool Addon::filterByWords(const core::stringw words) const for (unsigned int i = 0; i < list.size(); i++) { list[i].make_lower(); - + core::stringw name = core::stringw(m_name).make_lower(); if (name.find(list[i].c_str()) != -1) { return true; } - + core::stringw designer = core::stringw(m_designer).make_lower(); if (designer.find(list[i].c_str()) != -1) { return true; } - + core::stringw description = core::stringw(m_description).make_lower(); if (description.find(list[i].c_str()) != -1) { return true; } } - + return false; } // filterByWords diff --git a/src/addons/addon.hpp b/src/addons/addon.hpp index ede5ccbbc..fc3c111f1 100644 --- a/src/addons/addon.hpp +++ b/src/addons/addon.hpp @@ -271,7 +271,7 @@ public: // ------------------------------------------------------------------------ bool filterByWords(const core::stringw words) const; // ------------------------------------------------------------------------ - + /** Compares two addons according to the sort order currently defined. * \param a The addon to compare this addon to. */ diff --git a/src/addons/addons_manager.cpp b/src/addons/addons_manager.cpp index 0aa6d499e..6f765aea9 100644 --- a/src/addons/addons_manager.cpp +++ b/src/addons/addons_manager.cpp @@ -106,17 +106,17 @@ void AddonsManager::init(const XMLNode *xml, include->get("mtime", &tmp); mtime = tmp; - bool download = + bool download = ( mtime > UserConfigParams::m_addons_last_updated +frequency || force_refresh || !file_manager->fileExists(filename) ) && UserConfigParams::m_internet_status == RequestManager::IPERM_ALLOWED; - + if (download) { Log::info("NetworkHttp", "Downloading updated addons.xml"); Online::HTTPRequest *download_request = new Online::HTTPRequest("addons.xml"); - download_request->setURL(addon_list_url); + download_request->setURL(addon_list_url); download_request->executeNow(); if(download_request->hadDownloadError()) { @@ -130,7 +130,7 @@ void AddonsManager::init(const XMLNode *xml, } else Log::info("NetworkHttp", "Using cached addons.xml"); - + const XMLNode *xml_addons = new XMLNode(filename); addons_manager->initAddons(xml_addons); // will free xml_addons if(UserConfigParams::logAddons()) @@ -375,7 +375,7 @@ void AddonsManager::downloadIcons() m_addon->setIconReady(); } // callback public: - IconRequest(const std::string &filename, + IconRequest(const std::string &filename, const std::string &url, Addon *addon ) : HTTPRequest(filename, true, 1) { @@ -558,8 +558,8 @@ bool AddonsManager::uninstall(const Addon &addon) // some files were successfully removed. Since we can not // know if the addon is still functional, better remove it. // On the other hand, in case of a problem the user will have - // the option in the GUI to try again. In this case - // removeTrack/Kart would not find the addon and assert. So + // the option in the GUI to try again. In this case + // removeTrack/Kart would not find the addon and assert. So // check first if the track is still known. if(addon.getType()=="kart") { diff --git a/src/addons/news_manager.cpp b/src/addons/news_manager.cpp index b61dc89ff..e398538c2 100644 --- a/src/addons/news_manager.cpp +++ b/src/addons/news_manager.cpp @@ -52,7 +52,7 @@ NewsManager::~NewsManager() * separate thread to execute downloadNews() - which (if necessary) the * news.xml file and updating the list of news messages. It also initialises * the addons manager (which can trigger another download of news.xml). - * \param force_refresh Re-download news.xml, even if + * \param force_refresh Re-download news.xml, even if */ void NewsManager::init(bool force_refresh) { @@ -102,7 +102,7 @@ void* NewsManager::downloadNews(void *obj) bool download = ( UserConfigParams::m_news_last_updated==0 || UserConfigParams::m_news_last_updated +UserConfigParams::m_news_frequency - < StkTime::getTimeSinceEpoch() || + < StkTime::getTimeSinceEpoch() || me->m_force_refresh || !news_exists ) && UserConfigParams::m_internet_status==RequestManager::IPERM_ALLOWED; @@ -183,7 +183,7 @@ void* NewsManager::downloadNews(void *obj) if(xml) delete xml; xml = NULL; - + // Process new.xml now. if(file_manager->fileExists(xml_file)) { diff --git a/src/animations/three_d_animation.hpp b/src/animations/three_d_animation.hpp index fedf44daf..451ed2a82 100644 --- a/src/animations/three_d_animation.hpp +++ b/src/animations/three_d_animation.hpp @@ -53,7 +53,7 @@ private: /** True if a collision with this object should trigger * "exploding" a kart. */ bool m_explode_kart; - + bool m_flatten_kart; /** We have to store the rotation value as computed in blender, since diff --git a/src/audio/sfx_buffer.cpp b/src/audio/sfx_buffer.cpp index c40e13624..8bcefbfec 100644 --- a/src/audio/sfx_buffer.cpp +++ b/src/audio/sfx_buffer.cpp @@ -78,7 +78,7 @@ SFXBuffer::SFXBuffer(const std::string& file, bool SFXBuffer::load() { if (UserConfigParams::m_sfx == false) return false; - + #if HAVE_OGGVORBIS if (m_loaded) return false; diff --git a/src/audio/sfx_manager.cpp b/src/audio/sfx_manager.cpp index 914b854d2..af00cb056 100644 --- a/src/audio/sfx_manager.cpp +++ b/src/audio/sfx_manager.cpp @@ -251,7 +251,7 @@ SFXBuffer* SFXManager::loadSingleSfx(const XMLNode* node, } std::string sfx_name = StringUtils::removeExtension(filename); - + if(m_all_sfx_types.find(sfx_name)!=m_all_sfx_types.end()) { Log::error("SFXManager", @@ -262,7 +262,7 @@ SFXBuffer* SFXManager::loadSingleSfx(const XMLNode* node, // Only use the filename if no full path is specified. This is used // to load terrain specific sfx. - const std::string full_path = (path == "") + const std::string full_path = (path == "") ? file_manager->getAsset(FileManager::SFX,filename) : path; diff --git a/src/audio/sfx_openal.cpp b/src/audio/sfx_openal.cpp index 61b9dc77e..778f29032 100644 --- a/src/audio/sfx_openal.cpp +++ b/src/audio/sfx_openal.cpp @@ -159,7 +159,7 @@ void SFXOpenAL::volume(float gain) void SFXOpenAL::masterVolume(float gain) { m_master_gain = gain; - + if(!m_ok) return; alSourcef(m_soundSource, AL_GAIN, (m_gain < 0.0f ? m_defaultGain : m_gain) * m_master_gain); diff --git a/src/audio/sfx_openal.hpp b/src/audio/sfx_openal.hpp index 858c0c4f9..5ba26e8e0 100644 --- a/src/audio/sfx_openal.hpp +++ b/src/audio/sfx_openal.hpp @@ -55,7 +55,7 @@ private: the sound source won't be created and we'll be left with no clue when enabling sounds later. */ float m_gain; - + /** The master gain set in user preferences */ float m_master_gain; diff --git a/src/challenges/challenge_status.hpp b/src/challenges/challenge_status.hpp index aa3ea0c42..0026f7e76 100644 --- a/src/challenges/challenge_status.hpp +++ b/src/challenges/challenge_status.hpp @@ -45,7 +45,7 @@ class XMLNode; * challenge is not possible yet (inactive), active (i.e. user can try to * solve it), or solved. This status is stored for each difficulty level. * This data is saved to and loaded from the players.xml file. - * A StoryModeStatus instance will store an array of ChallengeStatuses, + * A StoryModeStatus instance will store an array of ChallengeStatuses, * one for each Challenge in STK. * * \ingroup challenges diff --git a/src/challenges/story_mode_status.hpp b/src/challenges/story_mode_status.hpp index 784a43605..c123a68b6 100644 --- a/src/challenges/story_mode_status.hpp +++ b/src/challenges/story_mode_status.hpp @@ -111,9 +111,9 @@ public: /** Returns if this is the first time the intro is shown. */ bool isFirstTime() const { return m_first_time; } // ------------------------------------------------------------------------ - const ChallengeStatus *getCurrentChallengeStatus() const + const ChallengeStatus *getCurrentChallengeStatus() const { - return m_current_challenge; + return m_current_challenge; } // getCurrentChallengeStatus // ------------------------------------------------------------------------ /** Returns a challenge given the challenge id. diff --git a/src/config/player_manager.cpp b/src/config/player_manager.cpp index fb80fc703..dbec8dc99 100644 --- a/src/config/player_manager.cpp +++ b/src/config/player_manager.cpp @@ -29,7 +29,7 @@ PlayerManager *PlayerManager::m_player_manager = NULL; -/** Create the instance of the player manager. +/** Create the instance of the player manager. * Also make sure that at least one player is defined (and if not, * create a default player and a guest player). */ @@ -137,7 +137,7 @@ void PlayerManager::addNewPlayer(const core::stringw& name) } // addNewPlayer // ---------------------------------------------------------------------------- -/** Deletes a player profile from the list of all profiles. +/** Deletes a player profile from the list of all profiles. */ void PlayerManager::deletePlayer(PlayerProfile *player) { @@ -146,7 +146,7 @@ void PlayerManager::deletePlayer(PlayerProfile *player) // ---------------------------------------------------------------------------- /** This function makes sure that a current player is defined. This is called - * when a screen skipping command line option is given (-N, -R, ...), in + * when a screen skipping command line option is given (-N, -R, ...), in * which case there might not be a current player (if no default player is * set in players.xml, i.e. the 'remember be' option was not picked ). Since * a lot of code depends on having a local player, just set the most diff --git a/src/config/player_manager.hpp b/src/config/player_manager.hpp index efe05836d..b167c70b5 100644 --- a/src/config/player_manager.hpp +++ b/src/config/player_manager.hpp @@ -70,7 +70,7 @@ public: m_player_manager = NULL; } // destroy // ------------------------------------------------------------------------ - + void save(); unsigned int getUniqueId() const; void addDefaultPlayer(); diff --git a/src/config/player_profile.cpp b/src/config/player_profile.cpp index e24d5a32e..c4f905266 100644 --- a/src/config/player_profile.cpp +++ b/src/config/player_profile.cpp @@ -45,7 +45,7 @@ PlayerProfile::PlayerProfile(const core::stringw& name, bool is_guest) m_unique_id = PlayerManager::get()->getUniqueId(); m_story_mode_status = unlock_manager->createStoryModeStatus(); m_is_default = false; - m_achievements_status = + m_achievements_status = AchievementsManager::get()->createAchievementsStatus(); } // PlayerProfile @@ -77,8 +77,8 @@ PlayerProfile::PlayerProfile(const XMLNode* node) */ void PlayerProfile::save(UTFWriter &out) { - out << L" \n"; @@ -111,7 +111,7 @@ void PlayerProfile::raceFinished() } // raceFinished //------------------------------------------------------------------------------ -/** Comparison used to sort players. +/** Comparison used to sort players. */ bool PlayerProfile::operator<(const PlayerProfile &other) { diff --git a/src/config/player_profile.hpp b/src/config/player_profile.hpp index 3affcbc7e..fe7c57f13 100644 --- a/src/config/player_profile.hpp +++ b/src/config/player_profile.hpp @@ -31,7 +31,7 @@ using namespace irr; class UTFWriter; class AchievementsStatus; -/** Class for managing player profiles (name, usage frequency, +/** Class for managing player profiles (name, usage frequency, * etc.). All PlayerProfiles are managed by the PlayerManager. * A PlayerProfile keeps track of the story mode progress using an instance * of StoryModeStatus, and achievements with AchievementsStatus. All data @@ -42,7 +42,7 @@ class PlayerProfile : public NoCopy { private: - /** The name of the player (wide string, so it can be in native + /** The name of the player (wide string, so it can be in native * language). */ core::stringw m_name; @@ -130,14 +130,14 @@ public: /** Returnes if the feature (kart, track) is locked. */ bool isLocked(const std::string &feature) const { - return m_story_mode_status->isLocked(feature); + return m_story_mode_status->isLocked(feature); } // isLocked // ------------------------------------------------------------------------ /** Returns all active challenges. */ void computeActive() { m_story_mode_status->computeActive(); } // ------------------------------------------------------------------------ /** Returns the list of recently completed challenges. */ - std::vector getRecentlyCompletedChallenges() + std::vector getRecentlyCompletedChallenges() { return m_story_mode_status->getRecentlyCompletedChallenges(); } // getRecently Completed Challenges @@ -173,7 +173,7 @@ public: // ------------------------------------------------------------------------ unsigned int getNumEasyTrophies() const { - return m_story_mode_status->getNumEasyTrophies(); + return m_story_mode_status->getNumEasyTrophies(); } // getNumEasyTrophies // ------------------------------------------------------------------------ unsigned int getNumMediumTrophies() const @@ -183,10 +183,10 @@ public: // ----------------------------------------------------------------------- unsigned int getNumHardTrophies() const { - return m_story_mode_status->getNumHardTrophies(); + return m_story_mode_status->getNumHardTrophies(); } // getNumHardTropies // ------------------------------------------------------------------------ - AchievementsStatus* getAchievementsStatus() + AchievementsStatus* getAchievementsStatus() { return m_achievements_status; } // getAchievementsStatus diff --git a/src/config/stk_config.hpp b/src/config/stk_config.hpp index 00c09d3ec..d24a49ba6 100644 --- a/src/config/stk_config.hpp +++ b/src/config/stk_config.hpp @@ -67,7 +67,7 @@ public: float m_parachute_ubound_fraction; /**::findYourDataInAChildOf(const XMLNode* node) std::string str; child->get( StringUtils::toString(n), &str); StringUtils::fromString(str, elt); - + // check if the element is already there : bool there = false; for (unsigned int i = 0; i < m_elements.size(); i++) @@ -692,7 +692,7 @@ bool UserConfig::loadConfig() "Could not read user config file '%s'.", filename.c_str()); if(root) delete root; // Create a default config file - just in case that stk crashes later - // there is a config file that can be modified (to e.g. disable + // there is a config file that can be modified (to e.g. disable // shaders) saveConfig(); return false; @@ -703,7 +703,7 @@ bool UserConfig::loadConfig() if(root->get("version", &config_file_version) < 1) { GUIEngine::showMessage( _("Your config file was malformed, so it was deleted and a new one will be created."), 10.0f); - Log::error("UserConfig", + Log::error("UserConfig", "Warning, malformed user config file! Contains no version"); } if (config_file_version < m_current_config_version) diff --git a/src/graphics/CBatchingMesh.cpp b/src/graphics/CBatchingMesh.cpp index a039f17bf..6a2171db2 100644 --- a/src/graphics/CBatchingMesh.cpp +++ b/src/graphics/CBatchingMesh.cpp @@ -14,232 +14,232 @@ CBatchingMesh::CBatchingMesh() CBatchingMesh::~CBatchingMesh() { - u32 i; - for (i=0; i < DestBuffers.size(); ++i) - DestBuffers[i].Buffer->drop(); + u32 i; + for (i=0; i < DestBuffers.size(); ++i) + DestBuffers[i].Buffer->drop(); - for (i=0; i < SourceBuffers.size(); ++i) - SourceBuffers[i]->drop(); + for (i=0; i < SourceBuffers.size(); ++i) + SourceBuffers[i]->drop(); } bool CBatchingMesh::isDirty(s32 id) { - if ((u32)id > DestBuffers.size()) - return IsDirty; - else - return DestBuffers[id].IsDirty; + if ((u32)id > DestBuffers.size()) + return IsDirty; + else + return DestBuffers[id].IsDirty; } //! refreshes the internal buffers from source void CBatchingMesh::update() { - // allocate the index and vertex arrays - u32 i; - for (i=0; igetIndexCount() || - DestBuffers[i].VertexCount != DestBuffers[i].Buffer->getVertexCount()) - { - DestBuffers[i].IsDirty = true; + // allocate the index and vertex arrays + u32 i; + for (i=0; igetIndexCount() || + DestBuffers[i].VertexCount != DestBuffers[i].Buffer->getVertexCount()) + { + DestBuffers[i].IsDirty = true; - switch (DestBuffers[i].VertexType) - { - case video::EVT_STANDARD: - { - SMeshBuffer* mb = (SMeshBuffer*)DestBuffers[i].Buffer; - mb->Vertices.set_used(DestBuffers[i].VertexCount); - mb->Indices.set_used(DestBuffers[i].IndexCount); - break; - } - case video::EVT_2TCOORDS: - { - SMeshBufferLightMap* mb = (SMeshBufferLightMap*)DestBuffers[i].Buffer; - mb->Vertices.set_used(DestBuffers[i].VertexCount); - mb->Indices.set_used(DestBuffers[i].IndexCount); - break; - } - case video::EVT_TANGENTS: - { - SMeshBufferTangents* mb = (SMeshBufferTangents*)DestBuffers[i].Buffer; - mb->Vertices.set_used(DestBuffers[i].VertexCount); - mb->Indices.set_used(DestBuffers[i].IndexCount); - break; - } - default: // shouldn't ever happen - continue; - } - } - } + switch (DestBuffers[i].VertexType) + { + case video::EVT_STANDARD: + { + SMeshBuffer* mb = (SMeshBuffer*)DestBuffers[i].Buffer; + mb->Vertices.set_used(DestBuffers[i].VertexCount); + mb->Indices.set_used(DestBuffers[i].IndexCount); + break; + } + case video::EVT_2TCOORDS: + { + SMeshBufferLightMap* mb = (SMeshBufferLightMap*)DestBuffers[i].Buffer; + mb->Vertices.set_used(DestBuffers[i].VertexCount); + mb->Indices.set_used(DestBuffers[i].IndexCount); + break; + } + case video::EVT_TANGENTS: + { + SMeshBufferTangents* mb = (SMeshBufferTangents*)DestBuffers[i].Buffer; + mb->Vertices.set_used(DestBuffers[i].VertexCount); + mb->Indices.set_used(DestBuffers[i].IndexCount); + break; + } + default: // shouldn't ever happen + continue; + } + } + } - // refresh dirty buffers from source - for (i=0; i CBatchingMesh::addMesh(IMesh* mesh, core::vector3df pos, core::vector3df rot, core::vector3df scale) { - core::matrix4 m; - m.setRotationDegrees(rot); - m.setTranslation(pos); + core::matrix4 m; + m.setRotationDegrees(rot); + m.setTranslation(pos); - core::matrix4 scalem; - scalem.setScale(scale); - m *= scalem; + core::matrix4 scalem; + scalem.setScale(scale); + m *= scalem; - return addMesh(mesh, m); + return addMesh(mesh, m); } //! adds a mesh with the given transformation core::array CBatchingMesh::addMesh(IMesh* mesh, const core::matrix4 &transform) { - core::array bufferNos; + core::array bufferNos; - if (!mesh) - return bufferNos; + if (!mesh) + return bufferNos; - u32 i; - for (i=0; igetMeshBufferCount(); ++i) - bufferNos.push_back(addMeshBuffer(mesh->getMeshBuffer(i), transform)); + u32 i; + for (i=0; igetMeshBufferCount(); ++i) + bufferNos.push_back(addMeshBuffer(mesh->getMeshBuffer(i), transform)); - return bufferNos; + return bufferNos; } //! adds a mesh buffer with the given transformation /** \Return Returns the ID of this mesh buffer */ s32 CBatchingMesh::addMeshBuffer(IMeshBuffer* buffer, core::vector3df pos, core::vector3df rot, core::vector3df scale) { - core::matrix4 m; - m.setRotationDegrees(rot); - m.setTranslation(pos); + core::matrix4 m; + m.setRotationDegrees(rot); + m.setTranslation(pos); - core::matrix4 scalem; - scalem.setScale(scale); - m *= scalem; + core::matrix4 scalem; + scalem.setScale(scale); + m *= scalem; - return addMeshBuffer(buffer, m); + return addMeshBuffer(buffer, m); } //! adds a mesh with the given transformation /** \Return Returns the ID of this mesh buffer */ s32 CBatchingMesh::addMeshBuffer(IMeshBuffer* buffer, const core::matrix4 &transform) { - if (!buffer || IsFinal) - return -1; + if (!buffer || IsFinal) + return -1; - u32 i; - video::SMaterial m = buffer->getMaterial(); + u32 i; + video::SMaterial m = buffer->getMaterial(); - // find material - bool found=false; - video::E_VERTEX_TYPE vt = buffer->getVertexType(); - for (i=0; igetIndexCount() + DestBuffers[ MaterialReferences[i].BufferIndex ].IndexCount; - u32 newTotalV = buffer->getVertexCount() + DestBuffers[ MaterialReferences[i].BufferIndex ].VertexCount; + // find material + bool found=false; + video::E_VERTEX_TYPE vt = buffer->getVertexType(); + for (i=0; igetIndexCount() + DestBuffers[ MaterialReferences[i].BufferIndex ].IndexCount; + u32 newTotalV = buffer->getVertexCount() + DestBuffers[ MaterialReferences[i].BufferIndex ].VertexCount; - if ( newTotalI < 65536*3 && newTotalV < 65536) - { - found = true; - DestBuffers[ MaterialReferences[i].BufferIndex ].IndexCount = newTotalI; - DestBuffers[ MaterialReferences[i].BufferIndex ].VertexCount = newTotalV; - break; - } - } - } + if ( newTotalI < 65536*3 && newTotalV < 65536) + { + found = true; + DestBuffers[ MaterialReferences[i].BufferIndex ].IndexCount = newTotalI; + DestBuffers[ MaterialReferences[i].BufferIndex ].VertexCount = newTotalV; + break; + } + } + } - if (!found) - { - // we need a new destination buffer and material reference - IMeshBuffer *mb=0; + if (!found) + { + // we need a new destination buffer and material reference + IMeshBuffer *mb=0; - SMaterialReference r; - r.Material = m; - r.VertexType = vt; - r.BufferIndex = DestBuffers.size(); - switch (vt) - { - case video::EVT_STANDARD: - mb = (IMeshBuffer*)new SMeshBuffer(); - mb->getMaterial() = m; - break; - case video::EVT_2TCOORDS: - mb = (IMeshBuffer*)new SMeshBufferLightMap(); - mb->getMaterial() = m; - break; - case video::EVT_TANGENTS: - mb = (IMeshBuffer*)new SMeshBufferTangents(); - mb->getMaterial() = m; - break; - default: // unknown vertex type - return -1; - } - i = MaterialReferences.size(); - MaterialReferences.push_back(r); + SMaterialReference r; + r.Material = m; + r.VertexType = vt; + r.BufferIndex = DestBuffers.size(); + switch (vt) + { + case video::EVT_STANDARD: + mb = (IMeshBuffer*)new SMeshBuffer(); + mb->getMaterial() = m; + break; + case video::EVT_2TCOORDS: + mb = (IMeshBuffer*)new SMeshBufferLightMap(); + mb->getMaterial() = m; + break; + case video::EVT_TANGENTS: + mb = (IMeshBuffer*)new SMeshBufferTangents(); + mb->getMaterial() = m; + break; + default: // unknown vertex type + return -1; + } + i = MaterialReferences.size(); + MaterialReferences.push_back(r); - SDestBufferReference db; - db.Buffer = mb; - db.IndexCount = buffer->getIndexCount(); - db.VertexCount = buffer->getVertexCount(); - db.IsDirty = true; - db.VertexType = vt; + SDestBufferReference db; + db.Buffer = mb; + db.IndexCount = buffer->getIndexCount(); + db.VertexCount = buffer->getVertexCount(); + db.IsDirty = true; + db.VertexType = vt; - DestBuffers.push_back(db); - } - // now we add the mesh reference - SBufferReference r; - r.DestReference = i; - r.SourceBuffer = buffer; - r.Transform = transform; - r.IndexCount = buffer->getIndexCount(); - r.VertexCount = buffer->getVertexCount(); - r.FirstIndex = DestBuffers[ MaterialReferences[i].BufferIndex ].IndexCount - r.IndexCount; - r.FirstVertex = DestBuffers[ MaterialReferences[i].BufferIndex ].VertexCount - r.VertexCount; - r.Initialized = false; - BufferReferences.push_back(r); - addSourceBuffer(buffer); + DestBuffers.push_back(db); + } + // now we add the mesh reference + SBufferReference r; + r.DestReference = i; + r.SourceBuffer = buffer; + r.Transform = transform; + r.IndexCount = buffer->getIndexCount(); + r.VertexCount = buffer->getVertexCount(); + r.FirstIndex = DestBuffers[ MaterialReferences[i].BufferIndex ].IndexCount - r.IndexCount; + r.FirstVertex = DestBuffers[ MaterialReferences[i].BufferIndex ].VertexCount - r.VertexCount; + r.Initialized = false; + BufferReferences.push_back(r); + addSourceBuffer(buffer); - IsDirty = true; - return BufferReferences.size()-1; + IsDirty = true; + return BufferReferences.size()-1; } //! updates bouding box from internal buffers void CBatchingMesh::recalculateBoundingBox() { - if (DestBuffers.size() == 0) - Box.reset(0,0,0); - else - { - Box.reset(DestBuffers[0].Buffer->getBoundingBox().MinEdge); + if (DestBuffers.size() == 0) + Box.reset(0,0,0); + else + { + Box.reset(DestBuffers[0].Buffer->getBoundingBox().MinEdge); - u32 i; - for (i=0; i < DestBuffers.size(); ++i) - Box.addInternalBox(DestBuffers[i].Buffer->getBoundingBox()); - } + u32 i; + for (i=0; i < DestBuffers.size(); ++i) + Box.addInternalBox(DestBuffers[i].Buffer->getBoundingBox()); + } } @@ -249,7 +249,7 @@ void CBatchingMesh::recalculateBoundingBox() /** \return Returns the amount of mesh buffers (IMeshBuffer) in this mesh. */ u32 CBatchingMesh::getMeshBufferCount() const { - return DestBuffers.size(); + return DestBuffers.size(); } //! Returns pointer to a mesh buffer. @@ -259,29 +259,29 @@ getMeshBufferCount() - 1; NULL if there is no such mesh buffer. */ IMeshBuffer* CBatchingMesh::getMeshBuffer(u32 nr) const { - if (nr < DestBuffers.size()) - return DestBuffers[nr].Buffer; - else - return 0; + if (nr < DestBuffers.size()) + return DestBuffers[nr].Buffer; + else + return 0; } //! Returns pointer to a mesh buffer which fits a material IMeshBuffer* CBatchingMesh::getMeshBuffer( const video::SMaterial &material) const { - return 0; + return 0; } //! Returns an axis aligned bounding box of the mesh. /** \return A bounding box of this mesh is returned. */ const core::aabbox3d& CBatchingMesh::getBoundingBox() const { - return Box; + return Box; } //! set user axis aligned bounding box void CBatchingMesh::setBoundingBox( const core::aabbox3df& box) { - Box = box; + Box = box; } //! Sets a flag of all contained materials to a new value. @@ -289,218 +289,218 @@ void CBatchingMesh::setBoundingBox( const core::aabbox3df& box) \param newvalue: New value to set in all materials. */ void CBatchingMesh::setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) { - for (u32 i=0; igetMaterial().setFlag(flag, newvalue); + for (u32 i=0; igetMaterial().setFlag(flag, newvalue); } //! drops all buffers and clears internal states void CBatchingMesh::clear() { - u32 i; - for (i=0; i < DestBuffers.size(); ++i) - DestBuffers[i].Buffer->drop(); + u32 i; + for (i=0; i < DestBuffers.size(); ++i) + DestBuffers[i].Buffer->drop(); - for (i=0; i < SourceBuffers.size(); ++i) - SourceBuffers[i]->drop(); + for (i=0; i < SourceBuffers.size(); ++i) + SourceBuffers[i]->drop(); - BufferReferences.clear(); - MaterialReferences.clear(); - DestBuffers.clear(); - SourceBuffers.clear(); + BufferReferences.clear(); + MaterialReferences.clear(); + DestBuffers.clear(); + SourceBuffers.clear(); - IsDirty = false; - IsFinal = false; + IsDirty = false; + IsFinal = false; } //! first updates the mesh, then drops all source buffers. /** once this mesh has been finalized, it cannot be changed again! */ void CBatchingMesh::finalize() { - update(); + update(); - for (u32 i=0; i < SourceBuffers.size(); ++i) - SourceBuffers[i]->drop(); + for (u32 i=0; i < SourceBuffers.size(); ++i) + SourceBuffers[i]->drop(); - SourceBuffers.clear(); + SourceBuffers.clear(); - IsFinal = true; + IsFinal = true; } //! Moves a mesh core::array CBatchingMesh::moveMesh(const core::array& bufferIDs, const core::matrix4 &newMatrix) { - core::array result; - result.reallocate(bufferIDs.size()); - for (u32 i=0; i result; + result.reallocate(bufferIDs.size()); + for (u32 i=0; i BufferReferences.size() || IsFinal ) - return false; + if ((u32)id > BufferReferences.size() || IsFinal ) + return false; - BufferReferences[id].Transform = newMatrix; + BufferReferences[id].Transform = newMatrix; - // is the source buffer dirty? - if (!DestBuffers[BufferReferences[id].DestReference].IsDirty) - { - // transform each vertex and normal - updateDestFromSourceBuffer(id); - recalculateDestBufferBoundingBox(BufferReferences[id].DestReference); - } - return true; + // is the source buffer dirty? + if (!DestBuffers[BufferReferences[id].DestReference].IsDirty) + { + // transform each vertex and normal + updateDestFromSourceBuffer(id); + recalculateDestBufferBoundingBox(BufferReferences[id].DestReference); + } + return true; } //! returns the source buffer, if available IMeshBuffer* CBatchingMesh::getSourceBuffer(s32 id) { - if ((u32)id > BufferReferences.size() || IsFinal) - return 0; - else - return BufferReferences[id].SourceBuffer; + if ((u32)id > BufferReferences.size() || IsFinal) + return 0; + else + return BufferReferences[id].SourceBuffer; } //! returns the matrix of the source buffer core::matrix4 CBatchingMesh::getSourceBufferMatrix(s32 id) { - core::matrix4 ret; - if ((u32)id > BufferReferences.size() || IsFinal) - ret.makeIdentity(); - else - ret = BufferReferences[id].Transform; + core::matrix4 ret; + if ((u32)id > BufferReferences.size() || IsFinal) + ret.makeIdentity(); + else + ret = BufferReferences[id].Transform; - return ret; + return ret; } //! returns the number of source buffers u32 CBatchingMesh::getSourceBufferCount() const { - return BufferReferences.size(); + return BufferReferences.size(); } // private functions void CBatchingMesh::recalculateDestBufferBoundingBox(u32 i) { - switch (DestBuffers[i].VertexType) - { - case video::EVT_STANDARD: - ((SMeshBuffer*)DestBuffers[i].Buffer)->recalculateBoundingBox(); - break; - case video::EVT_2TCOORDS: - ((SMeshBufferLightMap*)DestBuffers[i].Buffer)->recalculateBoundingBox(); - break; - case video::EVT_TANGENTS: - ((SMeshBufferTangents*)DestBuffers[i].Buffer)->recalculateBoundingBox(); - break; - } + switch (DestBuffers[i].VertexType) + { + case video::EVT_STANDARD: + ((SMeshBuffer*)DestBuffers[i].Buffer)->recalculateBoundingBox(); + break; + case video::EVT_2TCOORDS: + ((SMeshBufferLightMap*)DestBuffers[i].Buffer)->recalculateBoundingBox(); + break; + case video::EVT_TANGENTS: + ((SMeshBufferTangents*)DestBuffers[i].Buffer)->recalculateBoundingBox(); + break; + } } void CBatchingMesh::updateDestFromSourceBuffer(u32 i) { - u16* ind = BufferReferences[i].SourceBuffer->getIndices(); - void*ver = BufferReferences[i].SourceBuffer->getVertices(); - core::matrix4 m = BufferReferences[i].Transform; - u32 fi = BufferReferences[i].FirstIndex; - u32 fv = BufferReferences[i].FirstVertex; - u32 ic = BufferReferences[i].IndexCount; - u32 vc = BufferReferences[i].VertexCount; - u32 x; - video::E_VERTEX_TYPE vt = DestBuffers[BufferReferences[i].DestReference].VertexType; - switch (vt) - { - case video::EVT_STANDARD: - { - SMeshBuffer* dest = (SMeshBuffer*) DestBuffers[BufferReferences[i].DestReference].Buffer; + u16* ind = BufferReferences[i].SourceBuffer->getIndices(); + void*ver = BufferReferences[i].SourceBuffer->getVertices(); + core::matrix4 m = BufferReferences[i].Transform; + u32 fi = BufferReferences[i].FirstIndex; + u32 fv = BufferReferences[i].FirstVertex; + u32 ic = BufferReferences[i].IndexCount; + u32 vc = BufferReferences[i].VertexCount; + u32 x; + video::E_VERTEX_TYPE vt = DestBuffers[BufferReferences[i].DestReference].VertexType; + switch (vt) + { + case video::EVT_STANDARD: + { + SMeshBuffer* dest = (SMeshBuffer*) DestBuffers[BufferReferences[i].DestReference].Buffer; - for (x=fi; x < fi+ic; ++x) - dest->Indices[x] = ind[x-fi]+fv; + for (x=fi; x < fi+ic; ++x) + dest->Indices[x] = ind[x-fi]+fv; - video::S3DVertex* vertices= (video::S3DVertex*) ver; + video::S3DVertex* vertices= (video::S3DVertex*) ver; - for (x=fv; x < fv+vc; ++x) - { - dest->Vertices[x] = vertices[x-fv]; - m.transformVect(dest->Vertices[x].Pos); - m.rotateVect(dest->Vertices[x].Normal); - } - break; - } - case video::EVT_2TCOORDS: - { - SMeshBufferLightMap* dest = (SMeshBufferLightMap*) DestBuffers[BufferReferences[i].DestReference].Buffer; + for (x=fv; x < fv+vc; ++x) + { + dest->Vertices[x] = vertices[x-fv]; + m.transformVect(dest->Vertices[x].Pos); + m.rotateVect(dest->Vertices[x].Normal); + } + break; + } + case video::EVT_2TCOORDS: + { + SMeshBufferLightMap* dest = (SMeshBufferLightMap*) DestBuffers[BufferReferences[i].DestReference].Buffer; - for (x=fi; x < fi+ic; ++x) - dest->Indices[x] = ind[x-fi]+fv; + for (x=fi; x < fi+ic; ++x) + dest->Indices[x] = ind[x-fi]+fv; - video::S3DVertex2TCoords* vertices= (video::S3DVertex2TCoords*) ver; + video::S3DVertex2TCoords* vertices= (video::S3DVertex2TCoords*) ver; - for (x=fv; x < fv+vc; ++x) - { - dest->Vertices[x] = vertices[x-fv]; - m.transformVect(dest->Vertices[x].Pos); - m.rotateVect(dest->Vertices[x].Normal); - } - break; - } - case video::EVT_TANGENTS: - { - SMeshBufferTangents* dest = (SMeshBufferTangents*) DestBuffers[BufferReferences[i].DestReference].Buffer; + for (x=fv; x < fv+vc; ++x) + { + dest->Vertices[x] = vertices[x-fv]; + m.transformVect(dest->Vertices[x].Pos); + m.rotateVect(dest->Vertices[x].Normal); + } + break; + } + case video::EVT_TANGENTS: + { + SMeshBufferTangents* dest = (SMeshBufferTangents*) DestBuffers[BufferReferences[i].DestReference].Buffer; - for (x=fi; x < fi+ic; ++x) - dest->Indices[x] = ind[x-fi]+fv; + for (x=fi; x < fi+ic; ++x) + dest->Indices[x] = ind[x-fi]+fv; - video::S3DVertexTangents* vertices= (video::S3DVertexTangents*) ver; + video::S3DVertexTangents* vertices= (video::S3DVertexTangents*) ver; - for (x=fv; x < fv+vc; ++x) - { - dest->Vertices[x] = vertices[x-fv]; - m.transformVect(dest->Vertices[x].Pos); - m.rotateVect(dest->Vertices[x].Normal); // are tangents/binormals in face space? - } - break; - } - default: - break; - } + for (x=fv; x < fv+vc; ++x) + { + dest->Vertices[x] = vertices[x-fv]; + m.transformVect(dest->Vertices[x].Pos); + m.rotateVect(dest->Vertices[x].Normal); // are tangents/binormals in face space? + } + break; + } + default: + break; + } } void CBatchingMesh::addSourceBuffer(IMeshBuffer *source) { - bool found = false; - for (u32 i=0; igrab(); - SourceBuffers.push_back(source); - } + bool found = false; + for (u32 i=0; igrab(); + SourceBuffers.push_back(source); + } } void CBatchingMesh::setHardwareMappingHint(E_HARDWARE_MAPPING mapping, E_BUFFER_TYPE type) { - for (u32 i=0; i < DestBuffers.size(); ++i) - DestBuffers[i].Buffer->setHardwareMappingHint(mapping, type); + for (u32 i=0; i < DestBuffers.size(); ++i) + DestBuffers[i].Buffer->setHardwareMappingHint(mapping, type); } void CBatchingMesh::setDirty(E_BUFFER_TYPE type) { - for (u32 i=0; i < DestBuffers.size(); ++i) - DestBuffers[i].Buffer->setDirty(type); + for (u32 i=0; i < DestBuffers.size(); ++i) + DestBuffers[i].Buffer->setDirty(type); } } // namespace scene diff --git a/src/graphics/CBatchingMesh.hpp b/src/graphics/CBatchingMesh.hpp index 30d76c424..b92998399 100644 --- a/src/graphics/CBatchingMesh.hpp +++ b/src/graphics/CBatchingMesh.hpp @@ -15,157 +15,157 @@ namespace scene class CBatchingMesh : public IMesh { public: - CBatchingMesh(); + CBatchingMesh(); - virtual ~CBatchingMesh(); + virtual ~CBatchingMesh(); - //! returns true if new buffers have been added without updating the internal buffers - bool isDirty(s32 id=-1); + //! returns true if new buffers have been added without updating the internal buffers + bool isDirty(s32 id=-1); - //! refreshes the internal buffers from source - void update(); + //! refreshes the internal buffers from source + void update(); - //! drops all buffers and clears internal states - void clear(); + //! drops all buffers and clears internal states + void clear(); - //! first updates the mesh, then drops all source buffers. - /** once this mesh has been finalized, it cannot be changed again! */ - void finalize(); + //! first updates the mesh, then drops all source buffers. + /** once this mesh has been finalized, it cannot be changed again! */ + void finalize(); - //! adds a mesh to the buffers with the given offset - /** \Return: Returns an array of ID numbers */ - core::array addMesh(IMesh* mesh, - core::vector3df pos = core::vector3df(0,0,0), - core::vector3df rot = core::vector3df(0,0,0), - core::vector3df scale = core::vector3df(1,1,1)); + //! adds a mesh to the buffers with the given offset + /** \Return: Returns an array of ID numbers */ + core::array addMesh(IMesh* mesh, + core::vector3df pos = core::vector3df(0,0,0), + core::vector3df rot = core::vector3df(0,0,0), + core::vector3df scale = core::vector3df(1,1,1)); - //! adds a mesh with the given transformation - /** \Return: Returns an array of ID numbers */ - core::array addMesh(IMesh* mesh, const core::matrix4 &transform); + //! adds a mesh with the given transformation + /** \Return: Returns an array of ID numbers */ + core::array addMesh(IMesh* mesh, const core::matrix4 &transform); - //! adds a mesh buffer with the given transformation - /** \Return: Returns the ID of this mesh buffer */ - s32 addMeshBuffer(IMeshBuffer* buffer, - core::vector3df pos = core::vector3df(0,0,0), - core::vector3df rot = core::vector3df(0,0,0), - core::vector3df scale = core::vector3df(1,1,1)); + //! adds a mesh buffer with the given transformation + /** \Return: Returns the ID of this mesh buffer */ + s32 addMeshBuffer(IMeshBuffer* buffer, + core::vector3df pos = core::vector3df(0,0,0), + core::vector3df rot = core::vector3df(0,0,0), + core::vector3df scale = core::vector3df(1,1,1)); - //! adds a mesh with the given transformation - /** \Return Returns the ID of this mesh buffer */ - s32 addMeshBuffer(IMeshBuffer* buffer, const core::matrix4 &transform); + //! adds a mesh with the given transformation + /** \Return Returns the ID of this mesh buffer */ + s32 addMeshBuffer(IMeshBuffer* buffer, const core::matrix4 &transform); - //! updates bouding box from internal buffers - void recalculateBoundingBox(); + //! updates bouding box from internal buffers + void recalculateBoundingBox(); - //! Moves a mesh, - /** mesh buffers in clean destination buffers will be moved immediately, - ones in dirty buffers will be left until the next update */ - core::array moveMesh(const core::array& bufferIDs, const core::matrix4 &newMatrix); + //! Moves a mesh, + /** mesh buffers in clean destination buffers will be moved immediately, + ones in dirty buffers will be left until the next update */ + core::array moveMesh(const core::array& bufferIDs, const core::matrix4 &newMatrix); - //! Moves a mesh buffer - /** if the destination buffer is clean it will be moved immediately, - if a member of a dirty buffer, it will be left until the next update */ - bool moveMeshBuffer(const s32 id, const core::matrix4 &newMatrix); + //! Moves a mesh buffer + /** if the destination buffer is clean it will be moved immediately, + if a member of a dirty buffer, it will be left until the next update */ + bool moveMeshBuffer(const s32 id, const core::matrix4 &newMatrix); - //! returns the source buffer, if available - IMeshBuffer* getSourceBuffer(s32 id); + //! returns the source buffer, if available + IMeshBuffer* getSourceBuffer(s32 id); - //! returns the matrix of the source buffer - core::matrix4 getSourceBufferMatrix(s32 id); + //! returns the matrix of the source buffer + core::matrix4 getSourceBufferMatrix(s32 id); - //! returns the number of source buffers - u32 getSourceBufferCount() const; + //! returns the number of source buffers + u32 getSourceBufferCount() const; - /* Standard IMesh functions */ + /* Standard IMesh functions */ - //! Returns the amount of mesh buffers. - /** \return Returns the amount of mesh buffers (IMeshBuffer) in this mesh. */ - virtual u32 getMeshBufferCount() const; + //! Returns the amount of mesh buffers. + /** \return Returns the amount of mesh buffers (IMeshBuffer) in this mesh. */ + virtual u32 getMeshBufferCount() const; - //! Returns pointer to a mesh buffer. - /** \param nr: Zero based index of the mesh buffer. The maximum value is - getMeshBufferCount() - 1; - \return Returns the pointer to the mesh buffer or - NULL if there is no such mesh buffer. */ - virtual IMeshBuffer* getMeshBuffer(u32 nr) const; + //! Returns pointer to a mesh buffer. + /** \param nr: Zero based index of the mesh buffer. The maximum value is + getMeshBufferCount() - 1; + \return Returns the pointer to the mesh buffer or + NULL if there is no such mesh buffer. */ + virtual IMeshBuffer* getMeshBuffer(u32 nr) const; - //! Returns pointer to a mesh buffer which fits a material - /** \param material: material to search for - \return Returns the pointer to the mesh buffer or - NULL if there is no such mesh buffer. */ - virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const; + //! Returns pointer to a mesh buffer which fits a material + /** \param material: material to search for + \return Returns the pointer to the mesh buffer or + NULL if there is no such mesh buffer. */ + virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const; - //! Returns an axis aligned bounding box of the mesh. - /** \return A bounding box of this mesh is returned. */ - virtual const core::aabbox3d& getBoundingBox() const; + //! Returns an axis aligned bounding box of the mesh. + /** \return A bounding box of this mesh is returned. */ + virtual const core::aabbox3d& getBoundingBox() const; - //! set user axis aligned bounding box - virtual void setBoundingBox( const core::aabbox3df& box); + //! set user axis aligned bounding box + virtual void setBoundingBox( const core::aabbox3df& box); - //! Sets a flag of all contained materials to a new value. - /** \param flag: Flag to set in all materials. - \param newvalue: New value to set in all materials. */ - virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue); + //! Sets a flag of all contained materials to a new value. + /** \param flag: Flag to set in all materials. + \param newvalue: New value to set in all materials. */ + virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue); - virtual void setHardwareMappingHint(E_HARDWARE_MAPPING mapping, E_BUFFER_TYPE type); + virtual void setHardwareMappingHint(E_HARDWARE_MAPPING mapping, E_BUFFER_TYPE type); - virtual void setDirty(E_BUFFER_TYPE type); + virtual void setDirty(E_BUFFER_TYPE type); private: - // add a buffer to the source buffers array if it doesn't already exist - void addSourceBuffer(IMeshBuffer* source); + // add a buffer to the source buffers array if it doesn't already exist + void addSourceBuffer(IMeshBuffer* source); - // updates the vertices in dest buffer from the source one - void updateDestFromSourceBuffer(u32 id); + // updates the vertices in dest buffer from the source one + void updateDestFromSourceBuffer(u32 id); - // recalculates the bounding box for the given dest buffer - void recalculateDestBufferBoundingBox(u32 i); + // recalculates the bounding box for the given dest buffer + void recalculateDestBufferBoundingBox(u32 i); - struct SBufferReference - { - SBufferReference() - : SourceBuffer(0), DestReference(0), FirstVertex(0), VertexCount(0), - FirstIndex(0), IndexCount(0), Initialized(false) { } + struct SBufferReference + { + SBufferReference() + : SourceBuffer(0), DestReference(0), FirstVertex(0), VertexCount(0), + FirstIndex(0), IndexCount(0), Initialized(false) { } - IMeshBuffer* SourceBuffer; - u32 DestReference; - u32 FirstVertex, VertexCount, FirstIndex, IndexCount; - core::matrix4 Transform; - bool Initialized; - }; + IMeshBuffer* SourceBuffer; + u32 DestReference; + u32 FirstVertex, VertexCount, FirstIndex, IndexCount; + core::matrix4 Transform; + bool Initialized; + }; - struct SMaterialReference - { - video::SMaterial Material; - video::E_VERTEX_TYPE VertexType; - u32 BufferIndex; - }; + struct SMaterialReference + { + video::SMaterial Material; + video::E_VERTEX_TYPE VertexType; + u32 BufferIndex; + }; - struct SDestBufferReference - { - IMeshBuffer* Buffer; - video::E_VERTEX_TYPE VertexType; - u32 VertexCount; - u32 IndexCount; - bool IsDirty; - }; + struct SDestBufferReference + { + IMeshBuffer* Buffer; + video::E_VERTEX_TYPE VertexType; + u32 VertexCount; + u32 IndexCount; + bool IsDirty; + }; - //! Source mesh buffers, these are locked - core::array SourceBuffers; + //! Source mesh buffers, these are locked + core::array SourceBuffers; - core::array BufferReferences; - core::array MaterialReferences; - core::array DestBuffers; + core::array BufferReferences; + core::array MaterialReferences; + core::array DestBuffers; - //! bounding containing all destination buffers - core::aabbox3d Box; + //! bounding containing all destination buffers + core::aabbox3d Box; - //! does it require an update? - bool IsDirty; + //! does it require an update? + bool IsDirty; - //! can it be changed? - bool IsFinal; + //! can it be changed? + bool IsFinal; }; } // namespace scene diff --git a/src/graphics/callbacks.cpp b/src/graphics/callbacks.cpp index 2898fccf7..cadd5d332 100644 --- a/src/graphics/callbacks.cpp +++ b/src/graphics/callbacks.cpp @@ -130,7 +130,7 @@ void SkyboxProvider::OnSetConstants(IMaterialRendererServices *srv, int) vector3df sun_pos = m_sunpos; srv->setVertexShaderConstant("sun_pos", &sun_pos.X, 3); - + core::matrix4 ModelViewProjectionMatrix = srv->getVideoDriver()->getTransform(ETS_PROJECTION); ModelViewProjectionMatrix *= srv->getVideoDriver()->getTransform(ETS_VIEW); ModelViewProjectionMatrix *= srv->getVideoDriver()->getTransform(ETS_WORLD); @@ -558,21 +558,21 @@ void DisplaceProvider::OnSetConstants(IMaterialRendererServices *srv, int) void DisplaceProvider::update() { - const float time = irr_driver->getDevice()->getTimer()->getTime() / 1000.0f; - const float speed = World::getWorld()->getTrack()->getDisplacementSpeed(); + const float time = irr_driver->getDevice()->getTimer()->getTime() / 1000.0f; + const float speed = World::getWorld()->getTrack()->getDisplacementSpeed(); - float strength = time; - strength = fabsf(noise2d(strength / 10.0f)) * 0.006f + 0.002f; + float strength = time; + strength = fabsf(noise2d(strength / 10.0f)) * 0.006f + 0.002f; - vector3df wind = irr_driver->getWind() * strength * speed; - m_dir[0] += wind.X; - m_dir[1] += wind.Z; + vector3df wind = irr_driver->getWind() * strength * speed; + m_dir[0] += wind.X; + m_dir[1] += wind.Z; - strength = time * 0.56f + sinf(time); - strength = fabsf(noise2d(0.0, strength / 6.0f)) * 0.0095f + 0.0025f; + strength = time * 0.56f + sinf(time); + strength = fabsf(noise2d(0.0, strength / 6.0f)) * 0.0095f + 0.0025f; - wind = irr_driver->getWind() * strength * speed; - wind.rotateXZBy(cosf(time)); - m_dir2[0] += wind.X; - m_dir2[1] += wind.Z; -} + wind = irr_driver->getWind() * strength * speed; + wind.rotateXZBy(cosf(time)); + m_dir2[0] += wind.X; + m_dir2[1] += wind.Z; +} \ No newline at end of file diff --git a/src/graphics/callbacks.hpp b/src/graphics/callbacks.hpp index 93493393f..ab3b34503 100644 --- a/src/graphics/callbacks.hpp +++ b/src/graphics/callbacks.hpp @@ -121,15 +121,15 @@ public: m_amplitude = amp; } - float getSpeed() const - { - return m_speed; - } + float getSpeed() const + { + return m_speed; + } - float getAmplitude() const - { - return m_amplitude; - } + float getAmplitude() const + { + return m_amplitude; + } private: float m_amplitude, m_speed; @@ -141,7 +141,7 @@ class SkyboxProvider: public CallBase { public: virtual void OnSetConstants(video::IMaterialRendererServices *srv, int); - + void setSunPosition(const core::vector3df &in) { m_sunpos = in; @@ -327,20 +327,20 @@ public: m_color[2] = b; } - float getRed() const - { - return m_color[0]; - } + float getRed() const + { + return m_color[0]; + } - float getGreen() const - { - return m_color[1]; - } + float getGreen() const + { + return m_color[1]; + } - float getBlue() const - { - return m_color[2]; - } + float getBlue() const + { + return m_color[2]; + } private: float m_color[3]; @@ -375,7 +375,7 @@ public: m_color[1] = g; m_color[2] = b; } - + float getRed() const { return m_color[0]; @@ -385,7 +385,7 @@ public: { return m_color[1]; } - + float getBlue() const { return m_color[2]; @@ -405,7 +405,7 @@ public: m_pos[1] = pos.Y; m_pos[2] = pos.Z; } - + core::vector3df getPosition() const { return core::vector3df(m_pos[0], m_pos[1], m_pos[2]); @@ -555,27 +555,27 @@ public: m_dir[0] = m_dir[1] = m_dir2[0] = m_dir2[1] = 0; } - void update(); + void update(); - float getDirX() const - { - return m_dir[0]; - } + float getDirX() const + { + return m_dir[0]; + } - float getDirY() const - { - return m_dir[1]; - } + float getDirY() const + { + return m_dir[1]; + } - float getDir2X() const - { - return m_dir2[0]; - } + float getDir2X() const + { + return m_dir2[0]; + } - float getDir2Y() const - { - return m_dir2[1]; - } + float getDir2Y() const + { + return m_dir2[1]; + } private: float m_screen[2]; diff --git a/src/graphics/explosion.cpp b/src/graphics/explosion.cpp index 5076df52d..c38c30e8f 100644 --- a/src/graphics/explosion.cpp +++ b/src/graphics/explosion.cpp @@ -39,7 +39,7 @@ Explosion::Explosion(const Vec3& coord, const char* explosion_sound, const char { // short emision time, explosion, not constant flame m_remaining_time = burst_time; - + ParticleKindManager* pkm = ParticleKindManager::get(); ParticleKind* particles = pkm->getParticles(particle_file); m_emitter = new ParticleEmitter(particles, coord, NULL); @@ -72,7 +72,7 @@ bool Explosion::updateAndDelete(float dt) if (m_remaining_time < 0.0f && m_remaining_time >= -explosion_time) { scene::ISceneNode* node = m_emitter->getNode(); - + const int intensity = (int)(255-(m_remaining_time/-explosion_time)*255); node->getMaterial(0).AmbientColor.setGreen(intensity); node->getMaterial(0).DiffuseColor.setGreen(intensity); diff --git a/src/graphics/glwrap.cpp b/src/graphics/glwrap.cpp index 1647ba77c..fa7cebd95 100644 --- a/src/graphics/glwrap.cpp +++ b/src/graphics/glwrap.cpp @@ -1,588 +1,588 @@ -#include "graphics/glwrap.hpp" -#include "irr_driver.hpp" -#include -#include -#include "config/user_config.hpp" - -#ifdef _IRR_WINDOWS_API_ -#define IRR_OGL_LOAD_EXTENSION(X) wglGetProcAddress(reinterpret_cast(X)) -PFNGLGENTRANSFORMFEEDBACKSPROC glGenTransformFeedbacks; -PFNGLBINDTRANSFORMFEEDBACKPROC glBindTransformFeedback; -PFNGLDRAWTRANSFORMFEEDBACKPROC glDrawTransformFeedback; -PFNGLBEGINTRANSFORMFEEDBACKPROC glBeginTransformFeedback; -PFNGLENDTRANSFORMFEEDBACKPROC glEndTransformFeedback; -PFNGLTRANSFORMFEEDBACKVARYINGSPROC glTransformFeedbackVaryings; -PFNGLBINDBUFFERBASEPROC glBindBufferBase; -PFNGLGENBUFFERSPROC glGenBuffers; -PFNGLBINDBUFFERPROC glBindBuffer; -PFNGLBUFFERDATAPROC glBufferData; -PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer; -PFNGLCREATESHADERPROC glCreateShader; -PFNGLCOMPILESHADERPROC glCompileShader; -PFNGLSHADERSOURCEPROC glShaderSource; -PFNGLCREATEPROGRAMPROC glCreateProgram; -PFNGLATTACHSHADERPROC glAttachShader; -PFNGLLINKPROGRAMPROC glLinkProgram; -PFNGLUSEPROGRAMPROC glUseProgram; -PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray; -PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray; -PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation; -PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv; -PFNGLUNIFORM1FPROC glUniform1f; -PFNGLUNIFORM3FPROC glUniform3f; -PFNGLDELETESHADERPROC glDeleteShader; -PFNGLGETSHADERIVPROC glGetShaderiv; -PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog; -PFNGLACTIVETEXTUREPROC glActiveTexture; -PFNGLUNIFORM2FPROC glUniform2f; -PFNGLUNIFORM1IPROC glUniform1i; -PFNGLUNIFORM3IPROC glUniform3i; -PFNGLUNIFORM4IPROC glUniform4i; -PFNGLUNIFORM1FVPROC glUniform1fv; -PFNGLUNIFORM4FVPROC glUniform4fv; -PFNGLGETPROGRAMIVPROC glGetProgramiv; -PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog; -PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation; -PFNGLBLENDEQUATIONPROC glBlendEquation; -PFNGLVERTEXATTRIBDIVISORPROC glVertexAttribDivisor; -PFNGLDRAWARRAYSINSTANCEDPROC glDrawArraysInstanced; -PFNGLDELETEBUFFERSPROC glDeleteBuffers; -PFNGLGENVERTEXARRAYSPROC glGenVertexArrays; -PFNGLBINDVERTEXARRAYPROC glBindVertexArray; -PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays; -PFNGLTEXBUFFERPROC glTexBuffer; -PFNGLBUFFERSUBDATAPROC glBufferSubData; -PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer; -PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARB; -PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers; -PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer; -PFNGLFRAMEBUFFERTEXTUREPROC glFramebufferTexture; -PFNGLTEXIMAGE3DPROC glTexImage3D; -PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus; -#endif - -static bool is_gl_init = false; - -#ifdef DEBUG -#ifdef WIN32 -#define ARB_DEBUG_OUTPUT -#endif -#endif - -#ifdef ARB_DEBUG_OUTPUT -static void -#ifdef WIN32 -CALLBACK -#endif -debugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, - const GLchar* msg, const void *userparam) -{ - switch(source) - { - case GL_DEBUG_SOURCE_API_ARB: - Log::warn("GLWrap", "OpenGL debug callback - API"); - break; - case GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB: - Log::warn("GLWrap", "OpenGL debug callback - WINDOW_SYSTEM"); - break; - case GL_DEBUG_SOURCE_SHADER_COMPILER_ARB: - Log::warn("GLWrap", "OpenGL debug callback - SHADER_COMPILER"); - break; - case GL_DEBUG_SOURCE_THIRD_PARTY_ARB: - Log::warn("GLWrap", "OpenGL debug callback - THIRD_PARTY"); - break; - case GL_DEBUG_SOURCE_APPLICATION_ARB: - Log::warn("GLWrap", "OpenGL debug callback - APPLICATION"); - break; - case GL_DEBUG_SOURCE_OTHER_ARB: - Log::warn("GLWrap", "OpenGL debug callback - OTHER"); - break; - } - - switch(type) - { - case GL_DEBUG_TYPE_ERROR_ARB: - Log::warn("GLWrap", " Error type : ERROR"); - break; - case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB: - Log::warn("GLWrap", " Error type : DEPRECATED_BEHAVIOR"); - break; - case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB: - Log::warn("GLWrap", " Error type : UNDEFINED_BEHAVIOR"); - break; - case GL_DEBUG_TYPE_PORTABILITY_ARB: - Log::warn("GLWrap", " Error type : PORTABILITY"); - break; - case GL_DEBUG_TYPE_PERFORMANCE_ARB: - Log::warn("GLWrap", " Error type : PERFORMANCE"); - break; - case GL_DEBUG_TYPE_OTHER_ARB: - Log::warn("GLWrap", " Error type : OTHER"); - break; - } - - switch(severity) - { - case GL_DEBUG_SEVERITY_HIGH_ARB: - Log::warn("GLWrap", " Severity : HIGH"); - break; - case GL_DEBUG_SEVERITY_MEDIUM_ARB: - Log::warn("GLWrap", " Severity : MEDIUM"); - break; - case GL_DEBUG_SEVERITY_LOW_ARB: - Log::warn("GLWrap", " Severity : LOW"); - break; - } - - if (msg) - Log::warn("GLWrap", " Message : %s", msg); -} -#endif - -void initGL() -{ - if (is_gl_init) - return; - is_gl_init = true; -#ifdef _IRR_WINDOWS_API_ - glGenTransformFeedbacks = (PFNGLGENTRANSFORMFEEDBACKSPROC)IRR_OGL_LOAD_EXTENSION("glGenTransformFeedbacks"); - glBindTransformFeedback = (PFNGLBINDTRANSFORMFEEDBACKPROC)IRR_OGL_LOAD_EXTENSION("glBindTransformFeedback"); - glDrawTransformFeedback = (PFNGLDRAWTRANSFORMFEEDBACKPROC)IRR_OGL_LOAD_EXTENSION("glDrawTransformFeedback"); - glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC)IRR_OGL_LOAD_EXTENSION("glBeginTransformFeedback"); - glEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC)IRR_OGL_LOAD_EXTENSION("glEndTransformFeedback"); - glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)IRR_OGL_LOAD_EXTENSION("glBindBufferBase"); - glGenBuffers = (PFNGLGENBUFFERSPROC)IRR_OGL_LOAD_EXTENSION("glGenBuffers"); - glBindBuffer = (PFNGLBINDBUFFERPROC)IRR_OGL_LOAD_EXTENSION("glBindBuffer"); - glBufferData = (PFNGLBUFFERDATAPROC)IRR_OGL_LOAD_EXTENSION("glBufferData"); - glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)IRR_OGL_LOAD_EXTENSION("glVertexAttribPointer"); - glCreateShader = (PFNGLCREATESHADERPROC)IRR_OGL_LOAD_EXTENSION("glCreateShader"); - glCompileShader = (PFNGLCOMPILESHADERPROC)IRR_OGL_LOAD_EXTENSION("glCompileShader"); - glShaderSource = (PFNGLSHADERSOURCEPROC)IRR_OGL_LOAD_EXTENSION("glShaderSource"); - glCreateProgram = (PFNGLCREATEPROGRAMPROC)IRR_OGL_LOAD_EXTENSION("glCreateProgram"); - glAttachShader = (PFNGLATTACHSHADERPROC)IRR_OGL_LOAD_EXTENSION("glAttachShader"); - glLinkProgram = (PFNGLLINKPROGRAMPROC)IRR_OGL_LOAD_EXTENSION("glLinkProgram"); - glUseProgram = (PFNGLUSEPROGRAMPROC)IRR_OGL_LOAD_EXTENSION("glUseProgram"); - glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)IRR_OGL_LOAD_EXTENSION("glEnableVertexAttribArray"); - glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)IRR_OGL_LOAD_EXTENSION("glGetUniformLocation"); - glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)IRR_OGL_LOAD_EXTENSION("glUniformMatrix4fv"); - glUniform1f = (PFNGLUNIFORM1FPROC)IRR_OGL_LOAD_EXTENSION("glUniform1f"); - glUniform3f = (PFNGLUNIFORM3FPROC)IRR_OGL_LOAD_EXTENSION("glUniform3f"); - glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC)IRR_OGL_LOAD_EXTENSION("glDisableVertexAttribArray"); - glDeleteShader = (PFNGLDELETESHADERPROC)IRR_OGL_LOAD_EXTENSION("glDeleteShader"); - glGetShaderiv = (PFNGLGETSHADERIVPROC)IRR_OGL_LOAD_EXTENSION("glGetShaderiv"); - glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)IRR_OGL_LOAD_EXTENSION("glGetShaderInfoLog"); - glActiveTexture = (PFNGLACTIVETEXTUREPROC)IRR_OGL_LOAD_EXTENSION("glActiveTexture"); - glUniform2f = (PFNGLUNIFORM2FPROC)IRR_OGL_LOAD_EXTENSION("glUniform2f"); - glUniform4i = (PFNGLUNIFORM4IPROC)IRR_OGL_LOAD_EXTENSION("glUniform4i"); - glUniform3i = (PFNGLUNIFORM3IPROC)IRR_OGL_LOAD_EXTENSION("glUniform3i"); - glUniform1i = (PFNGLUNIFORM1IPROC)IRR_OGL_LOAD_EXTENSION("glUniform1i"); - glGetProgramiv = (PFNGLGETPROGRAMIVPROC)IRR_OGL_LOAD_EXTENSION("glGetProgramiv"); - glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)IRR_OGL_LOAD_EXTENSION("glGetProgramInfoLog"); - glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC)IRR_OGL_LOAD_EXTENSION("glTransformFeedbackVaryings"); - glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)IRR_OGL_LOAD_EXTENSION("glGetAttribLocation"); - glBlendEquation = (PFNGLBLENDEQUATIONPROC)IRR_OGL_LOAD_EXTENSION("glBlendEquation"); - glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORPROC)IRR_OGL_LOAD_EXTENSION("glVertexAttribDivisor"); - glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC)IRR_OGL_LOAD_EXTENSION("glDrawArraysInstanced"); - glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)IRR_OGL_LOAD_EXTENSION("glDeleteBuffers"); - glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)IRR_OGL_LOAD_EXTENSION("glGenVertexArrays"); - glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)IRR_OGL_LOAD_EXTENSION("glBindVertexArray"); - glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC)IRR_OGL_LOAD_EXTENSION("glDeleteVertexArrays"); - glTexBuffer = (PFNGLTEXBUFFERPROC)IRR_OGL_LOAD_EXTENSION("glTexBuffer"); - glUniform1fv = (PFNGLUNIFORM1FVPROC)IRR_OGL_LOAD_EXTENSION("glUniform1fv"); - glUniform4fv = (PFNGLUNIFORM4FVPROC)IRR_OGL_LOAD_EXTENSION("glUniform4fv"); - glBufferSubData = (PFNGLBUFFERSUBDATAPROC)IRR_OGL_LOAD_EXTENSION("glBufferSubData"); - glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC)IRR_OGL_LOAD_EXTENSION("glVertexAttribIPointer"); - glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)IRR_OGL_LOAD_EXTENSION("glGenFramebuffers"); - glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)IRR_OGL_LOAD_EXTENSION("glBindFramebuffer"); - glFramebufferTexture = (PFNGLFRAMEBUFFERTEXTUREPROC)IRR_OGL_LOAD_EXTENSION("glFramebufferTexture"); - glTexImage3D = (PFNGLTEXIMAGE3DPROC)IRR_OGL_LOAD_EXTENSION("glTexImage3D"); - glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)IRR_OGL_LOAD_EXTENSION("glCheckFramebufferStatus"); -#ifdef DEBUG - glDebugMessageCallbackARB = (PFNGLDEBUGMESSAGECALLBACKARBPROC)IRR_OGL_LOAD_EXTENSION("glDebugMessageCallbackARB"); -#endif -#endif -#ifdef ARB_DEBUG_OUTPUT - if (glDebugMessageCallbackARB) - glDebugMessageCallbackARB((GLDEBUGPROCARB)debugCallback, NULL); -#endif -} - -// Mostly from shader tutorial -GLuint LoadShader(const char * file, unsigned type) -{ - GLuint Id = glCreateShader(type); - char versionString[20]; - sprintf(versionString, "#version %d\n", irr_driver->getGLSLVersion()); - std::string Code = versionString; - std::ifstream Stream(file, std::ios::in); - if (Stream.is_open()) - { - std::string Line = ""; - while (getline(Stream, Line)) - Code += "\n" + Line; - Stream.close(); - } - GLint Result = GL_FALSE; - int InfoLogLength; - Log::info("GLWrap", "Compiling shader : %s", file); - char const * SourcePointer = Code.c_str(); - int length = strlen(SourcePointer); - glShaderSource(Id, 1, &SourcePointer, &length); - glCompileShader(Id); - - glGetShaderiv(Id, GL_COMPILE_STATUS, &Result); - if (Result == GL_FALSE) - { - Log::error("GLWrap", "Error in shader %s", file); - glGetShaderiv(Id, GL_INFO_LOG_LENGTH, &InfoLogLength); - char *ErrorMessage = new char[InfoLogLength]; - glGetShaderInfoLog(Id, InfoLogLength, NULL, ErrorMessage); - Log::error("GLWrap", ErrorMessage); - delete[] ErrorMessage; - } - - GLenum glErr = glGetError(); - if (glErr != GL_NO_ERROR) - { - Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr); - } - - return Id; -} - -GLuint LoadTFBProgram(const char * vertex_file_path, const char **varyings, unsigned varyingscount) -{ - GLuint Program = glCreateProgram(); - loadAndAttach(Program, GL_VERTEX_SHADER, vertex_file_path); - glTransformFeedbackVaryings(Program, varyingscount, varyings, GL_INTERLEAVED_ATTRIBS); - glLinkProgram(Program); - - GLint Result = GL_FALSE; - int InfoLogLength; - glGetProgramiv(Program, GL_LINK_STATUS, &Result); - if (Result == GL_FALSE) - { - glGetProgramiv(Program, GL_INFO_LOG_LENGTH, &InfoLogLength); - char *ErrorMessage = new char[InfoLogLength]; - glGetProgramInfoLog(Program, InfoLogLength, NULL, ErrorMessage); - printf(ErrorMessage); - delete[] ErrorMessage; - } - - GLenum glErr = glGetError(); - if (glErr != GL_NO_ERROR) - { - Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr); - } - - return Program; -} - -GLuint getTextureGLuint(irr::video::ITexture *tex) -{ - return static_cast(tex)->getOpenGLTextureName(); -} - -GLuint getDepthTexture(irr::video::ITexture *tex) -{ - assert(tex->isRenderTarget()); - return static_cast(tex)->DepthBufferTexture; -} - -void setTexture(unsigned TextureUnit, GLuint TextureId, GLenum MagFilter, GLenum MinFilter, bool allowAF) -{ - glActiveTexture(GL_TEXTURE0 + TextureUnit); - glBindTexture(GL_TEXTURE_2D, TextureId); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, MagFilter); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, MinFilter); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - - int aniso = UserConfigParams::m_anisotropic; - if (aniso == 0) aniso = 1; - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, allowAF ? (float)aniso : 1.0f); - - GLenum glErr = glGetError(); - if (glErr != GL_NO_ERROR) - { - Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr); - } -} - -static void drawTexColoredQuad(const video::ITexture *texture, const video::SColor *col, float width, float height, - float center_pos_x, float center_pos_y, float tex_center_pos_x, float tex_center_pos_y, - float tex_width, float tex_height) -{ - unsigned colors[] = { - col[0].getRed(), col[0].getGreen(), col[0].getBlue(), col[0].getAlpha(), - col[1].getRed(), col[1].getGreen(), col[1].getBlue(), col[1].getAlpha(), - col[2].getRed(), col[2].getGreen(), col[2].getBlue(), col[2].getAlpha(), - col[3].getRed(), col[3].getGreen(), col[3].getBlue(), col[3].getAlpha(), - }; - - glBindBuffer(GL_ARRAY_BUFFER, UIShader::ColoredTextureRectShader::colorvbo); - glBufferSubData(GL_ARRAY_BUFFER, 0, 16 * sizeof(unsigned), colors); - - glUseProgram(UIShader::ColoredTextureRectShader::Program); - glBindVertexArray(UIShader::ColoredTextureRectShader::vao); - - setTexture(0, static_cast(texture)->getOpenGLTextureName(), GL_LINEAR, GL_LINEAR); - UIShader::TextureRectShader::setUniforms(center_pos_x, center_pos_y, width, height, tex_center_pos_x, tex_center_pos_y, tex_width, tex_height, 0); - - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - glBindVertexArray(0); - glBindBuffer(GL_ARRAY_BUFFER, 0); - - GLenum glErr = glGetError(); - if (glErr != GL_NO_ERROR) - { - Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr); - } -} - -void drawTexQuad(const video::ITexture *texture, float width, float height, - float center_pos_x, float center_pos_y, float tex_center_pos_x, float tex_center_pos_y, - float tex_width, float tex_height) -{ - glUseProgram(UIShader::TextureRectShader::Program); - glBindVertexArray(UIShader::TextureRectShader::vao); - - setTexture(0, static_cast(texture)->getOpenGLTextureName(), GL_LINEAR, GL_LINEAR); - UIShader::TextureRectShader::setUniforms(center_pos_x, center_pos_y, width, height, tex_center_pos_x, tex_center_pos_y, tex_width, tex_height, 0); - - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - glBindVertexArray(0); - glBindBuffer(GL_ARRAY_BUFFER, 0); - - GLenum glErr = glGetError(); - if (glErr != GL_NO_ERROR) - { - Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr); - } -} - -static void -getSize(const video::ITexture* texture, const core::rect& destRect, -const core::rect& sourceRect, -float &width, float &height, -float ¢er_pos_x, float ¢er_pos_y, -float &tex_width, float &tex_height, -float &tex_center_pos_x, float &tex_center_pos_y -) -{ - core::dimension2d frame_size = - irr_driver->getVideoDriver()->getCurrentRenderTargetSize(); - const int screen_w = frame_size.Width; - const int screen_h = frame_size.Height; - center_pos_x = destRect.UpperLeftCorner.X + destRect.LowerRightCorner.X; - center_pos_x /= screen_w; - center_pos_x -= 1.; - center_pos_y = destRect.UpperLeftCorner.Y + destRect.LowerRightCorner.Y; - center_pos_y /= screen_h; - center_pos_y = 1. - center_pos_y; - width = destRect.LowerRightCorner.X - destRect.UpperLeftCorner.X; - width /= screen_w; - height = destRect.LowerRightCorner.Y - destRect.UpperLeftCorner.Y; - height /= screen_h; - - const core::dimension2d& ss = texture->getOriginalSize(); - tex_center_pos_x = sourceRect.UpperLeftCorner.X + sourceRect.LowerRightCorner.X; - tex_center_pos_x /= ss.Width * 2.; - tex_center_pos_y = sourceRect.UpperLeftCorner.Y + sourceRect.LowerRightCorner.Y; - tex_center_pos_y /= ss.Height * 2.; - tex_width = sourceRect.LowerRightCorner.X - sourceRect.UpperLeftCorner.X; - tex_width /= ss.Width * 2.; - tex_height = sourceRect.LowerRightCorner.Y - sourceRect.UpperLeftCorner.Y; - tex_height /= ss.Height * 2.; - - if (texture->isRenderTarget()) - { - tex_height = -tex_height; - } - - const f32 invW = 1.f / static_cast(ss.Width); - const f32 invH = 1.f / static_cast(ss.Height); - const core::rect tcoords( - sourceRect.UpperLeftCorner.X * invW, - sourceRect.UpperLeftCorner.Y * invH, - sourceRect.LowerRightCorner.X * invW, - sourceRect.LowerRightCorner.Y *invH); -} - -void draw2DImage(const video::ITexture* texture, const core::rect& destRect, - const core::rect& sourceRect, const core::rect* clipRect, - const video::SColor &colors, bool useAlphaChannelOfTexture) -{ - if (!irr_driver->isGLSL()) { - video::SColor duplicatedArray[4] = { - colors, colors, colors, colors - }; - draw2DImage(texture, destRect, sourceRect, clipRect, duplicatedArray, useAlphaChannelOfTexture); - return; - } - - float width, height, - center_pos_x, center_pos_y, - tex_width, tex_height, - tex_center_pos_x, tex_center_pos_y; - - getSize(texture, destRect, sourceRect, width, height, center_pos_x, center_pos_y, - tex_width, tex_height, tex_center_pos_x, tex_center_pos_y); - - if (useAlphaChannelOfTexture) - { - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - } - else - { - glDisable(GL_BLEND); - } - if (clipRect) - { - if (!clipRect->isValid()) - return; - - glEnable(GL_SCISSOR_TEST); - const core::dimension2d& renderTargetSize = irr_driver->getVideoDriver()->getCurrentRenderTargetSize(); - glScissor(clipRect->UpperLeftCorner.X, renderTargetSize.Height - clipRect->LowerRightCorner.Y, - clipRect->getWidth(), clipRect->getHeight()); - } - - glUseProgram(UIShader::UniformColoredTextureRectShader::Program); - glBindVertexArray(UIShader::UniformColoredTextureRectShader::vao); - - setTexture(0, static_cast(texture)->getOpenGLTextureName(), GL_LINEAR, GL_LINEAR); - UIShader::UniformColoredTextureRectShader::setUniforms(center_pos_x, center_pos_y, width, height, tex_center_pos_x, tex_center_pos_y, tex_width, tex_height,colors, 0); - - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - glBindVertexArray(0); - glBindBuffer(GL_ARRAY_BUFFER, 0); - if (clipRect) - glDisable(GL_SCISSOR_TEST); - glUseProgram(0); - - GLenum glErr = glGetError(); - if (glErr != GL_NO_ERROR) - { - Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr); - } -} - -void draw2DImage(const video::ITexture* texture, const core::rect& destRect, - const core::rect& sourceRect, const core::rect* clipRect, - const video::SColor* const colors, bool useAlphaChannelOfTexture) -{ - if (!irr_driver->isGLSL()) - { - irr_driver->getVideoDriver()->draw2DImage(texture, destRect, sourceRect, clipRect, colors, useAlphaChannelOfTexture); - return; - } - - float width, height, - center_pos_x, center_pos_y, - tex_width, tex_height, - tex_center_pos_x, tex_center_pos_y; - - getSize(texture, destRect, sourceRect, width, height, center_pos_x, center_pos_y, - tex_width, tex_height, tex_center_pos_x, tex_center_pos_y); - - if (useAlphaChannelOfTexture) - { - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - } - else - { - glDisable(GL_BLEND); - } - if (clipRect) - { - if (!clipRect->isValid()) - return; - - glEnable(GL_SCISSOR_TEST); - const core::dimension2d& renderTargetSize = irr_driver->getVideoDriver()->getCurrentRenderTargetSize(); - glScissor(clipRect->UpperLeftCorner.X, renderTargetSize.Height - clipRect->LowerRightCorner.Y, - clipRect->getWidth(), clipRect->getHeight()); - } - if (colors) - drawTexColoredQuad(texture, colors, width, height, center_pos_x, center_pos_y, - tex_center_pos_x, tex_center_pos_y, tex_width, tex_height); - else - drawTexQuad(texture, width, height, center_pos_x, center_pos_y, - tex_center_pos_x, tex_center_pos_y, tex_width, tex_height); - if (clipRect) - glDisable(GL_SCISSOR_TEST); - glUseProgram(0); - - GLenum glErr = glGetError(); - if (glErr != GL_NO_ERROR) - { - Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr); - } -} - -void GL32_draw2DRectangle(video::SColor color, const core::rect& position, - const core::rect* clip) -{ - - if (!irr_driver->isGLSL()) - { - irr_driver->getVideoDriver()->draw2DRectangle(color, position, clip); - return; - } - - core::dimension2d frame_size = - irr_driver->getVideoDriver()->getCurrentRenderTargetSize(); - const int screen_w = frame_size.Width; - const int screen_h = frame_size.Height; - float center_pos_x = position.UpperLeftCorner.X + position.LowerRightCorner.X; - center_pos_x /= screen_w; - center_pos_x -= 1; - float center_pos_y = position.UpperLeftCorner.Y + position.LowerRightCorner.Y; - center_pos_y /= screen_h; - center_pos_y = 1 - center_pos_y; - float width = position.LowerRightCorner.X - position.UpperLeftCorner.X; - width /= screen_w; - float height = position.LowerRightCorner.Y - position.UpperLeftCorner.Y; - height /= screen_h; - - if (color.getAlpha() < 255) - { - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - } - else - { - glDisable(GL_BLEND); - } - - if (clip) - { - if (!clip->isValid()) - return; - - glEnable(GL_SCISSOR_TEST); - const core::dimension2d& renderTargetSize = irr_driver->getVideoDriver()->getCurrentRenderTargetSize(); - glScissor(clip->UpperLeftCorner.X, renderTargetSize.Height - clip->LowerRightCorner.Y, - clip->getWidth(), clip->getHeight()); - } - - glUseProgram(UIShader::ColoredRectShader::Program); - glBindVertexArray(UIShader::ColoredRectShader::vao); - UIShader::ColoredRectShader::setUniforms(center_pos_x, center_pos_y, width, height, color); - - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindVertexArray(0); - if (clip) - glDisable(GL_SCISSOR_TEST); - glUseProgram(0); - - GLenum glErr = glGetError(); - if (glErr != GL_NO_ERROR) - { - Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr); - } -} +#include "graphics/glwrap.hpp" +#include "irr_driver.hpp" +#include +#include +#include "config/user_config.hpp" + +#ifdef _IRR_WINDOWS_API_ +#define IRR_OGL_LOAD_EXTENSION(X) wglGetProcAddress(reinterpret_cast(X)) +PFNGLGENTRANSFORMFEEDBACKSPROC glGenTransformFeedbacks; +PFNGLBINDTRANSFORMFEEDBACKPROC glBindTransformFeedback; +PFNGLDRAWTRANSFORMFEEDBACKPROC glDrawTransformFeedback; +PFNGLBEGINTRANSFORMFEEDBACKPROC glBeginTransformFeedback; +PFNGLENDTRANSFORMFEEDBACKPROC glEndTransformFeedback; +PFNGLTRANSFORMFEEDBACKVARYINGSPROC glTransformFeedbackVaryings; +PFNGLBINDBUFFERBASEPROC glBindBufferBase; +PFNGLGENBUFFERSPROC glGenBuffers; +PFNGLBINDBUFFERPROC glBindBuffer; +PFNGLBUFFERDATAPROC glBufferData; +PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer; +PFNGLCREATESHADERPROC glCreateShader; +PFNGLCOMPILESHADERPROC glCompileShader; +PFNGLSHADERSOURCEPROC glShaderSource; +PFNGLCREATEPROGRAMPROC glCreateProgram; +PFNGLATTACHSHADERPROC glAttachShader; +PFNGLLINKPROGRAMPROC glLinkProgram; +PFNGLUSEPROGRAMPROC glUseProgram; +PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray; +PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray; +PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation; +PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv; +PFNGLUNIFORM1FPROC glUniform1f; +PFNGLUNIFORM3FPROC glUniform3f; +PFNGLDELETESHADERPROC glDeleteShader; +PFNGLGETSHADERIVPROC glGetShaderiv; +PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog; +PFNGLACTIVETEXTUREPROC glActiveTexture; +PFNGLUNIFORM2FPROC glUniform2f; +PFNGLUNIFORM1IPROC glUniform1i; +PFNGLUNIFORM3IPROC glUniform3i; +PFNGLUNIFORM4IPROC glUniform4i; +PFNGLUNIFORM1FVPROC glUniform1fv; +PFNGLUNIFORM4FVPROC glUniform4fv; +PFNGLGETPROGRAMIVPROC glGetProgramiv; +PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog; +PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation; +PFNGLBLENDEQUATIONPROC glBlendEquation; +PFNGLVERTEXATTRIBDIVISORPROC glVertexAttribDivisor; +PFNGLDRAWARRAYSINSTANCEDPROC glDrawArraysInstanced; +PFNGLDELETEBUFFERSPROC glDeleteBuffers; +PFNGLGENVERTEXARRAYSPROC glGenVertexArrays; +PFNGLBINDVERTEXARRAYPROC glBindVertexArray; +PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays; +PFNGLTEXBUFFERPROC glTexBuffer; +PFNGLBUFFERSUBDATAPROC glBufferSubData; +PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer; +PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARB; +PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers; +PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer; +PFNGLFRAMEBUFFERTEXTUREPROC glFramebufferTexture; +PFNGLTEXIMAGE3DPROC glTexImage3D; +PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus; +#endif + +static bool is_gl_init = false; + +#ifdef DEBUG +#ifdef WIN32 +#define ARB_DEBUG_OUTPUT +#endif +#endif + +#ifdef ARB_DEBUG_OUTPUT +static void +#ifdef WIN32 +CALLBACK +#endif +debugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, + const GLchar* msg, const void *userparam) +{ + switch(source) + { + case GL_DEBUG_SOURCE_API_ARB: + Log::warn("GLWrap", "OpenGL debug callback - API"); + break; + case GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB: + Log::warn("GLWrap", "OpenGL debug callback - WINDOW_SYSTEM"); + break; + case GL_DEBUG_SOURCE_SHADER_COMPILER_ARB: + Log::warn("GLWrap", "OpenGL debug callback - SHADER_COMPILER"); + break; + case GL_DEBUG_SOURCE_THIRD_PARTY_ARB: + Log::warn("GLWrap", "OpenGL debug callback - THIRD_PARTY"); + break; + case GL_DEBUG_SOURCE_APPLICATION_ARB: + Log::warn("GLWrap", "OpenGL debug callback - APPLICATION"); + break; + case GL_DEBUG_SOURCE_OTHER_ARB: + Log::warn("GLWrap", "OpenGL debug callback - OTHER"); + break; + } + + switch(type) + { + case GL_DEBUG_TYPE_ERROR_ARB: + Log::warn("GLWrap", " Error type : ERROR"); + break; + case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB: + Log::warn("GLWrap", " Error type : DEPRECATED_BEHAVIOR"); + break; + case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB: + Log::warn("GLWrap", " Error type : UNDEFINED_BEHAVIOR"); + break; + case GL_DEBUG_TYPE_PORTABILITY_ARB: + Log::warn("GLWrap", " Error type : PORTABILITY"); + break; + case GL_DEBUG_TYPE_PERFORMANCE_ARB: + Log::warn("GLWrap", " Error type : PERFORMANCE"); + break; + case GL_DEBUG_TYPE_OTHER_ARB: + Log::warn("GLWrap", " Error type : OTHER"); + break; + } + + switch(severity) + { + case GL_DEBUG_SEVERITY_HIGH_ARB: + Log::warn("GLWrap", " Severity : HIGH"); + break; + case GL_DEBUG_SEVERITY_MEDIUM_ARB: + Log::warn("GLWrap", " Severity : MEDIUM"); + break; + case GL_DEBUG_SEVERITY_LOW_ARB: + Log::warn("GLWrap", " Severity : LOW"); + break; + } + + if (msg) + Log::warn("GLWrap", " Message : %s", msg); +} +#endif + +void initGL() +{ + if (is_gl_init) + return; + is_gl_init = true; +#ifdef _IRR_WINDOWS_API_ + glGenTransformFeedbacks = (PFNGLGENTRANSFORMFEEDBACKSPROC)IRR_OGL_LOAD_EXTENSION("glGenTransformFeedbacks"); + glBindTransformFeedback = (PFNGLBINDTRANSFORMFEEDBACKPROC)IRR_OGL_LOAD_EXTENSION("glBindTransformFeedback"); + glDrawTransformFeedback = (PFNGLDRAWTRANSFORMFEEDBACKPROC)IRR_OGL_LOAD_EXTENSION("glDrawTransformFeedback"); + glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC)IRR_OGL_LOAD_EXTENSION("glBeginTransformFeedback"); + glEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC)IRR_OGL_LOAD_EXTENSION("glEndTransformFeedback"); + glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)IRR_OGL_LOAD_EXTENSION("glBindBufferBase"); + glGenBuffers = (PFNGLGENBUFFERSPROC)IRR_OGL_LOAD_EXTENSION("glGenBuffers"); + glBindBuffer = (PFNGLBINDBUFFERPROC)IRR_OGL_LOAD_EXTENSION("glBindBuffer"); + glBufferData = (PFNGLBUFFERDATAPROC)IRR_OGL_LOAD_EXTENSION("glBufferData"); + glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)IRR_OGL_LOAD_EXTENSION("glVertexAttribPointer"); + glCreateShader = (PFNGLCREATESHADERPROC)IRR_OGL_LOAD_EXTENSION("glCreateShader"); + glCompileShader = (PFNGLCOMPILESHADERPROC)IRR_OGL_LOAD_EXTENSION("glCompileShader"); + glShaderSource = (PFNGLSHADERSOURCEPROC)IRR_OGL_LOAD_EXTENSION("glShaderSource"); + glCreateProgram = (PFNGLCREATEPROGRAMPROC)IRR_OGL_LOAD_EXTENSION("glCreateProgram"); + glAttachShader = (PFNGLATTACHSHADERPROC)IRR_OGL_LOAD_EXTENSION("glAttachShader"); + glLinkProgram = (PFNGLLINKPROGRAMPROC)IRR_OGL_LOAD_EXTENSION("glLinkProgram"); + glUseProgram = (PFNGLUSEPROGRAMPROC)IRR_OGL_LOAD_EXTENSION("glUseProgram"); + glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)IRR_OGL_LOAD_EXTENSION("glEnableVertexAttribArray"); + glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)IRR_OGL_LOAD_EXTENSION("glGetUniformLocation"); + glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)IRR_OGL_LOAD_EXTENSION("glUniformMatrix4fv"); + glUniform1f = (PFNGLUNIFORM1FPROC)IRR_OGL_LOAD_EXTENSION("glUniform1f"); + glUniform3f = (PFNGLUNIFORM3FPROC)IRR_OGL_LOAD_EXTENSION("glUniform3f"); + glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC)IRR_OGL_LOAD_EXTENSION("glDisableVertexAttribArray"); + glDeleteShader = (PFNGLDELETESHADERPROC)IRR_OGL_LOAD_EXTENSION("glDeleteShader"); + glGetShaderiv = (PFNGLGETSHADERIVPROC)IRR_OGL_LOAD_EXTENSION("glGetShaderiv"); + glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)IRR_OGL_LOAD_EXTENSION("glGetShaderInfoLog"); + glActiveTexture = (PFNGLACTIVETEXTUREPROC)IRR_OGL_LOAD_EXTENSION("glActiveTexture"); + glUniform2f = (PFNGLUNIFORM2FPROC)IRR_OGL_LOAD_EXTENSION("glUniform2f"); + glUniform4i = (PFNGLUNIFORM4IPROC)IRR_OGL_LOAD_EXTENSION("glUniform4i"); + glUniform3i = (PFNGLUNIFORM3IPROC)IRR_OGL_LOAD_EXTENSION("glUniform3i"); + glUniform1i = (PFNGLUNIFORM1IPROC)IRR_OGL_LOAD_EXTENSION("glUniform1i"); + glGetProgramiv = (PFNGLGETPROGRAMIVPROC)IRR_OGL_LOAD_EXTENSION("glGetProgramiv"); + glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)IRR_OGL_LOAD_EXTENSION("glGetProgramInfoLog"); + glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC)IRR_OGL_LOAD_EXTENSION("glTransformFeedbackVaryings"); + glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)IRR_OGL_LOAD_EXTENSION("glGetAttribLocation"); + glBlendEquation = (PFNGLBLENDEQUATIONPROC)IRR_OGL_LOAD_EXTENSION("glBlendEquation"); + glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORPROC)IRR_OGL_LOAD_EXTENSION("glVertexAttribDivisor"); + glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC)IRR_OGL_LOAD_EXTENSION("glDrawArraysInstanced"); + glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)IRR_OGL_LOAD_EXTENSION("glDeleteBuffers"); + glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)IRR_OGL_LOAD_EXTENSION("glGenVertexArrays"); + glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)IRR_OGL_LOAD_EXTENSION("glBindVertexArray"); + glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC)IRR_OGL_LOAD_EXTENSION("glDeleteVertexArrays"); + glTexBuffer = (PFNGLTEXBUFFERPROC)IRR_OGL_LOAD_EXTENSION("glTexBuffer"); + glUniform1fv = (PFNGLUNIFORM1FVPROC)IRR_OGL_LOAD_EXTENSION("glUniform1fv"); + glUniform4fv = (PFNGLUNIFORM4FVPROC)IRR_OGL_LOAD_EXTENSION("glUniform4fv"); + glBufferSubData = (PFNGLBUFFERSUBDATAPROC)IRR_OGL_LOAD_EXTENSION("glBufferSubData"); + glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC)IRR_OGL_LOAD_EXTENSION("glVertexAttribIPointer"); + glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)IRR_OGL_LOAD_EXTENSION("glGenFramebuffers"); + glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)IRR_OGL_LOAD_EXTENSION("glBindFramebuffer"); + glFramebufferTexture = (PFNGLFRAMEBUFFERTEXTUREPROC)IRR_OGL_LOAD_EXTENSION("glFramebufferTexture"); + glTexImage3D = (PFNGLTEXIMAGE3DPROC)IRR_OGL_LOAD_EXTENSION("glTexImage3D"); + glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)IRR_OGL_LOAD_EXTENSION("glCheckFramebufferStatus"); +#ifdef DEBUG + glDebugMessageCallbackARB = (PFNGLDEBUGMESSAGECALLBACKARBPROC)IRR_OGL_LOAD_EXTENSION("glDebugMessageCallbackARB"); +#endif +#endif +#ifdef ARB_DEBUG_OUTPUT + if (glDebugMessageCallbackARB) + glDebugMessageCallbackARB((GLDEBUGPROCARB)debugCallback, NULL); +#endif +} + +// Mostly from shader tutorial +GLuint LoadShader(const char * file, unsigned type) +{ + GLuint Id = glCreateShader(type); + char versionString[20]; + sprintf(versionString, "#version %d\n", irr_driver->getGLSLVersion()); + std::string Code = versionString; + std::ifstream Stream(file, std::ios::in); + if (Stream.is_open()) + { + std::string Line = ""; + while (getline(Stream, Line)) + Code += "\n" + Line; + Stream.close(); + } + GLint Result = GL_FALSE; + int InfoLogLength; + Log::info("GLWrap", "Compiling shader : %s", file); + char const * SourcePointer = Code.c_str(); + int length = strlen(SourcePointer); + glShaderSource(Id, 1, &SourcePointer, &length); + glCompileShader(Id); + + glGetShaderiv(Id, GL_COMPILE_STATUS, &Result); + if (Result == GL_FALSE) + { + Log::error("GLWrap", "Error in shader %s", file); + glGetShaderiv(Id, GL_INFO_LOG_LENGTH, &InfoLogLength); + char *ErrorMessage = new char[InfoLogLength]; + glGetShaderInfoLog(Id, InfoLogLength, NULL, ErrorMessage); + Log::error("GLWrap", ErrorMessage); + delete[] ErrorMessage; + } + + GLenum glErr = glGetError(); + if (glErr != GL_NO_ERROR) + { + Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr); + } + + return Id; +} + +GLuint LoadTFBProgram(const char * vertex_file_path, const char **varyings, unsigned varyingscount) +{ + GLuint Program = glCreateProgram(); + loadAndAttach(Program, GL_VERTEX_SHADER, vertex_file_path); + glTransformFeedbackVaryings(Program, varyingscount, varyings, GL_INTERLEAVED_ATTRIBS); + glLinkProgram(Program); + + GLint Result = GL_FALSE; + int InfoLogLength; + glGetProgramiv(Program, GL_LINK_STATUS, &Result); + if (Result == GL_FALSE) + { + glGetProgramiv(Program, GL_INFO_LOG_LENGTH, &InfoLogLength); + char *ErrorMessage = new char[InfoLogLength]; + glGetProgramInfoLog(Program, InfoLogLength, NULL, ErrorMessage); + printf(ErrorMessage); + delete[] ErrorMessage; + } + + GLenum glErr = glGetError(); + if (glErr != GL_NO_ERROR) + { + Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr); + } + + return Program; +} + +GLuint getTextureGLuint(irr::video::ITexture *tex) +{ + return static_cast(tex)->getOpenGLTextureName(); +} + +GLuint getDepthTexture(irr::video::ITexture *tex) +{ + assert(tex->isRenderTarget()); + return static_cast(tex)->DepthBufferTexture; +} + +void setTexture(unsigned TextureUnit, GLuint TextureId, GLenum MagFilter, GLenum MinFilter, bool allowAF) +{ + glActiveTexture(GL_TEXTURE0 + TextureUnit); + glBindTexture(GL_TEXTURE_2D, TextureId); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, MagFilter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, MinFilter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + + int aniso = UserConfigParams::m_anisotropic; + if (aniso == 0) aniso = 1; + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, allowAF ? (float)aniso : 1.0f); + + GLenum glErr = glGetError(); + if (glErr != GL_NO_ERROR) + { + Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr); + } +} + +static void drawTexColoredQuad(const video::ITexture *texture, const video::SColor *col, float width, float height, + float center_pos_x, float center_pos_y, float tex_center_pos_x, float tex_center_pos_y, + float tex_width, float tex_height) +{ + unsigned colors[] = { + col[0].getRed(), col[0].getGreen(), col[0].getBlue(), col[0].getAlpha(), + col[1].getRed(), col[1].getGreen(), col[1].getBlue(), col[1].getAlpha(), + col[2].getRed(), col[2].getGreen(), col[2].getBlue(), col[2].getAlpha(), + col[3].getRed(), col[3].getGreen(), col[3].getBlue(), col[3].getAlpha(), + }; + + glBindBuffer(GL_ARRAY_BUFFER, UIShader::ColoredTextureRectShader::colorvbo); + glBufferSubData(GL_ARRAY_BUFFER, 0, 16 * sizeof(unsigned), colors); + + glUseProgram(UIShader::ColoredTextureRectShader::Program); + glBindVertexArray(UIShader::ColoredTextureRectShader::vao); + + setTexture(0, static_cast(texture)->getOpenGLTextureName(), GL_LINEAR, GL_LINEAR); + UIShader::TextureRectShader::setUniforms(center_pos_x, center_pos_y, width, height, tex_center_pos_x, tex_center_pos_y, tex_width, tex_height, 0); + + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + glBindVertexArray(0); + glBindBuffer(GL_ARRAY_BUFFER, 0); + + GLenum glErr = glGetError(); + if (glErr != GL_NO_ERROR) + { + Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr); + } +} + +void drawTexQuad(const video::ITexture *texture, float width, float height, + float center_pos_x, float center_pos_y, float tex_center_pos_x, float tex_center_pos_y, + float tex_width, float tex_height) +{ + glUseProgram(UIShader::TextureRectShader::Program); + glBindVertexArray(UIShader::TextureRectShader::vao); + + setTexture(0, static_cast(texture)->getOpenGLTextureName(), GL_LINEAR, GL_LINEAR); + UIShader::TextureRectShader::setUniforms(center_pos_x, center_pos_y, width, height, tex_center_pos_x, tex_center_pos_y, tex_width, tex_height, 0); + + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + glBindVertexArray(0); + glBindBuffer(GL_ARRAY_BUFFER, 0); + + GLenum glErr = glGetError(); + if (glErr != GL_NO_ERROR) + { + Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr); + } +} + +static void +getSize(const video::ITexture* texture, const core::rect& destRect, +const core::rect& sourceRect, +float &width, float &height, +float ¢er_pos_x, float ¢er_pos_y, +float &tex_width, float &tex_height, +float &tex_center_pos_x, float &tex_center_pos_y +) +{ + core::dimension2d frame_size = + irr_driver->getVideoDriver()->getCurrentRenderTargetSize(); + const int screen_w = frame_size.Width; + const int screen_h = frame_size.Height; + center_pos_x = destRect.UpperLeftCorner.X + destRect.LowerRightCorner.X; + center_pos_x /= screen_w; + center_pos_x -= 1.; + center_pos_y = destRect.UpperLeftCorner.Y + destRect.LowerRightCorner.Y; + center_pos_y /= screen_h; + center_pos_y = 1. - center_pos_y; + width = destRect.LowerRightCorner.X - destRect.UpperLeftCorner.X; + width /= screen_w; + height = destRect.LowerRightCorner.Y - destRect.UpperLeftCorner.Y; + height /= screen_h; + + const core::dimension2d& ss = texture->getOriginalSize(); + tex_center_pos_x = sourceRect.UpperLeftCorner.X + sourceRect.LowerRightCorner.X; + tex_center_pos_x /= ss.Width * 2.; + tex_center_pos_y = sourceRect.UpperLeftCorner.Y + sourceRect.LowerRightCorner.Y; + tex_center_pos_y /= ss.Height * 2.; + tex_width = sourceRect.LowerRightCorner.X - sourceRect.UpperLeftCorner.X; + tex_width /= ss.Width * 2.; + tex_height = sourceRect.LowerRightCorner.Y - sourceRect.UpperLeftCorner.Y; + tex_height /= ss.Height * 2.; + + if (texture->isRenderTarget()) + { + tex_height = -tex_height; + } + + const f32 invW = 1.f / static_cast(ss.Width); + const f32 invH = 1.f / static_cast(ss.Height); + const core::rect tcoords( + sourceRect.UpperLeftCorner.X * invW, + sourceRect.UpperLeftCorner.Y * invH, + sourceRect.LowerRightCorner.X * invW, + sourceRect.LowerRightCorner.Y *invH); +} + +void draw2DImage(const video::ITexture* texture, const core::rect& destRect, + const core::rect& sourceRect, const core::rect* clipRect, + const video::SColor &colors, bool useAlphaChannelOfTexture) +{ + if (!irr_driver->isGLSL()) { + video::SColor duplicatedArray[4] = { + colors, colors, colors, colors + }; + draw2DImage(texture, destRect, sourceRect, clipRect, duplicatedArray, useAlphaChannelOfTexture); + return; + } + + float width, height, + center_pos_x, center_pos_y, + tex_width, tex_height, + tex_center_pos_x, tex_center_pos_y; + + getSize(texture, destRect, sourceRect, width, height, center_pos_x, center_pos_y, + tex_width, tex_height, tex_center_pos_x, tex_center_pos_y); + + if (useAlphaChannelOfTexture) + { + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } + else + { + glDisable(GL_BLEND); + } + if (clipRect) + { + if (!clipRect->isValid()) + return; + + glEnable(GL_SCISSOR_TEST); + const core::dimension2d& renderTargetSize = irr_driver->getVideoDriver()->getCurrentRenderTargetSize(); + glScissor(clipRect->UpperLeftCorner.X, renderTargetSize.Height - clipRect->LowerRightCorner.Y, + clipRect->getWidth(), clipRect->getHeight()); + } + + glUseProgram(UIShader::UniformColoredTextureRectShader::Program); + glBindVertexArray(UIShader::UniformColoredTextureRectShader::vao); + + setTexture(0, static_cast(texture)->getOpenGLTextureName(), GL_LINEAR, GL_LINEAR); + UIShader::UniformColoredTextureRectShader::setUniforms(center_pos_x, center_pos_y, width, height, tex_center_pos_x, tex_center_pos_y, tex_width, tex_height,colors, 0); + + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + glBindVertexArray(0); + glBindBuffer(GL_ARRAY_BUFFER, 0); + if (clipRect) + glDisable(GL_SCISSOR_TEST); + glUseProgram(0); + + GLenum glErr = glGetError(); + if (glErr != GL_NO_ERROR) + { + Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr); + } +} + +void draw2DImage(const video::ITexture* texture, const core::rect& destRect, + const core::rect& sourceRect, const core::rect* clipRect, + const video::SColor* const colors, bool useAlphaChannelOfTexture) +{ + if (!irr_driver->isGLSL()) + { + irr_driver->getVideoDriver()->draw2DImage(texture, destRect, sourceRect, clipRect, colors, useAlphaChannelOfTexture); + return; + } + + float width, height, + center_pos_x, center_pos_y, + tex_width, tex_height, + tex_center_pos_x, tex_center_pos_y; + + getSize(texture, destRect, sourceRect, width, height, center_pos_x, center_pos_y, + tex_width, tex_height, tex_center_pos_x, tex_center_pos_y); + + if (useAlphaChannelOfTexture) + { + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } + else + { + glDisable(GL_BLEND); + } + if (clipRect) + { + if (!clipRect->isValid()) + return; + + glEnable(GL_SCISSOR_TEST); + const core::dimension2d& renderTargetSize = irr_driver->getVideoDriver()->getCurrentRenderTargetSize(); + glScissor(clipRect->UpperLeftCorner.X, renderTargetSize.Height - clipRect->LowerRightCorner.Y, + clipRect->getWidth(), clipRect->getHeight()); + } + if (colors) + drawTexColoredQuad(texture, colors, width, height, center_pos_x, center_pos_y, + tex_center_pos_x, tex_center_pos_y, tex_width, tex_height); + else + drawTexQuad(texture, width, height, center_pos_x, center_pos_y, + tex_center_pos_x, tex_center_pos_y, tex_width, tex_height); + if (clipRect) + glDisable(GL_SCISSOR_TEST); + glUseProgram(0); + + GLenum glErr = glGetError(); + if (glErr != GL_NO_ERROR) + { + Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr); + } +} + +void GL32_draw2DRectangle(video::SColor color, const core::rect& position, + const core::rect* clip) +{ + + if (!irr_driver->isGLSL()) + { + irr_driver->getVideoDriver()->draw2DRectangle(color, position, clip); + return; + } + + core::dimension2d frame_size = + irr_driver->getVideoDriver()->getCurrentRenderTargetSize(); + const int screen_w = frame_size.Width; + const int screen_h = frame_size.Height; + float center_pos_x = position.UpperLeftCorner.X + position.LowerRightCorner.X; + center_pos_x /= screen_w; + center_pos_x -= 1; + float center_pos_y = position.UpperLeftCorner.Y + position.LowerRightCorner.Y; + center_pos_y /= screen_h; + center_pos_y = 1 - center_pos_y; + float width = position.LowerRightCorner.X - position.UpperLeftCorner.X; + width /= screen_w; + float height = position.LowerRightCorner.Y - position.UpperLeftCorner.Y; + height /= screen_h; + + if (color.getAlpha() < 255) + { + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } + else + { + glDisable(GL_BLEND); + } + + if (clip) + { + if (!clip->isValid()) + return; + + glEnable(GL_SCISSOR_TEST); + const core::dimension2d& renderTargetSize = irr_driver->getVideoDriver()->getCurrentRenderTargetSize(); + glScissor(clip->UpperLeftCorner.X, renderTargetSize.Height - clip->LowerRightCorner.Y, + clip->getWidth(), clip->getHeight()); + } + + glUseProgram(UIShader::ColoredRectShader::Program); + glBindVertexArray(UIShader::ColoredRectShader::vao); + UIShader::ColoredRectShader::setUniforms(center_pos_x, center_pos_y, width, height, color); + + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindVertexArray(0); + if (clip) + glDisable(GL_SCISSOR_TEST); + glUseProgram(0); + + GLenum glErr = glGetError(); + if (glErr != GL_NO_ERROR) + { + Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr); + } +} diff --git a/src/graphics/glwrap.hpp b/src/graphics/glwrap.hpp index cc587106c..461e9f5ce 100644 --- a/src/graphics/glwrap.hpp +++ b/src/graphics/glwrap.hpp @@ -1,164 +1,164 @@ -#ifndef GLWRAP_HEADER_H -#define GLWRAP_HEADER_H - -#if defined(__APPLE__) -# include -# include -# define OGL32CTX -#elif defined(ANDROID) -# include -#elif defined(WIN32) -# define _WINSOCKAPI_ -// has to be included before gl.h because of WINGDIAPI and APIENTRY definitions -# include -# include -#else -#define GL_GLEXT_PROTOTYPES -#define DEBUG_OUTPUT_DECLARED -# include -#endif - -#include "utils/log.hpp" - -// already includes glext.h, which defines useful GL constants. -// COpenGLDriver has already loaded the extension GL functions we use (e.g glBeginQuery) -#include "../../lib/irrlicht/source/Irrlicht/COpenGLDriver.h" -#ifdef WIN32 -extern PFNGLGENTRANSFORMFEEDBACKSPROC glGenTransformFeedbacks; -extern PFNGLBINDTRANSFORMFEEDBACKPROC glBindTransformFeedback; -extern PFNGLDRAWTRANSFORMFEEDBACKPROC glDrawTransformFeedback; -extern PFNGLBEGINTRANSFORMFEEDBACKPROC glBeginTransformFeedback; -extern PFNGLENDTRANSFORMFEEDBACKPROC glEndTransformFeedback; -extern PFNGLTRANSFORMFEEDBACKVARYINGSPROC glTransformFeedbackVaryings; -extern PFNGLBINDBUFFERBASEPROC glBindBufferBase; -extern PFNGLGENBUFFERSPROC glGenBuffers; -extern PFNGLBINDBUFFERPROC glBindBuffer; -extern PFNGLBUFFERDATAPROC glBufferData; -extern PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer; -extern PFNGLCREATESHADERPROC glCreateShader; -extern PFNGLCOMPILESHADERPROC glCompileShader; -extern PFNGLSHADERSOURCEPROC glShaderSource; -extern PFNGLCREATEPROGRAMPROC glCreateProgram; -extern PFNGLATTACHSHADERPROC glAttachShader; -extern PFNGLLINKPROGRAMPROC glLinkProgram; -extern PFNGLUSEPROGRAMPROC glUseProgram; -extern PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray; -extern PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray; -extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation; -extern PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv; -extern PFNGLUNIFORM1FPROC glUniform1f; -extern PFNGLUNIFORM3FPROC glUniform3f; -extern PFNGLUNIFORM1FVPROC glUniform1fv; -extern PFNGLUNIFORM4FVPROC glUniform4fv; -extern PFNGLDELETESHADERPROC glDeleteShader; -extern PFNGLGETSHADERIVPROC glGetShaderiv; -extern PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog; -extern PFNGLACTIVETEXTUREPROC glActiveTexture; -extern PFNGLUNIFORM2FPROC glUniform2f; -extern PFNGLUNIFORM1IPROC glUniform1i; -extern PFNGLUNIFORM3IPROC glUniform3i; -extern PFNGLUNIFORM4IPROC glUniform4i; -extern PFNGLGETPROGRAMIVPROC glGetProgramiv; -extern PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog; -extern PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation; -extern PFNGLBLENDEQUATIONPROC glBlendEquation; -extern PFNGLVERTEXATTRIBDIVISORPROC glVertexAttribDivisor; -extern PFNGLDRAWARRAYSINSTANCEDPROC glDrawArraysInstanced; -extern PFNGLDELETEBUFFERSPROC glDeleteBuffers; -extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays; -extern PFNGLBINDVERTEXARRAYPROC glBindVertexArray; -extern PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays; -extern PFNGLTEXBUFFERPROC glTexBuffer; -extern PFNGLBUFFERSUBDATAPROC glBufferSubData; -extern PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer; -extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers; -extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer; -extern PFNGLFRAMEBUFFERTEXTUREPROC glFramebufferTexture; -extern PFNGLTEXIMAGE3DPROC glTexImage3D; -extern PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus; -#ifdef DEBUG -extern PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARB; -#endif -#endif - - -void initGL(); -GLuint LoadTFBProgram(const char * vertex_file_path, const char **varyings, unsigned varyingscount); -void setTexture(unsigned TextureUnit, GLuint TextureId, GLenum MagFilter, GLenum MinFilter, bool allowAF = false); -GLuint LoadShader(const char * file, unsigned type); - -template -void loadAndAttach(GLint ProgramID) -{ - return; -} - -template -void loadAndAttach(GLint ProgramID, GLint ShaderType, const char *filepath, Types ... args) -{ - GLint ShaderID = LoadShader(filepath, ShaderType); - glAttachShader(ProgramID, ShaderID); - glDeleteShader(ShaderID); - loadAndAttach(ProgramID, args...); -} - -template -void printFileList() -{ - return; -} - -template -void printFileList(GLint ShaderType, const char *filepath, Types ... args) -{ - Log::error("GLWrapp", filepath); - printFileList(args...); -} - -template -GLint LoadProgram(Types ... args) -{ - GLint ProgramID = glCreateProgram(); - loadAndAttach(ProgramID, args...); - glLinkProgram(ProgramID); - - GLint Result = GL_FALSE; - int InfoLogLength; - glGetProgramiv(ProgramID, GL_LINK_STATUS, &Result); - if (Result == GL_FALSE) { - Log::error("GLWrapp", "Error when linking these shaders :"); - printFileList(args...); - glGetProgramiv(ProgramID, GL_INFO_LOG_LENGTH, &InfoLogLength); - char *ErrorMessage = new char[InfoLogLength]; - glGetProgramInfoLog(ProgramID, InfoLogLength, NULL, ErrorMessage); - Log::error("GLWrapp", ErrorMessage); - delete[] ErrorMessage; - } - - GLenum glErr = glGetError(); - if (glErr != GL_NO_ERROR) - { - Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr); - } - - return ProgramID; -} - -// core::rect needs these includes -#include -#include "utils/vec3.hpp" - -GLuint getTextureGLuint(irr::video::ITexture *tex); -GLuint getDepthTexture(irr::video::ITexture *tex); - -void draw2DImage(const irr::video::ITexture* texture, const irr::core::rect& destRect, - const irr::core::rect& sourceRect, const irr::core::rect* clipRect, - const irr::video::SColor &color, bool useAlphaChannelOfTexture); - -void draw2DImage(const irr::video::ITexture* texture, const irr::core::rect& destRect, - const irr::core::rect& sourceRect, const irr::core::rect* clipRect, - const irr::video::SColor* const colors, bool useAlphaChannelOfTexture); - -void GL32_draw2DRectangle(irr::video::SColor color, const irr::core::rect& position, - const irr::core::rect* clip = 0); -#endif +#ifndef GLWRAP_HEADER_H +#define GLWRAP_HEADER_H + +#if defined(__APPLE__) +# include +# include +# define OGL32CTX +#elif defined(ANDROID) +# include +#elif defined(WIN32) +# define _WINSOCKAPI_ +// has to be included before gl.h because of WINGDIAPI and APIENTRY definitions +# include +# include +#else +#define GL_GLEXT_PROTOTYPES +#define DEBUG_OUTPUT_DECLARED +# include +#endif + +#include "utils/log.hpp" + +// already includes glext.h, which defines useful GL constants. +// COpenGLDriver has already loaded the extension GL functions we use (e.g glBeginQuery) +#include "../../lib/irrlicht/source/Irrlicht/COpenGLDriver.h" +#ifdef WIN32 +extern PFNGLGENTRANSFORMFEEDBACKSPROC glGenTransformFeedbacks; +extern PFNGLBINDTRANSFORMFEEDBACKPROC glBindTransformFeedback; +extern PFNGLDRAWTRANSFORMFEEDBACKPROC glDrawTransformFeedback; +extern PFNGLBEGINTRANSFORMFEEDBACKPROC glBeginTransformFeedback; +extern PFNGLENDTRANSFORMFEEDBACKPROC glEndTransformFeedback; +extern PFNGLTRANSFORMFEEDBACKVARYINGSPROC glTransformFeedbackVaryings; +extern PFNGLBINDBUFFERBASEPROC glBindBufferBase; +extern PFNGLGENBUFFERSPROC glGenBuffers; +extern PFNGLBINDBUFFERPROC glBindBuffer; +extern PFNGLBUFFERDATAPROC glBufferData; +extern PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer; +extern PFNGLCREATESHADERPROC glCreateShader; +extern PFNGLCOMPILESHADERPROC glCompileShader; +extern PFNGLSHADERSOURCEPROC glShaderSource; +extern PFNGLCREATEPROGRAMPROC glCreateProgram; +extern PFNGLATTACHSHADERPROC glAttachShader; +extern PFNGLLINKPROGRAMPROC glLinkProgram; +extern PFNGLUSEPROGRAMPROC glUseProgram; +extern PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray; +extern PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray; +extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation; +extern PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv; +extern PFNGLUNIFORM1FPROC glUniform1f; +extern PFNGLUNIFORM3FPROC glUniform3f; +extern PFNGLUNIFORM1FVPROC glUniform1fv; +extern PFNGLUNIFORM4FVPROC glUniform4fv; +extern PFNGLDELETESHADERPROC glDeleteShader; +extern PFNGLGETSHADERIVPROC glGetShaderiv; +extern PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog; +extern PFNGLACTIVETEXTUREPROC glActiveTexture; +extern PFNGLUNIFORM2FPROC glUniform2f; +extern PFNGLUNIFORM1IPROC glUniform1i; +extern PFNGLUNIFORM3IPROC glUniform3i; +extern PFNGLUNIFORM4IPROC glUniform4i; +extern PFNGLGETPROGRAMIVPROC glGetProgramiv; +extern PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog; +extern PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation; +extern PFNGLBLENDEQUATIONPROC glBlendEquation; +extern PFNGLVERTEXATTRIBDIVISORPROC glVertexAttribDivisor; +extern PFNGLDRAWARRAYSINSTANCEDPROC glDrawArraysInstanced; +extern PFNGLDELETEBUFFERSPROC glDeleteBuffers; +extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays; +extern PFNGLBINDVERTEXARRAYPROC glBindVertexArray; +extern PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays; +extern PFNGLTEXBUFFERPROC glTexBuffer; +extern PFNGLBUFFERSUBDATAPROC glBufferSubData; +extern PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer; +extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers; +extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer; +extern PFNGLFRAMEBUFFERTEXTUREPROC glFramebufferTexture; +extern PFNGLTEXIMAGE3DPROC glTexImage3D; +extern PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus; +#ifdef DEBUG +extern PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARB; +#endif +#endif + + +void initGL(); +GLuint LoadTFBProgram(const char * vertex_file_path, const char **varyings, unsigned varyingscount); +void setTexture(unsigned TextureUnit, GLuint TextureId, GLenum MagFilter, GLenum MinFilter, bool allowAF = false); +GLuint LoadShader(const char * file, unsigned type); + +template +void loadAndAttach(GLint ProgramID) +{ + return; +} + +template +void loadAndAttach(GLint ProgramID, GLint ShaderType, const char *filepath, Types ... args) +{ + GLint ShaderID = LoadShader(filepath, ShaderType); + glAttachShader(ProgramID, ShaderID); + glDeleteShader(ShaderID); + loadAndAttach(ProgramID, args...); +} + +template +void printFileList() +{ + return; +} + +template +void printFileList(GLint ShaderType, const char *filepath, Types ... args) +{ + Log::error("GLWrapp", filepath); + printFileList(args...); +} + +template +GLint LoadProgram(Types ... args) +{ + GLint ProgramID = glCreateProgram(); + loadAndAttach(ProgramID, args...); + glLinkProgram(ProgramID); + + GLint Result = GL_FALSE; + int InfoLogLength; + glGetProgramiv(ProgramID, GL_LINK_STATUS, &Result); + if (Result == GL_FALSE) { + Log::error("GLWrapp", "Error when linking these shaders :"); + printFileList(args...); + glGetProgramiv(ProgramID, GL_INFO_LOG_LENGTH, &InfoLogLength); + char *ErrorMessage = new char[InfoLogLength]; + glGetProgramInfoLog(ProgramID, InfoLogLength, NULL, ErrorMessage); + Log::error("GLWrapp", ErrorMessage); + delete[] ErrorMessage; + } + + GLenum glErr = glGetError(); + if (glErr != GL_NO_ERROR) + { + Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr); + } + + return ProgramID; +} + +// core::rect needs these includes +#include +#include "utils/vec3.hpp" + +GLuint getTextureGLuint(irr::video::ITexture *tex); +GLuint getDepthTexture(irr::video::ITexture *tex); + +void draw2DImage(const irr::video::ITexture* texture, const irr::core::rect& destRect, + const irr::core::rect& sourceRect, const irr::core::rect* clipRect, + const irr::video::SColor &color, bool useAlphaChannelOfTexture); + +void draw2DImage(const irr::video::ITexture* texture, const irr::core::rect& destRect, + const irr::core::rect& sourceRect, const irr::core::rect* clipRect, + const irr::video::SColor* const colors, bool useAlphaChannelOfTexture); + +void GL32_draw2DRectangle(irr::video::SColor color, const irr::core::rect& position, + const irr::core::rect* clip = 0); +#endif diff --git a/src/graphics/gpuparticles.cpp b/src/graphics/gpuparticles.cpp index 81d1a7b0f..d8cf1947a 100644 --- a/src/graphics/gpuparticles.cpp +++ b/src/graphics/gpuparticles.cpp @@ -1,581 +1,581 @@ -#include "graphics/irr_driver.hpp" -#include "gpuparticles.hpp" -#include "io/file_manager.hpp" -#include "config/user_config.hpp" -#include -#include -#include "guiengine/engine.hpp" - -#define COMPONENTCOUNT 8 - -scene::IParticleSystemSceneNode *ParticleSystemProxy::addParticleNode( - bool withDefaultEmitter, ISceneNode* parent, s32 id, - const core::vector3df& position, - const core::vector3df& rotation, - const core::vector3df& scale) -{ - if (!parent) - parent = irr_driver->getSceneManager()->getRootSceneNode(); - - IParticleSystemSceneNode* node = new ParticleSystemProxy(withDefaultEmitter, - parent, irr_driver->getSceneManager(), id, position, rotation, scale); - node->drop(); - - return node; -} - -GLuint ParticleSystemProxy::quad_vertex_buffer = 0; - -ParticleSystemProxy::ParticleSystemProxy(bool createDefaultEmitter, - ISceneNode* parent, scene::ISceneManager* mgr, s32 id, - const core::vector3df& position, - const core::vector3df& rotation, - const core::vector3df& scale) : CParticleSystemSceneNode(createDefaultEmitter, parent, mgr, id, position, rotation, scale), m_alpha_additive(false) -{ - glGenBuffers(1, &initial_values_buffer); - glGenBuffers(2, tfb_buffers); - glGenBuffers(1, &quaternionsbuffer); - glGenVertexArrays(1, ¤t_rendering_vao); - glGenVertexArrays(1, &non_current_rendering_vao); - size_increase_factor = 0.; - - m_color_from[0] = m_color_from[1] = m_color_from[2] = 1.0; - m_color_to[0] = m_color_to[1] = m_color_to[2] = 1.0; - - - // We set these later but avoid coverity report them - heighmapbuffer = 0; - heightmaptexture = 0; - current_simulation_vao = 0; - has_height_map = false; - flip = false; - track_x = 0; - track_z = 0; - track_x_len = 0; - track_z_len = 0; - texture = 0; - - if (quad_vertex_buffer) - return; - static const GLfloat quad_vertex[] = { - -.5, -.5, 0., 0., - .5, -.5, 1., 0., - -.5, .5, 0., 1., - .5, .5, 1., 1., - }; - glGenBuffers(1, &quad_vertex_buffer); - glBindBuffer(GL_ARRAY_BUFFER, quad_vertex_buffer); - glBufferData(GL_ARRAY_BUFFER, sizeof(quad_vertex), quad_vertex, GL_STATIC_DRAW); - glBindBuffer(GL_ARRAY_BUFFER, 0); -} - -ParticleSystemProxy::~ParticleSystemProxy() -{ - glDeleteBuffers(2, tfb_buffers); - glDeleteBuffers(1, &initial_values_buffer); - if (quaternionsbuffer) - glDeleteBuffers(1, &quaternionsbuffer); - if (heighmapbuffer) - glDeleteBuffers(1, &heighmapbuffer); - if (heightmaptexture) - glDeleteTextures(1, &heightmaptexture); -} - -void ParticleSystemProxy::setFlip() -{ - flip = true; -} - -void ParticleSystemProxy::setHeightmap(const std::vector > &hm, - float f1, float f2, float f3, float f4) -{ - track_x = f1, track_z = f2, track_x_len = f3, track_z_len = f4; - - unsigned width = hm.size(); - unsigned height = hm[0].size(); - float *hm_array = new float[width * height]; - for (unsigned i = 0; i < width; i++) - { - for (unsigned j = 0; j < height; j++) - { - hm_array[i * height + j] = hm[i][j]; - } - } - has_height_map = true; - glGenBuffers(1, &heighmapbuffer); - glBindBuffer(GL_TEXTURE_BUFFER, heighmapbuffer); - glBufferData(GL_TEXTURE_BUFFER, width * height * sizeof(float), hm_array, GL_STATIC_DRAW); - glGenTextures(1, &heightmaptexture); - glBindTexture(GL_TEXTURE_BUFFER, heightmaptexture); - glTexBuffer(GL_TEXTURE_BUFFER, GL_R32F, heighmapbuffer); - glBindBuffer(GL_TEXTURE_BUFFER, 0); - - delete[] hm_array; -} - -static -void generateLifetimeSizeDirection(scene::IParticleEmitter *emitter, float &lifetime, float &size, float &dirX, float &dirY, float &dirZ) -{ - float sizeMin = emitter->getMinStartSize().Height; - float sizeMax = emitter->getMaxStartSize().Height; - float lifetime_range = float(emitter->getMaxLifeTime() - emitter->getMinLifeTime()); - - lifetime = os::Randomizer::frand() * lifetime_range; - lifetime += emitter->getMinLifeTime(); - - size = os::Randomizer::frand(); - size *= (sizeMax - sizeMin); - size += sizeMin; - - core::vector3df particledir = emitter->getDirection(); - particledir.rotateXYBy(os::Randomizer::frand() * emitter->getMaxAngleDegrees()); - particledir.rotateYZBy(os::Randomizer::frand() * emitter->getMaxAngleDegrees()); - particledir.rotateXZBy(os::Randomizer::frand() * emitter->getMaxAngleDegrees()); - - dirX = particledir.X; - dirY = particledir.Y; - dirZ = particledir.Z; -} - -struct ParticleData -{ - float PositionX; - float PositionY; - float PositionZ; - float Lifetime; - float DirectionX; - float DirectionY; - float DirectionZ; - float Size; -}; - -void ParticleSystemProxy::generateParticlesFromPointEmitter(scene::IParticlePointEmitter *emitter) -{ - ParticleData *particles = new ParticleData[count], *initialvalue = new ParticleData[count]; - - for (unsigned i = 0; i < count; i++) - { - particles[i].PositionX = 0; - particles[i].PositionY = 0; - particles[i].PositionZ = 0; - // Initial lifetime is >1 - particles[i].Lifetime = 2.; - - memcpy(&(initialvalue[i].PositionX), &(particles[i].PositionX), 3 * sizeof(float)); - - generateLifetimeSizeDirection(emitter, initialvalue[i].Lifetime, initialvalue[i].Size, - initialvalue[i].DirectionX, initialvalue[i].DirectionY, initialvalue[i].DirectionZ); - - memcpy(&(particles[i].DirectionX), &(initialvalue[i].DirectionX), 4 * sizeof(float)); - } - - glBindBuffer(GL_ARRAY_BUFFER, initial_values_buffer); - glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), initialvalue, GL_STREAM_DRAW); - glBindBuffer(GL_ARRAY_BUFFER, tfb_buffers[0]); - glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), particles, GL_STREAM_DRAW); - glBindBuffer(GL_ARRAY_BUFFER, tfb_buffers[1]); - glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), 0, GL_STREAM_DRAW); - delete[] particles; - delete[] initialvalue; -} - -void ParticleSystemProxy::generateParticlesFromBoxEmitter(scene::IParticleBoxEmitter *emitter) -{ - ParticleData *particles = new ParticleData[count], *initialvalue = new ParticleData[count]; - - const core::vector3df& extent = emitter->getBox().getExtent(); - - for (unsigned i = 0; i < count; i++) { - particles[i].PositionX = emitter->getBox().MinEdge.X + os::Randomizer::frand() * extent.X; - particles[i].PositionY = emitter->getBox().MinEdge.Y + os::Randomizer::frand() * extent.Y; - particles[i].PositionZ = emitter->getBox().MinEdge.Z + os::Randomizer::frand() * extent.Z; - // Initial lifetime is random - particles[i].Lifetime = os::Randomizer::frand(); - - memcpy(&(initialvalue[i].PositionX), &(particles[i].PositionX), 3 * sizeof(float)); - generateLifetimeSizeDirection(emitter, initialvalue[i].Lifetime, initialvalue[i].Size, - initialvalue[i].DirectionX, initialvalue[i].DirectionY, initialvalue[i].DirectionZ); - memcpy(&(particles[i].DirectionX), &(initialvalue[i].DirectionZ), 4 * sizeof(float)); - } - glBindBuffer(GL_ARRAY_BUFFER, initial_values_buffer); - glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), initialvalue, GL_STREAM_DRAW); - glBindBuffer(GL_ARRAY_BUFFER, tfb_buffers[0]); - glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), particles, GL_STREAM_DRAW); - glBindBuffer(GL_ARRAY_BUFFER, tfb_buffers[1]); - glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), 0, GL_STREAM_DRAW); - delete[] particles; - delete[] initialvalue; -} - -void ParticleSystemProxy::generateParticlesFromSphereEmitter(scene::IParticleSphereEmitter *emitter) -{ - ParticleData *particles = new ParticleData[count], *initialvalue = new ParticleData[count]; - - for (unsigned i = 0; i < count; i++) { - // Random distance from center - const f32 distance = os::Randomizer::frand() * emitter->getRadius(); - - // Random direction from center - vector3df pos = emitter->getCenter() + distance; - pos.rotateXYBy(os::Randomizer::frand() * 360.f, emitter->getCenter()); - pos.rotateYZBy(os::Randomizer::frand() * 360.f, emitter->getCenter()); - pos.rotateXZBy(os::Randomizer::frand() * 360.f, emitter->getCenter()); - - particles[i].PositionX = pos.X; - particles[i].PositionY = pos.Y; - particles[i].PositionZ = pos.Z; - // Initial lifetime is > 1 - particles[i].Lifetime = 2.; - - memcpy(&(initialvalue[i].PositionX), &(particles[i].PositionX), 3 * sizeof(float)); - generateLifetimeSizeDirection(emitter, initialvalue[i].Lifetime, initialvalue[i].Size, - initialvalue[i].DirectionX, initialvalue[i].DirectionY, initialvalue[i].DirectionZ); - memcpy(&(particles[i].DirectionX), &(initialvalue[i].DirectionX), 4 * sizeof(float)); - } - glBindBuffer(GL_ARRAY_BUFFER, initial_values_buffer); - glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), initialvalue, GL_STREAM_DRAW); - glBindBuffer(GL_ARRAY_BUFFER, tfb_buffers[0]); - glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), particles, GL_STREAM_DRAW); - glBindBuffer(GL_ARRAY_BUFFER, tfb_buffers[1]); - glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), 0, GL_STREAM_DRAW); - delete[] particles; - delete[] initialvalue; -} - -static bool isGPUParticleType(scene::E_PARTICLE_EMITTER_TYPE type) -{ - switch (type) - { - case scene::EPET_POINT: - case scene::EPET_BOX: - case scene::EPET_SPHERE: - return true; - default: - return false; - } -} - -void ParticleSystemProxy::FlipParticleVAOBind(GLuint PositionBuffer, GLuint QuaternionBuffer) -{ - glEnableVertexAttribArray(ParticleShader::FlipParticleRender::attrib_pos); - glEnableVertexAttribArray(ParticleShader::FlipParticleRender::attrib_lf); - glEnableVertexAttribArray(ParticleShader::FlipParticleRender::attrib_quadcorner); - glEnableVertexAttribArray(ParticleShader::FlipParticleRender::attrib_texcoord); - glEnableVertexAttribArray(ParticleShader::FlipParticleRender::attrib_sz); - - glEnableVertexAttribArray(ParticleShader::FlipParticleRender::attrib_rotationvec); - glEnableVertexAttribArray(ParticleShader::FlipParticleRender::attrib_anglespeed); - - glBindBuffer(GL_ARRAY_BUFFER, QuaternionBuffer); - glVertexAttribPointer(ParticleShader::FlipParticleRender::attrib_rotationvec, 3, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0); - glVertexAttribPointer(ParticleShader::FlipParticleRender::attrib_anglespeed, 1, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid *)(3 * sizeof(float))); - - glBindBuffer(GL_ARRAY_BUFFER, quad_vertex_buffer); - glVertexAttribPointer(ParticleShader::FlipParticleRender::attrib_quadcorner, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0); - glVertexAttribPointer(ParticleShader::FlipParticleRender::attrib_texcoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid *)(2 * sizeof(float))); - - glBindBuffer(GL_ARRAY_BUFFER, PositionBuffer); - glVertexAttribPointer(ParticleShader::FlipParticleRender::attrib_pos, 3, GL_FLOAT, GL_FALSE, sizeof(ParticleData), 0); - glVertexAttribPointer(ParticleShader::FlipParticleRender::attrib_lf, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid *)(3 * sizeof(float))); - glVertexAttribPointer(ParticleShader::FlipParticleRender::attrib_sz, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid *)(7 * sizeof(float))); - - glVertexAttribDivisor(ParticleShader::FlipParticleRender::attrib_lf, 1); - glVertexAttribDivisor(ParticleShader::FlipParticleRender::attrib_pos, 1); - glVertexAttribDivisor(ParticleShader::FlipParticleRender::attrib_sz, 1); - glVertexAttribDivisor(ParticleShader::FlipParticleRender::attrib_rotationvec, 1); - glVertexAttribDivisor(ParticleShader::FlipParticleRender::attrib_anglespeed, 1); -} - -void ParticleSystemProxy::SimpleParticleVAOBind(GLuint PositionBuffer) -{ - glEnableVertexAttribArray(ParticleShader::SimpleParticleRender::attrib_pos); - glEnableVertexAttribArray(ParticleShader::SimpleParticleRender::attrib_lf); - glEnableVertexAttribArray(ParticleShader::SimpleParticleRender::attrib_quadcorner); - glEnableVertexAttribArray(ParticleShader::SimpleParticleRender::attrib_texcoord); - glEnableVertexAttribArray(ParticleShader::SimpleParticleRender::attrib_sz); - - glBindBuffer(GL_ARRAY_BUFFER, quad_vertex_buffer); - glVertexAttribPointer(ParticleShader::SimpleParticleRender::attrib_quadcorner, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0); - glVertexAttribPointer(ParticleShader::SimpleParticleRender::attrib_texcoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid *)(2 * sizeof(float))); - - glBindBuffer(GL_ARRAY_BUFFER, PositionBuffer); - glVertexAttribPointer(ParticleShader::SimpleParticleRender::attrib_pos, 3, GL_FLOAT, GL_FALSE, sizeof(ParticleData), 0); - glVertexAttribPointer(ParticleShader::SimpleParticleRender::attrib_lf, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid *)(3 * sizeof(float))); - glVertexAttribPointer(ParticleShader::SimpleParticleRender::attrib_sz, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid *)(7 * sizeof(float))); - - glVertexAttribDivisor(ParticleShader::SimpleParticleRender::attrib_lf, 1); - glVertexAttribDivisor(ParticleShader::SimpleParticleRender::attrib_pos, 1); - glVertexAttribDivisor(ParticleShader::SimpleParticleRender::attrib_sz, 1); -} - -void ParticleSystemProxy::SimpleSimulationBind(GLuint PositionBuffer, GLuint InitialValuesBuffer) -{ - glEnableVertexAttribArray(ParticleShader::SimpleSimulationShader::attrib_position); - glEnableVertexAttribArray(ParticleShader::SimpleSimulationShader::attrib_lifetime); - glEnableVertexAttribArray(ParticleShader::SimpleSimulationShader::attrib_velocity); - glEnableVertexAttribArray(ParticleShader::SimpleSimulationShader::attrib_size); - glBindBuffer(GL_ARRAY_BUFFER, PositionBuffer); - glVertexAttribPointer(ParticleShader::SimpleSimulationShader::attrib_position, 3, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)0); - glVertexAttribPointer(ParticleShader::SimpleSimulationShader::attrib_lifetime, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(3 * sizeof(float))); - glVertexAttribPointer(ParticleShader::SimpleSimulationShader::attrib_velocity, 4, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(4 * sizeof(float))); - glVertexAttribPointer(ParticleShader::SimpleSimulationShader::attrib_size, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(7 * sizeof(float))); - glEnableVertexAttribArray(ParticleShader::SimpleSimulationShader::attrib_initial_position); - glEnableVertexAttribArray(ParticleShader::SimpleSimulationShader::attrib_initial_lifetime); - glEnableVertexAttribArray(ParticleShader::SimpleSimulationShader::attrib_initial_velocity); - glEnableVertexAttribArray(ParticleShader::SimpleSimulationShader::attrib_initial_size); - glBindBuffer(GL_ARRAY_BUFFER, InitialValuesBuffer); - glVertexAttribPointer(ParticleShader::SimpleSimulationShader::attrib_initial_position, 3, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)0); - glVertexAttribPointer(ParticleShader::SimpleSimulationShader::attrib_initial_lifetime, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(3 * sizeof(float))); - glVertexAttribPointer(ParticleShader::SimpleSimulationShader::attrib_initial_velocity, 4, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(4 * sizeof(float))); - glVertexAttribPointer(ParticleShader::SimpleSimulationShader::attrib_initial_size, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(7 * sizeof(float))); -} - -void ParticleSystemProxy::HeightmapSimulationBind(GLuint PositionBuffer, GLuint InitialValuesBuffer) -{ - // Position buffer - glEnableVertexAttribArray(ParticleShader::HeightmapSimulationShader::attrib_position); - glEnableVertexAttribArray(ParticleShader::HeightmapSimulationShader::attrib_lifetime); - glEnableVertexAttribArray(ParticleShader::HeightmapSimulationShader::attrib_velocity); - - glBindBuffer(GL_ARRAY_BUFFER, PositionBuffer); - glVertexAttribPointer(ParticleShader::HeightmapSimulationShader::attrib_position, 3, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)0); - glVertexAttribPointer(ParticleShader::HeightmapSimulationShader::attrib_lifetime, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(3 * sizeof(float))); - glVertexAttribPointer(ParticleShader::HeightmapSimulationShader::attrib_velocity, 4, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(4 * sizeof(float))); - - // Initial values buffer - glEnableVertexAttribArray(ParticleShader::HeightmapSimulationShader::attrib_initial_position); - glEnableVertexAttribArray(ParticleShader::HeightmapSimulationShader::attrib_initial_lifetime); - glEnableVertexAttribArray(ParticleShader::HeightmapSimulationShader::attrib_initial_velocity); - glEnableVertexAttribArray(ParticleShader::HeightmapSimulationShader::attrib_initial_size); - - glBindBuffer(GL_ARRAY_BUFFER, InitialValuesBuffer); - glVertexAttribPointer(ParticleShader::HeightmapSimulationShader::attrib_initial_position, 3, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)0); - glVertexAttribPointer(ParticleShader::HeightmapSimulationShader::attrib_initial_lifetime, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(3 * sizeof(float))); - glVertexAttribPointer(ParticleShader::HeightmapSimulationShader::attrib_initial_velocity, 4, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(4 * sizeof(float))); - glVertexAttribPointer(ParticleShader::HeightmapSimulationShader::attrib_initial_size, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(7 * sizeof(float))); -} - - -void ParticleSystemProxy::setEmitter(scene::IParticleEmitter* emitter) -{ - CParticleSystemSceneNode::setEmitter(emitter); - if (!emitter || !isGPUParticleType(emitter->getType())) - return; - has_height_map = false; - flip = false; - - count = emitter->getMaxParticlesPerSecond() * emitter->getMaxLifeTime() / 1000; - switch (emitter->getType()) - { - case scene::EPET_POINT: - generateParticlesFromPointEmitter(emitter); - break; - case scene::EPET_BOX: - generateParticlesFromBoxEmitter(static_cast(emitter)); - break; - case scene::EPET_SPHERE: - generateParticlesFromSphereEmitter(static_cast(emitter)); - break; - default: - assert(0 && "Wrong particle type"); - } - - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindVertexArray(0); - - texture = getTextureGLuint(getMaterial(0).getTexture(0)); -} - -void ParticleSystemProxy::simulateHeightmap() -{ - int timediff = int(GUIEngine::getLatestDt() * 1000.f); - int active_count = getEmitter()->getMaxLifeTime() * getEmitter()->getMaxParticlesPerSecond() / 1000; - core::matrix4 matrix = getAbsoluteTransformation(); - glUseProgram(ParticleShader::HeightmapSimulationShader::Program); - glEnable(GL_RASTERIZER_DISCARD); - - glUniform1i(ParticleShader::HeightmapSimulationShader::uniform_dt, timediff); - glUniform1i(ParticleShader::HeightmapSimulationShader::uniform_level, active_count); - glUniformMatrix4fv(ParticleShader::HeightmapSimulationShader::uniform_sourcematrix, 1, GL_FALSE, matrix.pointer()); - glUniform1f(ParticleShader::HeightmapSimulationShader::uniform_size_increase_factor, size_increase_factor); - glActiveTexture(GL_TEXTURE2); - glBindTexture(GL_TEXTURE_BUFFER, heightmaptexture); - glUniform1i(ParticleShader::HeightmapSimulationShader::uniform_heightmap, 2); - glUniform1f(ParticleShader::HeightmapSimulationShader::uniform_track_x, track_x); - glUniform1f(ParticleShader::HeightmapSimulationShader::uniform_track_z, track_z); - glUniform1f(ParticleShader::HeightmapSimulationShader::uniform_track_x_len, track_x_len); - glUniform1f(ParticleShader::HeightmapSimulationShader::uniform_track_z_len, track_z_len); - - glBindVertexArray(current_simulation_vao); - glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, tfb_buffers[1]); - - glBeginTransformFeedback(GL_POINTS); - glDrawArrays(GL_POINTS, 0, count); - glEndTransformFeedback(); - glBindVertexArray(0); - - glDisable(GL_RASTERIZER_DISCARD); - std::swap(tfb_buffers[0], tfb_buffers[1]); - std::swap(current_rendering_vao, non_current_rendering_vao); - std::swap(current_simulation_vao, non_current_simulation_vao); -} - -void ParticleSystemProxy::simulateNoHeightmap() -{ - int timediff = int(GUIEngine::getLatestDt() * 1000.f); - int active_count = getEmitter()->getMaxLifeTime() * getEmitter()->getMaxParticlesPerSecond() / 1000; - core::matrix4 matrix = getAbsoluteTransformation(); - glUseProgram(ParticleShader::SimpleSimulationShader::Program); - glEnable(GL_RASTERIZER_DISCARD); - - glUniform1i(ParticleShader::SimpleSimulationShader::uniform_dt, timediff); - glUniform1i(ParticleShader::SimpleSimulationShader::uniform_level, active_count); - glUniformMatrix4fv(ParticleShader::SimpleSimulationShader::uniform_sourcematrix, 1, GL_FALSE, matrix.pointer()); - glUniform1f(ParticleShader::SimpleSimulationShader::uniform_size_increase_factor, size_increase_factor); - - glBindVertexArray(current_simulation_vao); - glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, tfb_buffers[1]); - - glBeginTransformFeedback(GL_POINTS); - glDrawArrays(GL_POINTS, 0, count); - glEndTransformFeedback(); - glBindVertexArray(0); - - glDisable(GL_RASTERIZER_DISCARD); - std::swap(tfb_buffers[0], tfb_buffers[1]); - std::swap(current_rendering_vao, non_current_rendering_vao); - std::swap(current_simulation_vao, non_current_simulation_vao); -} - -void ParticleSystemProxy::simulate() -{ - if (has_height_map) - simulateHeightmap(); - else - simulateNoHeightmap(); -} - -void ParticleSystemProxy::drawFlip() -{ - glBlendFunc(GL_SRC_ALPHA, GL_ONE); - glUseProgram(ParticleShader::FlipParticleRender::Program); - - float screen[2] = { - (float)UserConfigParams::m_width, - (float)UserConfigParams::m_height - }; - - setTexture(0, texture, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR); - setTexture(1, static_cast(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH))->DepthBufferTexture, GL_NEAREST, GL_NEAREST); - - ParticleShader::FlipParticleRender::setUniforms(irr_driver->getViewMatrix(), irr_driver->getProjMatrix(), irr_driver->getInvProjMatrix(), screen[0], screen[1], 0, 1); - - glBindVertexArray(current_rendering_vao); - glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, count); -} - -void ParticleSystemProxy::drawNotFlip() -{ - if (m_alpha_additive) - glBlendFunc(GL_SRC_ALPHA, GL_ONE); - else - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glUseProgram(ParticleShader::SimpleParticleRender::Program); - - float screen[2] = { - (float)UserConfigParams::m_width, - (float)UserConfigParams::m_height - }; - - setTexture(0, texture, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR); - setTexture(1, static_cast(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH))->DepthBufferTexture, GL_NEAREST, GL_NEAREST); - - ParticleShader::SimpleParticleRender::setUniforms(irr_driver->getViewMatrix(), irr_driver->getProjMatrix(), - irr_driver->getInvProjMatrix(), screen[0], screen[1], 0, 1, this); - - glBindVertexArray(current_rendering_vao); - glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, count); -} - -void ParticleSystemProxy::draw() -{ - if (flip) - drawFlip(); - else - drawNotFlip(); -} - -void ParticleSystemProxy::generateVAOs() -{ - glGenVertexArrays(1, ¤t_rendering_vao); - glGenVertexArrays(1, &non_current_rendering_vao); - glGenVertexArrays(1, ¤t_simulation_vao); - glGenVertexArrays(1, &non_current_simulation_vao); - - glBindVertexArray(current_simulation_vao); - if (has_height_map) - HeightmapSimulationBind(tfb_buffers[0], initial_values_buffer); - else - SimpleSimulationBind(tfb_buffers[0], initial_values_buffer); - glBindVertexArray(non_current_simulation_vao); - if (has_height_map) - HeightmapSimulationBind(tfb_buffers[1], initial_values_buffer); - else - SimpleSimulationBind(tfb_buffers[1], initial_values_buffer); - - float *quaternions = new float[4 * count]; - glBindVertexArray(0); - if (flip) - { - for (unsigned i = 0; i < count; i++) - { - core::vector3df rotationdir(0., 1., 0.); - - quaternions[4 * i] = rotationdir.X; - quaternions[4 * i + 1] = rotationdir.Y; - quaternions[4 * i + 2] = rotationdir.Z; - quaternions[4 * i + 3] = 3.14f * 3.f * (2.f * os::Randomizer::frand() - 1.f); // 3 half rotation during lifetime at max - } - glGenBuffers(1, &quaternionsbuffer); - glBindBuffer(GL_ARRAY_BUFFER, quaternionsbuffer); - glBufferData(GL_ARRAY_BUFFER, 4 * count * sizeof(float), quaternions, GL_STATIC_DRAW); - } - - glBindVertexArray(current_rendering_vao); - if (flip) - FlipParticleVAOBind(tfb_buffers[0], quaternionsbuffer); - else - SimpleParticleVAOBind(tfb_buffers[0]); - - glBindVertexArray(non_current_rendering_vao); - if (flip) - FlipParticleVAOBind(tfb_buffers[1], quaternionsbuffer); - else - SimpleParticleVAOBind(tfb_buffers[1]); - glBindVertexArray(0); - - delete[] quaternions; -} - -void ParticleSystemProxy::render() { - if (!getEmitter() || !isGPUParticleType(getEmitter()->getType())) - { - CParticleSystemSceneNode::render(); - return; - } - if (!current_rendering_vao || !non_current_rendering_vao || !current_simulation_vao || !non_current_simulation_vao) - generateVAOs(); - simulate(); - draw(); -} - -void ParticleSystemProxy::OnRegisterSceneNode() -{ - doParticleSystem(os::Timer::getTime()); - - if (IsVisible && (Particles.size() != 0)) - { - SceneManager->registerNodeForRendering(this, scene::ESNRP_TRANSPARENT_EFFECT); - ISceneNode::OnRegisterSceneNode(); - } -} +#include "graphics/irr_driver.hpp" +#include "gpuparticles.hpp" +#include "io/file_manager.hpp" +#include "config/user_config.hpp" +#include +#include +#include "guiengine/engine.hpp" + +#define COMPONENTCOUNT 8 + +scene::IParticleSystemSceneNode *ParticleSystemProxy::addParticleNode( + bool withDefaultEmitter, ISceneNode* parent, s32 id, + const core::vector3df& position, + const core::vector3df& rotation, + const core::vector3df& scale) +{ + if (!parent) + parent = irr_driver->getSceneManager()->getRootSceneNode(); + + IParticleSystemSceneNode* node = new ParticleSystemProxy(withDefaultEmitter, + parent, irr_driver->getSceneManager(), id, position, rotation, scale); + node->drop(); + + return node; +} + +GLuint ParticleSystemProxy::quad_vertex_buffer = 0; + +ParticleSystemProxy::ParticleSystemProxy(bool createDefaultEmitter, + ISceneNode* parent, scene::ISceneManager* mgr, s32 id, + const core::vector3df& position, + const core::vector3df& rotation, + const core::vector3df& scale) : CParticleSystemSceneNode(createDefaultEmitter, parent, mgr, id, position, rotation, scale), m_alpha_additive(false) +{ + glGenBuffers(1, &initial_values_buffer); + glGenBuffers(2, tfb_buffers); + glGenBuffers(1, &quaternionsbuffer); + glGenVertexArrays(1, ¤t_rendering_vao); + glGenVertexArrays(1, &non_current_rendering_vao); + size_increase_factor = 0.; + + m_color_from[0] = m_color_from[1] = m_color_from[2] = 1.0; + m_color_to[0] = m_color_to[1] = m_color_to[2] = 1.0; + + + // We set these later but avoid coverity report them + heighmapbuffer = 0; + heightmaptexture = 0; + current_simulation_vao = 0; + has_height_map = false; + flip = false; + track_x = 0; + track_z = 0; + track_x_len = 0; + track_z_len = 0; + texture = 0; + + if (quad_vertex_buffer) + return; + static const GLfloat quad_vertex[] = { + -.5, -.5, 0., 0., + .5, -.5, 1., 0., + -.5, .5, 0., 1., + .5, .5, 1., 1., + }; + glGenBuffers(1, &quad_vertex_buffer); + glBindBuffer(GL_ARRAY_BUFFER, quad_vertex_buffer); + glBufferData(GL_ARRAY_BUFFER, sizeof(quad_vertex), quad_vertex, GL_STATIC_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, 0); +} + +ParticleSystemProxy::~ParticleSystemProxy() +{ + glDeleteBuffers(2, tfb_buffers); + glDeleteBuffers(1, &initial_values_buffer); + if (quaternionsbuffer) + glDeleteBuffers(1, &quaternionsbuffer); + if (heighmapbuffer) + glDeleteBuffers(1, &heighmapbuffer); + if (heightmaptexture) + glDeleteTextures(1, &heightmaptexture); +} + +void ParticleSystemProxy::setFlip() +{ + flip = true; +} + +void ParticleSystemProxy::setHeightmap(const std::vector > &hm, + float f1, float f2, float f3, float f4) +{ + track_x = f1, track_z = f2, track_x_len = f3, track_z_len = f4; + + unsigned width = hm.size(); + unsigned height = hm[0].size(); + float *hm_array = new float[width * height]; + for (unsigned i = 0; i < width; i++) + { + for (unsigned j = 0; j < height; j++) + { + hm_array[i * height + j] = hm[i][j]; + } + } + has_height_map = true; + glGenBuffers(1, &heighmapbuffer); + glBindBuffer(GL_TEXTURE_BUFFER, heighmapbuffer); + glBufferData(GL_TEXTURE_BUFFER, width * height * sizeof(float), hm_array, GL_STATIC_DRAW); + glGenTextures(1, &heightmaptexture); + glBindTexture(GL_TEXTURE_BUFFER, heightmaptexture); + glTexBuffer(GL_TEXTURE_BUFFER, GL_R32F, heighmapbuffer); + glBindBuffer(GL_TEXTURE_BUFFER, 0); + + delete[] hm_array; +} + +static +void generateLifetimeSizeDirection(scene::IParticleEmitter *emitter, float &lifetime, float &size, float &dirX, float &dirY, float &dirZ) +{ + float sizeMin = emitter->getMinStartSize().Height; + float sizeMax = emitter->getMaxStartSize().Height; + float lifetime_range = float(emitter->getMaxLifeTime() - emitter->getMinLifeTime()); + + lifetime = os::Randomizer::frand() * lifetime_range; + lifetime += emitter->getMinLifeTime(); + + size = os::Randomizer::frand(); + size *= (sizeMax - sizeMin); + size += sizeMin; + + core::vector3df particledir = emitter->getDirection(); + particledir.rotateXYBy(os::Randomizer::frand() * emitter->getMaxAngleDegrees()); + particledir.rotateYZBy(os::Randomizer::frand() * emitter->getMaxAngleDegrees()); + particledir.rotateXZBy(os::Randomizer::frand() * emitter->getMaxAngleDegrees()); + + dirX = particledir.X; + dirY = particledir.Y; + dirZ = particledir.Z; +} + +struct ParticleData +{ + float PositionX; + float PositionY; + float PositionZ; + float Lifetime; + float DirectionX; + float DirectionY; + float DirectionZ; + float Size; +}; + +void ParticleSystemProxy::generateParticlesFromPointEmitter(scene::IParticlePointEmitter *emitter) +{ + ParticleData *particles = new ParticleData[count], *initialvalue = new ParticleData[count]; + + for (unsigned i = 0; i < count; i++) + { + particles[i].PositionX = 0; + particles[i].PositionY = 0; + particles[i].PositionZ = 0; + // Initial lifetime is >1 + particles[i].Lifetime = 2.; + + memcpy(&(initialvalue[i].PositionX), &(particles[i].PositionX), 3 * sizeof(float)); + + generateLifetimeSizeDirection(emitter, initialvalue[i].Lifetime, initialvalue[i].Size, + initialvalue[i].DirectionX, initialvalue[i].DirectionY, initialvalue[i].DirectionZ); + + memcpy(&(particles[i].DirectionX), &(initialvalue[i].DirectionX), 4 * sizeof(float)); + } + + glBindBuffer(GL_ARRAY_BUFFER, initial_values_buffer); + glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), initialvalue, GL_STREAM_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, tfb_buffers[0]); + glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), particles, GL_STREAM_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, tfb_buffers[1]); + glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), 0, GL_STREAM_DRAW); + delete[] particles; + delete[] initialvalue; +} + +void ParticleSystemProxy::generateParticlesFromBoxEmitter(scene::IParticleBoxEmitter *emitter) +{ + ParticleData *particles = new ParticleData[count], *initialvalue = new ParticleData[count]; + + const core::vector3df& extent = emitter->getBox().getExtent(); + + for (unsigned i = 0; i < count; i++) { + particles[i].PositionX = emitter->getBox().MinEdge.X + os::Randomizer::frand() * extent.X; + particles[i].PositionY = emitter->getBox().MinEdge.Y + os::Randomizer::frand() * extent.Y; + particles[i].PositionZ = emitter->getBox().MinEdge.Z + os::Randomizer::frand() * extent.Z; + // Initial lifetime is random + particles[i].Lifetime = os::Randomizer::frand(); + + memcpy(&(initialvalue[i].PositionX), &(particles[i].PositionX), 3 * sizeof(float)); + generateLifetimeSizeDirection(emitter, initialvalue[i].Lifetime, initialvalue[i].Size, + initialvalue[i].DirectionX, initialvalue[i].DirectionY, initialvalue[i].DirectionZ); + memcpy(&(particles[i].DirectionX), &(initialvalue[i].DirectionZ), 4 * sizeof(float)); + } + glBindBuffer(GL_ARRAY_BUFFER, initial_values_buffer); + glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), initialvalue, GL_STREAM_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, tfb_buffers[0]); + glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), particles, GL_STREAM_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, tfb_buffers[1]); + glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), 0, GL_STREAM_DRAW); + delete[] particles; + delete[] initialvalue; +} + +void ParticleSystemProxy::generateParticlesFromSphereEmitter(scene::IParticleSphereEmitter *emitter) +{ + ParticleData *particles = new ParticleData[count], *initialvalue = new ParticleData[count]; + + for (unsigned i = 0; i < count; i++) { + // Random distance from center + const f32 distance = os::Randomizer::frand() * emitter->getRadius(); + + // Random direction from center + vector3df pos = emitter->getCenter() + distance; + pos.rotateXYBy(os::Randomizer::frand() * 360.f, emitter->getCenter()); + pos.rotateYZBy(os::Randomizer::frand() * 360.f, emitter->getCenter()); + pos.rotateXZBy(os::Randomizer::frand() * 360.f, emitter->getCenter()); + + particles[i].PositionX = pos.X; + particles[i].PositionY = pos.Y; + particles[i].PositionZ = pos.Z; + // Initial lifetime is > 1 + particles[i].Lifetime = 2.; + + memcpy(&(initialvalue[i].PositionX), &(particles[i].PositionX), 3 * sizeof(float)); + generateLifetimeSizeDirection(emitter, initialvalue[i].Lifetime, initialvalue[i].Size, + initialvalue[i].DirectionX, initialvalue[i].DirectionY, initialvalue[i].DirectionZ); + memcpy(&(particles[i].DirectionX), &(initialvalue[i].DirectionX), 4 * sizeof(float)); + } + glBindBuffer(GL_ARRAY_BUFFER, initial_values_buffer); + glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), initialvalue, GL_STREAM_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, tfb_buffers[0]); + glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), particles, GL_STREAM_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, tfb_buffers[1]); + glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), 0, GL_STREAM_DRAW); + delete[] particles; + delete[] initialvalue; +} + +static bool isGPUParticleType(scene::E_PARTICLE_EMITTER_TYPE type) +{ + switch (type) + { + case scene::EPET_POINT: + case scene::EPET_BOX: + case scene::EPET_SPHERE: + return true; + default: + return false; + } +} + +void ParticleSystemProxy::FlipParticleVAOBind(GLuint PositionBuffer, GLuint QuaternionBuffer) +{ + glEnableVertexAttribArray(ParticleShader::FlipParticleRender::attrib_pos); + glEnableVertexAttribArray(ParticleShader::FlipParticleRender::attrib_lf); + glEnableVertexAttribArray(ParticleShader::FlipParticleRender::attrib_quadcorner); + glEnableVertexAttribArray(ParticleShader::FlipParticleRender::attrib_texcoord); + glEnableVertexAttribArray(ParticleShader::FlipParticleRender::attrib_sz); + + glEnableVertexAttribArray(ParticleShader::FlipParticleRender::attrib_rotationvec); + glEnableVertexAttribArray(ParticleShader::FlipParticleRender::attrib_anglespeed); + + glBindBuffer(GL_ARRAY_BUFFER, QuaternionBuffer); + glVertexAttribPointer(ParticleShader::FlipParticleRender::attrib_rotationvec, 3, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0); + glVertexAttribPointer(ParticleShader::FlipParticleRender::attrib_anglespeed, 1, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid *)(3 * sizeof(float))); + + glBindBuffer(GL_ARRAY_BUFFER, quad_vertex_buffer); + glVertexAttribPointer(ParticleShader::FlipParticleRender::attrib_quadcorner, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0); + glVertexAttribPointer(ParticleShader::FlipParticleRender::attrib_texcoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid *)(2 * sizeof(float))); + + glBindBuffer(GL_ARRAY_BUFFER, PositionBuffer); + glVertexAttribPointer(ParticleShader::FlipParticleRender::attrib_pos, 3, GL_FLOAT, GL_FALSE, sizeof(ParticleData), 0); + glVertexAttribPointer(ParticleShader::FlipParticleRender::attrib_lf, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid *)(3 * sizeof(float))); + glVertexAttribPointer(ParticleShader::FlipParticleRender::attrib_sz, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid *)(7 * sizeof(float))); + + glVertexAttribDivisor(ParticleShader::FlipParticleRender::attrib_lf, 1); + glVertexAttribDivisor(ParticleShader::FlipParticleRender::attrib_pos, 1); + glVertexAttribDivisor(ParticleShader::FlipParticleRender::attrib_sz, 1); + glVertexAttribDivisor(ParticleShader::FlipParticleRender::attrib_rotationvec, 1); + glVertexAttribDivisor(ParticleShader::FlipParticleRender::attrib_anglespeed, 1); +} + +void ParticleSystemProxy::SimpleParticleVAOBind(GLuint PositionBuffer) +{ + glEnableVertexAttribArray(ParticleShader::SimpleParticleRender::attrib_pos); + glEnableVertexAttribArray(ParticleShader::SimpleParticleRender::attrib_lf); + glEnableVertexAttribArray(ParticleShader::SimpleParticleRender::attrib_quadcorner); + glEnableVertexAttribArray(ParticleShader::SimpleParticleRender::attrib_texcoord); + glEnableVertexAttribArray(ParticleShader::SimpleParticleRender::attrib_sz); + + glBindBuffer(GL_ARRAY_BUFFER, quad_vertex_buffer); + glVertexAttribPointer(ParticleShader::SimpleParticleRender::attrib_quadcorner, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0); + glVertexAttribPointer(ParticleShader::SimpleParticleRender::attrib_texcoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid *)(2 * sizeof(float))); + + glBindBuffer(GL_ARRAY_BUFFER, PositionBuffer); + glVertexAttribPointer(ParticleShader::SimpleParticleRender::attrib_pos, 3, GL_FLOAT, GL_FALSE, sizeof(ParticleData), 0); + glVertexAttribPointer(ParticleShader::SimpleParticleRender::attrib_lf, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid *)(3 * sizeof(float))); + glVertexAttribPointer(ParticleShader::SimpleParticleRender::attrib_sz, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid *)(7 * sizeof(float))); + + glVertexAttribDivisor(ParticleShader::SimpleParticleRender::attrib_lf, 1); + glVertexAttribDivisor(ParticleShader::SimpleParticleRender::attrib_pos, 1); + glVertexAttribDivisor(ParticleShader::SimpleParticleRender::attrib_sz, 1); +} + +void ParticleSystemProxy::SimpleSimulationBind(GLuint PositionBuffer, GLuint InitialValuesBuffer) +{ + glEnableVertexAttribArray(ParticleShader::SimpleSimulationShader::attrib_position); + glEnableVertexAttribArray(ParticleShader::SimpleSimulationShader::attrib_lifetime); + glEnableVertexAttribArray(ParticleShader::SimpleSimulationShader::attrib_velocity); + glEnableVertexAttribArray(ParticleShader::SimpleSimulationShader::attrib_size); + glBindBuffer(GL_ARRAY_BUFFER, PositionBuffer); + glVertexAttribPointer(ParticleShader::SimpleSimulationShader::attrib_position, 3, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)0); + glVertexAttribPointer(ParticleShader::SimpleSimulationShader::attrib_lifetime, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(3 * sizeof(float))); + glVertexAttribPointer(ParticleShader::SimpleSimulationShader::attrib_velocity, 4, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(4 * sizeof(float))); + glVertexAttribPointer(ParticleShader::SimpleSimulationShader::attrib_size, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(7 * sizeof(float))); + glEnableVertexAttribArray(ParticleShader::SimpleSimulationShader::attrib_initial_position); + glEnableVertexAttribArray(ParticleShader::SimpleSimulationShader::attrib_initial_lifetime); + glEnableVertexAttribArray(ParticleShader::SimpleSimulationShader::attrib_initial_velocity); + glEnableVertexAttribArray(ParticleShader::SimpleSimulationShader::attrib_initial_size); + glBindBuffer(GL_ARRAY_BUFFER, InitialValuesBuffer); + glVertexAttribPointer(ParticleShader::SimpleSimulationShader::attrib_initial_position, 3, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)0); + glVertexAttribPointer(ParticleShader::SimpleSimulationShader::attrib_initial_lifetime, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(3 * sizeof(float))); + glVertexAttribPointer(ParticleShader::SimpleSimulationShader::attrib_initial_velocity, 4, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(4 * sizeof(float))); + glVertexAttribPointer(ParticleShader::SimpleSimulationShader::attrib_initial_size, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(7 * sizeof(float))); +} + +void ParticleSystemProxy::HeightmapSimulationBind(GLuint PositionBuffer, GLuint InitialValuesBuffer) +{ + // Position buffer + glEnableVertexAttribArray(ParticleShader::HeightmapSimulationShader::attrib_position); + glEnableVertexAttribArray(ParticleShader::HeightmapSimulationShader::attrib_lifetime); + glEnableVertexAttribArray(ParticleShader::HeightmapSimulationShader::attrib_velocity); + + glBindBuffer(GL_ARRAY_BUFFER, PositionBuffer); + glVertexAttribPointer(ParticleShader::HeightmapSimulationShader::attrib_position, 3, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)0); + glVertexAttribPointer(ParticleShader::HeightmapSimulationShader::attrib_lifetime, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(3 * sizeof(float))); + glVertexAttribPointer(ParticleShader::HeightmapSimulationShader::attrib_velocity, 4, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(4 * sizeof(float))); + + // Initial values buffer + glEnableVertexAttribArray(ParticleShader::HeightmapSimulationShader::attrib_initial_position); + glEnableVertexAttribArray(ParticleShader::HeightmapSimulationShader::attrib_initial_lifetime); + glEnableVertexAttribArray(ParticleShader::HeightmapSimulationShader::attrib_initial_velocity); + glEnableVertexAttribArray(ParticleShader::HeightmapSimulationShader::attrib_initial_size); + + glBindBuffer(GL_ARRAY_BUFFER, InitialValuesBuffer); + glVertexAttribPointer(ParticleShader::HeightmapSimulationShader::attrib_initial_position, 3, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)0); + glVertexAttribPointer(ParticleShader::HeightmapSimulationShader::attrib_initial_lifetime, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(3 * sizeof(float))); + glVertexAttribPointer(ParticleShader::HeightmapSimulationShader::attrib_initial_velocity, 4, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(4 * sizeof(float))); + glVertexAttribPointer(ParticleShader::HeightmapSimulationShader::attrib_initial_size, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(7 * sizeof(float))); +} + + +void ParticleSystemProxy::setEmitter(scene::IParticleEmitter* emitter) +{ + CParticleSystemSceneNode::setEmitter(emitter); + if (!emitter || !isGPUParticleType(emitter->getType())) + return; + has_height_map = false; + flip = false; + + count = emitter->getMaxParticlesPerSecond() * emitter->getMaxLifeTime() / 1000; + switch (emitter->getType()) + { + case scene::EPET_POINT: + generateParticlesFromPointEmitter(emitter); + break; + case scene::EPET_BOX: + generateParticlesFromBoxEmitter(static_cast(emitter)); + break; + case scene::EPET_SPHERE: + generateParticlesFromSphereEmitter(static_cast(emitter)); + break; + default: + assert(0 && "Wrong particle type"); + } + + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindVertexArray(0); + + texture = getTextureGLuint(getMaterial(0).getTexture(0)); +} + +void ParticleSystemProxy::simulateHeightmap() +{ + int timediff = int(GUIEngine::getLatestDt() * 1000.f); + int active_count = getEmitter()->getMaxLifeTime() * getEmitter()->getMaxParticlesPerSecond() / 1000; + core::matrix4 matrix = getAbsoluteTransformation(); + glUseProgram(ParticleShader::HeightmapSimulationShader::Program); + glEnable(GL_RASTERIZER_DISCARD); + + glUniform1i(ParticleShader::HeightmapSimulationShader::uniform_dt, timediff); + glUniform1i(ParticleShader::HeightmapSimulationShader::uniform_level, active_count); + glUniformMatrix4fv(ParticleShader::HeightmapSimulationShader::uniform_sourcematrix, 1, GL_FALSE, matrix.pointer()); + glUniform1f(ParticleShader::HeightmapSimulationShader::uniform_size_increase_factor, size_increase_factor); + glActiveTexture(GL_TEXTURE2); + glBindTexture(GL_TEXTURE_BUFFER, heightmaptexture); + glUniform1i(ParticleShader::HeightmapSimulationShader::uniform_heightmap, 2); + glUniform1f(ParticleShader::HeightmapSimulationShader::uniform_track_x, track_x); + glUniform1f(ParticleShader::HeightmapSimulationShader::uniform_track_z, track_z); + glUniform1f(ParticleShader::HeightmapSimulationShader::uniform_track_x_len, track_x_len); + glUniform1f(ParticleShader::HeightmapSimulationShader::uniform_track_z_len, track_z_len); + + glBindVertexArray(current_simulation_vao); + glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, tfb_buffers[1]); + + glBeginTransformFeedback(GL_POINTS); + glDrawArrays(GL_POINTS, 0, count); + glEndTransformFeedback(); + glBindVertexArray(0); + + glDisable(GL_RASTERIZER_DISCARD); + std::swap(tfb_buffers[0], tfb_buffers[1]); + std::swap(current_rendering_vao, non_current_rendering_vao); + std::swap(current_simulation_vao, non_current_simulation_vao); +} + +void ParticleSystemProxy::simulateNoHeightmap() +{ + int timediff = int(GUIEngine::getLatestDt() * 1000.f); + int active_count = getEmitter()->getMaxLifeTime() * getEmitter()->getMaxParticlesPerSecond() / 1000; + core::matrix4 matrix = getAbsoluteTransformation(); + glUseProgram(ParticleShader::SimpleSimulationShader::Program); + glEnable(GL_RASTERIZER_DISCARD); + + glUniform1i(ParticleShader::SimpleSimulationShader::uniform_dt, timediff); + glUniform1i(ParticleShader::SimpleSimulationShader::uniform_level, active_count); + glUniformMatrix4fv(ParticleShader::SimpleSimulationShader::uniform_sourcematrix, 1, GL_FALSE, matrix.pointer()); + glUniform1f(ParticleShader::SimpleSimulationShader::uniform_size_increase_factor, size_increase_factor); + + glBindVertexArray(current_simulation_vao); + glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, tfb_buffers[1]); + + glBeginTransformFeedback(GL_POINTS); + glDrawArrays(GL_POINTS, 0, count); + glEndTransformFeedback(); + glBindVertexArray(0); + + glDisable(GL_RASTERIZER_DISCARD); + std::swap(tfb_buffers[0], tfb_buffers[1]); + std::swap(current_rendering_vao, non_current_rendering_vao); + std::swap(current_simulation_vao, non_current_simulation_vao); +} + +void ParticleSystemProxy::simulate() +{ + if (has_height_map) + simulateHeightmap(); + else + simulateNoHeightmap(); +} + +void ParticleSystemProxy::drawFlip() +{ + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + glUseProgram(ParticleShader::FlipParticleRender::Program); + + float screen[2] = { + (float)UserConfigParams::m_width, + (float)UserConfigParams::m_height + }; + + setTexture(0, texture, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR); + setTexture(1, static_cast(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH))->DepthBufferTexture, GL_NEAREST, GL_NEAREST); + + ParticleShader::FlipParticleRender::setUniforms(irr_driver->getViewMatrix(), irr_driver->getProjMatrix(), irr_driver->getInvProjMatrix(), screen[0], screen[1], 0, 1); + + glBindVertexArray(current_rendering_vao); + glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, count); +} + +void ParticleSystemProxy::drawNotFlip() +{ + if (m_alpha_additive) + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + else + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glUseProgram(ParticleShader::SimpleParticleRender::Program); + + float screen[2] = { + (float)UserConfigParams::m_width, + (float)UserConfigParams::m_height + }; + + setTexture(0, texture, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR); + setTexture(1, static_cast(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH))->DepthBufferTexture, GL_NEAREST, GL_NEAREST); + + ParticleShader::SimpleParticleRender::setUniforms(irr_driver->getViewMatrix(), irr_driver->getProjMatrix(), + irr_driver->getInvProjMatrix(), screen[0], screen[1], 0, 1, this); + + glBindVertexArray(current_rendering_vao); + glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, count); +} + +void ParticleSystemProxy::draw() +{ + if (flip) + drawFlip(); + else + drawNotFlip(); +} + +void ParticleSystemProxy::generateVAOs() +{ + glGenVertexArrays(1, ¤t_rendering_vao); + glGenVertexArrays(1, &non_current_rendering_vao); + glGenVertexArrays(1, ¤t_simulation_vao); + glGenVertexArrays(1, &non_current_simulation_vao); + + glBindVertexArray(current_simulation_vao); + if (has_height_map) + HeightmapSimulationBind(tfb_buffers[0], initial_values_buffer); + else + SimpleSimulationBind(tfb_buffers[0], initial_values_buffer); + glBindVertexArray(non_current_simulation_vao); + if (has_height_map) + HeightmapSimulationBind(tfb_buffers[1], initial_values_buffer); + else + SimpleSimulationBind(tfb_buffers[1], initial_values_buffer); + + float *quaternions = new float[4 * count]; + glBindVertexArray(0); + if (flip) + { + for (unsigned i = 0; i < count; i++) + { + core::vector3df rotationdir(0., 1., 0.); + + quaternions[4 * i] = rotationdir.X; + quaternions[4 * i + 1] = rotationdir.Y; + quaternions[4 * i + 2] = rotationdir.Z; + quaternions[4 * i + 3] = 3.14f * 3.f * (2.f * os::Randomizer::frand() - 1.f); // 3 half rotation during lifetime at max + } + glGenBuffers(1, &quaternionsbuffer); + glBindBuffer(GL_ARRAY_BUFFER, quaternionsbuffer); + glBufferData(GL_ARRAY_BUFFER, 4 * count * sizeof(float), quaternions, GL_STATIC_DRAW); + } + + glBindVertexArray(current_rendering_vao); + if (flip) + FlipParticleVAOBind(tfb_buffers[0], quaternionsbuffer); + else + SimpleParticleVAOBind(tfb_buffers[0]); + + glBindVertexArray(non_current_rendering_vao); + if (flip) + FlipParticleVAOBind(tfb_buffers[1], quaternionsbuffer); + else + SimpleParticleVAOBind(tfb_buffers[1]); + glBindVertexArray(0); + + delete[] quaternions; +} + +void ParticleSystemProxy::render() { + if (!getEmitter() || !isGPUParticleType(getEmitter()->getType())) + { + CParticleSystemSceneNode::render(); + return; + } + if (!current_rendering_vao || !non_current_rendering_vao || !current_simulation_vao || !non_current_simulation_vao) + generateVAOs(); + simulate(); + draw(); +} + +void ParticleSystemProxy::OnRegisterSceneNode() +{ + doParticleSystem(os::Timer::getTime()); + + if (IsVisible && (Particles.size() != 0)) + { + SceneManager->registerNodeForRendering(this, scene::ESNRP_TRANSPARENT_EFFECT); + ISceneNode::OnRegisterSceneNode(); + } +} \ No newline at end of file diff --git a/src/graphics/gpuparticles.hpp b/src/graphics/gpuparticles.hpp index b1db6b927..d60724b71 100644 --- a/src/graphics/gpuparticles.hpp +++ b/src/graphics/gpuparticles.hpp @@ -1,70 +1,70 @@ -#ifndef GPUPARTICLES_H -#define GPUPARTICLES_H - -#include "graphics/glwrap.hpp" - -#include "../lib/irrlicht/source/Irrlicht/CParticleSystemSceneNode.h" -#include -#include - -namespace irr { namespace video{ class ITexture; } } - -class ParticleSystemProxy : public scene::CParticleSystemSceneNode -{ -protected: - GLuint tfb_buffers[2], initial_values_buffer, heighmapbuffer, heightmaptexture, quaternionsbuffer; - GLuint current_simulation_vao, non_current_simulation_vao; - GLuint current_rendering_vao, non_current_rendering_vao; - bool m_alpha_additive, has_height_map, flip; - float size_increase_factor, track_x, track_z, track_x_len, track_z_len; - float m_color_from[3]; - float m_color_to[3]; - - static GLuint quad_vertex_buffer; - - GLuint texture; - unsigned count; - static void SimpleParticleVAOBind(GLuint PositionBuffer); - static void FlipParticleVAOBind(GLuint PositionBuffer, GLuint QuaternionBuffer); - static void SimpleSimulationBind(GLuint PositionBuffer, GLuint InitialValuesBuffer); - static void HeightmapSimulationBind(GLuint PositionBuffer, GLuint InitialValuesBuffer); - - void generateVAOs(); - - void simulateHeightmap(); - void simulateNoHeightmap(); - void drawFlip(); - void drawNotFlip(); - virtual void simulate(); - virtual void draw(); - void generateParticlesFromPointEmitter(scene::IParticlePointEmitter *); - void generateParticlesFromBoxEmitter(scene::IParticleBoxEmitter *); - void generateParticlesFromSphereEmitter(scene::IParticleSphereEmitter *); -public: - static IParticleSystemSceneNode *addParticleNode( - bool withDefaultEmitter = true, ISceneNode* parent = 0, s32 id = -1, - const core::vector3df& position = core::vector3df(0, 0, 0), - const core::vector3df& rotation = core::vector3df(0, 0, 0), - const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); - - ParticleSystemProxy(bool createDefaultEmitter, - ISceneNode* parent, scene::ISceneManager* mgr, s32 id, - const core::vector3df& position, - const core::vector3df& rotation, - const core::vector3df& scale); - ~ParticleSystemProxy(); - - virtual void setEmitter(scene::IParticleEmitter* emitter); - virtual void render(); - virtual void OnRegisterSceneNode(); - void setAlphaAdditive(bool val) { m_alpha_additive = val; } - void setIncreaseFactor(float val) { size_increase_factor = val; } - void setColorFrom(float r, float g, float b) { m_color_from[0] = r; m_color_from[1] = g; m_color_from[2] = b; } - void setColorTo(float r, float g, float b) { m_color_to[0] = r; m_color_to[1] = g; m_color_to[2] = b; } - const float* getColorFrom() const { return m_color_from; } - const float* getColorTo() const { return m_color_to; } - void setHeightmap(const std::vector >&, float, float, float, float); - void setFlip(); -}; - -#endif // GPUPARTICLES_H +#ifndef GPUPARTICLES_H +#define GPUPARTICLES_H + +#include "graphics/glwrap.hpp" + +#include "../lib/irrlicht/source/Irrlicht/CParticleSystemSceneNode.h" +#include +#include + +namespace irr { namespace video{ class ITexture; } } + +class ParticleSystemProxy : public scene::CParticleSystemSceneNode +{ +protected: + GLuint tfb_buffers[2], initial_values_buffer, heighmapbuffer, heightmaptexture, quaternionsbuffer; + GLuint current_simulation_vao, non_current_simulation_vao; + GLuint current_rendering_vao, non_current_rendering_vao; + bool m_alpha_additive, has_height_map, flip; + float size_increase_factor, track_x, track_z, track_x_len, track_z_len; + float m_color_from[3]; + float m_color_to[3]; + + static GLuint quad_vertex_buffer; + + GLuint texture; + unsigned count; + static void SimpleParticleVAOBind(GLuint PositionBuffer); + static void FlipParticleVAOBind(GLuint PositionBuffer, GLuint QuaternionBuffer); + static void SimpleSimulationBind(GLuint PositionBuffer, GLuint InitialValuesBuffer); + static void HeightmapSimulationBind(GLuint PositionBuffer, GLuint InitialValuesBuffer); + + void generateVAOs(); + + void simulateHeightmap(); + void simulateNoHeightmap(); + void drawFlip(); + void drawNotFlip(); + virtual void simulate(); + virtual void draw(); + void generateParticlesFromPointEmitter(scene::IParticlePointEmitter *); + void generateParticlesFromBoxEmitter(scene::IParticleBoxEmitter *); + void generateParticlesFromSphereEmitter(scene::IParticleSphereEmitter *); +public: + static IParticleSystemSceneNode *addParticleNode( + bool withDefaultEmitter = true, ISceneNode* parent = 0, s32 id = -1, + const core::vector3df& position = core::vector3df(0, 0, 0), + const core::vector3df& rotation = core::vector3df(0, 0, 0), + const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)); + + ParticleSystemProxy(bool createDefaultEmitter, + ISceneNode* parent, scene::ISceneManager* mgr, s32 id, + const core::vector3df& position, + const core::vector3df& rotation, + const core::vector3df& scale); + ~ParticleSystemProxy(); + + virtual void setEmitter(scene::IParticleEmitter* emitter); + virtual void render(); + virtual void OnRegisterSceneNode(); + void setAlphaAdditive(bool val) { m_alpha_additive = val; } + void setIncreaseFactor(float val) { size_increase_factor = val; } + void setColorFrom(float r, float g, float b) { m_color_from[0] = r; m_color_from[1] = g; m_color_from[2] = b; } + void setColorTo(float r, float g, float b) { m_color_to[0] = r; m_color_to[1] = g; m_color_to[2] = b; } + const float* getColorFrom() const { return m_color_from; } + const float* getColorTo() const { return m_color_to; } + void setHeightmap(const std::vector >&, float, float, float, float); + void setFlip(); +}; + +#endif // GPUPARTICLES_H diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp index e9f723186..60cf5e9fb 100644 --- a/src/graphics/irr_driver.cpp +++ b/src/graphics/irr_driver.cpp @@ -155,7 +155,7 @@ STKRenderingPass IrrDriver::getPhase() const void IrrDriver::IncreaseObjectCount() { - object_count[m_phase]++; + object_count[m_phase]++; } core::array &IrrDriver::getMainSetup() @@ -424,10 +424,10 @@ void IrrDriver::initDevice() GLMajorVersion = 2; GLMinorVersion = 1; - glGetIntegerv(GL_MAJOR_VERSION, &GLMajorVersion); + glGetIntegerv(GL_MAJOR_VERSION, &GLMajorVersion); glGetIntegerv(GL_MINOR_VERSION, &GLMinorVersion); Log::info("IrrDriver", "OPENGL VERSION IS %d.%d", GLMajorVersion, GLMinorVersion); - m_glsl = (GLMajorVersion > 3 || (GLMajorVersion == 3 && GLMinorVersion >= 1)) && UserConfigParams::m_pixel_shaders; + m_glsl = (GLMajorVersion > 3 || (GLMajorVersion == 3 && GLMinorVersion >= 1)) && UserConfigParams::m_pixel_shaders; // This remaps the window, so it has to be done before the clear to avoid flicker m_device->setResizable(false); @@ -458,7 +458,7 @@ void IrrDriver::initDevice() m_mrt.push_back(m_rtts->getRTT(RTT_COLOR)); m_mrt.push_back(m_rtts->getRTT(RTT_NORMAL_AND_DEPTH)); - irr::video::COpenGLDriver* gl_driver = (irr::video::COpenGLDriver*)m_device->getVideoDriver(); + irr::video::COpenGLDriver* gl_driver = (irr::video::COpenGLDriver*)m_device->getVideoDriver(); gl_driver->extGlGenQueries(1, &m_lensflare_query); m_query_issued = false; @@ -595,7 +595,7 @@ core::position2di IrrDriver::getMouseLocation() bool IrrDriver::moveWindow(const int x, const int y) { #ifdef WIN32 - const video::SExposedVideoData& videoData = + const video::SExposedVideoData& videoData = m_video_driver->getExposedVideoData(); // this should work even if using DirectX in theory, // because the HWnd is always third pointer in the struct, @@ -964,17 +964,17 @@ scene::ISceneNode *IrrDriver::addBillboard(const core::dimension2d< f32 > size, video::ITexture *texture, scene::ISceneNode* parent, bool alphaTesting) { - scene::IBillboardSceneNode* node; - if (isGLSL()) - { - if (!parent) - parent = m_scene_manager->getRootSceneNode(); + scene::IBillboardSceneNode* node; + if (isGLSL()) + { + if (!parent) + parent = m_scene_manager->getRootSceneNode(); - node = new STKBillboard(parent, m_scene_manager, -1, vector3df(0., 0., 0.), size); - node->drop(); - } - else - node = m_scene_manager->addBillboardSceneNode(parent, size); + node = new STKBillboard(parent, m_scene_manager, -1, vector3df(0., 0., 0.), size); + node->drop(); + } + else + node = m_scene_manager->addBillboardSceneNode(parent, size); assert(node->getMaterialCount() > 0); node->setMaterialTexture(0, texture); if(alphaTesting) @@ -1150,7 +1150,7 @@ scene::ISceneNode *IrrDriver::addSkyDome(video::ITexture *texture, float texture_percent, float sphere_percent) { - Log::error("skybox", "Using deprecated SkyDome"); + Log::error("skybox", "Using deprecated SkyDome"); return m_scene_manager->addSkyDomeSceneNode(texture, hori_res, vert_res, texture_percent, sphere_percent); @@ -1171,7 +1171,7 @@ scene::ISceneNode *IrrDriver::addSkyBox(const std::vector &texture) { assert(texture.size() == 6); - SkyboxTextures = texture; + SkyboxTextures = texture; SkyboxCubeMap = 0; ConvolutedSkyboxCubeMap = 0; return m_scene_manager->addSkyBoxSceneNode(texture[0], texture[1], @@ -1181,7 +1181,7 @@ scene::ISceneNode *IrrDriver::addSkyBox(const std::vector void IrrDriver::suppressSkyBox() { - SkyboxTextures.clear(); + SkyboxTextures.clear(); glDeleteTextures(1, &SkyboxCubeMap); glDeleteTextures(1, &ConvolutedSkyboxCubeMap); SkyboxCubeMap = 0; @@ -1518,9 +1518,9 @@ void IrrDriver::displayFPS() { sprintf(buffer, "FPS: %i/%i/%i - Objects (P1:%d P2:%d T:%d) KTris - LightDst : ~%d", min, fps, max, object_count[SOLID_NORMAL_AND_DEPTH_PASS], object_count[SOLID_NORMAL_AND_DEPTH_PASS], object_count[TRANSPARENT_PASS], m_last_light_bucket_distance); - object_count[SOLID_NORMAL_AND_DEPTH_PASS] = 0; - object_count[SOLID_NORMAL_AND_DEPTH_PASS] = 0; - object_count[TRANSPARENT_PASS] = 0; + object_count[SOLID_NORMAL_AND_DEPTH_PASS] = 0; + object_count[SOLID_NORMAL_AND_DEPTH_PASS] = 0; + object_count[TRANSPARENT_PASS] = 0; } else { @@ -1531,7 +1531,7 @@ void IrrDriver::displayFPS() core::stringw fpsString = buffer; static video::SColor fpsColor = video::SColor(255, 0, 0, 0); - + font->draw( fpsString.c_str(), core::rect< s32 >(100,0,400,50), fpsColor, false ); } // updateFPS @@ -2017,7 +2017,7 @@ void IrrDriver::RTTProvider::setupRTTScene(PtrVector& mesh, m_rtt_main_node->getMaterial(n).SpecularColor.set(255,50,50,50); m_rtt_main_node->getMaterial(n).DiffuseColor.set(255,150,150,150); - m_rtt_main_node->getMaterial(n).setFlag(video::EMF_GOURAUD_SHADING , + m_rtt_main_node->getMaterial(n).setFlag(video::EMF_GOURAUD_SHADING , true); } @@ -2136,7 +2136,7 @@ void IrrDriver::applyObjectPassShader(scene::ISceneNode * const node, bool rimli // viamb = (dynamic_cast(node))->isReadOnlyMaterials(); // mesh = (dynamic_cast(node))->getMesh(); //} - + for (i = 0; i < mcount; i++) { video::SMaterial &nodemat = node->getMaterial(i); @@ -2216,7 +2216,7 @@ scene::ISceneNode *IrrDriver::addLight(const core::vector3df &pos, float energy, } else { - return m_scene_manager->addLightSceneNode(m_scene_manager->getRootSceneNode(), + return m_scene_manager->addLightSceneNode(m_scene_manager->getRootSceneNode(), pos, video::SColorf(1.0f, r, g, b)); } } diff --git a/src/graphics/irr_driver.hpp b/src/graphics/irr_driver.hpp index 5cd0a4d18..08620da7f 100644 --- a/src/graphics/irr_driver.hpp +++ b/src/graphics/irr_driver.hpp @@ -65,13 +65,13 @@ class ShadowImportance; enum STKRenderingPass { - SOLID_NORMAL_AND_DEPTH_PASS, - SOLID_LIT_PASS, - TRANSPARENT_PASS, - GLOW_PASS, - DISPLACEMENT_PASS, - SHADOW_PASS, - PASS_COUNT, + SOLID_NORMAL_AND_DEPTH_PASS, + SOLID_LIT_PASS, + TRANSPARENT_PASS, + GLOW_PASS, + DISPLACEMENT_PASS, + SHADOW_PASS, + PASS_COUNT, }; /** @@ -115,7 +115,7 @@ private: /** Matrixes used in several places stored here to avoid recomputation. */ core::matrix4 m_ViewMatrix, m_InvViewMatrix, m_ProjMatrix, m_InvProjMatrix, m_ProjViewMatrix, m_InvProjViewMatrix; - std::vector SkyboxTextures; + std::vector SkyboxTextures; float blueSHCoeff[9]; float greenSHCoeff[9]; @@ -183,9 +183,9 @@ private: bool m_shadowviz; bool m_lightviz; bool m_distortviz; - /** Performance stats */ + /** Performance stats */ unsigned m_last_light_bucket_distance; - unsigned object_count[PASS_COUNT]; + unsigned object_count[PASS_COUNT]; u32 m_renderpass; u32 m_lensflare_query; bool m_query_issued; @@ -208,7 +208,7 @@ private: std::vector m_background; - STKRenderingPass m_phase; + STKRenderingPass m_phase; #ifdef DEBUG /** Used to visualise skeletons. */ @@ -244,13 +244,13 @@ public: void reset(); void generateSkyboxCubemap(); void renderSkybox(); - void setPhase(STKRenderingPass); - STKRenderingPass getPhase() const; + void setPhase(STKRenderingPass); + STKRenderingPass getPhase() const; const std::vector &getShadowViewProj() const { return sun_ortho_matrix; } - void IncreaseObjectCount(); + void IncreaseObjectCount(); core::array &getMainSetup(); void updateConfigIfRelevant(); void setAllMaterialFlags(scene::IMesh *mesh) const; @@ -261,7 +261,7 @@ public: void displayFPS(); bool OnEvent(const irr::SEvent &event); void setAmbientLight(const video::SColor &light); - video::ITexture *getTexture(FileManager::AssetType type, + video::ITexture *getTexture(FileManager::AssetType type, const std::string &filename, bool is_premul=false, bool is_prediv=false, @@ -297,7 +297,7 @@ public: int vert_res, float texture_percent, float sphere_percent); scene::ISceneNode *addSkyBox(const std::vector &texture_names); - void suppressSkyBox(); + void suppressSkyBox(); void removeNode(scene::ISceneNode *node); void removeMeshFromCache(scene::IMesh *mesh); void removeTexture(video::ITexture *t); @@ -369,7 +369,7 @@ public: char *detail=NULL) { if(!detail) - return getTexture(filename, std::string(error_message), + return getTexture(filename, std::string(error_message), std::string("")); return getTexture(filename, std::string(error_message), @@ -384,7 +384,7 @@ public: */ const std::string &getTextureErrorMessage() { - return m_texture_error_message; + return m_texture_error_message; } // getTextureErrorMessage // ------------------------------------------------------------------------ @@ -420,7 +420,7 @@ public: // ----------------------------------------------------------------------- inline void updateShaders() {m_shaders->loadShaders();} // ------------------------------------------------------------------------ - inline video::IShaderConstantSetCallBack* getCallback(const ShaderType num) + inline video::IShaderConstantSetCallBack* getCallback(const ShaderType num) { return (m_shaders == NULL ? NULL : m_shaders->m_callbacks[num]); } diff --git a/src/graphics/large_mesh_buffer.hpp b/src/graphics/large_mesh_buffer.hpp index 034ef7b4e..84c77fd17 100644 --- a/src/graphics/large_mesh_buffer.hpp +++ b/src/graphics/large_mesh_buffer.hpp @@ -13,43 +13,43 @@ namespace irr { namespace scene { - //! A SMeshBuffer with 32-bit indices - class LargeMeshBuffer : public SMeshBuffer - { - public: - //! Get type of index data which is stored in this meshbuffer. - /** \return Index type of this buffer. */ - virtual video::E_INDEX_TYPE getIndexType() const - { - return video::EIT_32BIT; - } + //! A SMeshBuffer with 32-bit indices + class LargeMeshBuffer : public SMeshBuffer + { + public: + //! Get type of index data which is stored in this meshbuffer. + /** \return Index type of this buffer. */ + virtual video::E_INDEX_TYPE getIndexType() const + { + return video::EIT_32BIT; + } - //! Get pointer to indices - /** \return Pointer to indices. */ - virtual const u16* getIndices() const - { - return (u16 *) Indices.const_pointer(); - } + //! Get pointer to indices + /** \return Pointer to indices. */ + virtual const u16* getIndices() const + { + return (u16 *) Indices.const_pointer(); + } - //! Get pointer to indices - /** \return Pointer to indices. */ - virtual u16* getIndices() - { - return (u16 *) Indices.pointer(); - } + //! Get pointer to indices + /** \return Pointer to indices. */ + virtual u16* getIndices() + { + return (u16 *) Indices.pointer(); + } - //! Get number of indices - /** \return Number of indices. */ - virtual u32 getIndexCount() const - { - return Indices.size(); - } + //! Get number of indices + /** \return Number of indices. */ + virtual u32 getIndexCount() const + { + return Indices.size(); + } - //! Indices into the vertices of this buffer. - core::array Indices; - }; + //! Indices into the vertices of this buffer. + core::array Indices; + }; } // end namespace scene } // end namespace irr diff --git a/src/graphics/material.cpp b/src/graphics/material.cpp index 2a7206d73..0fde95157 100644 --- a/src/graphics/material.cpp +++ b/src/graphics/material.cpp @@ -86,7 +86,7 @@ Material::Material(const XMLNode *node, int index, bool deprecated) else if (s=="" || s=="none") m_adjust_image = ADJ_NONE; else - Log::warn("material", + Log::warn("material", "Incorrect adjust-image specification: '%s' - ignored.", s.c_str()); node->get("alpha", &m_alpha_blending ); @@ -121,7 +121,7 @@ Material::Material(const XMLNode *node, int index, bool deprecated) } else if (creaction.size() > 0) { - Log::warn("Material","Unknown collision reaction '%s'", + Log::warn("Material","Unknown collision reaction '%s'", creaction.c_str()); } @@ -239,7 +239,7 @@ Material::Material(const XMLNode *node, int index, bool deprecated) } else if (s != "") { - Log::warn("material", + Log::warn("material", "Invalid graphical effect specification: '%s' - ignored.", s.c_str()); } @@ -261,7 +261,7 @@ Material::Material(const XMLNode *node, int index, bool deprecated) } else { - Log::warn("material", + Log::warn("material", "Could not find normal map image in materials.xml"); } @@ -554,7 +554,7 @@ void Material::initParticlesEffect(const XMLNode *node) try { particles = pkm->getParticles(base.c_str()); - + if (particles == NULL) { Log::warn("Material::initParticlesEffect", @@ -650,22 +650,22 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m // materials.xml, if you want to set flags for all surfaces, see // 'MaterialManager::setAllMaterialFlags' - if (m_deprecated || - (m->getTexture(0) != NULL && + if (m_deprecated || + (m->getTexture(0) != NULL && ((core::stringc)m->getTexture(0)->getName()).find("deprecated") != -1)) { - Log::warn("material", "Track uses deprecated texture '%s'", + Log::warn("material", "Track uses deprecated texture '%s'", m_texname.c_str()); } int modes = 0; - if (!m_lighting && irr_driver->isGLSL() && !m_alpha_blending && !m_add) - { - m->MaterialType = irr_driver->getShader(ES_OBJECT_UNLIT); - modes++; - } + if (!m_lighting && irr_driver->isGLSL() && !m_alpha_blending && !m_add) + { + m->MaterialType = irr_driver->getShader(ES_OBJECT_UNLIT); + modes++; + } if (m_alpha_testing) { @@ -765,8 +765,8 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m if (irr_driver->isGLSL()) { - if (mb->getVertexType() != video::EVT_TANGENTS) - Log::error("material", "Requiring normal map without tangent enabled mesh"); + if (mb->getVertexType() != video::EVT_TANGENTS) + Log::error("material", "Requiring normal map without tangent enabled mesh"); ITexture* tex = irr_driver->getTexture(m_normal_map_tex); if (m_is_heightmap) { @@ -810,13 +810,13 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m m->SpecularColor.set(0,0,0,0); modes++; } - + if(m_graphical_effect == GE_SKYBOX && irr_driver->isGLSL()) { ITexture* tex = irr_driver->getTexture("cloud_mask.png"); m->setTexture(1, tex); - + m->MaterialType = irr_driver->getShader(ES_SKYBOX); } if (m_graphical_effect == GE_SPLATTING) diff --git a/src/graphics/material.hpp b/src/graphics/material.hpp index 7d3e86373..be236b452 100644 --- a/src/graphics/material.hpp +++ b/src/graphics/material.hpp @@ -107,7 +107,7 @@ private: /** If a kart is rescued when driving on this surface. */ bool m_drive_reset; - /** True if this is a texture that will start the jump animatoin when + /** True if this is a texture that will start the jump animatoin when * leaving it and being in the air. */ bool m_is_jump_texture; @@ -179,8 +179,8 @@ private: float m_slowdown_time; /** Maximum speed at which no more slow down occurs. */ float m_max_speed_fraction; - /** Minimum speed on this terrain. This is used for zippers on a ramp to - * guarantee the right jump distance. A negative value indicates no + /** Minimum speed on this terrain. This is used for zippers on a ramp to + * guarantee the right jump distance. A negative value indicates no * minimum speed. */ float m_zipper_min_speed; /** The minimum speed at which a special sfx is started to be played. */ @@ -346,9 +346,9 @@ public: void onMadeVisible(scene::IMeshBuffer* who); void onHidden(scene::IMeshBuffer* who); void isInitiallyHidden(scene::IMeshBuffer* who); - /** For particle system : specify if the particle should be additively blended - */ - bool isAlphaAdditive() const { return !m_alpha_blending; } + /** For particle system : specify if the particle should be additively blended + */ + bool isAlphaAdditive() const { return !m_alpha_blending; } } ; diff --git a/src/graphics/material_manager.cpp b/src/graphics/material_manager.cpp index 85a849532..d5612854c 100644 --- a/src/graphics/material_manager.cpp +++ b/src/graphics/material_manager.cpp @@ -183,7 +183,7 @@ void MaterialManager::loadMaterial() // Use temp material for reading, but then set the shared // material index later, so that these materials are not popped // - addSharedMaterial(file_manager->getAssetChecked(FileManager::TEXTURE, + addSharedMaterial(file_manager->getAssetChecked(FileManager::TEXTURE, "materials.xml", true)); std::string deprecated = file_manager->getAssetChecked(FileManager::TEXTURE, "deprecated/materials.xml"); @@ -298,12 +298,12 @@ Material *MaterialManager::getMaterial(const std::string& fname, } std::string basename; - + if (strip_path) basename = StringUtils::getBasename(fname); else basename = fname; - + // Search backward so that temporary (track) textures are found first for(int i = (int)m_materials.size()-1; i>=0; i-- ) { diff --git a/src/graphics/particle_emitter.cpp b/src/graphics/particle_emitter.cpp index b769bb1db..ab65e2994 100644 --- a/src/graphics/particle_emitter.cpp +++ b/src/graphics/particle_emitter.cpp @@ -390,21 +390,21 @@ void ParticleEmitter::setCreationRateAbsolute(float f) if (f <= 0.0f && m_node->getEmitter()) { - m_node->clearParticles(); + m_node->clearParticles(); } else if (m_node->getEmitter() == NULL) { m_node->setEmitter(m_emitter); } #endif -/* if (f <= 0.0f) - { - m_node->setVisible(false); - } - else - { - m_node->setVisible(true); - }*/ +/* if (f <= 0.0f) + { + m_node->setVisible(false); + } + else + { + m_node->setVisible(true); + }*/ } // setCreationRateAbsolute //----------------------------------------------------------------------------- @@ -451,7 +451,7 @@ void ParticleEmitter::setParticleType(const ParticleKind* type) m_node = ParticleSystemProxy::addParticleNode(m_is_glsl); else m_node = irr_driver->addParticleNode(); - + if (m_is_glsl) static_cast(m_node)->setAlphaAdditive(type->getMaterial()->isAlphaAdditive()); } @@ -520,7 +520,7 @@ void ParticleEmitter::setParticleType(const ParticleKind* type) case EMITTER_POINT: { m_emitter = m_node->createPointEmitter(velocity, - type->getMinRate(), type->getMaxRate(), + type->getMinRate(), type->getMaxRate(), type->getMinColor(), type->getMinColor(), lifeTimeMin, lifeTimeMax, m_particle_type->getAngleSpread() /* angle */ @@ -680,7 +680,7 @@ void ParticleEmitter::setParticleType(const ParticleKind* type) if (flips) { if (m_is_glsl) - static_cast(m_node)->setFlip(); + static_cast(m_node)->setFlip(); } } } // setParticleType @@ -689,7 +689,7 @@ void ParticleEmitter::setParticleType(const ParticleKind* type) void ParticleEmitter::addHeightMapAffector(Track* t) { - + if (m_is_glsl) { const Vec3* aabb_min; diff --git a/src/graphics/particle_kind.cpp b/src/graphics/particle_kind.cpp index 161baee74..e23b4e92e 100644 --- a/src/graphics/particle_kind.cpp +++ b/src/graphics/particle_kind.cpp @@ -95,7 +95,7 @@ ParticleKind::ParticleKind(const std::string file) : m_min_start_color(255,255,2 else if (emitterShape == "sphere") { m_shape = EMITTER_SPHERE; - + xml->get("radius", &m_sphere_radius); } else @@ -169,7 +169,7 @@ ParticleKind::ParticleKind(const std::string file) : m_min_start_color(255,255,2 bool has_y = size->get("y-increase-factor", &m_scale_affector_factor_y) == 1; m_has_scale_affector = (has_x || has_y); } - + else { m_has_scale_affector = false; diff --git a/src/graphics/post_processing.cpp b/src/graphics/post_processing.cpp index 4a2aa1216..b10dad033 100644 --- a/src/graphics/post_processing.cpp +++ b/src/graphics/post_processing.cpp @@ -58,11 +58,11 @@ PostProcessing::PostProcessing(IVideoDriver* video_driver) io::IReadFile *areamap = irr_driver->getDevice()->getFileSystem()-> createMemoryReadFile((void *) AreaMap33, sizeof(AreaMap33), "AreaMap33", false); - if (!areamap) - { - Log::fatal("postprocessing", "Failed to load the areamap"); - return; - } + if (!areamap) + { + Log::fatal("postprocessing", "Failed to load the areamap"); + return; + } m_areamap = irr_driver->getVideoDriver()->getTexture(areamap); areamap->drop(); @@ -207,77 +207,77 @@ void PostProcessing::update(float dt) static void renderBloom(ITexture *in) { - const float threshold = World::getWorld()->getTrack()->getBloomThreshold(); - glUseProgram(FullScreenShader::BloomShader::Program); - glBindVertexArray(FullScreenShader::BloomShader::vao); - glUniform1f(FullScreenShader::BloomShader::uniform_low, threshold); + const float threshold = World::getWorld()->getTrack()->getBloomThreshold(); + glUseProgram(FullScreenShader::BloomShader::Program); + glBindVertexArray(FullScreenShader::BloomShader::vao); + glUniform1f(FullScreenShader::BloomShader::uniform_low, threshold); - glActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, getTextureGLuint(in)); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glUniform1i(FullScreenShader::BloomShader::uniform_texture, 0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glUniform1i(FullScreenShader::BloomShader::uniform_texture, 0); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - glBindVertexArray(0); - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + glBindVertexArray(0); + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); } static void renderBloomBlend(ITexture *in) { - glEnable(GL_BLEND); - glBlendEquation(GL_FUNC_ADD); - glBlendFunc(GL_ONE, GL_ONE); - glDisable(GL_DEPTH_TEST); + glEnable(GL_BLEND); + glBlendEquation(GL_FUNC_ADD); + glBlendFunc(GL_ONE, GL_ONE); + glDisable(GL_DEPTH_TEST); - glUseProgram(FullScreenShader::BloomBlendShader::Program); - glBindVertexArray(FullScreenShader::BloomBlendShader::vao); + glUseProgram(FullScreenShader::BloomBlendShader::Program); + glBindVertexArray(FullScreenShader::BloomBlendShader::vao); - glActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, getTextureGLuint(in)); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glUniform1i(FullScreenShader::BloomBlendShader::uniform_texture, 0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glUniform1i(FullScreenShader::BloomBlendShader::uniform_texture, 0); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - glBindVertexArray(0); - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glEnable(GL_DEPTH_TEST); - glDisable(GL_BLEND); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + glBindVertexArray(0); + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + glEnable(GL_DEPTH_TEST); + glDisable(GL_BLEND); } static void renderColorLevel(ITexture *in) { - core::vector3df m_inlevel = World::getWorld()->getTrack()->getColorLevelIn(); - core::vector2df m_outlevel = World::getWorld()->getTrack()->getColorLevelOut(); + core::vector3df m_inlevel = World::getWorld()->getTrack()->getColorLevelIn(); + core::vector2df m_outlevel = World::getWorld()->getTrack()->getColorLevelOut(); - glDisable(GL_BLEND); - glDisable(GL_DEPTH_TEST); + glDisable(GL_BLEND); + glDisable(GL_DEPTH_TEST); - glUseProgram(FullScreenShader::ColorLevelShader::Program); - glBindVertexArray(FullScreenShader::ColorLevelShader::vao); - glUniform3f(FullScreenShader::ColorLevelShader::uniform_inlevel, m_inlevel.X, m_inlevel.Y, m_inlevel.Z); - glUniform2f(FullScreenShader::ColorLevelShader::uniform_outlevel, m_outlevel.X, m_outlevel.Y); + glUseProgram(FullScreenShader::ColorLevelShader::Program); + glBindVertexArray(FullScreenShader::ColorLevelShader::vao); + glUniform3f(FullScreenShader::ColorLevelShader::uniform_inlevel, m_inlevel.X, m_inlevel.Y, m_inlevel.Z); + glUniform2f(FullScreenShader::ColorLevelShader::uniform_outlevel, m_outlevel.X, m_outlevel.Y); - glActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, getTextureGLuint(in)); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, getDepthTexture(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH))); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glUniform1i(FullScreenShader::ColorLevelShader::uniform_tex, 0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glUniform1i(FullScreenShader::ColorLevelShader::uniform_tex, 0); glUniform1i(FullScreenShader::ColorLevelShader::uniform_dtex, 1); glUniformMatrix4fv(FullScreenShader::ColorLevelShader::uniform_invprojm, 1, GL_FALSE, irr_driver->getInvProjMatrix().pointer()); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - glBindVertexArray(0); - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glEnable(GL_DEPTH_TEST); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + glBindVertexArray(0); + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + glEnable(GL_DEPTH_TEST); } void PostProcessing::renderDiffuseEnvMap(const float *bSHCoeff, const float *gSHCoeff, const float *rSHCoeff) @@ -349,103 +349,103 @@ void PostProcessing::renderShadowedSunlight(const std::vector &su void PostProcessing::renderGaussian3Blur(video::ITexture *in, video::ITexture *temprtt, float inv_width, float inv_height) { - glDisable(GL_BLEND); - glDisable(GL_DEPTH_TEST); - { - irr_driver->getVideoDriver()->setRenderTarget(temprtt, false, false); - glUseProgram(FullScreenShader::Gaussian3VBlurShader::Program); - glBindVertexArray(FullScreenShader::Gaussian3VBlurShader::vao); + glDisable(GL_BLEND); + glDisable(GL_DEPTH_TEST); + { + irr_driver->getVideoDriver()->setRenderTarget(temprtt, false, false); + glUseProgram(FullScreenShader::Gaussian3VBlurShader::Program); + glBindVertexArray(FullScreenShader::Gaussian3VBlurShader::vao); - glUniform2f(FullScreenShader::Gaussian3VBlurShader::uniform_pixel, inv_width, inv_height); + glUniform2f(FullScreenShader::Gaussian3VBlurShader::uniform_pixel, inv_width, inv_height); - glActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, getTextureGLuint(in)); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glUniform1i(FullScreenShader::Gaussian3VBlurShader::uniform_tex, 0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glUniform1i(FullScreenShader::Gaussian3VBlurShader::uniform_tex, 0); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - } - { - irr_driver->getVideoDriver()->setRenderTarget(in, false, false); - glUseProgram(FullScreenShader::Gaussian3HBlurShader::Program); - glBindVertexArray(FullScreenShader::Gaussian3HBlurShader::vao); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + } + { + irr_driver->getVideoDriver()->setRenderTarget(in, false, false); + glUseProgram(FullScreenShader::Gaussian3HBlurShader::Program); + glBindVertexArray(FullScreenShader::Gaussian3HBlurShader::vao); - glUniform2f(FullScreenShader::Gaussian3HBlurShader::uniform_pixel, inv_width, inv_height); + glUniform2f(FullScreenShader::Gaussian3HBlurShader::uniform_pixel, inv_width, inv_height); - glActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, getTextureGLuint(temprtt)); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glUniform1i(FullScreenShader::Gaussian3HBlurShader::uniform_tex, 0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glUniform1i(FullScreenShader::Gaussian3HBlurShader::uniform_tex, 0); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - } - glBindVertexArray(0); - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glEnable(GL_DEPTH_TEST); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + } + glBindVertexArray(0); + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + glEnable(GL_DEPTH_TEST); } void PostProcessing::renderGaussian6Blur(video::ITexture *in, video::ITexture *temprtt, float inv_width, float inv_height) { - glDisable(GL_BLEND); - glDisable(GL_DEPTH_TEST); - { - irr_driver->getVideoDriver()->setRenderTarget(temprtt, false, false); - glUseProgram(FullScreenShader::Gaussian6VBlurShader::Program); - glBindVertexArray(FullScreenShader::Gaussian6VBlurShader::vao); + glDisable(GL_BLEND); + glDisable(GL_DEPTH_TEST); + { + irr_driver->getVideoDriver()->setRenderTarget(temprtt, false, false); + glUseProgram(FullScreenShader::Gaussian6VBlurShader::Program); + glBindVertexArray(FullScreenShader::Gaussian6VBlurShader::vao); - glUniform2f(FullScreenShader::Gaussian6VBlurShader::uniform_pixel, inv_width, inv_height); + glUniform2f(FullScreenShader::Gaussian6VBlurShader::uniform_pixel, inv_width, inv_height); - glActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, getTextureGLuint(in)); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glUniform1i(FullScreenShader::Gaussian6VBlurShader::uniform_tex, 0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glUniform1i(FullScreenShader::Gaussian6VBlurShader::uniform_tex, 0); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - } - { - irr_driver->getVideoDriver()->setRenderTarget(in, false, false); - glUseProgram(FullScreenShader::Gaussian6HBlurShader::Program); - glBindVertexArray(FullScreenShader::Gaussian6HBlurShader::vao); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + } + { + irr_driver->getVideoDriver()->setRenderTarget(in, false, false); + glUseProgram(FullScreenShader::Gaussian6HBlurShader::Program); + glBindVertexArray(FullScreenShader::Gaussian6HBlurShader::vao); - glUniform2f(FullScreenShader::Gaussian6HBlurShader::uniform_pixel, inv_width, inv_height); + glUniform2f(FullScreenShader::Gaussian6HBlurShader::uniform_pixel, inv_width, inv_height); - glActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, getTextureGLuint(temprtt)); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glUniform1i(FullScreenShader::Gaussian6HBlurShader::uniform_tex, 0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glUniform1i(FullScreenShader::Gaussian6HBlurShader::uniform_tex, 0); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - } - glBindVertexArray(0); - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glEnable(GL_DEPTH_TEST); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + } + glBindVertexArray(0); + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + glEnable(GL_DEPTH_TEST); } void PostProcessing::renderPassThrough(ITexture *tex) { - glDisable(GL_DEPTH_TEST); + glDisable(GL_DEPTH_TEST); - glUseProgram(FullScreenShader::PassThroughShader::Program); - glBindVertexArray(FullScreenShader::PassThroughShader::vao); + glUseProgram(FullScreenShader::PassThroughShader::Program); + glBindVertexArray(FullScreenShader::PassThroughShader::vao); - glActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, getTextureGLuint(tex)); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glUniform1i(FullScreenShader::PassThroughShader::uniform_texture, 0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glUniform1i(FullScreenShader::PassThroughShader::uniform_texture, 0); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - glBindVertexArray(0); - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glEnable(GL_DEPTH_TEST); - glDisable(GL_BLEND); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + glBindVertexArray(0); + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + glEnable(GL_DEPTH_TEST); + glDisable(GL_BLEND); } void PostProcessing::renderPassThrough(GLuint tex) @@ -471,85 +471,85 @@ void PostProcessing::renderPassThrough(GLuint tex) void PostProcessing::renderGlow(ITexture *tex) { - glDisable(GL_DEPTH_TEST); + glDisable(GL_DEPTH_TEST); - glUseProgram(FullScreenShader::GlowShader::Program); - glBindVertexArray(FullScreenShader::GlowShader::vao); + glUseProgram(FullScreenShader::GlowShader::Program); + glBindVertexArray(FullScreenShader::GlowShader::vao); - glActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, getTextureGLuint(tex)); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glUniform1i(FullScreenShader::GlowShader::uniform_tex, 0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glUniform1i(FullScreenShader::GlowShader::uniform_tex, 0); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - glBindVertexArray(0); - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glEnable(GL_DEPTH_TEST); - glDisable(GL_BLEND); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + glBindVertexArray(0); + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + glEnable(GL_DEPTH_TEST); + glDisable(GL_BLEND); } ITexture *noise_tex = 0; void PostProcessing::renderSSAO(const core::matrix4 &invprojm, const core::matrix4 &projm) { - glDisable(GL_DEPTH_TEST); - glDisable(GL_BLEND); - glDisable(GL_ALPHA_TEST); + glDisable(GL_DEPTH_TEST); + glDisable(GL_BLEND); + glDisable(GL_ALPHA_TEST); - if (!noise_tex) - noise_tex = irr_driver->getTexture(file_manager->getAsset("textures/noise.png").c_str()); + if (!noise_tex) + noise_tex = irr_driver->getTexture(file_manager->getAsset("textures/noise.png").c_str()); - glUseProgram(FullScreenShader::SSAOShader::Program); - glBindVertexArray(FullScreenShader::SSAOShader::vao); + glUseProgram(FullScreenShader::SSAOShader::Program); + glBindVertexArray(FullScreenShader::SSAOShader::vao); setTexture(0, getTextureGLuint(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH)), GL_NEAREST, GL_NEAREST); setTexture(1, getDepthTexture(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH)), GL_LINEAR, GL_LINEAR); setTexture(2, getTextureGLuint(noise_tex), GL_NEAREST, GL_NEAREST); - FullScreenShader::SSAOShader::setUniforms(projm, invprojm, 0, 1, 2); + FullScreenShader::SSAOShader::setUniforms(projm, invprojm, 0, 1, 2); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - glBindVertexArray(0); - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glEnable(GL_DEPTH_TEST); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + glBindVertexArray(0); + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + glEnable(GL_DEPTH_TEST); } void PostProcessing::renderFog(const core::matrix4 &ipvmat) { - irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_COLOR), false, false); - const Track * const track = World::getWorld()->getTrack(); + irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_COLOR), false, false); + const Track * const track = World::getWorld()->getTrack(); - // This function is only called once per frame - thus no need for setters. - const float fogmax = track->getFogMax(); - const float startH = track->getFogStartHeight(); - const float endH = track->getFogEndHeight(); - const float start = track->getFogStart(); - const float end = track->getFogEnd(); - const SColor tmpcol = track->getFogColor(); + // This function is only called once per frame - thus no need for setters. + const float fogmax = track->getFogMax(); + const float startH = track->getFogStartHeight(); + const float endH = track->getFogEndHeight(); + const float start = track->getFogStart(); + const float end = track->getFogEnd(); + const SColor tmpcol = track->getFogColor(); - core::vector3df col( tmpcol.getRed() / 255.0f, - tmpcol.getGreen() / 255.0f, - tmpcol.getBlue() / 255.0f ); + core::vector3df col( tmpcol.getRed() / 255.0f, + tmpcol.getGreen() / 255.0f, + tmpcol.getBlue() / 255.0f ); - glDisable(GL_DEPTH_TEST); - glEnable(GL_BLEND); - glBlendEquation(GL_FUNC_ADD); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glDisable(GL_DEPTH_TEST); + glEnable(GL_BLEND); + glBlendEquation(GL_FUNC_ADD); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glUseProgram(FullScreenShader::FogShader::Program); - glBindVertexArray(FullScreenShader::FogShader::vao); + glUseProgram(FullScreenShader::FogShader::Program); + glBindVertexArray(FullScreenShader::FogShader::vao); setTexture(0, getDepthTexture(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH)), GL_NEAREST, GL_NEAREST); - FullScreenShader::FogShader::setUniforms(ipvmat, fogmax, startH, endH, start, end, col, 0); + FullScreenShader::FogShader::setUniforms(ipvmat, fogmax, startH, endH, start, end, col, 0); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - glBindVertexArray(0); - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glEnable(GL_DEPTH_TEST); - glDisable(GL_BLEND); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + glBindVertexArray(0); + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + glEnable(GL_DEPTH_TEST); + glDisable(GL_BLEND); } void PostProcessing::renderMotionBlur(unsigned cam, ITexture *in, ITexture *out) @@ -647,24 +647,24 @@ void PostProcessing::render() mocb->setCurrentCamera(cam); ITexture *in = irr_driver->getRTT(RTT_COLOR); ITexture *out = irr_driver->getRTT(RTT_TMP1); - // Each effect uses these as named, and sets them up for the next effect. - // This allows chaining effects where some may be disabled. + // Each effect uses these as named, and sets them up for the next effect. + // This allows chaining effects where some may be disabled. - // As the original color shouldn't be touched, the first effect can't be disabled. + // As the original color shouldn't be touched, the first effect can't be disabled. PROFILER_PUSH_CPU_MARKER("- Bloom", 0xFF, 0x00, 0x00); if (1) // bloom { - // Blit the base to tmp1 - drv->setRenderTarget(out, true, false); - renderPassThrough(in); + // Blit the base to tmp1 + drv->setRenderTarget(out, true, false); + renderPassThrough(in); const bool globalbloom = World::getWorld()->getTrack()->getBloom(); if (globalbloom) { - drv->setRenderTarget(irr_driver->getRTT(RTT_TMP3), true, false); - renderBloom(in); + drv->setRenderTarget(irr_driver->getRTT(RTT_TMP3), true, false); + renderBloom(in); } @@ -681,23 +681,23 @@ void PostProcessing::render() // To half drv->setRenderTarget(irr_driver->getRTT(RTT_HALF1), true, false); - renderPassThrough(irr_driver->getRTT(RTT_TMP3)); + renderPassThrough(irr_driver->getRTT(RTT_TMP3)); // To quarter - drv->setRenderTarget(irr_driver->getRTT(RTT_QUARTER1), true, false); - renderPassThrough(irr_driver->getRTT(RTT_HALF1)); - + drv->setRenderTarget(irr_driver->getRTT(RTT_QUARTER1), true, false); + renderPassThrough(irr_driver->getRTT(RTT_HALF1)); + // To eighth - drv->setRenderTarget(irr_driver->getRTT(RTT_EIGHTH1), true, false); - renderPassThrough(irr_driver->getRTT(RTT_QUARTER1)); + drv->setRenderTarget(irr_driver->getRTT(RTT_EIGHTH1), true, false); + renderPassThrough(irr_driver->getRTT(RTT_QUARTER1)); // Blur it for distribution. - renderGaussian6Blur(irr_driver->getRTT(RTT_EIGHTH1), irr_driver->getRTT(RTT_EIGHTH2), 8.f / UserConfigParams::m_width, 8.f / UserConfigParams::m_height); + renderGaussian6Blur(irr_driver->getRTT(RTT_EIGHTH1), irr_driver->getRTT(RTT_EIGHTH2), 8.f / UserConfigParams::m_width, 8.f / UserConfigParams::m_height); // Additively blend on top of tmp1 - drv->setRenderTarget(out, false, false); - renderBloomBlend(irr_driver->getRTT(RTT_EIGHTH1)); + drv->setRenderTarget(out, false, false); + renderBloomBlend(irr_driver->getRTT(RTT_EIGHTH1)); } // end if bloom in = irr_driver->getRTT(RTT_TMP1); @@ -735,7 +735,7 @@ void PostProcessing::render() // Blur - renderGaussian3Blur(irr_driver->getRTT(RTT_QUARTER1), + renderGaussian3Blur(irr_driver->getRTT(RTT_QUARTER1), irr_driver->getRTT(RTT_QUARTER2), 4.f / UserConfigParams::m_width, 4.f / UserConfigParams::m_height); @@ -853,14 +853,14 @@ void PostProcessing::render() } // Final blit - // TODO : Use glBlitFramebuffer - drv->setRenderTarget(ERT_FRAME_BUFFER, false, false); + // TODO : Use glBlitFramebuffer + drv->setRenderTarget(ERT_FRAME_BUFFER, false, false); if (irr_driver->getNormals()) - renderPassThrough(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH)); + renderPassThrough(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH)); else if (irr_driver->getSSAOViz()) - renderPassThrough(irr_driver->getRTT(RTT_SSAO)); + renderPassThrough(irr_driver->getRTT(RTT_SSAO)); else - renderColorLevel(in); + renderColorLevel(in); } } // render diff --git a/src/graphics/post_processing.hpp b/src/graphics/post_processing.hpp index e64598864..bac7bdb5c 100644 --- a/src/graphics/post_processing.hpp +++ b/src/graphics/post_processing.hpp @@ -72,24 +72,24 @@ public: void begin(); void update(float dt); - /** Generate diffuse and specular map */ - void renderSunlight(); + /** Generate diffuse and specular map */ + void renderSunlight(); void renderShadowedSunlight(const std::vector &sun_ortho_matrix, unsigned depthtex); - void renderFog(const core::matrix4 &ipvmat); - void renderSSAO(const core::matrix4 &invprojm, const core::matrix4 &projm); + void renderFog(const core::matrix4 &ipvmat); + void renderSSAO(const core::matrix4 &invprojm, const core::matrix4 &projm); void renderDiffuseEnvMap(const float *bSHCoeff, const float *gSHCoeff, const float *rSHCoeff); - /** Blur the in texture */ - void renderGaussian3Blur(video::ITexture *in, video::ITexture *temprtt, float inv_width, float inv_height); - void renderGaussian6Blur(video::ITexture *in, video::ITexture *temprtt, float inv_width, float inv_height); + /** Blur the in texture */ + void renderGaussian3Blur(video::ITexture *in, video::ITexture *temprtt, float inv_width, float inv_height); + void renderGaussian6Blur(video::ITexture *in, video::ITexture *temprtt, float inv_width, float inv_height); - /** Render tex. Used for blit/texture resize */ - void renderPassThrough(video::ITexture *tex); + /** Render tex. Used for blit/texture resize */ + void renderPassThrough(video::ITexture *tex); void renderPassThrough(unsigned tex); void renderMotionBlur(unsigned cam, video::ITexture *in, video::ITexture *out); - void renderGlow(video::ITexture *tex); + void renderGlow(video::ITexture *tex); /** Render the post-processed scene */ void render(); diff --git a/src/graphics/render.cpp b/src/graphics/render.cpp index 8688a1076..b7962c511 100644 --- a/src/graphics/render.cpp +++ b/src/graphics/render.cpp @@ -189,14 +189,14 @@ void IrrDriver::renderGLSL(float dt) }*/ // Fire up the MRT - irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH), false, false); - PROFILER_PUSH_CPU_MARKER("- Solid Pass 1", 0xFF, 0x00, 0x00); + irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH), false, false); + PROFILER_PUSH_CPU_MARKER("- Solid Pass 1", 0xFF, 0x00, 0x00); m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_SOLID; - glDepthFunc(GL_LEQUAL); - glEnable(GL_DEPTH_TEST); - glDisable(GL_ALPHA_TEST); - glDepthMask(GL_TRUE); - glDisable(GL_BLEND); + glDepthFunc(GL_LEQUAL); + glEnable(GL_DEPTH_TEST); + glDisable(GL_ALPHA_TEST); + glDepthMask(GL_TRUE); + glDisable(GL_BLEND); glEnable(GL_CULL_FACE); irr_driver->setPhase(SOLID_NORMAL_AND_DEPTH_PASS); m_scene_manager->drawAll(m_renderpass); @@ -204,7 +204,7 @@ void IrrDriver::renderGLSL(float dt) irr_driver->setViewMatrix(irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW)); irr_driver->genProjViewMatrix(); - PROFILER_POP_CPU_MARKER(); + PROFILER_POP_CPU_MARKER(); // Todo : reenable glow and shadows //ShadowImportanceProvider * const sicb = (ShadowImportanceProvider *) @@ -227,14 +227,14 @@ void IrrDriver::renderGLSL(float dt) // Lights renderLights(cambox, camnode, overridemat, cam, dt); - PROFILER_POP_CPU_MARKER(); + PROFILER_POP_CPU_MARKER(); - PROFILER_PUSH_CPU_MARKER("- Solid Pass 2", 0x00, 0x00, 0xFF); + PROFILER_PUSH_CPU_MARKER("- Solid Pass 2", 0x00, 0x00, 0xFF); irr_driver->setPhase(SOLID_LIT_PASS); - glEnable(GL_DEPTH_TEST); - glDisable(GL_ALPHA_TEST); - glDepthMask(GL_FALSE); - glDisable(GL_BLEND); + glEnable(GL_DEPTH_TEST); + glDisable(GL_ALPHA_TEST); + glDepthMask(GL_FALSE); + glDisable(GL_BLEND); m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_SOLID; setTexture(0, getTextureGLuint(irr_driver->getRTT(RTT_TMP1)), GL_NEAREST, GL_NEAREST); setTexture(1, getTextureGLuint(irr_driver->getRTT(RTT_TMP2)), GL_NEAREST, GL_NEAREST); @@ -248,27 +248,27 @@ void IrrDriver::renderGLSL(float dt) PROFILER_POP_CPU_MARKER(); - if (World::getWorld()->getTrack()->isFogEnabled()) - { - PROFILER_PUSH_CPU_MARKER("- Fog", 0xFF, 0x00, 0x00); - m_post_processing->renderFog(irr_driver->getInvProjMatrix()); - PROFILER_POP_CPU_MARKER(); - } + if (World::getWorld()->getTrack()->isFogEnabled()) + { + PROFILER_PUSH_CPU_MARKER("- Fog", 0xFF, 0x00, 0x00); + m_post_processing->renderFog(irr_driver->getInvProjMatrix()); + PROFILER_POP_CPU_MARKER(); + } PROFILER_PUSH_CPU_MARKER("- Glow", 0xFF, 0xFF, 0x00); - // Render anything glowing. - if (!m_mipviz && !m_wireframe) - { - irr_driver->setPhase(GLOW_PASS); - renderGlow(overridemat, glows, cambox, cam); - } // end glow + // Render anything glowing. + if (!m_mipviz && !m_wireframe) + { + irr_driver->setPhase(GLOW_PASS); + renderGlow(overridemat, glows, cambox, cam); + } // end glow PROFILER_POP_CPU_MARKER(); - PROFILER_PUSH_CPU_MARKER("- Skybox", 0xFF, 0x00, 0xFF); - renderSkybox(); - PROFILER_POP_CPU_MARKER(); + PROFILER_PUSH_CPU_MARKER("- Skybox", 0xFF, 0x00, 0xFF); + renderSkybox(); + PROFILER_POP_CPU_MARKER(); PROFILER_PUSH_CPU_MARKER("- Lensflare/godray", 0x00, 0xFF, 0xFF); // Is the lens flare enabled & visible? Check last frame's query. @@ -276,7 +276,7 @@ void IrrDriver::renderGLSL(float dt) const bool hasgodrays = World::getWorld()->getTrack()->hasGodRays(); if (true)//hasflare || hasgodrays) { - irr::video::COpenGLDriver* gl_driver = (irr::video::COpenGLDriver*)m_device->getVideoDriver(); + irr::video::COpenGLDriver* gl_driver = (irr::video::COpenGLDriver*)m_device->getVideoDriver(); GLuint res = 0; if (m_query_issued) @@ -305,26 +305,26 @@ void IrrDriver::renderGLSL(float dt) // We need to re-render camera due to the per-cam-node hack. PROFILER_PUSH_CPU_MARKER("- Transparent Pass", 0xFF, 0x00, 0x00); - irr_driver->setPhase(TRANSPARENT_PASS); - m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_TRANSPARENT; - glEnable(GL_DEPTH_TEST); - glDisable(GL_ALPHA_TEST); - glDepthMask(GL_FALSE); - glEnable(GL_BLEND); - glBlendEquation(GL_FUNC_ADD); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glDisable(GL_CULL_FACE); + irr_driver->setPhase(TRANSPARENT_PASS); + m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_TRANSPARENT; + glEnable(GL_DEPTH_TEST); + glDisable(GL_ALPHA_TEST); + glDepthMask(GL_FALSE); + glEnable(GL_BLEND); + glBlendEquation(GL_FUNC_ADD); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glDisable(GL_CULL_FACE); m_scene_manager->drawAll(m_renderpass); - PROFILER_POP_CPU_MARKER(); + PROFILER_POP_CPU_MARKER(); - PROFILER_PUSH_CPU_MARKER("- Particles", 0xFF, 0xFF, 0x00); - m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_TRANSPARENT_EFFECT; - glDepthMask(GL_FALSE); - glDisable(GL_CULL_FACE); - glEnable(GL_BLEND); - glBlendEquation(GL_FUNC_ADD); - m_scene_manager->drawAll(m_renderpass); - PROFILER_POP_CPU_MARKER(); + PROFILER_PUSH_CPU_MARKER("- Particles", 0xFF, 0xFF, 0x00); + m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_TRANSPARENT_EFFECT; + glDepthMask(GL_FALSE); + glDisable(GL_CULL_FACE); + glEnable(GL_BLEND); + glBlendEquation(GL_FUNC_ADD); + m_scene_manager->drawAll(m_renderpass); + PROFILER_POP_CPU_MARKER(); PROFILER_PUSH_CPU_MARKER("- Displacement", 0x00, 0x00, 0xFF); // Handle displacing nodes, if any @@ -689,10 +689,10 @@ void IrrDriver::renderGlow(video::SOverrideMaterial &overridemat, glStencilFunc(GL_ALWAYS, 1, ~0); glEnable(GL_STENCIL_TEST); - glEnable(GL_DEPTH_TEST); - glDisable(GL_ALPHA_TEST); - glDepthMask(GL_FALSE); - glDisable(GL_BLEND); + glEnable(GL_DEPTH_TEST); + glDisable(GL_ALPHA_TEST); + glDepthMask(GL_FALSE); + glDisable(GL_BLEND); for (u32 i = 0; i < glowcount; i++) { @@ -723,22 +723,22 @@ void IrrDriver::renderGlow(video::SOverrideMaterial &overridemat, // To half m_video_driver->setRenderTarget(m_rtts->getRTT(RTT_HALF1), false, false); - m_post_processing->renderPassThrough(m_rtts->getRTT(RTT_TMP1)); + m_post_processing->renderPassThrough(m_rtts->getRTT(RTT_TMP1)); // To quarter m_video_driver->setRenderTarget(m_rtts->getRTT(RTT_QUARTER1), false, false); - m_post_processing->renderPassThrough(m_rtts->getRTT(RTT_HALF1)); + m_post_processing->renderPassThrough(m_rtts->getRTT(RTT_HALF1)); // Blur it - m_post_processing->renderGaussian6Blur(m_rtts->getRTT(RTT_QUARTER1), m_rtts->getRTT(RTT_QUARTER2), 4.f / UserConfigParams::m_width, 4.f / UserConfigParams::m_height); + m_post_processing->renderGaussian6Blur(m_rtts->getRTT(RTT_QUARTER1), m_rtts->getRTT(RTT_QUARTER2), 4.f / UserConfigParams::m_width, 4.f / UserConfigParams::m_height); - glEnable(GL_BLEND); - glBlendEquation(GL_FUNC_ADD); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glStencilFunc(GL_EQUAL, 0, ~0); - glEnable(GL_STENCIL_TEST); + glEnable(GL_BLEND); + glBlendEquation(GL_FUNC_ADD); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glStencilFunc(GL_EQUAL, 0, ~0); + glEnable(GL_STENCIL_TEST); m_video_driver->setRenderTarget(m_rtts->getRTT(RTT_COLOR), false, false); - m_post_processing->renderGlow(m_rtts->getRTT(RTT_QUARTER1)); + m_post_processing->renderGlow(m_rtts->getRTT(RTT_QUARTER1)); glDisable(GL_STENCIL_TEST); } @@ -863,9 +863,9 @@ void IrrDriver::renderLights(const core::aabbox3df& cambox, // Blur it to reduce noise. if(UserConfigParams::m_ssao == 1) - m_post_processing->renderGaussian3Blur(irr_driver->getRTT(RTT_SSAO), irr_driver->getRTT(RTT_QUARTER4), 4.f / UserConfigParams::m_width, 4.f / UserConfigParams::m_height); + m_post_processing->renderGaussian3Blur(irr_driver->getRTT(RTT_SSAO), irr_driver->getRTT(RTT_QUARTER4), 4.f / UserConfigParams::m_width, 4.f / UserConfigParams::m_height); else if (UserConfigParams::m_ssao == 2) - m_post_processing->renderGaussian6Blur(irr_driver->getRTT(RTT_SSAO), irr_driver->getRTT(RTT_TMP4), 1.f / UserConfigParams::m_width, 1.f / UserConfigParams::m_height); + m_post_processing->renderGaussian6Blur(irr_driver->getRTT(RTT_SSAO), irr_driver->getRTT(RTT_TMP4), 1.f / UserConfigParams::m_width, 1.f / UserConfigParams::m_height); m_video_driver->setRenderTarget(m_rtts->getRTT(RTT_COLOR), false, false); } @@ -1265,17 +1265,17 @@ void IrrDriver::renderSkybox() if (!SkyboxCubeMap) generateSkyboxCubemap(); glBindVertexArray(MeshShader::SkyboxShader::cubevao); - glDisable(GL_CULL_FACE); - assert(SkyboxTextures.size() == 6); - core::matrix4 transform = irr_driver->getProjViewMatrix(); - core::matrix4 translate; - translate.setTranslation(camera->getAbsolutePosition()); + glDisable(GL_CULL_FACE); + assert(SkyboxTextures.size() == 6); + core::matrix4 transform = irr_driver->getProjViewMatrix(); + core::matrix4 translate; + translate.setTranslation(camera->getAbsolutePosition()); - // Draw the sky box between the near and far clip plane - const f32 viewDistance = (camera->getNearValue() + camera->getFarValue()) * 0.5f; - core::matrix4 scale; - scale.setScale(core::vector3df(viewDistance, viewDistance, viewDistance)); - transform *= translate * scale; + // Draw the sky box between the near and far clip plane + const f32 viewDistance = (camera->getNearValue() + camera->getFarValue()) * 0.5f; + core::matrix4 scale; + scale.setScale(core::vector3df(viewDistance, viewDistance, viewDistance)); + transform *= translate * scale; core::matrix4 invtransform; transform.getInverse(invtransform); @@ -1297,15 +1297,15 @@ void IrrDriver::renderDisplacement(video::SOverrideMaterial &overridemat, irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_TMP4), true, false); irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_DISPLACE), true, false); - DisplaceProvider * const cb = (DisplaceProvider *)irr_driver->getCallback(ES_DISPLACE); - cb->update(); + DisplaceProvider * const cb = (DisplaceProvider *)irr_driver->getCallback(ES_DISPLACE); + cb->update(); const int displacingcount = m_displacing.size(); - irr_driver->setPhase(DISPLACEMENT_PASS); - glEnable(GL_DEPTH_TEST); - glDisable(GL_ALPHA_TEST); - glDepthMask(GL_FALSE); - glDisable(GL_BLEND); + irr_driver->setPhase(DISPLACEMENT_PASS); + glEnable(GL_DEPTH_TEST); + glDisable(GL_ALPHA_TEST); + glDepthMask(GL_FALSE); + glDisable(GL_BLEND); glClear(GL_STENCIL_BUFFER_BIT); glEnable(GL_STENCIL_TEST); glStencilFunc(GL_ALWAYS, 1, 0xFF); diff --git a/src/graphics/rtts.cpp b/src/graphics/rtts.cpp index 3860a7094..c8ef946cd 100644 --- a/src/graphics/rtts.cpp +++ b/src/graphics/rtts.cpp @@ -70,7 +70,7 @@ RTT::RTT() rtts[RTT_TMP2] = drv->addRenderTargetTexture(res, "rtt.tmp2", ECF_A8R8G8B8, stencil); rtts[RTT_TMP3] = drv->addRenderTargetTexture(res, "rtt.tmp3", ECF_A8R8G8B8, stencil); rtts[RTT_TMP4] = drv->addRenderTargetTexture(res, "rtt.tmp4", ECF_R8, stencil); - rtts[RTT_NORMAL_AND_DEPTH] = drv->addRenderTargetTexture(res, "rtt.normal_and_depth", ECF_G16R16F, stencil); + rtts[RTT_NORMAL_AND_DEPTH] = drv->addRenderTargetTexture(res, "rtt.normal_and_depth", ECF_G16R16F, stencil); rtts[RTT_COLOR] = drv->addRenderTargetTexture(res, "rtt.color", ECF_A16B16G16R16F, stencil); rtts[RTT_HALF1] = drv->addRenderTargetTexture(half, "rtt.half1", ECF_A8R8G8B8, stencil); diff --git a/src/graphics/screenquad.cpp b/src/graphics/screenquad.cpp index c332339ec..da2a8a176 100644 --- a/src/graphics/screenquad.cpp +++ b/src/graphics/screenquad.cpp @@ -23,8 +23,8 @@ const u16 ScreenQuad::indices[4] = {0, 1, 2, 3}; static const SColor white(255, 255, 255, 255); const S3DVertex ScreenQuad::vertices[4] = { - S3DVertex(-1, 1, 0, 0, 1, 0, white, 0, 1), - S3DVertex(1, 1, 0, 0, 1, 0, white, 1, 1), - S3DVertex(-1, -1, 0, 0, 1, 0, white, 0, 0), - S3DVertex(1, -1, 0, 0, 1, 0, white, 1, 0), - }; + S3DVertex(-1, 1, 0, 0, 1, 0, white, 0, 1), + S3DVertex(1, 1, 0, 0, 1, 0, white, 1, 1), + S3DVertex(-1, -1, 0, 0, 1, 0, white, 0, 0), + S3DVertex(1, -1, 0, 0, 1, 0, white, 1, 0), + }; diff --git a/src/graphics/shaders.cpp b/src/graphics/shaders.cpp index 63e39a711..f5c9caad1 100644 --- a/src/graphics/shaders.cpp +++ b/src/graphics/shaders.cpp @@ -62,16 +62,16 @@ GLuint quad_vbo; static void initQuadVBO() { - const float quad_vertex[] = { - -1., -1., 0., 0., // UpperLeft - -1., 1., 0., 1., // LowerLeft - 1., -1., 1., 0., // UpperRight - 1., 1., 1., 1., // LowerRight - }; - glGenBuffers(1, &quad_vbo); - glBindBuffer(GL_ARRAY_BUFFER, quad_vbo); - glBufferData(GL_ARRAY_BUFFER, 16 * sizeof(float), quad_vertex, GL_STATIC_DRAW); - glBindBuffer(GL_ARRAY_BUFFER, 0); + const float quad_vertex[] = { + -1., -1., 0., 0., // UpperLeft + -1., 1., 0., 1., // LowerLeft + 1., -1., 1., 0., // UpperRight + 1., 1., 1., 1., // LowerRight + }; + glGenBuffers(1, &quad_vbo); + glBindBuffer(GL_ARRAY_BUFFER, quad_vbo); + glBufferData(GL_ARRAY_BUFFER, 16 * sizeof(float), quad_vertex, GL_STATIC_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, 0); } // It should be possible to merge it with previous one... @@ -79,15 +79,15 @@ GLuint quad_buffer; static void initQuadBuffer() { - const float quad_vertex[] = { - -1., -1., -1., 1., // UpperLeft - -1., 1., -1., -1., // LowerLeft - 1., -1., 1., 1., // UpperRight - 1., 1., 1., -1., // LowerRight - }; - glGenBuffers(1, &quad_buffer); - glBindBuffer(GL_ARRAY_BUFFER, quad_buffer); - glBufferData(GL_ARRAY_BUFFER, 16 * sizeof(float), quad_vertex, GL_STATIC_DRAW); + const float quad_vertex[] = { + -1., -1., -1., 1., // UpperLeft + -1., 1., -1., -1., // LowerLeft + 1., -1., 1., 1., // UpperRight + 1., 1., 1., -1., // LowerRight + }; + glGenBuffers(1, &quad_buffer); + glBindBuffer(GL_ARRAY_BUFFER, quad_buffer); + glBufferData(GL_ARRAY_BUFFER, 16 * sizeof(float), quad_vertex, GL_STATIC_DRAW); } GLuint SharedObject::billboardvbo = 0; @@ -290,63 +290,63 @@ void Shaders::loadShaders() m_shaders[i] = saved_shaders[i]; } - initGL(); - initQuadVBO(); - initQuadBuffer(); + initGL(); + initQuadVBO(); + initQuadBuffer(); initBillboardVBO(); initCubeVBO(); - FullScreenShader::BloomBlendShader::init(); - FullScreenShader::BloomShader::init(); - FullScreenShader::ColorLevelShader::init(); - FullScreenShader::FogShader::init(); - FullScreenShader::Gaussian3HBlurShader::init(); - FullScreenShader::Gaussian3VBlurShader::init(); - FullScreenShader::Gaussian6HBlurShader::init(); - FullScreenShader::Gaussian6VBlurShader::init(); + FullScreenShader::BloomBlendShader::init(); + FullScreenShader::BloomShader::init(); + FullScreenShader::ColorLevelShader::init(); + FullScreenShader::FogShader::init(); + FullScreenShader::Gaussian3HBlurShader::init(); + FullScreenShader::Gaussian3VBlurShader::init(); + FullScreenShader::Gaussian6HBlurShader::init(); + FullScreenShader::Gaussian6VBlurShader::init(); FullScreenShader::PenumbraHShader::init(); FullScreenShader::PenumbraVShader::init(); - FullScreenShader::GlowShader::init(); - FullScreenShader::PassThroughShader::init(); - FullScreenShader::SSAOShader::init(); - FullScreenShader::SunLightShader::init(); + FullScreenShader::GlowShader::init(); + FullScreenShader::PassThroughShader::init(); + FullScreenShader::SSAOShader::init(); + FullScreenShader::SunLightShader::init(); FullScreenShader::DiffuseEnvMapShader::init(); FullScreenShader::ShadowedSunLightShader::init(); FullScreenShader::MotionBlurShader::init(); FullScreenShader::GodFadeShader::init(); FullScreenShader::GodRayShader::init(); - MeshShader::ColorizeShader::init(); - MeshShader::NormalMapShader::init(); - MeshShader::ObjectPass1Shader::init(); - MeshShader::ObjectRefPass1Shader::init(); - MeshShader::ObjectPass2Shader::init(); - MeshShader::DetailledObjectPass2Shader::init(); - MeshShader::ObjectRimLimitShader::init(); - MeshShader::UntexturedObjectShader::init(); - MeshShader::ObjectRefPass2Shader::init(); - MeshShader::ObjectUnlitShader::init(); - MeshShader::SphereMapShader::init(); - MeshShader::SplattingShader::init(); - MeshShader::GrassPass1Shader::init(); - MeshShader::GrassPass2Shader::init(); + MeshShader::ColorizeShader::init(); + MeshShader::NormalMapShader::init(); + MeshShader::ObjectPass1Shader::init(); + MeshShader::ObjectRefPass1Shader::init(); + MeshShader::ObjectPass2Shader::init(); + MeshShader::DetailledObjectPass2Shader::init(); + MeshShader::ObjectRimLimitShader::init(); + MeshShader::UntexturedObjectShader::init(); + MeshShader::ObjectRefPass2Shader::init(); + MeshShader::ObjectUnlitShader::init(); + MeshShader::SphereMapShader::init(); + MeshShader::SplattingShader::init(); + MeshShader::GrassPass1Shader::init(); + MeshShader::GrassPass2Shader::init(); MeshShader::CausticsShader::init(); - MeshShader::BubbleShader::init(); - MeshShader::TransparentShader::init(); + MeshShader::BubbleShader::init(); + MeshShader::TransparentShader::init(); MeshShader::TransparentFogShader::init(); - MeshShader::BillboardShader::init(); + MeshShader::BillboardShader::init(); LightShader::PointLightShader::init(); - MeshShader::DisplaceShader::init(); + MeshShader::DisplaceShader::init(); MeshShader::DisplaceMaskShader::init(); MeshShader::ShadowShader::init(); MeshShader::RefShadowShader::init(); MeshShader::GrassShadowShader::init(); MeshShader::SkyboxShader::init(); - ParticleShader::FlipParticleRender::init(); - ParticleShader::HeightmapSimulationShader::init(); - ParticleShader::SimpleParticleRender::init(); - ParticleShader::SimpleSimulationShader::init(); - UIShader::ColoredRectShader::init(); - UIShader::ColoredTextureRectShader::init(); - UIShader::TextureRectShader::init(); + ParticleShader::FlipParticleRender::init(); + ParticleShader::HeightmapSimulationShader::init(); + ParticleShader::SimpleParticleRender::init(); + ParticleShader::SimpleSimulationShader::init(); + UIShader::ColoredRectShader::init(); + UIShader::ColoredTextureRectShader::init(); + UIShader::TextureRectShader::init(); UIShader::UniformColoredTextureRectShader::init(); } @@ -380,61 +380,61 @@ namespace MeshShader { // Solid Normal and depth pass shaders - GLuint ObjectPass1Shader::Program; - GLuint ObjectPass1Shader::attrib_position; - GLuint ObjectPass1Shader::attrib_normal; - GLuint ObjectPass1Shader::uniform_MVP; - GLuint ObjectPass1Shader::uniform_TIMV; + GLuint ObjectPass1Shader::Program; + GLuint ObjectPass1Shader::attrib_position; + GLuint ObjectPass1Shader::attrib_normal; + GLuint ObjectPass1Shader::uniform_MVP; + GLuint ObjectPass1Shader::uniform_TIMV; - void ObjectPass1Shader::init() - { + void ObjectPass1Shader::init() + { Program = LoadProgram( GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_pass1.frag").c_str()); - attrib_position = glGetAttribLocation(Program, "Position"); - attrib_normal = glGetAttribLocation(Program, "Normal"); - uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); - uniform_TIMV = glGetUniformLocation(Program, "TransposeInverseModelView"); - } + attrib_position = glGetAttribLocation(Program, "Position"); + attrib_normal = glGetAttribLocation(Program, "Normal"); + uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); + uniform_TIMV = glGetUniformLocation(Program, "TransposeInverseModelView"); + } - void ObjectPass1Shader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView) - { - glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); - glUniformMatrix4fv(uniform_TIMV, 1, GL_FALSE, TransposeInverseModelView.pointer()); - } + void ObjectPass1Shader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView) + { + glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); + glUniformMatrix4fv(uniform_TIMV, 1, GL_FALSE, TransposeInverseModelView.pointer()); + } - GLuint ObjectRefPass1Shader::Program; - GLuint ObjectRefPass1Shader::attrib_position; - GLuint ObjectRefPass1Shader::attrib_normal; - GLuint ObjectRefPass1Shader::attrib_texcoord; - GLuint ObjectRefPass1Shader::uniform_MVP; - GLuint ObjectRefPass1Shader::uniform_TIMV; + GLuint ObjectRefPass1Shader::Program; + GLuint ObjectRefPass1Shader::attrib_position; + GLuint ObjectRefPass1Shader::attrib_normal; + GLuint ObjectRefPass1Shader::attrib_texcoord; + GLuint ObjectRefPass1Shader::uniform_MVP; + GLuint ObjectRefPass1Shader::uniform_TIMV; GLuint ObjectRefPass1Shader::uniform_TM; - GLuint ObjectRefPass1Shader::uniform_tex; + GLuint ObjectRefPass1Shader::uniform_tex; - void ObjectRefPass1Shader::init() - { - Program = LoadProgram( + void ObjectRefPass1Shader::init() + { + Program = LoadProgram( GL_VERTEX_SHADER, file_manager->getAsset("shaders/objectref_pass1.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass1.frag").c_str()); - attrib_position = glGetAttribLocation(Program, "Position"); - attrib_normal = glGetAttribLocation(Program, "Normal"); - attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); - uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); - uniform_TIMV = glGetUniformLocation(Program, "TransposeInverseModelView"); + attrib_position = glGetAttribLocation(Program, "Position"); + attrib_normal = glGetAttribLocation(Program, "Normal"); + attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); + uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); + uniform_TIMV = glGetUniformLocation(Program, "TransposeInverseModelView"); uniform_TM = glGetUniformLocation(Program, "TextureMatrix"); - uniform_tex = glGetUniformLocation(Program, "tex"); - } + uniform_tex = glGetUniformLocation(Program, "tex"); + } void ObjectRefPass1Shader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix, unsigned TU_tex) - { - glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); + { + glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); glUniformMatrix4fv(uniform_TM, 1, GL_FALSE, TextureMatrix.pointer()); - glUniformMatrix4fv(uniform_TIMV, 1, GL_FALSE, TransposeInverseModelView.pointer()); - glUniform1i(uniform_tex, TU_tex); - } + glUniformMatrix4fv(uniform_TIMV, 1, GL_FALSE, TransposeInverseModelView.pointer()); + glUniform1i(uniform_tex, TU_tex); + } GLuint GrassPass1Shader::Program; GLuint GrassPass1Shader::attrib_position; @@ -503,31 +503,31 @@ namespace MeshShader // Solid Lit pass shaders - GLuint ObjectPass2Shader::Program; - GLuint ObjectPass2Shader::attrib_position; - GLuint ObjectPass2Shader::attrib_texcoord; - GLuint ObjectPass2Shader::uniform_MVP; + GLuint ObjectPass2Shader::Program; + GLuint ObjectPass2Shader::attrib_position; + GLuint ObjectPass2Shader::attrib_texcoord; + GLuint ObjectPass2Shader::uniform_MVP; GLuint ObjectPass2Shader::uniform_TM; - GLuint ObjectPass2Shader::uniform_screen; - GLuint ObjectPass2Shader::uniform_ambient; + GLuint ObjectPass2Shader::uniform_screen; + GLuint ObjectPass2Shader::uniform_ambient; GLuint ObjectPass2Shader::TU_Albedo; - void ObjectPass2Shader::init() - { - Program = LoadProgram( + void ObjectPass2Shader::init() + { + Program = LoadProgram( GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_pass2.frag").c_str()); - attrib_position = glGetAttribLocation(Program, "Position"); - attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); - uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); + attrib_position = glGetAttribLocation(Program, "Position"); + attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); + uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); uniform_TM = glGetUniformLocation(Program, "TextureMatrix"); GLuint uniform_Albedo = glGetUniformLocation(Program, "Albedo"); GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap"); GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap"); GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO"); - uniform_screen = glGetUniformLocation(Program, "screen"); - uniform_ambient = glGetUniformLocation(Program, "ambient"); + uniform_screen = glGetUniformLocation(Program, "screen"); + uniform_ambient = glGetUniformLocation(Program, "ambient"); TU_Albedo = 3; glUseProgram(Program); @@ -536,44 +536,44 @@ namespace MeshShader glUniform1i(uniform_SSAO, 2); glUniform1i(uniform_Albedo, TU_Albedo); glUseProgram(0); - } + } void ObjectPass2Shader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix) - { - glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); + { + glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); glUniformMatrix4fv(uniform_TM, 1, GL_FALSE, TextureMatrix.pointer()); - glUniform2f(uniform_screen, UserConfigParams::m_width, UserConfigParams::m_height); - const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight(); - glUniform3f(uniform_ambient, s.r, s.g, s.b); - } + glUniform2f(uniform_screen, UserConfigParams::m_width, UserConfigParams::m_height); + const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight(); + glUniform3f(uniform_ambient, s.r, s.g, s.b); + } - GLuint DetailledObjectPass2Shader::Program; - GLuint DetailledObjectPass2Shader::attrib_position; - GLuint DetailledObjectPass2Shader::attrib_texcoord; - GLuint DetailledObjectPass2Shader::attrib_second_texcoord; - GLuint DetailledObjectPass2Shader::uniform_MVP; - GLuint DetailledObjectPass2Shader::uniform_screen; - GLuint DetailledObjectPass2Shader::uniform_ambient; + GLuint DetailledObjectPass2Shader::Program; + GLuint DetailledObjectPass2Shader::attrib_position; + GLuint DetailledObjectPass2Shader::attrib_texcoord; + GLuint DetailledObjectPass2Shader::attrib_second_texcoord; + GLuint DetailledObjectPass2Shader::uniform_MVP; + GLuint DetailledObjectPass2Shader::uniform_screen; + GLuint DetailledObjectPass2Shader::uniform_ambient; GLuint DetailledObjectPass2Shader::TU_Albedo; GLuint DetailledObjectPass2Shader::TU_detail; - void DetailledObjectPass2Shader::init() - { - Program = LoadProgram( + void DetailledObjectPass2Shader::init() + { + Program = LoadProgram( GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/detailledobject_pass2.frag").c_str()); - attrib_position = glGetAttribLocation(Program, "Position"); - attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); - attrib_second_texcoord = glGetAttribLocation(Program, "SecondTexcoord"); - uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); + attrib_position = glGetAttribLocation(Program, "Position"); + attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); + attrib_second_texcoord = glGetAttribLocation(Program, "SecondTexcoord"); + uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); GLuint uniform_Albedo = glGetUniformLocation(Program, "Albedo"); GLuint uniform_Detail = glGetUniformLocation(Program, "Detail"); GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap"); GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap"); GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO"); uniform_screen = glGetUniformLocation(Program, "screen"); - uniform_ambient = glGetUniformLocation(Program, "ambient"); + uniform_ambient = glGetUniformLocation(Program, "ambient"); TU_Albedo = 3; TU_detail = 4; @@ -584,71 +584,71 @@ namespace MeshShader glUniform1i(uniform_Albedo, TU_Albedo); glUniform1i(uniform_Detail, TU_detail); glUseProgram(0); - } + } - void DetailledObjectPass2Shader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix) - { - glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); - glUniform2f(uniform_screen, UserConfigParams::m_width, UserConfigParams::m_height); - const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight(); - glUniform3f(uniform_ambient, s.r, s.g, s.b); - } + void DetailledObjectPass2Shader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix) + { + glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); + glUniform2f(uniform_screen, UserConfigParams::m_width, UserConfigParams::m_height); + const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight(); + glUniform3f(uniform_ambient, s.r, s.g, s.b); + } - GLuint ObjectUnlitShader::Program; - GLuint ObjectUnlitShader::attrib_position; - GLuint ObjectUnlitShader::attrib_texcoord; - GLuint ObjectUnlitShader::uniform_MVP; - GLuint ObjectUnlitShader::TU_tex; + GLuint ObjectUnlitShader::Program; + GLuint ObjectUnlitShader::attrib_position; + GLuint ObjectUnlitShader::attrib_texcoord; + GLuint ObjectUnlitShader::uniform_MVP; + GLuint ObjectUnlitShader::TU_tex; - void ObjectUnlitShader::init() - { - Program = LoadProgram( + void ObjectUnlitShader::init() + { + Program = LoadProgram( GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_unlit.frag").c_str()); - attrib_position = glGetAttribLocation(Program, "Position"); - attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); - uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); - GLuint uniform_tex = glGetUniformLocation(Program, "tex"); + attrib_position = glGetAttribLocation(Program, "Position"); + attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); + uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); + GLuint uniform_tex = glGetUniformLocation(Program, "tex"); TU_tex = 3; glUseProgram(Program); glUniform1i(uniform_tex, TU_tex); glUseProgram(0); - } + } - void ObjectUnlitShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix) - { - glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); - } + void ObjectUnlitShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix) + { + glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); + } - GLuint ObjectRimLimitShader::Program; - GLuint ObjectRimLimitShader::attrib_position; - GLuint ObjectRimLimitShader::attrib_texcoord; - GLuint ObjectRimLimitShader::attrib_normal; - GLuint ObjectRimLimitShader::uniform_MVP; - GLuint ObjectRimLimitShader::uniform_TIMV; + GLuint ObjectRimLimitShader::Program; + GLuint ObjectRimLimitShader::attrib_position; + GLuint ObjectRimLimitShader::attrib_texcoord; + GLuint ObjectRimLimitShader::attrib_normal; + GLuint ObjectRimLimitShader::uniform_MVP; + GLuint ObjectRimLimitShader::uniform_TIMV; GLuint ObjectRimLimitShader::uniform_TM; - GLuint ObjectRimLimitShader::uniform_screen; - GLuint ObjectRimLimitShader::uniform_ambient; + GLuint ObjectRimLimitShader::uniform_screen; + GLuint ObjectRimLimitShader::uniform_ambient; GLuint ObjectRimLimitShader::TU_Albedo; - void ObjectRimLimitShader::init() - { - Program = LoadProgram( + void ObjectRimLimitShader::init() + { + Program = LoadProgram( GL_VERTEX_SHADER, file_manager->getAsset("shaders/objectpass_rimlit.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectpass_rimlit.frag").c_str()); - attrib_position = glGetAttribLocation(Program, "Position"); - attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); - attrib_normal = glGetAttribLocation(Program, "Normal"); - uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); - uniform_TIMV = glGetUniformLocation(Program, "TransposeInverseModelView"); + attrib_position = glGetAttribLocation(Program, "Position"); + attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); + attrib_normal = glGetAttribLocation(Program, "Normal"); + uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); + uniform_TIMV = glGetUniformLocation(Program, "TransposeInverseModelView"); uniform_TM = glGetUniformLocation(Program, "TextureMatrix"); GLuint uniform_Albedo = glGetUniformLocation(Program, "Albedo"); GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap"); GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap"); GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO"); - uniform_screen = glGetUniformLocation(Program, "screen"); - uniform_ambient = glGetUniformLocation(Program, "ambient"); + uniform_screen = glGetUniformLocation(Program, "screen"); + uniform_ambient = glGetUniformLocation(Program, "ambient"); TU_Albedo = 3; glUseProgram(Program); @@ -657,82 +657,82 @@ namespace MeshShader glUniform1i(uniform_SSAO, 2); glUniform1i(uniform_Albedo, TU_Albedo); glUseProgram(0); - } + } void ObjectRimLimitShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix) - { - glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); - glUniformMatrix4fv(uniform_TIMV, 1, GL_FALSE, TransposeInverseModelView.pointer()); + { + glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); + glUniformMatrix4fv(uniform_TIMV, 1, GL_FALSE, TransposeInverseModelView.pointer()); glUniformMatrix4fv(uniform_TM, 1, GL_FALSE, TextureMatrix.pointer()); - glUniform2f(uniform_screen, UserConfigParams::m_width, UserConfigParams::m_height); - const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight(); - glUniform3f(uniform_ambient, s.r, s.g, s.b); - } + glUniform2f(uniform_screen, UserConfigParams::m_width, UserConfigParams::m_height); + const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight(); + glUniform3f(uniform_ambient, s.r, s.g, s.b); + } - GLuint UntexturedObjectShader::Program; - GLuint UntexturedObjectShader::attrib_position; - GLuint UntexturedObjectShader::attrib_color; - GLuint UntexturedObjectShader::uniform_MVP; - GLuint UntexturedObjectShader::uniform_screen; - GLuint UntexturedObjectShader::uniform_ambient; + GLuint UntexturedObjectShader::Program; + GLuint UntexturedObjectShader::attrib_position; + GLuint UntexturedObjectShader::attrib_color; + GLuint UntexturedObjectShader::uniform_MVP; + GLuint UntexturedObjectShader::uniform_screen; + GLuint UntexturedObjectShader::uniform_ambient; - void UntexturedObjectShader::init() - { - Program = LoadProgram( + void UntexturedObjectShader::init() + { + Program = LoadProgram( GL_VERTEX_SHADER, file_manager->getAsset("shaders/untextured_object.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/untextured_object.frag").c_str()); - attrib_position = glGetAttribLocation(Program, "Position"); - attrib_color = glGetAttribLocation(Program, "Color"); - uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); + attrib_position = glGetAttribLocation(Program, "Position"); + attrib_color = glGetAttribLocation(Program, "Color"); + uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap"); GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap"); GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO"); - uniform_screen = glGetUniformLocation(Program, "screen"); - uniform_ambient = glGetUniformLocation(Program, "ambient"); + uniform_screen = glGetUniformLocation(Program, "screen"); + uniform_ambient = glGetUniformLocation(Program, "ambient"); glUseProgram(Program); glUniform1i(uniform_DiffuseMap, 0); glUniform1i(uniform_SpecularMap, 1); glUniform1i(uniform_SSAO, 2); glUseProgram(0); - } + } - void UntexturedObjectShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix) - { - glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); - glUniform2f(uniform_screen, UserConfigParams::m_width, UserConfigParams::m_height); - const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight(); - glUniform3f(uniform_ambient, s.r, s.g, s.b); - } + void UntexturedObjectShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix) + { + glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); + glUniform2f(uniform_screen, UserConfigParams::m_width, UserConfigParams::m_height); + const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight(); + glUniform3f(uniform_ambient, s.r, s.g, s.b); + } - GLuint ObjectRefPass2Shader::Program; - GLuint ObjectRefPass2Shader::attrib_position; - GLuint ObjectRefPass2Shader::attrib_texcoord; - GLuint ObjectRefPass2Shader::uniform_MVP; + GLuint ObjectRefPass2Shader::Program; + GLuint ObjectRefPass2Shader::attrib_position; + GLuint ObjectRefPass2Shader::attrib_texcoord; + GLuint ObjectRefPass2Shader::uniform_MVP; GLuint ObjectRefPass2Shader::uniform_TM; - GLuint ObjectRefPass2Shader::uniform_screen; - GLuint ObjectRefPass2Shader::uniform_ambient; + GLuint ObjectRefPass2Shader::uniform_screen; + GLuint ObjectRefPass2Shader::uniform_ambient; GLuint ObjectRefPass2Shader::TU_Albedo; - void ObjectRefPass2Shader::init() - { - initGL(); - Program = LoadProgram( + void ObjectRefPass2Shader::init() + { + initGL(); + Program = LoadProgram( GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass2.frag").c_str()); - attrib_position = glGetAttribLocation(Program, "Position"); - attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); - uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); + attrib_position = glGetAttribLocation(Program, "Position"); + attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); + uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); uniform_TM = glGetUniformLocation(Program, "TextureMatrix"); GLuint uniform_Albedo = glGetUniformLocation(Program, "Albedo"); GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap"); GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap"); - GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO"); - uniform_screen = glGetUniformLocation(Program, "screen"); - uniform_ambient = glGetUniformLocation(Program, "ambient"); + GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO"); + uniform_screen = glGetUniformLocation(Program, "screen"); + uniform_ambient = glGetUniformLocation(Program, "ambient"); TU_Albedo = 3; glUseProgram(Program); @@ -741,44 +741,44 @@ namespace MeshShader glUniform1i(uniform_SSAO, 2); glUniform1i(uniform_Albedo, TU_Albedo); glUseProgram(0); - } + } - void ObjectRefPass2Shader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix) - { - glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); + void ObjectRefPass2Shader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix) + { + glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); glUniformMatrix4fv(uniform_TM, 1, GL_FALSE, TextureMatrix.pointer()); - glUniform2f(uniform_screen, UserConfigParams::m_width, UserConfigParams::m_height); - const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight(); - glUniform3f(uniform_ambient, s.r, s.g, s.b); - } + glUniform2f(uniform_screen, UserConfigParams::m_width, UserConfigParams::m_height); + const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight(); + glUniform3f(uniform_ambient, s.r, s.g, s.b); + } - GLuint GrassPass2Shader::Program; - GLuint GrassPass2Shader::attrib_position; - GLuint GrassPass2Shader::attrib_texcoord; - GLuint GrassPass2Shader::attrib_color; - GLuint GrassPass2Shader::uniform_MVP; - GLuint GrassPass2Shader::uniform_screen; - GLuint GrassPass2Shader::uniform_ambient; - GLuint GrassPass2Shader::uniform_windDir; + GLuint GrassPass2Shader::Program; + GLuint GrassPass2Shader::attrib_position; + GLuint GrassPass2Shader::attrib_texcoord; + GLuint GrassPass2Shader::attrib_color; + GLuint GrassPass2Shader::uniform_MVP; + GLuint GrassPass2Shader::uniform_screen; + GLuint GrassPass2Shader::uniform_ambient; + GLuint GrassPass2Shader::uniform_windDir; GLuint GrassPass2Shader::TU_Albedo; - void GrassPass2Shader::init() - { - Program = LoadProgram( + void GrassPass2Shader::init() + { + Program = LoadProgram( GL_VERTEX_SHADER, file_manager->getAsset("shaders/grass_pass2.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass2.frag").c_str()); - attrib_position = glGetAttribLocation(Program, "Position"); - attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); - attrib_color = glGetAttribLocation(Program, "Color"); - uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); + attrib_position = glGetAttribLocation(Program, "Position"); + attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); + attrib_color = glGetAttribLocation(Program, "Color"); + uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); GLuint uniform_Albedo = glGetUniformLocation(Program, "Albedo"); GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap"); GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap"); GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO"); - uniform_screen = glGetUniformLocation(Program, "screen"); - uniform_ambient = glGetUniformLocation(Program, "ambient"); - uniform_windDir = glGetUniformLocation(Program, "windDir"); + uniform_screen = glGetUniformLocation(Program, "screen"); + uniform_ambient = glGetUniformLocation(Program, "ambient"); + uniform_windDir = glGetUniformLocation(Program, "windDir"); TU_Albedo = 3; glUseProgram(Program); @@ -787,36 +787,36 @@ namespace MeshShader glUniform1i(uniform_SSAO, 2); glUniform1i(uniform_Albedo, TU_Albedo); glUseProgram(0); - } + } - void GrassPass2Shader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::vector3df &windDirection) - { - glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); - glUniform2f(uniform_screen, UserConfigParams::m_width, UserConfigParams::m_height); - const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight(); - glUniform3f(uniform_ambient, s.r, s.g, s.b); - glUniform3f(uniform_windDir, windDirection.X, windDirection.Y, windDirection.Z); - } + void GrassPass2Shader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::vector3df &windDirection) + { + glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); + glUniform2f(uniform_screen, UserConfigParams::m_width, UserConfigParams::m_height); + const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight(); + glUniform3f(uniform_ambient, s.r, s.g, s.b); + glUniform3f(uniform_windDir, windDirection.X, windDirection.Y, windDirection.Z); + } - GLuint SphereMapShader::Program; - GLuint SphereMapShader::attrib_position; - GLuint SphereMapShader::attrib_normal; - GLuint SphereMapShader::uniform_MVP; - GLuint SphereMapShader::uniform_TIMV; + GLuint SphereMapShader::Program; + GLuint SphereMapShader::attrib_position; + GLuint SphereMapShader::attrib_normal; + GLuint SphereMapShader::uniform_MVP; + GLuint SphereMapShader::uniform_TIMV; GLuint SphereMapShader::uniform_TVM; GLuint SphereMapShader::uniform_invproj; GLuint SphereMapShader::uniform_screen; GLuint SphereMapShader::TU_tex; - void SphereMapShader::init() - { - Program = LoadProgram( + void SphereMapShader::init() + { + Program = LoadProgram( GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectpass_spheremap.frag").c_str()); - attrib_position = glGetAttribLocation(Program, "Position"); - attrib_normal = glGetAttribLocation(Program, "Normal"); - uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); - uniform_TIMV = glGetUniformLocation(Program, "TransposeInverseModelView"); + attrib_position = glGetAttribLocation(Program, "Position"); + attrib_normal = glGetAttribLocation(Program, "Normal"); + uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); + uniform_TIMV = glGetUniformLocation(Program, "TransposeInverseModelView"); uniform_TVM = glGetUniformLocation(Program, "TransposeViewMatrix"); GLuint uniform_tex = glGetUniformLocation(Program, "tex"); uniform_invproj = glGetUniformLocation(Program, "invproj"); @@ -826,39 +826,39 @@ namespace MeshShader glUseProgram(Program); glUniform1i(uniform_tex, TU_tex); glUseProgram(0); - } + } void SphereMapShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeViewMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &InvProj, const core::vector2df& screen) - { - glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); - glUniformMatrix4fv(uniform_TIMV, 1, GL_FALSE, TransposeInverseModelView.pointer()); + { + glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); + glUniformMatrix4fv(uniform_TIMV, 1, GL_FALSE, TransposeInverseModelView.pointer()); glUniformMatrix4fv(uniform_TVM, 1, GL_FALSE, TransposeViewMatrix.pointer()); glUniformMatrix4fv(uniform_invproj, 1, GL_FALSE, InvProj.pointer()); glUniform2f(uniform_screen, screen.X, screen.Y); - } + } - GLuint SplattingShader::Program; - GLuint SplattingShader::attrib_position; - GLuint SplattingShader::attrib_texcoord; - GLuint SplattingShader::attrib_second_texcoord; - GLuint SplattingShader::uniform_MVP; - GLuint SplattingShader::uniform_screen; - GLuint SplattingShader::uniform_ambient; + GLuint SplattingShader::Program; + GLuint SplattingShader::attrib_position; + GLuint SplattingShader::attrib_texcoord; + GLuint SplattingShader::attrib_second_texcoord; + GLuint SplattingShader::uniform_MVP; + GLuint SplattingShader::uniform_screen; + GLuint SplattingShader::uniform_ambient; GLuint SplattingShader::TU_tex_layout; GLuint SplattingShader::TU_tex_detail0; GLuint SplattingShader::TU_tex_detail1; GLuint SplattingShader::TU_tex_detail2; GLuint SplattingShader::TU_tex_detail3; - void SplattingShader::init() - { - Program = LoadProgram( + void SplattingShader::init() + { + Program = LoadProgram( GL_VERTEX_SHADER, file_manager->getAsset("shaders/splatting.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/splatting.frag").c_str()); - attrib_position = glGetAttribLocation(Program, "Position"); - attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); - attrib_second_texcoord = glGetAttribLocation(Program, "SecondTexcoord"); - uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); + attrib_position = glGetAttribLocation(Program, "Position"); + attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); + attrib_second_texcoord = glGetAttribLocation(Program, "SecondTexcoord"); + uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); GLuint uniform_tex_layout = glGetUniformLocation(Program, "tex_layout"); GLuint uniform_tex_detail0 = glGetUniformLocation(Program, "tex_detail0"); GLuint uniform_tex_detail1 = glGetUniformLocation(Program, "tex_detail1"); @@ -867,8 +867,8 @@ namespace MeshShader GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap"); GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap"); GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO"); - uniform_screen = glGetUniformLocation(Program, "screen"); - uniform_ambient = glGetUniformLocation(Program, "ambient"); + uniform_screen = glGetUniformLocation(Program, "screen"); + uniform_ambient = glGetUniformLocation(Program, "ambient"); TU_tex_layout = 3; TU_tex_detail0 = 4; TU_tex_detail1 = 5; @@ -885,15 +885,15 @@ namespace MeshShader glUniform1i(uniform_tex_detail2, TU_tex_detail2); glUniform1i(uniform_tex_detail3, TU_tex_detail3); glUseProgram(0); - } + } - void SplattingShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix) - { - glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); - glUniform2f(uniform_screen, UserConfigParams::m_width, UserConfigParams::m_height); - const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight(); - glUniform3f(uniform_ambient, s.r, s.g, s.b); - } + void SplattingShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix) + { + glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); + glUniform2f(uniform_screen, UserConfigParams::m_width, UserConfigParams::m_height); + const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight(); + glUniform3f(uniform_ambient, s.r, s.g, s.b); + } GLuint CausticsShader::Program; GLuint CausticsShader::attrib_position; @@ -946,61 +946,61 @@ namespace MeshShader glUniform3f(uniform_ambient, s.r, s.g, s.b); } - GLuint BubbleShader::Program; - GLuint BubbleShader::attrib_position; - GLuint BubbleShader::attrib_texcoord; - GLuint BubbleShader::uniform_MVP; - GLuint BubbleShader::uniform_tex; - GLuint BubbleShader::uniform_time; - GLuint BubbleShader::uniform_transparency; + GLuint BubbleShader::Program; + GLuint BubbleShader::attrib_position; + GLuint BubbleShader::attrib_texcoord; + GLuint BubbleShader::uniform_MVP; + GLuint BubbleShader::uniform_tex; + GLuint BubbleShader::uniform_time; + GLuint BubbleShader::uniform_transparency; - void BubbleShader::init() - { - Program = LoadProgram( + void BubbleShader::init() + { + Program = LoadProgram( GL_VERTEX_SHADER, file_manager->getAsset("shaders/bubble.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/bubble.frag").c_str()); - attrib_position = glGetAttribLocation(Program, "Position"); - attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); - uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); - uniform_tex = glGetUniformLocation(Program, "tex"); - uniform_time = glGetUniformLocation(Program, "time"); - uniform_transparency = glGetUniformLocation(Program, "transparency"); - } + attrib_position = glGetAttribLocation(Program, "Position"); + attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); + uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); + uniform_tex = glGetUniformLocation(Program, "tex"); + uniform_time = glGetUniformLocation(Program, "time"); + uniform_transparency = glGetUniformLocation(Program, "transparency"); + } void BubbleShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, unsigned TU_tex, float time, float transparency) - { - glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); - glUniform1i(uniform_tex, TU_tex); - glUniform1f(uniform_time, time); - glUniform1f(uniform_transparency, transparency); - } + { + glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); + glUniform1i(uniform_tex, TU_tex); + glUniform1f(uniform_time, time); + glUniform1f(uniform_transparency, transparency); + } - GLuint TransparentShader::Program; - GLuint TransparentShader::attrib_position; - GLuint TransparentShader::attrib_texcoord; + GLuint TransparentShader::Program; + GLuint TransparentShader::attrib_position; + GLuint TransparentShader::attrib_texcoord; GLuint TransparentShader::attrib_color; - GLuint TransparentShader::uniform_MVP; + GLuint TransparentShader::uniform_MVP; GLuint TransparentShader::uniform_TM; - GLuint TransparentShader::uniform_tex; + GLuint TransparentShader::uniform_tex; - void TransparentShader::init() - { - Program = LoadProgram( + void TransparentShader::init() + { + Program = LoadProgram( GL_VERTEX_SHADER, file_manager->getAsset("shaders/transparent.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/transparent.frag").c_str()); - attrib_position = glGetAttribLocation(Program, "Position"); - attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); + attrib_position = glGetAttribLocation(Program, "Position"); + attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); attrib_color = glGetAttribLocation(Program, "Color"); - uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); + uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); uniform_TM = glGetUniformLocation(Program, "TextureMatrix"); - uniform_tex = glGetUniformLocation(Program, "tex"); - } + uniform_tex = glGetUniformLocation(Program, "tex"); + } void TransparentShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix, unsigned TU_tex) - { - glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); + { + glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); glUniformMatrix4fv(uniform_TM, 1, GL_FALSE, TextureMatrix.pointer()); - glUniform1i(uniform_tex, TU_tex); - } + glUniform1i(uniform_tex, TU_tex); + } GLuint TransparentFogShader::Program; GLuint TransparentFogShader::attrib_position; @@ -1053,59 +1053,59 @@ namespace MeshShader glUniformMatrix4fv(uniform_ipvmat, 1, GL_FALSE, ipvmat.pointer()); glUniform1i(uniform_tex, TU_tex); } + + GLuint BillboardShader::Program; + GLuint BillboardShader::attrib_corner; + GLuint BillboardShader::attrib_texcoord; + GLuint BillboardShader::uniform_MV; + GLuint BillboardShader::uniform_P; + GLuint BillboardShader::uniform_tex; + GLuint BillboardShader::uniform_Position; + GLuint BillboardShader::uniform_Size; - GLuint BillboardShader::Program; - GLuint BillboardShader::attrib_corner; - GLuint BillboardShader::attrib_texcoord; - GLuint BillboardShader::uniform_MV; - GLuint BillboardShader::uniform_P; - GLuint BillboardShader::uniform_tex; - GLuint BillboardShader::uniform_Position; - GLuint BillboardShader::uniform_Size; - - void BillboardShader::init() - { - Program = LoadProgram( + void BillboardShader::init() + { + Program = LoadProgram( GL_VERTEX_SHADER, file_manager->getAsset("shaders/billboard.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/billboard.frag").c_str()); - attrib_corner = glGetAttribLocation(Program, "Corner"); - attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); - uniform_MV = glGetUniformLocation(Program, "ModelViewMatrix"); - uniform_P = glGetUniformLocation(Program, "ProjectionMatrix"); - uniform_Position = glGetUniformLocation(Program, "Position"); - uniform_Size = glGetUniformLocation(Program, "Size"); - uniform_tex = glGetUniformLocation(Program, "tex"); - } + attrib_corner = glGetAttribLocation(Program, "Corner"); + attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); + uniform_MV = glGetUniformLocation(Program, "ModelViewMatrix"); + uniform_P = glGetUniformLocation(Program, "ProjectionMatrix"); + uniform_Position = glGetUniformLocation(Program, "Position"); + uniform_Size = glGetUniformLocation(Program, "Size"); + uniform_tex = glGetUniformLocation(Program, "tex"); + } - void BillboardShader::setUniforms(const core::matrix4 &ModelViewMatrix, const core::matrix4 &ProjectionMatrix, const core::vector3df &Position, const core::dimension2d &size, unsigned TU_tex) - { - glUniformMatrix4fv(uniform_MV, 1, GL_FALSE, ModelViewMatrix.pointer()); - glUniformMatrix4fv(uniform_P, 1, GL_FALSE, ProjectionMatrix.pointer()); - glUniform3f(uniform_Position, Position.X, Position.Y, Position.Z); - glUniform2f(uniform_Size, size.Width, size.Height); - glUniform1i(uniform_tex, TU_tex); - } + void BillboardShader::setUniforms(const core::matrix4 &ModelViewMatrix, const core::matrix4 &ProjectionMatrix, const core::vector3df &Position, const core::dimension2d &size, unsigned TU_tex) + { + glUniformMatrix4fv(uniform_MV, 1, GL_FALSE, ModelViewMatrix.pointer()); + glUniformMatrix4fv(uniform_P, 1, GL_FALSE, ProjectionMatrix.pointer()); + glUniform3f(uniform_Position, Position.X, Position.Y, Position.Z); + glUniform2f(uniform_Size, size.Width, size.Height); + glUniform1i(uniform_tex, TU_tex); + } - GLuint ColorizeShader::Program; - GLuint ColorizeShader::attrib_position; - GLuint ColorizeShader::uniform_MVP; - GLuint ColorizeShader::uniform_col; + GLuint ColorizeShader::Program; + GLuint ColorizeShader::attrib_position; + GLuint ColorizeShader::uniform_MVP; + GLuint ColorizeShader::uniform_col; - void ColorizeShader::init() - { - Program = LoadProgram( + void ColorizeShader::init() + { + Program = LoadProgram( GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/colorize.frag").c_str()); - attrib_position = glGetAttribLocation(Program, "Position"); - uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); - uniform_col = glGetUniformLocation(Program, "col"); - } + attrib_position = glGetAttribLocation(Program, "Position"); + uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); + uniform_col = glGetUniformLocation(Program, "col"); + } - void ColorizeShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, float r, float g, float b) - { - glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); - glUniform3f(uniform_col, r, g, b); - } + void ColorizeShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, float r, float g, float b) + { + glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); + glUniform3f(uniform_col, r, g, b); + } GLuint ShadowShader::Program; GLuint ShadowShader::attrib_position; @@ -1221,48 +1221,48 @@ namespace MeshShader glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); } - GLuint DisplaceShader::Program; - GLuint DisplaceShader::attrib_position; - GLuint DisplaceShader::attrib_texcoord; - GLuint DisplaceShader::attrib_second_texcoord; - GLuint DisplaceShader::uniform_MVP; - GLuint DisplaceShader::uniform_MV; - GLuint DisplaceShader::uniform_displacement_tex; + GLuint DisplaceShader::Program; + GLuint DisplaceShader::attrib_position; + GLuint DisplaceShader::attrib_texcoord; + GLuint DisplaceShader::attrib_second_texcoord; + GLuint DisplaceShader::uniform_MVP; + GLuint DisplaceShader::uniform_MV; + GLuint DisplaceShader::uniform_displacement_tex; GLuint DisplaceShader::uniform_mask_tex; GLuint DisplaceShader::uniform_color_tex; - GLuint DisplaceShader::uniform_dir; - GLuint DisplaceShader::uniform_dir2; + GLuint DisplaceShader::uniform_dir; + GLuint DisplaceShader::uniform_dir2; GLuint DisplaceShader::uniform_screen; - void DisplaceShader::init() - { - Program = LoadProgram( + void DisplaceShader::init() + { + Program = LoadProgram( GL_VERTEX_SHADER, file_manager->getAsset("shaders/displace.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/displace.frag").c_str()); - attrib_position = glGetAttribLocation(Program, "Position"); - attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); - attrib_second_texcoord = glGetAttribLocation(Program, "SecondTexcoord"); - uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); - uniform_MV = glGetUniformLocation(Program, "ModelViewMatrix"); - uniform_displacement_tex = glGetUniformLocation(Program, "displacement_tex"); + attrib_position = glGetAttribLocation(Program, "Position"); + attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); + attrib_second_texcoord = glGetAttribLocation(Program, "SecondTexcoord"); + uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); + uniform_MV = glGetUniformLocation(Program, "ModelViewMatrix"); + uniform_displacement_tex = glGetUniformLocation(Program, "displacement_tex"); uniform_color_tex = glGetUniformLocation(Program, "color_tex"); uniform_mask_tex = glGetUniformLocation(Program, "mask_tex"); - uniform_dir = glGetUniformLocation(Program, "dir"); - uniform_dir2 = glGetUniformLocation(Program, "dir2"); + uniform_dir = glGetUniformLocation(Program, "dir"); + uniform_dir2 = glGetUniformLocation(Program, "dir2"); uniform_screen = glGetUniformLocation(Program, "screen"); - } + } - void DisplaceShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &ModelViewMatrix, const core::vector2df &dir, const core::vector2df &dir2, const core::vector2df &screen, unsigned TU_displacement_tex, unsigned TU_mask_tex, unsigned TU_color_tex) - { - glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); - glUniformMatrix4fv(uniform_MV, 1, GL_FALSE, ModelViewMatrix.pointer()); - glUniform2f(uniform_dir, dir.X, dir.Y); - glUniform2f(uniform_dir2, dir2.X, dir2.Y); + void DisplaceShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &ModelViewMatrix, const core::vector2df &dir, const core::vector2df &dir2, const core::vector2df &screen, unsigned TU_displacement_tex, unsigned TU_mask_tex, unsigned TU_color_tex) + { + glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); + glUniformMatrix4fv(uniform_MV, 1, GL_FALSE, ModelViewMatrix.pointer()); + glUniform2f(uniform_dir, dir.X, dir.Y); + glUniform2f(uniform_dir2, dir2.X, dir2.Y); glUniform2f(uniform_screen, screen.X, screen.Y); - glUniform1i(uniform_displacement_tex, TU_displacement_tex); + glUniform1i(uniform_displacement_tex, TU_displacement_tex); glUniform1i(uniform_mask_tex, TU_mask_tex); glUniform1i(uniform_color_tex, TU_color_tex); - } + } GLuint SkyboxShader::Program; GLuint SkyboxShader::attrib_position; @@ -1377,293 +1377,293 @@ namespace LightShader namespace ParticleShader { - GLuint SimpleSimulationShader::Program; - GLuint SimpleSimulationShader::attrib_position; - GLuint SimpleSimulationShader::attrib_velocity; - GLuint SimpleSimulationShader::attrib_lifetime; - GLuint SimpleSimulationShader::attrib_initial_position; - GLuint SimpleSimulationShader::attrib_initial_velocity; - GLuint SimpleSimulationShader::attrib_initial_lifetime; - GLuint SimpleSimulationShader::attrib_size; - GLuint SimpleSimulationShader::attrib_initial_size; - GLuint SimpleSimulationShader::uniform_sourcematrix; - GLuint SimpleSimulationShader::uniform_dt; - GLuint SimpleSimulationShader::uniform_level; - GLuint SimpleSimulationShader::uniform_size_increase_factor; + GLuint SimpleSimulationShader::Program; + GLuint SimpleSimulationShader::attrib_position; + GLuint SimpleSimulationShader::attrib_velocity; + GLuint SimpleSimulationShader::attrib_lifetime; + GLuint SimpleSimulationShader::attrib_initial_position; + GLuint SimpleSimulationShader::attrib_initial_velocity; + GLuint SimpleSimulationShader::attrib_initial_lifetime; + GLuint SimpleSimulationShader::attrib_size; + GLuint SimpleSimulationShader::attrib_initial_size; + GLuint SimpleSimulationShader::uniform_sourcematrix; + GLuint SimpleSimulationShader::uniform_dt; + GLuint SimpleSimulationShader::uniform_level; + GLuint SimpleSimulationShader::uniform_size_increase_factor; - void SimpleSimulationShader::init() - { - const char *varyings[] = { - "new_particle_position", - "new_lifetime", - "new_particle_velocity", - "new_size", - }; - Program = LoadTFBProgram(file_manager->getAsset("shaders/pointemitter.vert").c_str(), varyings, 4); + void SimpleSimulationShader::init() + { + const char *varyings[] = { + "new_particle_position", + "new_lifetime", + "new_particle_velocity", + "new_size", + }; + Program = LoadTFBProgram(file_manager->getAsset("shaders/pointemitter.vert").c_str(), varyings, 4); - uniform_dt = glGetUniformLocation(Program, "dt"); - uniform_sourcematrix = glGetUniformLocation(Program, "sourcematrix"); - uniform_level = glGetUniformLocation(Program, "level"); - uniform_size_increase_factor = glGetUniformLocation(Program, "size_increase_factor"); + uniform_dt = glGetUniformLocation(Program, "dt"); + uniform_sourcematrix = glGetUniformLocation(Program, "sourcematrix"); + uniform_level = glGetUniformLocation(Program, "level"); + uniform_size_increase_factor = glGetUniformLocation(Program, "size_increase_factor"); - attrib_position = glGetAttribLocation(Program, "particle_position"); - attrib_lifetime = glGetAttribLocation(Program, "lifetime"); - attrib_velocity = glGetAttribLocation(Program, "particle_velocity"); - attrib_size = glGetAttribLocation(Program, "size"); - attrib_initial_position = glGetAttribLocation(Program, "particle_position_initial"); - attrib_initial_lifetime = glGetAttribLocation(Program, "lifetime_initial"); - attrib_initial_velocity = glGetAttribLocation(Program, "particle_velocity_initial"); - attrib_initial_size = glGetAttribLocation(Program, "size_initial"); - } + attrib_position = glGetAttribLocation(Program, "particle_position"); + attrib_lifetime = glGetAttribLocation(Program, "lifetime"); + attrib_velocity = glGetAttribLocation(Program, "particle_velocity"); + attrib_size = glGetAttribLocation(Program, "size"); + attrib_initial_position = glGetAttribLocation(Program, "particle_position_initial"); + attrib_initial_lifetime = glGetAttribLocation(Program, "lifetime_initial"); + attrib_initial_velocity = glGetAttribLocation(Program, "particle_velocity_initial"); + attrib_initial_size = glGetAttribLocation(Program, "size_initial"); + } - GLuint HeightmapSimulationShader::Program; - GLuint HeightmapSimulationShader::attrib_position; - GLuint HeightmapSimulationShader::attrib_velocity; - GLuint HeightmapSimulationShader::attrib_lifetime; - GLuint HeightmapSimulationShader::attrib_initial_position; - GLuint HeightmapSimulationShader::attrib_initial_velocity; - GLuint HeightmapSimulationShader::attrib_initial_lifetime; - GLuint HeightmapSimulationShader::attrib_size; - GLuint HeightmapSimulationShader::attrib_initial_size; - GLuint HeightmapSimulationShader::uniform_sourcematrix; - GLuint HeightmapSimulationShader::uniform_dt; - GLuint HeightmapSimulationShader::uniform_level; - GLuint HeightmapSimulationShader::uniform_size_increase_factor; - GLuint HeightmapSimulationShader::uniform_track_x; - GLuint HeightmapSimulationShader::uniform_track_z; - GLuint HeightmapSimulationShader::uniform_track_x_len; - GLuint HeightmapSimulationShader::uniform_track_z_len; - GLuint HeightmapSimulationShader::uniform_heightmap; + GLuint HeightmapSimulationShader::Program; + GLuint HeightmapSimulationShader::attrib_position; + GLuint HeightmapSimulationShader::attrib_velocity; + GLuint HeightmapSimulationShader::attrib_lifetime; + GLuint HeightmapSimulationShader::attrib_initial_position; + GLuint HeightmapSimulationShader::attrib_initial_velocity; + GLuint HeightmapSimulationShader::attrib_initial_lifetime; + GLuint HeightmapSimulationShader::attrib_size; + GLuint HeightmapSimulationShader::attrib_initial_size; + GLuint HeightmapSimulationShader::uniform_sourcematrix; + GLuint HeightmapSimulationShader::uniform_dt; + GLuint HeightmapSimulationShader::uniform_level; + GLuint HeightmapSimulationShader::uniform_size_increase_factor; + GLuint HeightmapSimulationShader::uniform_track_x; + GLuint HeightmapSimulationShader::uniform_track_z; + GLuint HeightmapSimulationShader::uniform_track_x_len; + GLuint HeightmapSimulationShader::uniform_track_z_len; + GLuint HeightmapSimulationShader::uniform_heightmap; - void HeightmapSimulationShader::init() - { - const char *varyings[] = { - "new_particle_position", - "new_lifetime", - "new_particle_velocity", - "new_size", - }; - Program = LoadTFBProgram(file_manager->getAsset("shaders/particlesimheightmap.vert").c_str(), varyings, 4); + void HeightmapSimulationShader::init() + { + const char *varyings[] = { + "new_particle_position", + "new_lifetime", + "new_particle_velocity", + "new_size", + }; + Program = LoadTFBProgram(file_manager->getAsset("shaders/particlesimheightmap.vert").c_str(), varyings, 4); - uniform_dt = glGetUniformLocation(Program, "dt"); - uniform_sourcematrix = glGetUniformLocation(Program, "sourcematrix"); - uniform_level = glGetUniformLocation(Program, "level"); - uniform_size_increase_factor = glGetUniformLocation(Program, "size_increase_factor"); + uniform_dt = glGetUniformLocation(Program, "dt"); + uniform_sourcematrix = glGetUniformLocation(Program, "sourcematrix"); + uniform_level = glGetUniformLocation(Program, "level"); + uniform_size_increase_factor = glGetUniformLocation(Program, "size_increase_factor"); - attrib_position = glGetAttribLocation(Program, "particle_position"); - attrib_lifetime = glGetAttribLocation(Program, "lifetime"); - attrib_velocity = glGetAttribLocation(Program, "particle_velocity"); - attrib_size = glGetAttribLocation(Program, "size"); - attrib_initial_position = glGetAttribLocation(Program, "particle_position_initial"); - attrib_initial_lifetime = glGetAttribLocation(Program, "lifetime_initial"); - attrib_initial_velocity = glGetAttribLocation(Program, "particle_velocity_initial"); - attrib_initial_size = glGetAttribLocation(Program, "size_initial"); + attrib_position = glGetAttribLocation(Program, "particle_position"); + attrib_lifetime = glGetAttribLocation(Program, "lifetime"); + attrib_velocity = glGetAttribLocation(Program, "particle_velocity"); + attrib_size = glGetAttribLocation(Program, "size"); + attrib_initial_position = glGetAttribLocation(Program, "particle_position_initial"); + attrib_initial_lifetime = glGetAttribLocation(Program, "lifetime_initial"); + attrib_initial_velocity = glGetAttribLocation(Program, "particle_velocity_initial"); + attrib_initial_size = glGetAttribLocation(Program, "size_initial"); - uniform_heightmap = glGetUniformLocation(Program, "heightmap"); - uniform_track_x = glGetUniformLocation(Program, "track_x"); - uniform_track_x_len = glGetUniformLocation(Program, "track_x_len"); - uniform_track_z = glGetUniformLocation(Program, "track_z"); - uniform_track_z_len = glGetUniformLocation(Program, "track_z_len"); - } + uniform_heightmap = glGetUniformLocation(Program, "heightmap"); + uniform_track_x = glGetUniformLocation(Program, "track_x"); + uniform_track_x_len = glGetUniformLocation(Program, "track_x_len"); + uniform_track_z = glGetUniformLocation(Program, "track_z"); + uniform_track_z_len = glGetUniformLocation(Program, "track_z_len"); + } - GLuint SimpleParticleRender::Program; - GLuint SimpleParticleRender::attrib_pos; - GLuint SimpleParticleRender::attrib_lf; - GLuint SimpleParticleRender::attrib_quadcorner; - GLuint SimpleParticleRender::attrib_texcoord; - GLuint SimpleParticleRender::attrib_sz; - GLuint SimpleParticleRender::uniform_matrix; - GLuint SimpleParticleRender::uniform_viewmatrix; - GLuint SimpleParticleRender::uniform_tex; - GLuint SimpleParticleRender::uniform_dtex; - GLuint SimpleParticleRender::uniform_screen; - GLuint SimpleParticleRender::uniform_invproj; + GLuint SimpleParticleRender::Program; + GLuint SimpleParticleRender::attrib_pos; + GLuint SimpleParticleRender::attrib_lf; + GLuint SimpleParticleRender::attrib_quadcorner; + GLuint SimpleParticleRender::attrib_texcoord; + GLuint SimpleParticleRender::attrib_sz; + GLuint SimpleParticleRender::uniform_matrix; + GLuint SimpleParticleRender::uniform_viewmatrix; + GLuint SimpleParticleRender::uniform_tex; + GLuint SimpleParticleRender::uniform_dtex; + GLuint SimpleParticleRender::uniform_screen; + GLuint SimpleParticleRender::uniform_invproj; GLuint SimpleParticleRender::uniform_color_from; GLuint SimpleParticleRender::uniform_color_to; - void SimpleParticleRender::init() - { + void SimpleParticleRender::init() + { Program = LoadProgram( GL_VERTEX_SHADER, file_manager->getAsset("shaders/particle.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/particle.frag").c_str()); - attrib_pos = glGetAttribLocation(Program, "position"); - attrib_sz = glGetAttribLocation(Program, "size"); - attrib_lf = glGetAttribLocation(Program, "lifetime"); - attrib_quadcorner = glGetAttribLocation(Program, "quadcorner"); - attrib_texcoord = glGetAttribLocation(Program, "texcoord"); + attrib_pos = glGetAttribLocation(Program, "position"); + attrib_sz = glGetAttribLocation(Program, "size"); + attrib_lf = glGetAttribLocation(Program, "lifetime"); + attrib_quadcorner = glGetAttribLocation(Program, "quadcorner"); + attrib_texcoord = glGetAttribLocation(Program, "texcoord"); - uniform_matrix = glGetUniformLocation(Program, "ProjectionMatrix"); - uniform_viewmatrix = glGetUniformLocation(Program, "ViewMatrix"); - uniform_tex = glGetUniformLocation(Program, "tex"); - uniform_invproj = glGetUniformLocation(Program, "invproj"); - uniform_screen = glGetUniformLocation(Program, "screen"); - uniform_dtex = glGetUniformLocation(Program, "dtex"); + uniform_matrix = glGetUniformLocation(Program, "ProjectionMatrix"); + uniform_viewmatrix = glGetUniformLocation(Program, "ViewMatrix"); + uniform_tex = glGetUniformLocation(Program, "tex"); + uniform_invproj = glGetUniformLocation(Program, "invproj"); + uniform_screen = glGetUniformLocation(Program, "screen"); + uniform_dtex = glGetUniformLocation(Program, "dtex"); uniform_color_from = glGetUniformLocation(Program, "color_from"); assert(uniform_color_from != -1); uniform_color_to = glGetUniformLocation(Program, "color_to"); assert(uniform_color_to != -1); - } + } - void SimpleParticleRender::setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, + void SimpleParticleRender::setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex, unsigned TU_dtex, const ParticleSystemProxy* particle_system) - { - glUniformMatrix4fv(uniform_invproj, 1, GL_FALSE, InvProjMatrix.pointer()); - glUniform2f(uniform_screen, width, height); - glUniformMatrix4fv(uniform_matrix, 1, GL_FALSE, irr_driver->getProjMatrix().pointer()); - glUniformMatrix4fv(uniform_viewmatrix, 1, GL_FALSE, irr_driver->getViewMatrix().pointer()); - glUniform1i(uniform_tex, TU_tex); - glUniform1i(uniform_dtex, TU_dtex); + { + glUniformMatrix4fv(uniform_invproj, 1, GL_FALSE, InvProjMatrix.pointer()); + glUniform2f(uniform_screen, width, height); + glUniformMatrix4fv(uniform_matrix, 1, GL_FALSE, irr_driver->getProjMatrix().pointer()); + glUniformMatrix4fv(uniform_viewmatrix, 1, GL_FALSE, irr_driver->getViewMatrix().pointer()); + glUniform1i(uniform_tex, TU_tex); + glUniform1i(uniform_dtex, TU_dtex); const float* color_from = particle_system->getColorFrom(); const float* color_to = particle_system->getColorTo(); glUniform3f(uniform_color_from, color_from[0], color_from[1], color_from[2]); glUniform3f(uniform_color_to, color_to[0], color_to[1], color_to[2]); - } + } - GLuint FlipParticleRender::Program; - GLuint FlipParticleRender::attrib_pos; - GLuint FlipParticleRender::attrib_lf; - GLuint FlipParticleRender::attrib_quadcorner; - GLuint FlipParticleRender::attrib_texcoord; - GLuint FlipParticleRender::attrib_sz; - GLuint FlipParticleRender::attrib_rotationvec; - GLuint FlipParticleRender::attrib_anglespeed; - GLuint FlipParticleRender::uniform_matrix; - GLuint FlipParticleRender::uniform_viewmatrix; - GLuint FlipParticleRender::uniform_tex; - GLuint FlipParticleRender::uniform_dtex; - GLuint FlipParticleRender::uniform_screen; - GLuint FlipParticleRender::uniform_invproj; + GLuint FlipParticleRender::Program; + GLuint FlipParticleRender::attrib_pos; + GLuint FlipParticleRender::attrib_lf; + GLuint FlipParticleRender::attrib_quadcorner; + GLuint FlipParticleRender::attrib_texcoord; + GLuint FlipParticleRender::attrib_sz; + GLuint FlipParticleRender::attrib_rotationvec; + GLuint FlipParticleRender::attrib_anglespeed; + GLuint FlipParticleRender::uniform_matrix; + GLuint FlipParticleRender::uniform_viewmatrix; + GLuint FlipParticleRender::uniform_tex; + GLuint FlipParticleRender::uniform_dtex; + GLuint FlipParticleRender::uniform_screen; + GLuint FlipParticleRender::uniform_invproj; - void FlipParticleRender::init() - { - Program = LoadProgram( + void FlipParticleRender::init() + { + Program = LoadProgram( GL_VERTEX_SHADER, file_manager->getAsset("shaders/flipparticle.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/particle.frag").c_str()); - attrib_pos = glGetAttribLocation(Program, "position"); - attrib_sz = glGetAttribLocation(Program, "size"); - attrib_lf = glGetAttribLocation(Program, "lifetime"); - attrib_quadcorner = glGetAttribLocation(Program, "quadcorner"); - attrib_texcoord = glGetAttribLocation(Program, "texcoord"); - attrib_anglespeed = glGetAttribLocation(Program, "anglespeed"); - attrib_rotationvec = glGetAttribLocation(Program, "rotationvec"); + attrib_pos = glGetAttribLocation(Program, "position"); + attrib_sz = glGetAttribLocation(Program, "size"); + attrib_lf = glGetAttribLocation(Program, "lifetime"); + attrib_quadcorner = glGetAttribLocation(Program, "quadcorner"); + attrib_texcoord = glGetAttribLocation(Program, "texcoord"); + attrib_anglespeed = glGetAttribLocation(Program, "anglespeed"); + attrib_rotationvec = glGetAttribLocation(Program, "rotationvec"); - uniform_matrix = glGetUniformLocation(Program, "ProjectionMatrix"); - uniform_viewmatrix = glGetUniformLocation(Program, "ViewMatrix"); - uniform_tex = glGetUniformLocation(Program, "tex"); - uniform_invproj = glGetUniformLocation(Program, "invproj"); - uniform_screen = glGetUniformLocation(Program, "screen"); - uniform_dtex = glGetUniformLocation(Program, "dtex"); - } + uniform_matrix = glGetUniformLocation(Program, "ProjectionMatrix"); + uniform_viewmatrix = glGetUniformLocation(Program, "ViewMatrix"); + uniform_tex = glGetUniformLocation(Program, "tex"); + uniform_invproj = glGetUniformLocation(Program, "invproj"); + uniform_screen = glGetUniformLocation(Program, "screen"); + uniform_dtex = glGetUniformLocation(Program, "dtex"); + } - void FlipParticleRender::setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex, unsigned TU_dtex) - { - glUniformMatrix4fv(uniform_invproj, 1, GL_FALSE, InvProjMatrix.pointer()); - glUniform2f(uniform_screen, width, height); - glUniformMatrix4fv(uniform_matrix, 1, GL_FALSE, irr_driver->getProjMatrix().pointer()); - glUniformMatrix4fv(uniform_viewmatrix, 1, GL_FALSE, irr_driver->getViewMatrix().pointer()); - glUniform1i(uniform_tex, TU_tex); - glUniform1i(uniform_dtex, TU_dtex); - } + void FlipParticleRender::setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex, unsigned TU_dtex) + { + glUniformMatrix4fv(uniform_invproj, 1, GL_FALSE, InvProjMatrix.pointer()); + glUniform2f(uniform_screen, width, height); + glUniformMatrix4fv(uniform_matrix, 1, GL_FALSE, irr_driver->getProjMatrix().pointer()); + glUniformMatrix4fv(uniform_viewmatrix, 1, GL_FALSE, irr_driver->getViewMatrix().pointer()); + glUniform1i(uniform_tex, TU_tex); + glUniform1i(uniform_dtex, TU_dtex); + } } static GLuint createVAO(GLuint Program) { - GLuint vao; - glGenVertexArrays(1, &vao); - glBindVertexArray(vao); - GLuint attrib_position = glGetAttribLocation(Program, "Position"); - GLuint attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); - glBindBuffer(GL_ARRAY_BUFFER, quad_vbo); - glEnableVertexAttribArray(attrib_position); - glEnableVertexAttribArray(attrib_texcoord); - glVertexAttribPointer(attrib_position, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0); - glVertexAttribPointer(attrib_texcoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid*)(2 * sizeof(float))); - glBindVertexArray(0); - return vao; + GLuint vao; + glGenVertexArrays(1, &vao); + glBindVertexArray(vao); + GLuint attrib_position = glGetAttribLocation(Program, "Position"); + GLuint attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); + glBindBuffer(GL_ARRAY_BUFFER, quad_vbo); + glEnableVertexAttribArray(attrib_position); + glEnableVertexAttribArray(attrib_texcoord); + glVertexAttribPointer(attrib_position, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0); + glVertexAttribPointer(attrib_texcoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid*)(2 * sizeof(float))); + glBindVertexArray(0); + return vao; } namespace FullScreenShader { - GLuint BloomShader::Program; - GLuint BloomShader::uniform_texture; - GLuint BloomShader::uniform_low; - GLuint BloomShader::vao; - void BloomShader::init() - { - Program = LoadProgram( + GLuint BloomShader::Program; + GLuint BloomShader::uniform_texture; + GLuint BloomShader::uniform_low; + GLuint BloomShader::vao; + void BloomShader::init() + { + Program = LoadProgram( GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/bloom.frag").c_str()); - uniform_texture = glGetUniformLocation(Program, "tex"); - uniform_low = glGetUniformLocation(Program, "low"); - vao = createVAO(Program); - } + uniform_texture = glGetUniformLocation(Program, "tex"); + uniform_low = glGetUniformLocation(Program, "low"); + vao = createVAO(Program); + } - GLuint BloomBlendShader::Program; - GLuint BloomBlendShader::uniform_texture; - GLuint BloomBlendShader::uniform_low; - GLuint BloomBlendShader::vao; - void BloomBlendShader::init() - { - Program = LoadProgram( - GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(), + GLuint BloomBlendShader::Program; + GLuint BloomBlendShader::uniform_texture; + GLuint BloomBlendShader::uniform_low; + GLuint BloomBlendShader::vao; + void BloomBlendShader::init() + { + Program = LoadProgram( + GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/bloomblend.frag").c_str()); - uniform_texture = glGetUniformLocation(Program, "tex"); - vao = createVAO(Program); - } + uniform_texture = glGetUniformLocation(Program, "tex"); + vao = createVAO(Program); + } - GLuint ColorLevelShader::Program; - GLuint ColorLevelShader::uniform_tex; - GLuint ColorLevelShader::uniform_inlevel; - GLuint ColorLevelShader::uniform_outlevel; - GLuint ColorLevelShader::vao; + GLuint ColorLevelShader::Program; + GLuint ColorLevelShader::uniform_tex; + GLuint ColorLevelShader::uniform_inlevel; + GLuint ColorLevelShader::uniform_outlevel; + GLuint ColorLevelShader::vao; GLuint ColorLevelShader::uniform_invprojm; GLuint ColorLevelShader::uniform_dtex; - void ColorLevelShader::init() - { + void ColorLevelShader::init() + { Program = LoadProgram( GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/color_levels.frag").c_str()); - uniform_tex = glGetUniformLocation(Program, "tex"); + uniform_tex = glGetUniformLocation(Program, "tex"); uniform_dtex = glGetUniformLocation(Program, "dtex"); - uniform_inlevel = glGetUniformLocation(Program, "inlevel"); - uniform_outlevel = glGetUniformLocation(Program, "outlevel"); + uniform_inlevel = glGetUniformLocation(Program, "inlevel"); + uniform_outlevel = glGetUniformLocation(Program, "outlevel"); uniform_invprojm = glGetUniformLocation(Program, "invprojm"); - vao = createVAO(Program); - } + vao = createVAO(Program); + } - GLuint SunLightShader::Program; - GLuint SunLightShader::uniform_ntex; - GLuint SunLightShader::uniform_dtex; - GLuint SunLightShader::uniform_direction; - GLuint SunLightShader::uniform_col; - GLuint SunLightShader::uniform_invproj; - GLuint SunLightShader::vao; + GLuint SunLightShader::Program; + GLuint SunLightShader::uniform_ntex; + GLuint SunLightShader::uniform_dtex; + GLuint SunLightShader::uniform_direction; + GLuint SunLightShader::uniform_col; + GLuint SunLightShader::uniform_invproj; + GLuint SunLightShader::vao; - void SunLightShader::init() - { + void SunLightShader::init() + { Program = LoadProgram( GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/decodeNormal.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/sunlight.frag").c_str()); - uniform_ntex = glGetUniformLocation(Program, "ntex"); - uniform_dtex = glGetUniformLocation(Program, "dtex"); - uniform_direction = glGetUniformLocation(Program, "direction"); - uniform_col = glGetUniformLocation(Program, "col"); - uniform_invproj = glGetUniformLocation(Program, "invproj"); - vao = createVAO(Program); - } + uniform_ntex = glGetUniformLocation(Program, "ntex"); + uniform_dtex = glGetUniformLocation(Program, "dtex"); + uniform_direction = glGetUniformLocation(Program, "direction"); + uniform_col = glGetUniformLocation(Program, "col"); + uniform_invproj = glGetUniformLocation(Program, "invproj"); + vao = createVAO(Program); + } - void SunLightShader::setUniforms(const core::vector3df &direction, const core::matrix4 &InvProjMatrix, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex) - { - glUniformMatrix4fv(uniform_invproj, 1, GL_FALSE, InvProjMatrix.pointer()); - glUniform3f(uniform_direction, direction.X, direction.Y, direction.Z); - glUniform3f(uniform_col, r, g, b); - glUniform1i(uniform_ntex, TU_ntex); - glUniform1i(uniform_dtex, TU_dtex); - } + void SunLightShader::setUniforms(const core::vector3df &direction, const core::matrix4 &InvProjMatrix, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex) + { + glUniformMatrix4fv(uniform_invproj, 1, GL_FALSE, InvProjMatrix.pointer()); + glUniform3f(uniform_direction, direction.X, direction.Y, direction.Z); + glUniform3f(uniform_col, r, g, b); + glUniform1i(uniform_ntex, TU_ntex); + glUniform1i(uniform_dtex, TU_dtex); + } GLuint DiffuseEnvMapShader::Program; GLuint DiffuseEnvMapShader::uniform_ntex; @@ -1740,61 +1740,61 @@ namespace FullScreenShader delete[] tmp; } - GLuint Gaussian6HBlurShader::Program; - GLuint Gaussian6HBlurShader::uniform_tex; - GLuint Gaussian6HBlurShader::uniform_pixel; - GLuint Gaussian6HBlurShader::vao; - void Gaussian6HBlurShader::init() - { - Program = LoadProgram( + GLuint Gaussian6HBlurShader::Program; + GLuint Gaussian6HBlurShader::uniform_tex; + GLuint Gaussian6HBlurShader::uniform_pixel; + GLuint Gaussian6HBlurShader::vao; + void Gaussian6HBlurShader::init() + { + Program = LoadProgram( GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/gaussian6h.frag").c_str()); - uniform_tex = glGetUniformLocation(Program, "tex"); - uniform_pixel = glGetUniformLocation(Program, "pixel"); - vao = createVAO(Program); - } + uniform_tex = glGetUniformLocation(Program, "tex"); + uniform_pixel = glGetUniformLocation(Program, "pixel"); + vao = createVAO(Program); + } - GLuint Gaussian3HBlurShader::Program; - GLuint Gaussian3HBlurShader::uniform_tex; - GLuint Gaussian3HBlurShader::uniform_pixel; - GLuint Gaussian3HBlurShader::vao; - void Gaussian3HBlurShader::init() - { - Program = LoadProgram( + GLuint Gaussian3HBlurShader::Program; + GLuint Gaussian3HBlurShader::uniform_tex; + GLuint Gaussian3HBlurShader::uniform_pixel; + GLuint Gaussian3HBlurShader::vao; + void Gaussian3HBlurShader::init() + { + Program = LoadProgram( GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/gaussian3h.frag").c_str()); - uniform_tex = glGetUniformLocation(Program, "tex"); - uniform_pixel = glGetUniformLocation(Program, "pixel"); - vao = createVAO(Program); - } + uniform_tex = glGetUniformLocation(Program, "tex"); + uniform_pixel = glGetUniformLocation(Program, "pixel"); + vao = createVAO(Program); + } - GLuint Gaussian6VBlurShader::Program; - GLuint Gaussian6VBlurShader::uniform_tex; - GLuint Gaussian6VBlurShader::uniform_pixel; - GLuint Gaussian6VBlurShader::vao; - void Gaussian6VBlurShader::init() - { - Program = LoadProgram( + GLuint Gaussian6VBlurShader::Program; + GLuint Gaussian6VBlurShader::uniform_tex; + GLuint Gaussian6VBlurShader::uniform_pixel; + GLuint Gaussian6VBlurShader::vao; + void Gaussian6VBlurShader::init() + { + Program = LoadProgram( GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/gaussian6v.frag").c_str()); - uniform_tex = glGetUniformLocation(Program, "tex"); - uniform_pixel = glGetUniformLocation(Program, "pixel"); - vao = createVAO(Program); - } + uniform_tex = glGetUniformLocation(Program, "tex"); + uniform_pixel = glGetUniformLocation(Program, "pixel"); + vao = createVAO(Program); + } - GLuint Gaussian3VBlurShader::Program; - GLuint Gaussian3VBlurShader::uniform_tex; - GLuint Gaussian3VBlurShader::uniform_pixel; - GLuint Gaussian3VBlurShader::vao; - void Gaussian3VBlurShader::init() - { - Program = LoadProgram( + GLuint Gaussian3VBlurShader::Program; + GLuint Gaussian3VBlurShader::uniform_tex; + GLuint Gaussian3VBlurShader::uniform_pixel; + GLuint Gaussian3VBlurShader::vao; + void Gaussian3VBlurShader::init() + { + Program = LoadProgram( GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/gaussian3v.frag").c_str()); - uniform_tex = glGetUniformLocation(Program, "tex"); - uniform_pixel = glGetUniformLocation(Program, "pixel"); - vao = createVAO(Program); - } + uniform_tex = glGetUniformLocation(Program, "tex"); + uniform_pixel = glGetUniformLocation(Program, "pixel"); + vao = createVAO(Program); + } GLuint PenumbraHShader::Program; GLuint PenumbraHShader::uniform_tex; @@ -1844,7 +1844,7 @@ namespace FullScreenShader void ShadowGenShader::init() { Program = LoadProgram( - GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(), + GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/shadowgen.frag").c_str()); uniform_halft = glGetUniformLocation(Program, "halft"); uniform_quarter = glGetUniformLocation(Program, "quarter"); @@ -1859,217 +1859,217 @@ namespace FullScreenShader glUniform1i(uniform_height, TU_height); } - GLuint PassThroughShader::Program; - GLuint PassThroughShader::uniform_texture; - GLuint PassThroughShader::vao; - void PassThroughShader::init() - { - Program = LoadProgram( + GLuint PassThroughShader::Program; + GLuint PassThroughShader::uniform_texture; + GLuint PassThroughShader::vao; + void PassThroughShader::init() + { + Program = LoadProgram( GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/texturedquad.frag").c_str()); - uniform_texture = glGetUniformLocation(Program, "texture"); - vao = createVAO(Program); - } + uniform_texture = glGetUniformLocation(Program, "texture"); + vao = createVAO(Program); + } - GLuint GlowShader::Program; - GLuint GlowShader::uniform_tex; - GLuint GlowShader::vao; - void GlowShader::init() - { - Program = LoadProgram( + GLuint GlowShader::Program; + GLuint GlowShader::uniform_tex; + GLuint GlowShader::vao; + void GlowShader::init() + { + Program = LoadProgram( GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/glow.frag").c_str()); - uniform_tex = glGetUniformLocation(Program, "tex"); - vao = createVAO(Program); - } + uniform_tex = glGetUniformLocation(Program, "tex"); + vao = createVAO(Program); + } - GLuint SSAOShader::Program; - GLuint SSAOShader::uniform_ntex; - GLuint SSAOShader::uniform_dtex; - GLuint SSAOShader::uniform_noise_texture; - GLuint SSAOShader::uniform_invprojm; - GLuint SSAOShader::uniform_projm; - GLuint SSAOShader::uniform_samplePoints; - GLuint SSAOShader::vao; - float SSAOShader::SSAOSamples[64]; + GLuint SSAOShader::Program; + GLuint SSAOShader::uniform_ntex; + GLuint SSAOShader::uniform_dtex; + GLuint SSAOShader::uniform_noise_texture; + GLuint SSAOShader::uniform_invprojm; + GLuint SSAOShader::uniform_projm; + GLuint SSAOShader::uniform_samplePoints; + GLuint SSAOShader::vao; + float SSAOShader::SSAOSamples[64]; - void SSAOShader::init() - { - Program = LoadProgram( + void SSAOShader::init() + { + Program = LoadProgram( GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/decodeNormal.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/ssao.frag").c_str()); - uniform_ntex = glGetUniformLocation(Program, "ntex"); - uniform_dtex = glGetUniformLocation(Program, "dtex"); - uniform_noise_texture = glGetUniformLocation(Program, "noise_texture"); - uniform_invprojm = glGetUniformLocation(Program, "invprojm"); - uniform_projm = glGetUniformLocation(Program, "projm"); - uniform_samplePoints = glGetUniformLocation(Program, "samplePoints[0]"); - vao = createVAO(Program); + uniform_ntex = glGetUniformLocation(Program, "ntex"); + uniform_dtex = glGetUniformLocation(Program, "dtex"); + uniform_noise_texture = glGetUniformLocation(Program, "noise_texture"); + uniform_invprojm = glGetUniformLocation(Program, "invprojm"); + uniform_projm = glGetUniformLocation(Program, "projm"); + uniform_samplePoints = glGetUniformLocation(Program, "samplePoints[0]"); + vao = createVAO(Program); - // SSAOSamples[4 * i] and SSAOSamples[4 * i + 1] can be negative + // SSAOSamples[4 * i] and SSAOSamples[4 * i + 1] can be negative - SSAOSamples[0] = 0.135061f; - SSAOSamples[1] = 0.207948f; - SSAOSamples[2] = 0.968770f; - SSAOSamples[3] = 0.983032f; + SSAOSamples[0] = 0.135061f; + SSAOSamples[1] = 0.207948f; + SSAOSamples[2] = 0.968770f; + SSAOSamples[3] = 0.983032f; - SSAOSamples[4] = 0.273456f; - SSAOSamples[5] = -0.805390f; - SSAOSamples[6] = 0.525898f; - SSAOSamples[7] = 0.942808f; + SSAOSamples[4] = 0.273456f; + SSAOSamples[5] = -0.805390f; + SSAOSamples[6] = 0.525898f; + SSAOSamples[7] = 0.942808f; - SSAOSamples[8] = 0.443450f; - SSAOSamples[9] = -0.803786f; - SSAOSamples[10] = 0.396585f; - SSAOSamples[11] = 0.007996f; + SSAOSamples[8] = 0.443450f; + SSAOSamples[9] = -0.803786f; + SSAOSamples[10] = 0.396585f; + SSAOSamples[11] = 0.007996f; - SSAOSamples[12] = 0.742420f; - SSAOSamples[13] = -0.620072f; - SSAOSamples[14] = 0.253621f; - SSAOSamples[15] = 0.284829f; + SSAOSamples[12] = 0.742420f; + SSAOSamples[13] = -0.620072f; + SSAOSamples[14] = 0.253621f; + SSAOSamples[15] = 0.284829f; - SSAOSamples[16] = 0.892464f; - SSAOSamples[17] = 0.046221f; - SSAOSamples[18] = 0.448744f; - SSAOSamples[19] = 0.753655f; + SSAOSamples[16] = 0.892464f; + SSAOSamples[17] = 0.046221f; + SSAOSamples[18] = 0.448744f; + SSAOSamples[19] = 0.753655f; - SSAOSamples[20] = 0.830350f; - SSAOSamples[21] = -0.043593f; - SSAOSamples[22] = 0.555535f; - SSAOSamples[23] = 0.357463f; + SSAOSamples[20] = 0.830350f; + SSAOSamples[21] = -0.043593f; + SSAOSamples[22] = 0.555535f; + SSAOSamples[23] = 0.357463f; - SSAOSamples[24] = -0.600612f; - SSAOSamples[25] = -0.536421f; - SSAOSamples[26] = 0.592889f; - SSAOSamples[27] = 0.670583f; + SSAOSamples[24] = -0.600612f; + SSAOSamples[25] = -0.536421f; + SSAOSamples[26] = 0.592889f; + SSAOSamples[27] = 0.670583f; - SSAOSamples[28] = -0.280658f; - SSAOSamples[29] = 0.674894f; - SSAOSamples[30] = 0.682458f; - SSAOSamples[31] = 0.553362f; + SSAOSamples[28] = -0.280658f; + SSAOSamples[29] = 0.674894f; + SSAOSamples[30] = 0.682458f; + SSAOSamples[31] = 0.553362f; - SSAOSamples[32] = -0.654493f; - SSAOSamples[33] = -0.140866f; - SSAOSamples[34] = 0.742830f; - SSAOSamples[35] = 0.699820f; + SSAOSamples[32] = -0.654493f; + SSAOSamples[33] = -0.140866f; + SSAOSamples[34] = 0.742830f; + SSAOSamples[35] = 0.699820f; - SSAOSamples[36] = 0.114730f; - SSAOSamples[37] = 0.873130f; - SSAOSamples[38] = 0.473794f; - SSAOSamples[39] = 0.483901f; + SSAOSamples[36] = 0.114730f; + SSAOSamples[37] = 0.873130f; + SSAOSamples[38] = 0.473794f; + SSAOSamples[39] = 0.483901f; - SSAOSamples[40] = 0.699167f; - SSAOSamples[41] = 0.632210f; - SSAOSamples[42] = 0.333879f; - SSAOSamples[43] = 0.010956f; + SSAOSamples[40] = 0.699167f; + SSAOSamples[41] = 0.632210f; + SSAOSamples[42] = 0.333879f; + SSAOSamples[43] = 0.010956f; - SSAOSamples[44] = 0.904603f; - SSAOSamples[45] = 0.393410f; - SSAOSamples[46] = 0.164080f; - SSAOSamples[47] = 0.780297f; + SSAOSamples[44] = 0.904603f; + SSAOSamples[45] = 0.393410f; + SSAOSamples[46] = 0.164080f; + SSAOSamples[47] = 0.780297f; - SSAOSamples[48] = 0.631662f; - SSAOSamples[49] = -0.405195f; - SSAOSamples[50] = 0.660924f; - SSAOSamples[51] = 0.865596f; + SSAOSamples[48] = 0.631662f; + SSAOSamples[49] = -0.405195f; + SSAOSamples[50] = 0.660924f; + SSAOSamples[51] = 0.865596f; - SSAOSamples[52] = -0.195668f; - SSAOSamples[53] = 0.629185f; - SSAOSamples[54] = 0.752223f; - SSAOSamples[55] = 0.019013f; + SSAOSamples[52] = -0.195668f; + SSAOSamples[53] = 0.629185f; + SSAOSamples[54] = 0.752223f; + SSAOSamples[55] = 0.019013f; - SSAOSamples[56] = -0.511316f; - SSAOSamples[57] = 0.635504f; - SSAOSamples[58] = 0.578524f; - SSAOSamples[59] = 0.605457f; + SSAOSamples[56] = -0.511316f; + SSAOSamples[57] = 0.635504f; + SSAOSamples[58] = 0.578524f; + SSAOSamples[59] = 0.605457f; - SSAOSamples[60] = -0.898843f; - SSAOSamples[61] = 0.067382f; - SSAOSamples[62] = 0.433061f; - SSAOSamples[63] = 0.772942f; + SSAOSamples[60] = -0.898843f; + SSAOSamples[61] = 0.067382f; + SSAOSamples[62] = 0.433061f; + SSAOSamples[63] = 0.772942f; - // Generate another random distribution, if needed -/* for (unsigned i = 0; i < 16; i++) { - // Use double to avoid denorm and get a true uniform distribution - // Generate z component between [0.1; 1] to avoid being too close from surface - double z = rand(); - z /= RAND_MAX; - z = 0.1 + 0.9 * z; + // Generate another random distribution, if needed +/* for (unsigned i = 0; i < 16; i++) { + // Use double to avoid denorm and get a true uniform distribution + // Generate z component between [0.1; 1] to avoid being too close from surface + double z = rand(); + z /= RAND_MAX; + z = 0.1 + 0.9 * z; - // Now generate x,y on the unit circle - double x = rand(); - x /= RAND_MAX; - x = 2 * x - 1; - double y = rand(); - y /= RAND_MAX; - y = 2 * y - 1; - double xynorm = sqrt(x * x + y * y); - x /= xynorm; - y /= xynorm; - // Now resize x,y so that norm(x,y,z) is one - x *= sqrt(1. - z * z); - y *= sqrt(1. - z * z); + // Now generate x,y on the unit circle + double x = rand(); + x /= RAND_MAX; + x = 2 * x - 1; + double y = rand(); + y /= RAND_MAX; + y = 2 * y - 1; + double xynorm = sqrt(x * x + y * y); + x /= xynorm; + y /= xynorm; + // Now resize x,y so that norm(x,y,z) is one + x *= sqrt(1. - z * z); + y *= sqrt(1. - z * z); - // Norm factor - double w = rand(); - w /= RAND_MAX; - SSAOSamples[4 * i] = (float)x; - SSAOSamples[4 * i + 1] = (float)y; - SSAOSamples[4 * i + 2] = (float)z; - SSAOSamples[4 * i + 3] = (float)w; - }*/ - } + // Norm factor + double w = rand(); + w /= RAND_MAX; + SSAOSamples[4 * i] = (float)x; + SSAOSamples[4 * i + 1] = (float)y; + SSAOSamples[4 * i + 2] = (float)z; + SSAOSamples[4 * i + 3] = (float)w; + }*/ + } - void SSAOShader::setUniforms(const core::matrix4& projm, const core::matrix4 &invprojm, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_noise) - { - glUniformMatrix4fv(FullScreenShader::SSAOShader::uniform_invprojm, 1, GL_FALSE, invprojm.pointer()); - glUniformMatrix4fv(FullScreenShader::SSAOShader::uniform_projm, 1, GL_FALSE, projm.pointer()); - glUniform4fv(FullScreenShader::SSAOShader::uniform_samplePoints, 16, FullScreenShader::SSAOShader::SSAOSamples); + void SSAOShader::setUniforms(const core::matrix4& projm, const core::matrix4 &invprojm, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_noise) + { + glUniformMatrix4fv(FullScreenShader::SSAOShader::uniform_invprojm, 1, GL_FALSE, invprojm.pointer()); + glUniformMatrix4fv(FullScreenShader::SSAOShader::uniform_projm, 1, GL_FALSE, projm.pointer()); + glUniform4fv(FullScreenShader::SSAOShader::uniform_samplePoints, 16, FullScreenShader::SSAOShader::SSAOSamples); - glUniform1i(FullScreenShader::SSAOShader::uniform_ntex, TU_ntex); - glUniform1i(FullScreenShader::SSAOShader::uniform_dtex, TU_dtex); - glUniform1i(FullScreenShader::SSAOShader::uniform_noise_texture, TU_noise); - } + glUniform1i(FullScreenShader::SSAOShader::uniform_ntex, TU_ntex); + glUniform1i(FullScreenShader::SSAOShader::uniform_dtex, TU_dtex); + glUniform1i(FullScreenShader::SSAOShader::uniform_noise_texture, TU_noise); + } - GLuint FogShader::Program; - GLuint FogShader::uniform_tex; - GLuint FogShader::uniform_fogmax; - GLuint FogShader::uniform_startH; - GLuint FogShader::uniform_endH; - GLuint FogShader::uniform_start; - GLuint FogShader::uniform_end; - GLuint FogShader::uniform_col; - GLuint FogShader::uniform_ipvmat; - GLuint FogShader::vao; + GLuint FogShader::Program; + GLuint FogShader::uniform_tex; + GLuint FogShader::uniform_fogmax; + GLuint FogShader::uniform_startH; + GLuint FogShader::uniform_endH; + GLuint FogShader::uniform_start; + GLuint FogShader::uniform_end; + GLuint FogShader::uniform_col; + GLuint FogShader::uniform_ipvmat; + GLuint FogShader::vao; - void FogShader::init() - { - Program = LoadProgram( + void FogShader::init() + { + Program = LoadProgram( GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/fog.frag").c_str()); - uniform_tex = glGetUniformLocation(Program, "tex"); - uniform_fogmax = glGetUniformLocation(Program, "fogmax"); - uniform_startH = glGetUniformLocation(Program, "startH"); - uniform_endH = glGetUniformLocation(Program, "endH"); - uniform_start = glGetUniformLocation(Program, "start"); - uniform_end = glGetUniformLocation(Program, "end"); - uniform_col = glGetUniformLocation(Program, "col"); - uniform_ipvmat = glGetUniformLocation(Program, "ipvmat"); - vao = createVAO(Program); - } + uniform_tex = glGetUniformLocation(Program, "tex"); + uniform_fogmax = glGetUniformLocation(Program, "fogmax"); + uniform_startH = glGetUniformLocation(Program, "startH"); + uniform_endH = glGetUniformLocation(Program, "endH"); + uniform_start = glGetUniformLocation(Program, "start"); + uniform_end = glGetUniformLocation(Program, "end"); + uniform_col = glGetUniformLocation(Program, "col"); + uniform_ipvmat = glGetUniformLocation(Program, "ipvmat"); + vao = createVAO(Program); + } - void FogShader::setUniforms(const core::matrix4 &ipvmat, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, unsigned TU_ntex) - { - glUniform1f(uniform_fogmax, fogmax); - glUniform1f(uniform_startH, startH); - glUniform1f(uniform_endH, endH); - glUniform1f(uniform_start, start); - glUniform1f(uniform_end, end); - glUniform3f(uniform_col, col.X, col.Y, col.Z); - glUniformMatrix4fv(uniform_ipvmat, 1, GL_FALSE, ipvmat.pointer()); - glUniform1i(uniform_tex, TU_ntex); - } + void FogShader::setUniforms(const core::matrix4 &ipvmat, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, unsigned TU_ntex) + { + glUniform1f(uniform_fogmax, fogmax); + glUniform1f(uniform_startH, startH); + glUniform1f(uniform_endH, endH); + glUniform1f(uniform_start, start); + glUniform1f(uniform_end, end); + glUniform3f(uniform_col, col.X, col.Y, col.Z); + glUniformMatrix4fv(uniform_ipvmat, 1, GL_FALSE, ipvmat.pointer()); + glUniform1i(uniform_tex, TU_ntex); + } GLuint MotionBlurShader::Program; GLuint MotionBlurShader::uniform_boost_amount; @@ -2149,47 +2149,47 @@ namespace FullScreenShader namespace UIShader { - GLuint TextureRectShader::Program; - GLuint TextureRectShader::attrib_position; - GLuint TextureRectShader::attrib_texcoord; - GLuint TextureRectShader::uniform_tex; - GLuint TextureRectShader::uniform_center; - GLuint TextureRectShader::uniform_size; - GLuint TextureRectShader::uniform_texcenter; - GLuint TextureRectShader::uniform_texsize; - GLuint TextureRectShader::vao; + GLuint TextureRectShader::Program; + GLuint TextureRectShader::attrib_position; + GLuint TextureRectShader::attrib_texcoord; + GLuint TextureRectShader::uniform_tex; + GLuint TextureRectShader::uniform_center; + GLuint TextureRectShader::uniform_size; + GLuint TextureRectShader::uniform_texcenter; + GLuint TextureRectShader::uniform_texsize; + GLuint TextureRectShader::vao; - void TextureRectShader::init() - { - Program = LoadProgram( + void TextureRectShader::init() + { + Program = LoadProgram( GL_VERTEX_SHADER, file_manager->getAsset("shaders/texturedquad.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/texturedquad.frag").c_str()); - attrib_position = glGetAttribLocation(Program, "position"); - attrib_texcoord = glGetAttribLocation(Program, "texcoord"); - uniform_tex = glGetUniformLocation(Program, "tex"); - uniform_center = glGetUniformLocation(Program, "center"); - uniform_size = glGetUniformLocation(Program, "size"); - uniform_texcenter = glGetUniformLocation(Program, "texcenter"); - uniform_texsize = glGetUniformLocation(Program, "texsize"); - glGenVertexArrays(1, &vao); - glBindVertexArray(vao); - glEnableVertexAttribArray(attrib_position); - glEnableVertexAttribArray(attrib_texcoord); - glBindBuffer(GL_ARRAY_BUFFER, quad_buffer); - glVertexAttribPointer(attrib_position, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0); - glVertexAttribPointer(attrib_texcoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid *)(2 * sizeof(float))); - glBindVertexArray(0); - } + attrib_position = glGetAttribLocation(Program, "position"); + attrib_texcoord = glGetAttribLocation(Program, "texcoord"); + uniform_tex = glGetUniformLocation(Program, "tex"); + uniform_center = glGetUniformLocation(Program, "center"); + uniform_size = glGetUniformLocation(Program, "size"); + uniform_texcenter = glGetUniformLocation(Program, "texcenter"); + uniform_texsize = glGetUniformLocation(Program, "texsize"); + glGenVertexArrays(1, &vao); + glBindVertexArray(vao); + glEnableVertexAttribArray(attrib_position); + glEnableVertexAttribArray(attrib_texcoord); + glBindBuffer(GL_ARRAY_BUFFER, quad_buffer); + glVertexAttribPointer(attrib_position, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0); + glVertexAttribPointer(attrib_texcoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid *)(2 * sizeof(float))); + glBindVertexArray(0); + } - void TextureRectShader::setUniforms(float center_pos_x, float center_pos_y, float width, float height, float tex_center_pos_x, float tex_center_pos_y, float tex_width, float tex_height, unsigned TU_tex) - { - glUniform1i(uniform_tex, TU_tex); - glUniform2f(uniform_center, center_pos_x, center_pos_y); - glUniform2f(uniform_size, width, height); - glUniform2f(uniform_texcenter, tex_center_pos_x, tex_center_pos_y); - glUniform2f(uniform_texsize, tex_width, tex_height); - } + void TextureRectShader::setUniforms(float center_pos_x, float center_pos_y, float width, float height, float tex_center_pos_x, float tex_center_pos_y, float tex_width, float tex_height, unsigned TU_tex) + { + glUniform1i(uniform_tex, TU_tex); + glUniform2f(uniform_center, center_pos_x, center_pos_y); + glUniform2f(uniform_size, width, height); + glUniform2f(uniform_texcenter, tex_center_pos_x, tex_center_pos_y); + glUniform2f(uniform_texsize, tex_width, tex_height); + } GLuint UniformColoredTextureRectShader::Program; GLuint UniformColoredTextureRectShader::attrib_position; @@ -2236,90 +2236,90 @@ namespace UIShader glUniform4i(uniform_color, color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); } - GLuint ColoredTextureRectShader::Program; - GLuint ColoredTextureRectShader::attrib_position; - GLuint ColoredTextureRectShader::attrib_texcoord; - GLuint ColoredTextureRectShader::attrib_color; - GLuint ColoredTextureRectShader::uniform_tex; - GLuint ColoredTextureRectShader::uniform_center; - GLuint ColoredTextureRectShader::uniform_size; - GLuint ColoredTextureRectShader::uniform_texcenter; - GLuint ColoredTextureRectShader::uniform_texsize; - GLuint ColoredTextureRectShader::colorvbo; - GLuint ColoredTextureRectShader::vao; + GLuint ColoredTextureRectShader::Program; + GLuint ColoredTextureRectShader::attrib_position; + GLuint ColoredTextureRectShader::attrib_texcoord; + GLuint ColoredTextureRectShader::attrib_color; + GLuint ColoredTextureRectShader::uniform_tex; + GLuint ColoredTextureRectShader::uniform_center; + GLuint ColoredTextureRectShader::uniform_size; + GLuint ColoredTextureRectShader::uniform_texcenter; + GLuint ColoredTextureRectShader::uniform_texsize; + GLuint ColoredTextureRectShader::colorvbo; + GLuint ColoredTextureRectShader::vao; - void ColoredTextureRectShader::init() - { + void ColoredTextureRectShader::init() + { Program = LoadProgram( GL_VERTEX_SHADER, file_manager->getAsset("shaders/colortexturedquad.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/colortexturedquad.frag").c_str()); - attrib_position = glGetAttribLocation(Program, "position"); - attrib_texcoord = glGetAttribLocation(Program, "texcoord"); - attrib_color = glGetAttribLocation(Program, "color"); - uniform_tex = glGetUniformLocation(Program, "tex"); - uniform_center = glGetUniformLocation(Program, "center"); - uniform_size = glGetUniformLocation(Program, "size"); - uniform_texcenter = glGetUniformLocation(Program, "texcenter"); - uniform_texsize = glGetUniformLocation(Program, "texsize"); - glGenVertexArrays(1, &vao); - glBindVertexArray(vao); - glEnableVertexAttribArray(attrib_position); - glEnableVertexAttribArray(attrib_texcoord); - glEnableVertexAttribArray(attrib_color); - glBindBuffer(GL_ARRAY_BUFFER, quad_buffer); - glVertexAttribPointer(attrib_position, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0); - glVertexAttribPointer(attrib_texcoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid *)(2 * sizeof(float))); - const unsigned quad_color[] = { - 0, 0, 0, 255, - 255, 0, 0, 255, - 0, 255, 0, 255, - 0, 0, 255, 255, - }; - glGenBuffers(1, &colorvbo); - glBindBuffer(GL_ARRAY_BUFFER, colorvbo); - glBufferData(GL_ARRAY_BUFFER, 16 * sizeof(unsigned), quad_color, GL_DYNAMIC_DRAW); - glVertexAttribIPointer(attrib_color, 4, GL_UNSIGNED_INT, 4 * sizeof(unsigned), 0); - glBindVertexArray(0); - } + attrib_position = glGetAttribLocation(Program, "position"); + attrib_texcoord = glGetAttribLocation(Program, "texcoord"); + attrib_color = glGetAttribLocation(Program, "color"); + uniform_tex = glGetUniformLocation(Program, "tex"); + uniform_center = glGetUniformLocation(Program, "center"); + uniform_size = glGetUniformLocation(Program, "size"); + uniform_texcenter = glGetUniformLocation(Program, "texcenter"); + uniform_texsize = glGetUniformLocation(Program, "texsize"); + glGenVertexArrays(1, &vao); + glBindVertexArray(vao); + glEnableVertexAttribArray(attrib_position); + glEnableVertexAttribArray(attrib_texcoord); + glEnableVertexAttribArray(attrib_color); + glBindBuffer(GL_ARRAY_BUFFER, quad_buffer); + glVertexAttribPointer(attrib_position, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0); + glVertexAttribPointer(attrib_texcoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid *)(2 * sizeof(float))); + const unsigned quad_color[] = { + 0, 0, 0, 255, + 255, 0, 0, 255, + 0, 255, 0, 255, + 0, 0, 255, 255, + }; + glGenBuffers(1, &colorvbo); + glBindBuffer(GL_ARRAY_BUFFER, colorvbo); + glBufferData(GL_ARRAY_BUFFER, 16 * sizeof(unsigned), quad_color, GL_DYNAMIC_DRAW); + glVertexAttribIPointer(attrib_color, 4, GL_UNSIGNED_INT, 4 * sizeof(unsigned), 0); + glBindVertexArray(0); + } - void ColoredTextureRectShader::setUniforms(float center_pos_x, float center_pos_y, float width, float height, float tex_center_pos_x, float tex_center_pos_y, float tex_width, float tex_height, unsigned TU_tex) - { - glUniform1i(uniform_tex, TU_tex); - glUniform2f(uniform_center, center_pos_x, center_pos_y); - glUniform2f(uniform_size, width, height); - glUniform2f(uniform_texcenter, tex_center_pos_x, tex_center_pos_y); - glUniform2f(uniform_texsize, tex_width, tex_height); - } + void ColoredTextureRectShader::setUniforms(float center_pos_x, float center_pos_y, float width, float height, float tex_center_pos_x, float tex_center_pos_y, float tex_width, float tex_height, unsigned TU_tex) + { + glUniform1i(uniform_tex, TU_tex); + glUniform2f(uniform_center, center_pos_x, center_pos_y); + glUniform2f(uniform_size, width, height); + glUniform2f(uniform_texcenter, tex_center_pos_x, tex_center_pos_y); + glUniform2f(uniform_texsize, tex_width, tex_height); + } - GLuint ColoredRectShader::Program; - GLuint ColoredRectShader::attrib_position; - GLuint ColoredRectShader::uniform_center; - GLuint ColoredRectShader::uniform_size; - GLuint ColoredRectShader::uniform_color; - GLuint ColoredRectShader::vao; + GLuint ColoredRectShader::Program; + GLuint ColoredRectShader::attrib_position; + GLuint ColoredRectShader::uniform_center; + GLuint ColoredRectShader::uniform_size; + GLuint ColoredRectShader::uniform_color; + GLuint ColoredRectShader::vao; - void ColoredRectShader::init() - { - Program = LoadProgram( + void ColoredRectShader::init() + { + Program = LoadProgram( GL_VERTEX_SHADER, file_manager->getAsset("shaders/coloredquad.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/coloredquad.frag").c_str()); - attrib_position = glGetAttribLocation(Program, "position"); - uniform_color = glGetUniformLocation(Program, "color"); - uniform_center = glGetUniformLocation(Program, "center"); - uniform_size = glGetUniformLocation(Program, "size"); - glGenVertexArrays(1, &vao); - glBindVertexArray(vao); - glEnableVertexAttribArray(attrib_position); - glBindBuffer(GL_ARRAY_BUFFER, quad_buffer); - glVertexAttribPointer(attrib_position, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0); - glBindVertexArray(0); - } + attrib_position = glGetAttribLocation(Program, "position"); + uniform_color = glGetUniformLocation(Program, "color"); + uniform_center = glGetUniformLocation(Program, "center"); + uniform_size = glGetUniformLocation(Program, "size"); + glGenVertexArrays(1, &vao); + glBindVertexArray(vao); + glEnableVertexAttribArray(attrib_position); + glBindBuffer(GL_ARRAY_BUFFER, quad_buffer); + glVertexAttribPointer(attrib_position, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0); + glBindVertexArray(0); + } - void ColoredRectShader::setUniforms(float center_pos_x, float center_pos_y, float width, float height, const video::SColor &color) - { - glUniform2f(uniform_center, center_pos_x, center_pos_y); - glUniform2f(uniform_size, width, height); - glUniform4i(uniform_color, color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); - } + void ColoredRectShader::setUniforms(float center_pos_x, float center_pos_y, float width, float height, const video::SColor &color) + { + glUniform2f(uniform_center, center_pos_x, center_pos_y); + glUniform2f(uniform_size, width, height); + glUniform4i(uniform_color, color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); + } } diff --git a/src/graphics/shaders.hpp b/src/graphics/shaders.hpp index 88983f2fd..dc23e28c2 100644 --- a/src/graphics/shaders.hpp +++ b/src/graphics/shaders.hpp @@ -21,7 +21,7 @@ #include #include -typedef unsigned int GLuint; +typedef unsigned int GLuint; using namespace irr; class ParticleSystemProxy; @@ -36,22 +36,22 @@ namespace MeshShader class ObjectPass1Shader { public: - static GLuint Program; - static GLuint attrib_position, attrib_normal; - static GLuint uniform_MVP, uniform_TIMV; + static GLuint Program; + static GLuint attrib_position, attrib_normal; + static GLuint uniform_MVP, uniform_TIMV; - static void init(); - static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView); + static void init(); + static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView); }; class ObjectRefPass1Shader { public: - static GLuint Program; - static GLuint attrib_position, attrib_normal, attrib_texcoord; - static GLuint uniform_MVP, uniform_TM, uniform_TIMV, uniform_tex; + static GLuint Program; + static GLuint attrib_position, attrib_normal, attrib_texcoord; + static GLuint uniform_MVP, uniform_TM, uniform_TIMV, uniform_tex; - static void init(); + static void init(); static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix, unsigned TU_texture); }; @@ -80,108 +80,108 @@ public: class ObjectPass2Shader { public: - static GLuint Program; - static GLuint attrib_position, attrib_texcoord; + static GLuint Program; + static GLuint attrib_position, attrib_texcoord; static GLuint uniform_MVP, uniform_TM, uniform_screen, uniform_ambient; static GLuint TU_Albedo; - static void init(); + static void init(); static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix); }; class DetailledObjectPass2Shader { public: - static GLuint Program; - static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord; - static GLuint uniform_MVP, uniform_screen, uniform_ambient; + static GLuint Program; + static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord; + static GLuint uniform_MVP, uniform_screen, uniform_ambient; static GLuint TU_Albedo, TU_detail; - static void init(); - static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix); + static void init(); + static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix); }; class ObjectRimLimitShader { public: - static GLuint Program; - static GLuint attrib_position, attrib_normal, attrib_texcoord; - static GLuint uniform_MVP, uniform_TIMV, uniform_TM, uniform_screen, uniform_ambient; + static GLuint Program; + static GLuint attrib_position, attrib_normal, attrib_texcoord; + static GLuint uniform_MVP, uniform_TIMV, uniform_TM, uniform_screen, uniform_ambient; static GLuint TU_Albedo; - static void init(); + static void init(); static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix); }; class UntexturedObjectShader { public: - static GLuint Program; - static GLuint attrib_position, attrib_color; - static GLuint uniform_MVP, uniform_screen, uniform_ambient; + static GLuint Program; + static GLuint attrib_position, attrib_color; + static GLuint uniform_MVP, uniform_screen, uniform_ambient; - static void init(); - static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix); + static void init(); + static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix); }; class ObjectUnlitShader { public: - static GLuint Program; - static GLuint attrib_position, attrib_texcoord; + static GLuint Program; + static GLuint attrib_position, attrib_texcoord; static GLuint uniform_MVP; static GLuint TU_tex; - static void init(); - static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix); + static void init(); + static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix); }; class ObjectRefPass2Shader { public: - static GLuint Program; - static GLuint attrib_position, attrib_texcoord; - static GLuint uniform_MVP, uniform_TM, uniform_screen, uniform_ambient; + static GLuint Program; + static GLuint attrib_position, attrib_texcoord; + static GLuint uniform_MVP, uniform_TM, uniform_screen, uniform_ambient; static GLuint TU_Albedo; - static void init(); + static void init(); static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix); }; class GrassPass2Shader { public: - static GLuint Program; - static GLuint attrib_position, attrib_texcoord, attrib_color; - static GLuint uniform_MVP, uniform_screen, uniform_ambient, uniform_windDir; + static GLuint Program; + static GLuint attrib_position, attrib_texcoord, attrib_color; + static GLuint uniform_MVP, uniform_screen, uniform_ambient, uniform_windDir; static GLuint TU_Albedo; - static void init(); - static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::vector3df &windDirection); + static void init(); + static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::vector3df &windDirection); }; class SphereMapShader { public: - static GLuint Program; - static GLuint attrib_position, attrib_normal; + static GLuint Program; + static GLuint attrib_position, attrib_normal; static GLuint uniform_MVP, uniform_TIMV, uniform_TVM, uniform_invproj, uniform_screen; static GLuint TU_tex; - static void init(); + static void init(); static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeViewMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &InvProj, const core::vector2df& screen); }; class SplattingShader { public: - static GLuint Program; - static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord; - static GLuint uniform_MVP, uniform_screen, uniform_ambient; + static GLuint Program; + static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord; + static GLuint uniform_MVP, uniform_screen, uniform_ambient; static GLuint TU_tex_layout, TU_tex_detail0, TU_tex_detail1, TU_tex_detail2, TU_tex_detail3; - static void init(); - static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix); + static void init(); + static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix); }; class CausticsShader @@ -199,22 +199,22 @@ public: class BubbleShader { public: - static GLuint Program; - static GLuint attrib_position, attrib_texcoord; + static GLuint Program; + static GLuint attrib_position, attrib_texcoord; static GLuint uniform_MVP, uniform_tex, uniform_time, uniform_transparency; - static void init(); + static void init(); static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, unsigned TU_tex, float time, float transparency); }; class TransparentShader { public: - static GLuint Program; - static GLuint attrib_position, attrib_texcoord, attrib_color; - static GLuint uniform_MVP, uniform_TM, uniform_tex; + static GLuint Program; + static GLuint attrib_position, attrib_texcoord, attrib_color; + static GLuint uniform_MVP, uniform_TM, uniform_tex; - static void init(); + static void init(); static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix, unsigned TU_tex); }; @@ -232,24 +232,24 @@ public: class BillboardShader { public: - static GLuint Program; - static GLuint attrib_corner, attrib_texcoord; - static GLuint uniform_MV, uniform_P, uniform_tex, uniform_Position, uniform_Size; + static GLuint Program; + static GLuint attrib_corner, attrib_texcoord; + static GLuint uniform_MV, uniform_P, uniform_tex, uniform_Position, uniform_Size; - static void init(); - static void setUniforms(const core::matrix4 &ModelViewMatrix, const core::matrix4 &ProjectionMatrix, const core::vector3df &Position, const core::dimension2d &size, unsigned TU_tex); + static void init(); + static void setUniforms(const core::matrix4 &ModelViewMatrix, const core::matrix4 &ProjectionMatrix, const core::vector3df &Position, const core::dimension2d &size, unsigned TU_tex); }; class ColorizeShader { public: - static GLuint Program; - static GLuint attrib_position; - static GLuint uniform_MVP, uniform_col; + static GLuint Program; + static GLuint attrib_position; + static GLuint uniform_MVP, uniform_col; - static void init(); - static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, float r, float g, float b); + static void init(); + static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, float r, float g, float b); }; class ShadowShader @@ -299,11 +299,11 @@ public: class DisplaceShader { public: - static GLuint Program; - static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord; + static GLuint Program; + static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord; static GLuint uniform_MVP, uniform_MV, uniform_displacement_tex, uniform_mask_tex, uniform_color_tex, uniform_screen, uniform_dir, uniform_dir2; - static void init(); + static void init(); static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &ModelViewMatrix, const core::vector2df &dir, const core::vector2df &dir2, const core::vector2df &screen, unsigned TU_displacement_tex, unsigned TU_mask_tex, unsigned TU_color_tex); }; @@ -359,11 +359,11 @@ namespace ParticleShader class SimpleSimulationShader { public: - static GLuint Program; - static GLuint attrib_position, attrib_velocity, attrib_lifetime, attrib_initial_position, attrib_initial_velocity, attrib_initial_lifetime, attrib_size, attrib_initial_size; - static GLuint uniform_sourcematrix, uniform_dt, uniform_level, uniform_size_increase_factor; + static GLuint Program; + static GLuint attrib_position, attrib_velocity, attrib_lifetime, attrib_initial_position, attrib_initial_velocity, attrib_initial_lifetime, attrib_size, attrib_initial_size; + static GLuint uniform_sourcematrix, uniform_dt, uniform_level, uniform_size_increase_factor; - static void init(); + static void init(); }; @@ -371,23 +371,23 @@ public: class HeightmapSimulationShader { public: - static GLuint Program; - static GLuint attrib_position, attrib_velocity, attrib_lifetime, attrib_initial_position, attrib_initial_velocity, attrib_initial_lifetime, attrib_size, attrib_initial_size; - static GLuint uniform_sourcematrix, uniform_dt, uniform_level, uniform_size_increase_factor; - static GLuint uniform_track_x, uniform_track_z, uniform_track_x_len, uniform_track_z_len, uniform_heightmap; + static GLuint Program; + static GLuint attrib_position, attrib_velocity, attrib_lifetime, attrib_initial_position, attrib_initial_velocity, attrib_initial_lifetime, attrib_size, attrib_initial_size; + static GLuint uniform_sourcematrix, uniform_dt, uniform_level, uniform_size_increase_factor; + static GLuint uniform_track_x, uniform_track_z, uniform_track_x_len, uniform_track_z_len, uniform_heightmap; - static void init(); + static void init(); }; class SimpleParticleRender { public: - static GLuint Program; - static GLuint attrib_pos, attrib_lf, attrib_quadcorner, attrib_texcoord, attrib_sz; - static GLuint uniform_matrix, uniform_viewmatrix, uniform_tex, uniform_dtex, uniform_screen, uniform_invproj, uniform_color_from, uniform_color_to; + static GLuint Program; + static GLuint attrib_pos, attrib_lf, attrib_quadcorner, attrib_texcoord, attrib_sz; + static GLuint uniform_matrix, uniform_viewmatrix, uniform_tex, uniform_dtex, uniform_screen, uniform_invproj, uniform_color_from, uniform_color_to; - static void init(); - static void setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, + static void init(); + static void setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex, unsigned TU_normal_and_depth, const ParticleSystemProxy* particle_system); }; @@ -395,12 +395,12 @@ public: class FlipParticleRender { public: - static GLuint Program; - static GLuint attrib_pos, attrib_lf, attrib_quadcorner, attrib_texcoord, attrib_sz, attrib_rotationvec, attrib_anglespeed; - static GLuint uniform_matrix, uniform_viewmatrix, uniform_tex, uniform_dtex, uniform_screen, uniform_invproj; + static GLuint Program; + static GLuint attrib_pos, attrib_lf, attrib_quadcorner, attrib_texcoord, attrib_sz, attrib_rotationvec, attrib_anglespeed; + static GLuint uniform_matrix, uniform_viewmatrix, uniform_tex, uniform_dtex, uniform_screen, uniform_invproj; - static void init(); - static void setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex, unsigned TU_normal_and_depth); + static void init(); + static void setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex, unsigned TU_normal_and_depth); }; } @@ -410,42 +410,42 @@ namespace FullScreenShader class BloomShader { public: - static GLuint Program; - static GLuint uniform_texture, uniform_low; - static GLuint vao; + static GLuint Program; + static GLuint uniform_texture, uniform_low; + static GLuint vao; - static void init(); + static void init(); }; class BloomBlendShader { public: - static GLuint Program; - static GLuint uniform_texture, uniform_low; - static GLuint vao; + static GLuint Program; + static GLuint uniform_texture, uniform_low; + static GLuint vao; - static void init(); + static void init(); }; class ColorLevelShader { public: - static GLuint Program; + static GLuint Program; static GLuint uniform_tex, uniform_invprojm, uniform_dtex, uniform_inlevel, uniform_outlevel; - static GLuint vao; + static GLuint vao; - static void init(); + static void init(); }; class SunLightShader { public: - static GLuint Program; - static GLuint uniform_ntex, uniform_dtex, uniform_direction, uniform_col, uniform_invproj; - static GLuint vao; + static GLuint Program; + static GLuint uniform_ntex, uniform_dtex, uniform_direction, uniform_col, uniform_invproj; + static GLuint vao; - static void init(); - static void setUniforms(const core::vector3df &direction, const core::matrix4 &InvProjMatrix, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex); + static void init(); + static void setUniforms(const core::vector3df &direction, const core::matrix4 &InvProjMatrix, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex); }; class DiffuseEnvMapShader @@ -473,41 +473,41 @@ public: class Gaussian6HBlurShader { public: - static GLuint Program; - static GLuint uniform_tex, uniform_pixel; - static GLuint vao; + static GLuint Program; + static GLuint uniform_tex, uniform_pixel; + static GLuint vao; - static void init(); + static void init(); }; class Gaussian3HBlurShader { public: - static GLuint Program; - static GLuint uniform_tex, uniform_pixel; - static GLuint vao; + static GLuint Program; + static GLuint uniform_tex, uniform_pixel; + static GLuint vao; - static void init(); + static void init(); }; class Gaussian6VBlurShader { public: - static GLuint Program; - static GLuint uniform_tex, uniform_pixel; - static GLuint vao; + static GLuint Program; + static GLuint uniform_tex, uniform_pixel; + static GLuint vao; - static void init(); + static void init(); }; class Gaussian3VBlurShader { public: - static GLuint Program; - static GLuint uniform_tex, uniform_pixel; - static GLuint vao; + static GLuint Program; + static GLuint uniform_tex, uniform_pixel; + static GLuint vao; - static void init(); + static void init(); }; class PenumbraHShader @@ -546,44 +546,44 @@ public: class PassThroughShader { public: - static GLuint Program; - static GLuint uniform_texture; - static GLuint vao; + static GLuint Program; + static GLuint uniform_texture; + static GLuint vao; - static void init(); + static void init(); }; class GlowShader { public: - static GLuint Program; - static GLuint uniform_tex; - static GLuint vao; + static GLuint Program; + static GLuint uniform_tex; + static GLuint vao; - static void init(); + static void init(); }; class SSAOShader { public: - static GLuint Program; - static GLuint uniform_ntex, uniform_dtex, uniform_noise_texture, uniform_invprojm, uniform_projm, uniform_samplePoints; - static GLuint vao; - static float SSAOSamples[64]; - - static void init(); - static void setUniforms(const core::matrix4& projm, const core::matrix4 &invprojm, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_noise); + static GLuint Program; + static GLuint uniform_ntex, uniform_dtex, uniform_noise_texture, uniform_invprojm, uniform_projm, uniform_samplePoints; + static GLuint vao; + static float SSAOSamples[64]; + + static void init(); + static void setUniforms(const core::matrix4& projm, const core::matrix4 &invprojm, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_noise); }; class FogShader { public: - static GLuint Program; - static GLuint uniform_tex, uniform_fogmax, uniform_startH, uniform_endH, uniform_start, uniform_end, uniform_col, uniform_ipvmat; - static GLuint vao; + static GLuint Program; + static GLuint uniform_tex, uniform_fogmax, uniform_startH, uniform_endH, uniform_start, uniform_end, uniform_col, uniform_ipvmat; + static GLuint vao; - static void init(); - static void setUniforms(const core::matrix4 &ipvmat, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, unsigned TU_ntex); + static void init(); + static void setUniforms(const core::matrix4 &ipvmat, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, unsigned TU_ntex); }; class MotionBlurShader @@ -626,13 +626,13 @@ namespace UIShader class TextureRectShader { public: - static GLuint Program; - static GLuint attrib_position, attrib_texcoord; - static GLuint uniform_tex, uniform_center, uniform_size, uniform_texcenter, uniform_texsize; - static GLuint vao; + static GLuint Program; + static GLuint attrib_position, attrib_texcoord; + static GLuint uniform_tex, uniform_center, uniform_size, uniform_texcenter, uniform_texsize; + static GLuint vao; - static void init(); - static void setUniforms(float center_pos_x, float center_pos_y, float width, float height, float tex_center_pos_x, float tex_center_pos_y, float tex_width, float tex_height, unsigned TU_tex); + static void init(); + static void setUniforms(float center_pos_x, float center_pos_y, float width, float height, float tex_center_pos_x, float tex_center_pos_y, float tex_width, float tex_height, unsigned TU_tex); }; class UniformColoredTextureRectShader @@ -650,26 +650,26 @@ public: class ColoredTextureRectShader { public: - static GLuint Program; - static GLuint attrib_position, attrib_texcoord, attrib_color; - static GLuint uniform_tex, uniform_center, uniform_size, uniform_texcenter, uniform_texsize; - static GLuint colorvbo; - static GLuint vao; + static GLuint Program; + static GLuint attrib_position, attrib_texcoord, attrib_color; + static GLuint uniform_tex, uniform_center, uniform_size, uniform_texcenter, uniform_texsize; + static GLuint colorvbo; + static GLuint vao; - static void init(); - static void setUniforms(float center_pos_x, float center_pos_y, float width, float height, float tex_center_pos_x, float tex_center_pos_y, float tex_width, float tex_height, unsigned TU_tex); + static void init(); + static void setUniforms(float center_pos_x, float center_pos_y, float width, float height, float tex_center_pos_x, float tex_center_pos_y, float tex_width, float tex_height, unsigned TU_tex); }; class ColoredRectShader { public: - static GLuint Program; - static GLuint attrib_position; - static GLuint uniform_center, uniform_size, uniform_color; - static GLuint vao; + static GLuint Program; + static GLuint attrib_position; + static GLuint uniform_center, uniform_size, uniform_color; + static GLuint vao; - static void init(); - static void setUniforms(float center_pos_x, float center_pos_y, float width, float height, const video::SColor &color); + static void init(); + static void setUniforms(float center_pos_x, float center_pos_y, float width, float height, const video::SColor &color); }; } @@ -690,7 +690,7 @@ public: ACT(ES_GAUSSIAN3V) \ ACT(ES_MIPVIZ) \ ACT(ES_COLORIZE) \ - ACT(ES_OBJECT_UNLIT) \ + ACT(ES_OBJECT_UNLIT) \ ACT(ES_OBJECTPASS) \ ACT(ES_OBJECTPASS_REF) \ ACT(ES_SUNLIGHT) \ @@ -740,7 +740,7 @@ public: void loadShaders(); private: void check(const int num) const; - + int m_shaders[ES_COUNT]; }; diff --git a/src/graphics/stkanimatedmesh.cpp b/src/graphics/stkanimatedmesh.cpp index 5a613b8cd..2591c5248 100644 --- a/src/graphics/stkanimatedmesh.cpp +++ b/src/graphics/stkanimatedmesh.cpp @@ -16,7 +16,7 @@ const core::vector3df& rotation, const core::vector3df& scale) : CAnimatedMeshSceneNode(mesh, parent, mgr, id, position, rotation, scale) { - firstTime = true; + firstTime = true; } void STKAnimatedMesh::cleanGLMeshes() @@ -45,13 +45,13 @@ void STKAnimatedMesh::cleanGLMeshes() void STKAnimatedMesh::setMesh(scene::IAnimatedMesh* mesh) { - firstTime = true; - GLmeshes.clear(); + firstTime = true; + GLmeshes.clear(); for (unsigned i = 0; i < FPSM_COUNT; i++) GeometricMesh[i].clear(); for (unsigned i = 0; i < SM_COUNT; i++) ShadedMesh[i].clear(); - CAnimatedMeshSceneNode::setMesh(mesh); + CAnimatedMeshSceneNode::setMesh(mesh); } void STKAnimatedMesh::drawSolidPass1(const GLMesh &mesh, GeometricMaterial type) @@ -97,26 +97,26 @@ void STKAnimatedMesh::drawSolidPass2(const GLMesh &mesh, ShadedMaterial type) void STKAnimatedMesh::render() { - video::IVideoDriver* driver = SceneManager->getVideoDriver(); + video::IVideoDriver* driver = SceneManager->getVideoDriver(); - bool isTransparentPass = - SceneManager->getSceneNodeRenderPass() == scene::ESNRP_TRANSPARENT; + bool isTransparentPass = + SceneManager->getSceneNodeRenderPass() == scene::ESNRP_TRANSPARENT; - ++PassCount; + ++PassCount; - scene::IMesh* m = getMeshForCurrentFrame(); + scene::IMesh* m = getMeshForCurrentFrame(); - if (m) - { - Box = m->getBoundingBox(); - } - else - { - Log::error("animated mesh", "Animated Mesh returned no mesh to render."); - return; - } + if (m) + { + Box = m->getBoundingBox(); + } + else + { + Log::error("animated mesh", "Animated Mesh returned no mesh to render."); + return; + } - driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); + driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); if (firstTime) { @@ -157,7 +157,7 @@ void STKAnimatedMesh::render() } } } - firstTime = false; + firstTime = false; for (u32 i = 0; igetMeshBufferCount(); ++i) { diff --git a/src/graphics/stkanimatedmesh.hpp b/src/graphics/stkanimatedmesh.hpp index a59538727..ab0ee3db9 100644 --- a/src/graphics/stkanimatedmesh.hpp +++ b/src/graphics/stkanimatedmesh.hpp @@ -10,11 +10,11 @@ class STKAnimatedMesh : public irr::scene::CAnimatedMeshSceneNode { protected: - bool firstTime; + bool firstTime; std::vector GeometricMesh[FPSM_COUNT]; std::vector ShadedMesh[SM_COUNT]; std::vector TransparentMesh[TM_COUNT]; - std::vector GLmeshes; + std::vector GLmeshes; core::matrix4 ModelViewProjectionMatrix, TransposeInverseModelView; void drawSolidPass1(const GLMesh &mesh, GeometricMaterial type); void drawSolidPass2(const GLMesh &mesh, ShadedMaterial type); diff --git a/src/graphics/stkbillboard.cpp b/src/graphics/stkbillboard.cpp index d6de5085f..1acfab27b 100644 --- a/src/graphics/stkbillboard.cpp +++ b/src/graphics/stkbillboard.cpp @@ -9,36 +9,36 @@ static GLuint billboardvao = 0; static void createbillboardvao() { - glGenVertexArrays(1, &billboardvao); - glBindVertexArray(billboardvao); + glGenVertexArrays(1, &billboardvao); + glBindVertexArray(billboardvao); glBindBuffer(GL_ARRAY_BUFFER, SharedObject::billboardvbo); - glEnableVertexAttribArray(MeshShader::BillboardShader::attrib_corner); - glEnableVertexAttribArray(MeshShader::BillboardShader::attrib_texcoord); - glVertexAttribPointer(MeshShader::BillboardShader::attrib_corner, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0); - glVertexAttribPointer(MeshShader::BillboardShader::attrib_texcoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid*) (2 * sizeof(float))); - glBindVertexArray(0); + glEnableVertexAttribArray(MeshShader::BillboardShader::attrib_corner); + glEnableVertexAttribArray(MeshShader::BillboardShader::attrib_texcoord); + glVertexAttribPointer(MeshShader::BillboardShader::attrib_corner, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0); + glVertexAttribPointer(MeshShader::BillboardShader::attrib_texcoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid*) (2 * sizeof(float))); + glBindVertexArray(0); } STKBillboard::STKBillboard(irr::scene::ISceneNode* parent, irr::scene::ISceneManager* mgr, irr::s32 id, - const irr::core::vector3df& position, const irr::core::dimension2d& size, - irr::video::SColor colorTop, irr::video::SColor colorBottom) : - CBillboardSceneNode(parent, mgr, id, position, size, colorTop, colorBottom), IBillboardSceneNode(parent, mgr, id, position) + const irr::core::vector3df& position, const irr::core::dimension2d& size, + irr::video::SColor colorTop, irr::video::SColor colorBottom) : + CBillboardSceneNode(parent, mgr, id, position, size, colorTop, colorBottom), IBillboardSceneNode(parent, mgr, id, position) { - if (!billboardvao) - createbillboardvao(); + if (!billboardvao) + createbillboardvao(); } void STKBillboard::render() { if (irr_driver->getPhase() != TRANSPARENT_PASS) return; - core::vector3df pos = getAbsolutePosition(); - glBindVertexArray(billboardvao); + core::vector3df pos = getAbsolutePosition(); + glBindVertexArray(billboardvao); GLuint texid = getTextureGLuint(Material.getTexture(0)); - setTexture(0, texid, GL_LINEAR, GL_LINEAR); - glUseProgram(MeshShader::BillboardShader::Program); - MeshShader::BillboardShader::setUniforms(irr_driver->getViewMatrix(), irr_driver->getProjMatrix(), pos, Size, 0); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - glBindVertexArray(0); - return; + setTexture(0, texid, GL_LINEAR, GL_LINEAR); + glUseProgram(MeshShader::BillboardShader::Program); + MeshShader::BillboardShader::setUniforms(irr_driver->getViewMatrix(), irr_driver->getProjMatrix(), pos, Size, 0); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + glBindVertexArray(0); + return; } diff --git a/src/graphics/stkbillboard.hpp b/src/graphics/stkbillboard.hpp index 19788f53d..cae618e05 100644 --- a/src/graphics/stkbillboard.hpp +++ b/src/graphics/stkbillboard.hpp @@ -8,12 +8,12 @@ class STKBillboard : public irr::scene::CBillboardSceneNode { public: - STKBillboard(irr::scene::ISceneNode* parent, irr::scene::ISceneManager* mgr, irr::s32 id, - const irr::core::vector3df& position, const irr::core::dimension2d& size, - irr::video::SColor colorTop = irr::video::SColor(0xFFFFFFFF), - irr::video::SColor colorBottom = irr::video::SColor(0xFFFFFFFF)); + STKBillboard(irr::scene::ISceneNode* parent, irr::scene::ISceneManager* mgr, irr::s32 id, + const irr::core::vector3df& position, const irr::core::dimension2d& size, + irr::video::SColor colorTop = irr::video::SColor(0xFFFFFFFF), + irr::video::SColor colorBottom = irr::video::SColor(0xFFFFFFFF)); - virtual void render(); + virtual void render(); }; -#endif +#endif \ No newline at end of file diff --git a/src/graphics/stkmesh.cpp b/src/graphics/stkmesh.cpp index 718091466..27a0119ff 100644 --- a/src/graphics/stkmesh.cpp +++ b/src/graphics/stkmesh.cpp @@ -57,153 +57,153 @@ GLuint createVAO(GLuint vbo, GLuint idx, GLuint attrib_position, GLuint attrib_t { if (attrib_position == -1) return 0; - GLuint vao; - glGenVertexArrays(1, &vao); - glBindVertexArray(vao); - glBindBuffer(GL_ARRAY_BUFFER, vbo); - glEnableVertexAttribArray(attrib_position); - if ((GLint)attrib_texcoord != -1) - glEnableVertexAttribArray(attrib_texcoord); - if ((GLint)attrib_second_texcoord != -1) - glEnableVertexAttribArray(attrib_second_texcoord); - if ((GLint)attrib_normal != -1) - glEnableVertexAttribArray(attrib_normal); - if ((GLint)attrib_tangent != -1) - glEnableVertexAttribArray(attrib_tangent); - if ((GLint)attrib_bitangent != -1) - glEnableVertexAttribArray(attrib_bitangent); - if ((GLint)attrib_color != -1) - glEnableVertexAttribArray(attrib_color); - glVertexAttribPointer(attrib_position, 3, GL_FLOAT, GL_FALSE, stride, 0); - if ((GLint)attrib_texcoord != -1) - glVertexAttribPointer(attrib_texcoord, 2, GL_FLOAT, GL_FALSE, stride, (GLvoid*) 28); - if ((GLint)attrib_second_texcoord != -1) - { - if (stride < 44) - Log::error("material", "Second texcoords not present in VBO"); - glVertexAttribPointer(attrib_second_texcoord, 2, GL_FLOAT, GL_FALSE, stride, (GLvoid*) 36); - } - if ((GLint)attrib_normal != -1) - glVertexAttribPointer(attrib_normal, 3, GL_FLOAT, GL_FALSE, stride, (GLvoid*) 12); - if ((GLint)attrib_tangent != -1) - { - if (stride < 48) - Log::error("material", "Tangents not present in VBO"); - glVertexAttribPointer(attrib_tangent, 3, GL_FLOAT, GL_FALSE, stride, (GLvoid*)36); - } - - if ((GLint)attrib_bitangent != -1) - { - if (stride < 60) - Log::error("material", "Bitangents not present in VBO"); - glVertexAttribPointer(attrib_bitangent, 3, GL_FLOAT, GL_FALSE, stride, (GLvoid*)48); - } - if ((GLint)attrib_color != -1) - glVertexAttribPointer(attrib_color, 4, GL_UNSIGNED_BYTE, GL_TRUE, stride, (GLvoid*)24); - - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, idx); - glBindVertexArray(0); - return vao; + GLuint vao; + glGenVertexArrays(1, &vao); + glBindVertexArray(vao); + glBindBuffer(GL_ARRAY_BUFFER, vbo); + glEnableVertexAttribArray(attrib_position); + if ((GLint)attrib_texcoord != -1) + glEnableVertexAttribArray(attrib_texcoord); + if ((GLint)attrib_second_texcoord != -1) + glEnableVertexAttribArray(attrib_second_texcoord); + if ((GLint)attrib_normal != -1) + glEnableVertexAttribArray(attrib_normal); + if ((GLint)attrib_tangent != -1) + glEnableVertexAttribArray(attrib_tangent); + if ((GLint)attrib_bitangent != -1) + glEnableVertexAttribArray(attrib_bitangent); + if ((GLint)attrib_color != -1) + glEnableVertexAttribArray(attrib_color); + glVertexAttribPointer(attrib_position, 3, GL_FLOAT, GL_FALSE, stride, 0); + if ((GLint)attrib_texcoord != -1) + glVertexAttribPointer(attrib_texcoord, 2, GL_FLOAT, GL_FALSE, stride, (GLvoid*) 28); + if ((GLint)attrib_second_texcoord != -1) + { + if (stride < 44) + Log::error("material", "Second texcoords not present in VBO"); + glVertexAttribPointer(attrib_second_texcoord, 2, GL_FLOAT, GL_FALSE, stride, (GLvoid*) 36); + } + if ((GLint)attrib_normal != -1) + glVertexAttribPointer(attrib_normal, 3, GL_FLOAT, GL_FALSE, stride, (GLvoid*) 12); + if ((GLint)attrib_tangent != -1) + { + if (stride < 48) + Log::error("material", "Tangents not present in VBO"); + glVertexAttribPointer(attrib_tangent, 3, GL_FLOAT, GL_FALSE, stride, (GLvoid*)36); + } + + if ((GLint)attrib_bitangent != -1) + { + if (stride < 60) + Log::error("material", "Bitangents not present in VBO"); + glVertexAttribPointer(attrib_bitangent, 3, GL_FLOAT, GL_FALSE, stride, (GLvoid*)48); + } + if ((GLint)attrib_color != -1) + glVertexAttribPointer(attrib_color, 4, GL_UNSIGNED_BYTE, GL_TRUE, stride, (GLvoid*)24); + + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, idx); + glBindVertexArray(0); + return vao; } GLMesh allocateMeshBuffer(scene::IMeshBuffer* mb) { - GLMesh result = {}; - if (!mb) - return result; - glBindVertexArray(0); - glGenBuffers(1, &(result.vertex_buffer)); - glGenBuffers(1, &(result.index_buffer)); + GLMesh result = {}; + if (!mb) + return result; + glBindVertexArray(0); + glGenBuffers(1, &(result.vertex_buffer)); + glGenBuffers(1, &(result.index_buffer)); - glBindBuffer(GL_ARRAY_BUFFER, result.vertex_buffer); - const void* vertices = mb->getVertices(); - const u32 vertexCount = mb->getVertexCount(); - const irr::video::E_VERTEX_TYPE vType = mb->getVertexType(); - result.Stride = getVertexPitchFromType(vType); - const c8* vbuf = static_cast(vertices); - glBufferData(GL_ARRAY_BUFFER, vertexCount * result.Stride, vbuf, GL_STATIC_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, result.vertex_buffer); + const void* vertices = mb->getVertices(); + const u32 vertexCount = mb->getVertexCount(); + const irr::video::E_VERTEX_TYPE vType = mb->getVertexType(); + result.Stride = getVertexPitchFromType(vType); + const c8* vbuf = static_cast(vertices); + glBufferData(GL_ARRAY_BUFFER, vertexCount * result.Stride, vbuf, GL_STATIC_DRAW); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, result.index_buffer); - const void* indices = mb->getIndices(); - u32 indexCount = mb->getIndexCount(); - GLenum indexSize; - switch (mb->getIndexType()) - { - case irr::video::EIT_16BIT: - { - indexSize = sizeof(u16); - result.IndexType = GL_UNSIGNED_SHORT; - break; - } - case irr::video::EIT_32BIT: - { - indexSize = sizeof(u32); - result.IndexType = GL_UNSIGNED_INT; - break; - } - default: - { - assert(0 && "Wrong index size"); - } - } - glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexCount * indexSize, indices, GL_STATIC_DRAW); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, result.index_buffer); + const void* indices = mb->getIndices(); + u32 indexCount = mb->getIndexCount(); + GLenum indexSize; + switch (mb->getIndexType()) + { + case irr::video::EIT_16BIT: + { + indexSize = sizeof(u16); + result.IndexType = GL_UNSIGNED_SHORT; + break; + } + case irr::video::EIT_32BIT: + { + indexSize = sizeof(u32); + result.IndexType = GL_UNSIGNED_INT; + break; + } + default: + { + assert(0 && "Wrong index size"); + } + } + glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexCount * indexSize, indices, GL_STATIC_DRAW); - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - result.IndexCount = mb->getIndexCount(); - switch (mb->getPrimitiveType()) - { - case scene::EPT_POINTS: - result.PrimitiveType = GL_POINTS; + result.IndexCount = mb->getIndexCount(); + switch (mb->getPrimitiveType()) + { + case scene::EPT_POINTS: + result.PrimitiveType = GL_POINTS; + break; + case scene::EPT_TRIANGLE_STRIP: + result.PrimitiveType = GL_TRIANGLE_STRIP; + break; + case scene::EPT_TRIANGLE_FAN: + result.PrimitiveType = GL_TRIANGLE_FAN; + break; + case scene::EPT_LINES: + result.PrimitiveType = GL_LINES; break; - case scene::EPT_TRIANGLE_STRIP: - result.PrimitiveType = GL_TRIANGLE_STRIP; - break; - case scene::EPT_TRIANGLE_FAN: - result.PrimitiveType = GL_TRIANGLE_FAN; - break; - case scene::EPT_LINES: - result.PrimitiveType = GL_LINES; - break; - case scene::EPT_TRIANGLES: - result.PrimitiveType = GL_TRIANGLES; - break; - case scene::EPT_POINT_SPRITES: - case scene::EPT_LINE_LOOP: - case scene::EPT_POLYGON: - case scene::EPT_LINE_STRIP: - case scene::EPT_QUAD_STRIP: - case scene::EPT_QUADS: - assert(0 && "Unsupported primitive type"); - } - ITexture *tex; - for (unsigned i = 0; i < 6; i++) - { - tex = mb->getMaterial().getTexture(i); - if (tex) - result.textures[i] = getTextureGLuint(tex); - else - result.textures[i] = 0; - } + case scene::EPT_TRIANGLES: + result.PrimitiveType = GL_TRIANGLES; + break; + case scene::EPT_POINT_SPRITES: + case scene::EPT_LINE_LOOP: + case scene::EPT_POLYGON: + case scene::EPT_LINE_STRIP: + case scene::EPT_QUAD_STRIP: + case scene::EPT_QUADS: + assert(0 && "Unsupported primitive type"); + } + ITexture *tex; + for (unsigned i = 0; i < 6; i++) + { + tex = mb->getMaterial().getTexture(i); + if (tex) + result.textures[i] = getTextureGLuint(tex); + else + result.textures[i] = 0; + } result.TextureMatrix = 0; - return result; + return result; } void computeMVP(core::matrix4 &ModelViewProjectionMatrix) { - ModelViewProjectionMatrix = irr_driver->getVideoDriver()->getTransform(video::ETS_PROJECTION); - ModelViewProjectionMatrix *= irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW); - ModelViewProjectionMatrix *= irr_driver->getVideoDriver()->getTransform(video::ETS_WORLD); + ModelViewProjectionMatrix = irr_driver->getVideoDriver()->getTransform(video::ETS_PROJECTION); + ModelViewProjectionMatrix *= irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW); + ModelViewProjectionMatrix *= irr_driver->getVideoDriver()->getTransform(video::ETS_WORLD); } void computeTIMV(core::matrix4 &TransposeInverseModelView) { - TransposeInverseModelView = irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW); - TransposeInverseModelView *= irr_driver->getVideoDriver()->getTransform(video::ETS_WORLD); - TransposeInverseModelView.makeInverse(); - TransposeInverseModelView = TransposeInverseModelView.getTransposed(); + TransposeInverseModelView = irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW); + TransposeInverseModelView *= irr_driver->getVideoDriver()->getTransform(video::ETS_WORLD); + TransposeInverseModelView.makeInverse(); + TransposeInverseModelView = TransposeInverseModelView.getTransposed(); } void drawObjectPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView) @@ -240,34 +240,34 @@ void drawObjectRefPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProje void drawGrassPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, core::vector3df windDir) { irr_driver->IncreaseObjectCount(); - GLenum ptype = mesh.PrimitiveType; - GLenum itype = mesh.IndexType; - size_t count = mesh.IndexCount; + GLenum ptype = mesh.PrimitiveType; + GLenum itype = mesh.IndexType; + size_t count = mesh.IndexCount; - setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true); + setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true); - MeshShader::GrassPass1Shader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, windDir, 0); + MeshShader::GrassPass1Shader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, windDir, 0); assert(mesh.vao_first_pass); - glBindVertexArray(mesh.vao_first_pass); - glDrawElements(ptype, count, itype, 0); + glBindVertexArray(mesh.vao_first_pass); + glDrawElements(ptype, count, itype, 0); } void drawNormalPass(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView) { irr_driver->IncreaseObjectCount(); - GLenum ptype = mesh.PrimitiveType; - GLenum itype = mesh.IndexType; - size_t count = mesh.IndexCount; + GLenum ptype = mesh.PrimitiveType; + GLenum itype = mesh.IndexType; + size_t count = mesh.IndexCount; - assert(mesh.textures[1]); - setTexture(0, mesh.textures[1], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true); + assert(mesh.textures[1]); + setTexture(0, mesh.textures[1], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true); - MeshShader::NormalMapShader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, 0); + MeshShader::NormalMapShader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, 0); assert(mesh.vao_first_pass); - glBindVertexArray(mesh.vao_first_pass); - glDrawElements(ptype, count, itype, 0); + glBindVertexArray(mesh.vao_first_pass); + glDrawElements(ptype, count, itype, 0); } void drawSphereMap(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView) @@ -437,27 +437,27 @@ void drawCaustics(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionM void drawGrassPass2(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, core::vector3df windDir) { irr_driver->IncreaseObjectCount(); - GLenum ptype = mesh.PrimitiveType; - GLenum itype = mesh.IndexType; - size_t count = mesh.IndexCount; + GLenum ptype = mesh.PrimitiveType; + GLenum itype = mesh.IndexType; + size_t count = mesh.IndexCount; setTexture(MeshShader::GrassPass2Shader::TU_Albedo, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true); - if (irr_driver->getLightViz()) - { - GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA}; - glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); - } - else - { - GLint swizzleMask[] = {GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA}; - glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); - } + if (irr_driver->getLightViz()) + { + GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA}; + glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); + } + else + { + GLint swizzleMask[] = {GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA}; + glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); + } MeshShader::GrassPass2Shader::setUniforms(ModelViewProjectionMatrix, windDir); assert(mesh.vao_second_pass); - glBindVertexArray(mesh.vao_second_pass); - glDrawElements(ptype, count, itype, 0); + glBindVertexArray(mesh.vao_second_pass); + glDrawElements(ptype, count, itype, 0); } void drawUntexturedObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix) @@ -477,53 +477,53 @@ void drawUntexturedObject(const GLMesh &mesh, const core::matrix4 &ModelViewProj void drawObjectRimLimit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix) { irr_driver->IncreaseObjectCount(); - GLenum ptype = mesh.PrimitiveType; - GLenum itype = mesh.IndexType; - size_t count = mesh.IndexCount; + GLenum ptype = mesh.PrimitiveType; + GLenum itype = mesh.IndexType; + size_t count = mesh.IndexCount; setTexture(MeshShader::ObjectRimLimitShader::TU_Albedo, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true); - if (irr_driver->getLightViz()) - { - GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA }; - glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); - } - else - { - GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }; - glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); - } + if (irr_driver->getLightViz()) + { + GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA }; + glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); + } + else + { + GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }; + glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); + } MeshShader::ObjectRimLimitShader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, TextureMatrix); assert(mesh.vao_second_pass); - glBindVertexArray(mesh.vao_second_pass); - glDrawElements(ptype, count, itype, 0); + glBindVertexArray(mesh.vao_second_pass); + glDrawElements(ptype, count, itype, 0); } void drawObjectUnlit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix) { irr_driver->IncreaseObjectCount(); - GLenum ptype = mesh.PrimitiveType; - GLenum itype = mesh.IndexType; - size_t count = mesh.IndexCount; + GLenum ptype = mesh.PrimitiveType; + GLenum itype = mesh.IndexType; + size_t count = mesh.IndexCount; setTexture(MeshShader::ObjectUnlitShader::TU_tex, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true); - if (irr_driver->getLightViz()) - { - GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA }; - glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); - } - else - { - GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }; - glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); - } + if (irr_driver->getLightViz()) + { + GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA }; + glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); + } + else + { + GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }; + glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); + } MeshShader::ObjectUnlitShader::setUniforms(ModelViewProjectionMatrix); assert(mesh.vao_second_pass); - glBindVertexArray(mesh.vao_second_pass); - glDrawElements(ptype, count, itype, 0); + glBindVertexArray(mesh.vao_second_pass); + glDrawElements(ptype, count, itype, 0); } void drawDetailledObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix) @@ -557,43 +557,43 @@ void drawDetailledObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelView void drawObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix) { irr_driver->IncreaseObjectCount(); - GLenum ptype = mesh.PrimitiveType; - GLenum itype = mesh.IndexType; - size_t count = mesh.IndexCount; + GLenum ptype = mesh.PrimitiveType; + GLenum itype = mesh.IndexType; + size_t count = mesh.IndexCount; setTexture(MeshShader::ObjectPass2Shader::TU_Albedo, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true); - if (irr_driver->getLightViz()) - { - GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA }; - glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); - } - else - { - GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }; - glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); - } + if (irr_driver->getLightViz()) + { + GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA }; + glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); + } + else + { + GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }; + glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); + } MeshShader::ObjectPass2Shader::setUniforms(ModelViewProjectionMatrix, TextureMatrix); assert(mesh.vao_second_pass); - glBindVertexArray(mesh.vao_second_pass); - glDrawElements(ptype, count, itype, 0); + glBindVertexArray(mesh.vao_second_pass); + glDrawElements(ptype, count, itype, 0); } void drawTransparentObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix) { irr_driver->IncreaseObjectCount(); - GLenum ptype = mesh.PrimitiveType; - GLenum itype = mesh.IndexType; - size_t count = mesh.IndexCount; + GLenum ptype = mesh.PrimitiveType; + GLenum itype = mesh.IndexType; + size_t count = mesh.IndexCount; - setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true); + setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true); MeshShader::TransparentShader::setUniforms(ModelViewProjectionMatrix, TextureMatrix, 0); assert(mesh.vao_first_pass); - glBindVertexArray(mesh.vao_first_pass); - glDrawElements(ptype, count, itype, 0); + glBindVertexArray(mesh.vao_first_pass); + glDrawElements(ptype, count, itype, 0); } void drawTransparentFogObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix) @@ -630,20 +630,20 @@ void drawTransparentFogObject(const GLMesh &mesh, const core::matrix4 &ModelView void drawBubble(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix) { irr_driver->IncreaseObjectCount(); - const float time = irr_driver->getDevice()->getTimer()->getTime() / 1000.0f; - float transparency = 1.; + const float time = irr_driver->getDevice()->getTimer()->getTime() / 1000.0f; + float transparency = 1.; - GLenum ptype = mesh.PrimitiveType; - GLenum itype = mesh.IndexType; - size_t count = mesh.IndexCount; + GLenum ptype = mesh.PrimitiveType; + GLenum itype = mesh.IndexType; + size_t count = mesh.IndexCount; - setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true); + setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true); - MeshShader::BubbleShader::setUniforms(ModelViewProjectionMatrix, 0, time, transparency); + MeshShader::BubbleShader::setUniforms(ModelViewProjectionMatrix, 0, time, transparency); assert(mesh.vao_first_pass); - glBindVertexArray(mesh.vao_first_pass); - glDrawElements(ptype, count, itype, 0); + glBindVertexArray(mesh.vao_first_pass); + glDrawElements(ptype, count, itype, 0); } void drawShadowRef(const GLMesh &mesh) @@ -692,41 +692,41 @@ void drawShadow(const GLMesh &mesh) bool isObject(video::E_MATERIAL_TYPE type) { - if (type == irr_driver->getShader(ES_OBJECTPASS)) - return true; - if (type == irr_driver->getShader(ES_OBJECTPASS_REF)) - return true; - if (type == irr_driver->getShader(ES_OBJECTPASS_RIMLIT)) - return true; - if (type == irr_driver->getShader(ES_NORMAL_MAP)) - return true; - if (type == irr_driver->getShader(ES_SPHERE_MAP)) - return true; - if (type == irr_driver->getShader(ES_SPLATTING)) - return true; - if (type == irr_driver->getShader(ES_GRASS)) - return true; - if (type == irr_driver->getShader(ES_GRASS_REF)) - return true; - if (type == irr_driver->getShader(ES_BUBBLES)) - return true; - if (type == irr_driver->getShader(ES_OBJECT_UNLIT)) - return true; + if (type == irr_driver->getShader(ES_OBJECTPASS)) + return true; + if (type == irr_driver->getShader(ES_OBJECTPASS_REF)) + return true; + if (type == irr_driver->getShader(ES_OBJECTPASS_RIMLIT)) + return true; + if (type == irr_driver->getShader(ES_NORMAL_MAP)) + return true; + if (type == irr_driver->getShader(ES_SPHERE_MAP)) + return true; + if (type == irr_driver->getShader(ES_SPLATTING)) + return true; + if (type == irr_driver->getShader(ES_GRASS)) + return true; + if (type == irr_driver->getShader(ES_GRASS_REF)) + return true; + if (type == irr_driver->getShader(ES_BUBBLES)) + return true; + if (type == irr_driver->getShader(ES_OBJECT_UNLIT)) + return true; if (type == irr_driver->getShader(ES_CAUSTICS)) return true; - if (type == video::EMT_TRANSPARENT_ALPHA_CHANNEL) - return true; - if (type == video::EMT_ONETEXTURE_BLEND) - return true; - if (type == video::EMT_TRANSPARENT_ADD_COLOR) - return true; + if (type == video::EMT_TRANSPARENT_ALPHA_CHANNEL) + return true; + if (type == video::EMT_ONETEXTURE_BLEND) + return true; + if (type == video::EMT_TRANSPARENT_ADD_COLOR) + return true; if (type == video::EMT_SOLID) return true; if (type == video::EMT_LIGHTMAP_LIGHTING) return true; if (type == video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF) return true; - return false; + return false; } void initvaostate(GLMesh &mesh, GeometricMaterial GeoMat, ShadedMaterial ShadedMat) diff --git a/src/graphics/stkmesh.hpp b/src/graphics/stkmesh.hpp index a7da5a207..d24834ed7 100644 --- a/src/graphics/stkmesh.hpp +++ b/src/graphics/stkmesh.hpp @@ -40,19 +40,19 @@ enum TransparentMaterial }; struct GLMesh { - GLuint vao_first_pass; - GLuint vao_second_pass; - GLuint vao_glow_pass; - GLuint vao_displace_pass; + GLuint vao_first_pass; + GLuint vao_second_pass; + GLuint vao_glow_pass; + GLuint vao_displace_pass; GLuint vao_displace_mask_pass; GLuint vao_shadow_pass; - GLuint vertex_buffer; - GLuint index_buffer; - GLuint textures[6]; - GLenum PrimitiveType; - GLenum IndexType; - size_t IndexCount; - size_t Stride; + GLuint vertex_buffer; + GLuint index_buffer; + GLuint textures[6]; + GLenum PrimitiveType; + GLenum IndexType; + size_t IndexCount; + size_t Stride; core::matrix4 TextureMatrix; }; diff --git a/src/graphics/wind.hpp b/src/graphics/wind.hpp index afa011d43..651258f2b 100644 --- a/src/graphics/wind.hpp +++ b/src/graphics/wind.hpp @@ -24,14 +24,14 @@ using core::vector3df; class Wind { public: - Wind(); + Wind(); - vector3df getWind() const; - void update(); + vector3df getWind() const; + void update(); private: - vector3df m_wind; - float m_seed; + vector3df m_wind; + float m_seed; }; #endif diff --git a/src/guiengine/engine.cpp b/src/guiengine/engine.cpp index 70397a404..f77cb55d1 100644 --- a/src/guiengine/engine.cpp +++ b/src/guiengine/engine.cpp @@ -794,14 +794,14 @@ namespace GUIEngine { return Private::small_font_height; } // getSmallFontHeight - - // ------------------------------------------------------------------------ + + // ------------------------------------------------------------------------ int getLargeFontHeight() { return Private::large_font_height; } // getSmallFontHeight - + // ------------------------------------------------------------------------ void clear() { diff --git a/src/guiengine/engine.hpp b/src/guiengine/engine.hpp index 9669503c7..5dcfce20d 100644 --- a/src/guiengine/engine.hpp +++ b/src/guiengine/engine.hpp @@ -170,7 +170,7 @@ namespace GUIEngine inline Skin* getSkin() { return Private::g_skin; } Screen* getScreenNamed(const char* name); - + /** \return the height of the title font in pixels */ int getTitleFontHeight(); diff --git a/src/guiengine/event_handler.cpp b/src/guiengine/event_handler.cpp index 0080dd276..acce1b1d9 100644 --- a/src/guiengine/event_handler.cpp +++ b/src/guiengine/event_handler.cpp @@ -65,7 +65,7 @@ bool EventHandler::OnEvent (const SEvent &event) if(!Debug::onEvent(event)) return false; - + // TO DEBUG HATS (when you don't actually have a hat) /* if (event.EventType == EET_KEY_INPUT_EVENT) @@ -630,7 +630,7 @@ EventPropagation EventHandler::onWidgetActivated(GUIEngine::Widget* w, const int if (w->m_deactivated) return EVENT_BLOCK; Widget* parent = w->m_event_handler; - + if (ModalDialog::isADialogActive() && (parent == NULL || parent->m_type != GUIEngine::WTYPE_RIBBON)) { if (ModalDialog::getCurrent()->processEvent(w->m_properties[PROP_ID]) == EVENT_BLOCK) diff --git a/src/guiengine/event_handler.hpp b/src/guiengine/event_handler.hpp index 38344149a..f4207f4e8 100644 --- a/src/guiengine/event_handler.hpp +++ b/src/guiengine/event_handler.hpp @@ -59,7 +59,7 @@ namespace GUIEngine a player cannot trigger an action by clicking on the window during loading screen for example */ bool m_accept_events; - + EventPropagation onGUIEvent(const irr::SEvent& event); EventPropagation onWidgetActivated(Widget* w, const int playerID); void navigateUp(const int playerID, Input::InputType type, const bool pressedDown); @@ -102,7 +102,7 @@ namespace GUIEngine /** singleton access */ static EventHandler* get(); static void deallocate(); - + void startAcceptingEvents() { m_accept_events = true; } }; diff --git a/src/guiengine/layout_manager.cpp b/src/guiengine/layout_manager.cpp index ea61201fb..32643e221 100644 --- a/src/guiengine/layout_manager.cpp +++ b/src/guiengine/layout_manager.cpp @@ -302,19 +302,19 @@ void LayoutManager::applyCoords(Widget* self, AbstractTopLevelContainer* topLeve parent_x = parent->m_x; parent_y = parent->m_y; } - + if (parent != NULL && parent->getType() == WTYPE_DIV && parent->m_show_bounding_box) { int padding = 15; if (parent->m_properties[PROP_DIV_PADDING].length() > 0) padding = atoi(parent->m_properties[PROP_DIV_PADDING].c_str()); - + parent_x += padding; parent_y += padding; parent_w -= padding*2; parent_h -= padding*2; } - + if (self->m_absolute_x > -1) self->m_x = parent_x + self->m_absolute_x; else if (self->m_absolute_reverse_x > -1) self->m_x = parent_x + (parent_w - self->m_absolute_reverse_x); else if (self->m_relative_x > -1) self->m_x = (int)(parent_x + parent_w*self->m_relative_x/100); @@ -434,13 +434,13 @@ void LayoutManager::doCalculateLayout(PtrVector& widgets, AbstractTopLev int padding = 15; if (parent->m_properties[PROP_DIV_PADDING].length() > 0) padding = atoi(parent->m_properties[PROP_DIV_PADDING].c_str()); - + x += padding; y += padding; w -= padding*2; h -= padding*2; } - + // find space left after placing all absolutely-sized widgets in a row // (the space left will be divided between remaining widgets later) int left_space = (horizontal ? w : h); diff --git a/src/guiengine/modaldialog.cpp b/src/guiengine/modaldialog.cpp index 961358b8b..57565ad9a 100644 --- a/src/guiengine/modaldialog.cpp +++ b/src/guiengine/modaldialog.cpp @@ -89,7 +89,7 @@ void ModalDialog::doInit() pointer_was_shown = irr_driver->isPointerShown(); irr_driver->showPointer(); - const core::dimension2d& frame_size = + const core::dimension2d& frame_size = GUIEngine::getDriver()->getCurrentRenderTargetSize(); const int w = (int)(frame_size.Width* m_percent_width); @@ -131,7 +131,7 @@ void ModalDialog::doInit() } modalWindow = this; - m_irrlicht_window = GUIEngine::getGUIEnv()->addWindow(m_area, + m_irrlicht_window = GUIEngine::getGUIEnv()->addWindow(m_area, true /* modal */); GUIEngine::getSkin()->m_dialog = true; diff --git a/src/guiengine/skin.cpp b/src/guiengine/skin.cpp index 371f25e9f..c2a01af7d 100644 --- a/src/guiengine/skin.cpp +++ b/src/guiengine/skin.cpp @@ -818,7 +818,7 @@ void Skin::drawRatingBar(Widget *w, const core::recti &rect, const int texture_w = texture->getSize().Width / 4; const int texture_h = texture->getSize().Height; const float aspect_ratio = 1.0f; - + const int star_number = ratingBar->getStarNumber(); int star_h = rect.getHeight(); @@ -830,7 +830,7 @@ void Skin::drawRatingBar(Widget *w, const core::recti &rect, star_w = (int)(star_w * scale_factor); star_h = (int)(star_h * scale_factor); } - + // center horizontally and vertically const int x_from = rect.UpperLeftCorner.X; const int y_from = rect.UpperLeftCorner.Y; @@ -853,10 +853,10 @@ void Skin::drawRatingBar(Widget *w, const core::recti &rect, star_rect.UpperLeftCorner.Y = y_from; star_rect.LowerRightCorner.X = x_from + (i + 1) * star_w; star_rect.LowerRightCorner.Y = y_from + star_h; - + int step = ratingBar->getStepsOfStar(i); - - const core::recti source_area(texture_w * step, 0, + + const core::recti source_area(texture_w * step, 0, texture_w * (step + 1), texture_h); draw2DImage(texture, @@ -1253,7 +1253,7 @@ void Skin::drawSpinnerBody(const core::recti &rect, Widget* widget, rect2.LowerRightCorner.Y += 5; drawBoxFromStretchableTexture(widget, rect2, SkinConfig::m_render_params["squareFocusHalo::neutral"]); - + } else if (widget->isFocusedForPlayer(1)) @@ -1314,7 +1314,7 @@ void Skin::drawSpinnerBody(const core::recti &rect, Widget* widget, // ---- If this spinner is of "gauge" type, draw filling const SpinnerWidget* w = dynamic_cast(widget); - + if (w->isGauge() && !w->m_deactivated) { const int handle_size = (int)( widget->m_h*params->m_left_border @@ -1651,7 +1651,7 @@ void Skin::renderSections(PtrVector* within_vector) drawBoxFromStretchableTexture(&widget, rect, SkinConfig::m_render_params["section::neutral"]); } - + renderSections( &widget.m_children ); } else if (widget.isBottomBar()) @@ -2097,7 +2097,7 @@ void Skin::draw3DSunkenPane (IGUIElement *element, video::SColor bgcolor, core::recti innerArea = borderArea; innerArea.UpperLeftCorner += position2d< s32 >( 3, 3 ); innerArea.LowerRightCorner -= position2d< s32 >( 3, 3 ); - GL32_draw2DRectangle(focused ? bg_color_focused : bg_color, innerArea); + GL32_draw2DRectangle(focused ? bg_color_focused : bg_color, innerArea); return; } else if (type == WTYPE_LIST) @@ -2161,7 +2161,7 @@ void Skin::drawBGFadeColor() SColor color = SkinConfig::m_colors["dialog_background::neutral"]; if (m_dialog_size < 1.0f) color.setAlpha( (unsigned int)(color.getAlpha()*m_dialog_size )); - GL32_draw2DRectangle(color, + GL32_draw2DRectangle(color, core::recti(position2d< s32 >(0,0), GUIEngine::getDriver()->getCurrentRenderTargetSize()) ); } // drawBGFadeColor @@ -2211,7 +2211,7 @@ void Skin::draw3DMenuPane (IGUIElement *element, const core::recti &rect, const core::recti *clip) { SColor color = SColor(150, 96, 74, 196); - GL32_draw2DRectangle(color, rect); + GL32_draw2DRectangle(color, rect); } // draw3DMenuPane // ----------------------------------------------------------------------------- diff --git a/src/guiengine/widgets/CGUIEditBox.h b/src/guiengine/widgets/CGUIEditBox.h index d9555bbf3..763780c9a 100644 --- a/src/guiengine/widgets/CGUIEditBox.h +++ b/src/guiengine/widgets/CGUIEditBox.h @@ -16,155 +16,155 @@ using namespace irr; using namespace gui; - class CGUIEditBox : public IGUIEditBox - { - public: + class CGUIEditBox : public IGUIEditBox + { + public: LEAK_CHECK() - //! constructor - CGUIEditBox(const wchar_t* text, bool border, IGUIEnvironment* environment, - IGUIElement* parent, s32 id, const core::rect& rectangle, bool is_rtl); + //! constructor + CGUIEditBox(const wchar_t* text, bool border, IGUIEnvironment* environment, + IGUIElement* parent, s32 id, const core::rect& rectangle, bool is_rtl); - //! destructor - virtual ~CGUIEditBox(); + //! destructor + virtual ~CGUIEditBox(); - //! Sets another skin independent font. - virtual void setOverrideFont(IGUIFont* font=0); + //! Sets another skin independent font. + virtual void setOverrideFont(IGUIFont* font=0); - //! Sets another color for the text. - virtual void setOverrideColor(video::SColor color); + //! Sets another color for the text. + virtual void setOverrideColor(video::SColor color); - //! Gets the override color - virtual video::SColor getOverrideColor() const; + //! Gets the override color + virtual video::SColor getOverrideColor() const; - //! Sets if the text should use the overide color or the - //! color in the gui skin. - virtual void enableOverrideColor(bool enable); + //! Sets if the text should use the overide color or the + //! color in the gui skin. + virtual void enableOverrideColor(bool enable); - //! Checks if an override color is enabled - /** \return true if the override color is enabled, false otherwise */ - virtual bool isOverrideColorEnabled(void) const; + //! Checks if an override color is enabled + /** \return true if the override color is enabled, false otherwise */ + virtual bool isOverrideColorEnabled(void) const; - //! Turns the border on or off - virtual void setDrawBorder(bool border); + //! Turns the border on or off + virtual void setDrawBorder(bool border); - //! Enables or disables word wrap for using the edit box as multiline text editor. - virtual void setWordWrap(bool enable); + //! Enables or disables word wrap for using the edit box as multiline text editor. + virtual void setWordWrap(bool enable); - //! Checks if word wrap is enabled - //! \return true if word wrap is enabled, false otherwise - virtual bool isWordWrapEnabled() const; + //! Checks if word wrap is enabled + //! \return true if word wrap is enabled, false otherwise + virtual bool isWordWrapEnabled() const; - //! Enables or disables newlines. - /** \param enable: If set to true, the EGET_EDITBOX_ENTER event will not be fired, - instead a newline character will be inserted. */ - virtual void setMultiLine(bool enable); + //! Enables or disables newlines. + /** \param enable: If set to true, the EGET_EDITBOX_ENTER event will not be fired, + instead a newline character will be inserted. */ + virtual void setMultiLine(bool enable); - //! Checks if multi line editing is enabled - //! \return true if mult-line is enabled, false otherwise - virtual bool isMultiLineEnabled() const; + //! Checks if multi line editing is enabled + //! \return true if mult-line is enabled, false otherwise + virtual bool isMultiLineEnabled() const; - //! Enables or disables automatic scrolling with cursor position - //! \param enable: If set to true, the text will move around with the cursor position - virtual void setAutoScroll(bool enable); + //! Enables or disables automatic scrolling with cursor position + //! \param enable: If set to true, the text will move around with the cursor position + virtual void setAutoScroll(bool enable); - //! Checks to see if automatic scrolling is enabled - //! \return true if automatic scrolling is enabled, false if not - virtual bool isAutoScrollEnabled() const; + //! Checks to see if automatic scrolling is enabled + //! \return true if automatic scrolling is enabled, false if not + virtual bool isAutoScrollEnabled() const; - //! Gets the size area of the text in the edit box - //! \return Returns the size in pixels of the text - virtual core::dimension2du getTextDimension(); + //! Gets the size area of the text in the edit box + //! \return Returns the size in pixels of the text + virtual core::dimension2du getTextDimension(); - //! Sets text justification - virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical); + //! Sets text justification + virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical); - //! called if an event happened. - virtual bool OnEvent(const SEvent& event); + //! called if an event happened. + virtual bool OnEvent(const SEvent& event); - //! draws the element and its children - virtual void draw(); + //! draws the element and its children + virtual void draw(); - //! Sets the new caption of this element. - virtual void setText(const wchar_t* text); + //! Sets the new caption of this element. + virtual void setText(const wchar_t* text); - //! Sets the maximum amount of characters which may be entered in the box. - //! \param max: Maximum amount of characters. If 0, the character amount is - //! infinity. - virtual void setMax(u32 max); + //! Sets the maximum amount of characters which may be entered in the box. + //! \param max: Maximum amount of characters. If 0, the character amount is + //! infinity. + virtual void setMax(u32 max); - //! Returns maximum amount of characters, previously set by setMax(); - virtual u32 getMax() const; + //! Returns maximum amount of characters, previously set by setMax(); + virtual u32 getMax() const; - //! Sets whether the edit box is a password box. Setting this to true will - /** disable MultiLine, WordWrap and the ability to copy with ctrl+c or ctrl+x - \param passwordBox: true to enable password, false to disable - \param passwordChar: the character that is displayed instead of letters */ - virtual void setPasswordBox(bool passwordBox, wchar_t passwordChar = L'*'); + //! Sets whether the edit box is a password box. Setting this to true will + /** disable MultiLine, WordWrap and the ability to copy with ctrl+c or ctrl+x + \param passwordBox: true to enable password, false to disable + \param passwordChar: the character that is displayed instead of letters */ + virtual void setPasswordBox(bool passwordBox, wchar_t passwordChar = L'*'); - //! Returns true if the edit box is currently a password box. - virtual bool isPasswordBox() const; + //! Returns true if the edit box is currently a password box. + virtual bool isPasswordBox() const; - //! Updates the absolute position, splits text if required - virtual void updateAbsolutePosition(); + //! Updates the absolute position, splits text if required + virtual void updateAbsolutePosition(); - //! Writes attributes of the element. - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; + //! Writes attributes of the element. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; - //! Reads attributes of the element - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); + //! Reads attributes of the element + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); virtual irr::gui::IGUIFont* getOverrideFont() const { return NULL; } virtual irr::gui::IGUIFont* getActiveFont() const { return NULL; } virtual void setDrawBackground(bool) { } - protected: - //! Breaks the single text line. - void breakText(); - //! sets the area of the given line - void setTextRect(s32 line); - //! returns the line number that the cursor is on - s32 getLineFromPos(s32 pos); - //! adds a letter to the edit box - void inputChar(wchar_t c); - //! calculates the current scroll position - void calculateScrollPos(); - //! send some gui event to parent - void sendGuiEvent(EGUI_EVENT_TYPE type); - //! set text markers - void setTextMarkers(s32 begin, s32 end); + protected: + //! Breaks the single text line. + void breakText(); + //! sets the area of the given line + void setTextRect(s32 line); + //! returns the line number that the cursor is on + s32 getLineFromPos(s32 pos); + //! adds a letter to the edit box + void inputChar(wchar_t c); + //! calculates the current scroll position + void calculateScrollPos(); + //! send some gui event to parent + void sendGuiEvent(EGUI_EVENT_TYPE type); + //! set text markers + void setTextMarkers(s32 begin, s32 end); - bool processKey(const SEvent& event); - bool processMouse(const SEvent& event); - s32 getCursorPos(s32 x, s32 y); + bool processKey(const SEvent& event); + bool processMouse(const SEvent& event); + s32 getCursorPos(s32 x, s32 y); - bool MouseMarking; - bool Border; - bool OverrideColorEnabled; - s32 MarkBegin; - s32 MarkEnd; + bool MouseMarking; + bool Border; + bool OverrideColorEnabled; + s32 MarkBegin; + s32 MarkEnd; - video::SColor OverrideColor; - gui::IGUIFont *OverrideFont, *LastBreakFont; - IOSOperator* Operator; + video::SColor OverrideColor; + gui::IGUIFont *OverrideFont, *LastBreakFont; + IOSOperator* Operator; StkTime::TimeType BlinkStartTime; - s32 CursorPos; - s32 HScrollPos, VScrollPos; // scroll position in characters - u32 Max; + s32 CursorPos; + s32 HScrollPos, VScrollPos; // scroll position in characters + u32 Max; bool m_rtl; - bool WordWrap, MultiLine, AutoScroll, PasswordBox; - wchar_t PasswordChar; - EGUI_ALIGNMENT HAlign, VAlign; + bool WordWrap, MultiLine, AutoScroll, PasswordBox; + wchar_t PasswordChar; + EGUI_ALIGNMENT HAlign, VAlign; - core::array< core::stringw > BrokenText; - core::array< s32 > BrokenTextPositions; + core::array< core::stringw > BrokenText; + core::array< s32 > BrokenTextPositions; - core::rect CurrentTextRect, FrameRect; // temporary values - }; + core::rect CurrentTextRect, FrameRect; // temporary values + }; diff --git a/src/guiengine/widgets/CGUISTKListBox.cpp b/src/guiengine/widgets/CGUISTKListBox.cpp index 21d3bbfe6..8689b12bd 100644 --- a/src/guiengine/widgets/CGUISTKListBox.cpp +++ b/src/guiengine/widgets/CGUISTKListBox.cpp @@ -21,59 +21,59 @@ namespace gui //! constructor CGUISTKListBox::CGUISTKListBox(IGUIEnvironment* environment, IGUIElement* parent, - s32 id, core::rect rectangle, bool clip, - bool drawBack, bool moveOverSelect) + s32 id, core::rect rectangle, bool clip, + bool drawBack, bool moveOverSelect) : IGUIElement(EGUIET_LIST_BOX, environment, parent, id, rectangle), Selected(-1), - ItemHeight(0),ItemHeightOverride(0), - TotalItemHeight(0), ItemsIconWidth(0), Font(0), IconBank(0), - ScrollBar(0), selectTime(0), LastKeyTime(0), Selecting(false), DrawBack(drawBack), - MoveOverSelect(moveOverSelect), AutoScroll(true), HighlightWhenNotFocused(true) + ItemHeight(0),ItemHeightOverride(0), + TotalItemHeight(0), ItemsIconWidth(0), Font(0), IconBank(0), + ScrollBar(0), selectTime(0), LastKeyTime(0), Selecting(false), DrawBack(drawBack), + MoveOverSelect(moveOverSelect), AutoScroll(true), HighlightWhenNotFocused(true) { - #ifdef _DEBUG - setDebugName("CGUISTKListBox"); - #endif + #ifdef _DEBUG + setDebugName("CGUISTKListBox"); + #endif - IGUISkin* skin = Environment->getSkin(); - const s32 s = skin->getSize(EGDS_SCROLLBAR_SIZE); + IGUISkin* skin = Environment->getSkin(); + const s32 s = skin->getSize(EGDS_SCROLLBAR_SIZE); - ScrollBar = Environment->addScrollBar(false, - core::rect(RelativeRect.getWidth() - s, 0, + ScrollBar = Environment->addScrollBar(false, + core::rect(RelativeRect.getWidth() - s, 0, RelativeRect.getWidth(), RelativeRect.getHeight()), this, -1); ScrollBar->grab(); - ScrollBar->setSubElement(true); - ScrollBar->setTabStop(false); - ScrollBar->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); - ScrollBar->setVisible(false); - ScrollBar->setPos(0); + ScrollBar->setSubElement(true); + ScrollBar->setTabStop(false); + ScrollBar->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); + ScrollBar->setVisible(false); + ScrollBar->setPos(0); - setNotClipped(!clip); + setNotClipped(!clip); - // this element can be tabbed to - setTabStop(true); - setTabOrder(-1); + // this element can be tabbed to + setTabStop(true); + setTabOrder(-1); - updateAbsolutePosition(); + updateAbsolutePosition(); } //! destructor CGUISTKListBox::~CGUISTKListBox() { - if (ScrollBar) - ScrollBar->drop(); + if (ScrollBar) + ScrollBar->drop(); - if (Font) - Font->drop(); + if (Font) + Font->drop(); - if (IconBank) - IconBank->drop(); + if (IconBank) + IconBank->drop(); } //! returns amount of list items u32 CGUISTKListBox::getItemCount() const { - return Items.size(); + return Items.size(); } @@ -84,7 +84,7 @@ const wchar_t* CGUISTKListBox::getCellText(u32 row_num, u32 col_num) const return 0; if ( col_num >= Items[row_num].m_contents.size() ) return 0; - return Items[row_num].m_contents[col_num].m_text.c_str(); + return Items[row_num].m_contents[col_num].m_text.c_str(); } CGUISTKListBox::ListItem CGUISTKListBox::getItem(u32 id) const @@ -105,109 +105,109 @@ s32 CGUISTKListBox::getIcon(u32 row_num, u32 col_num) const void CGUISTKListBox::removeItem(u32 id) { - if (id >= Items.size()) - return; + if (id >= Items.size()) + return; - if ((u32)Selected==id) - { - Selected = -1; - } - else if ((u32)Selected > id) - { - Selected -= 1; - selectTime = (u32)StkTime::getTimeSinceEpoch(); - } + if ((u32)Selected==id) + { + Selected = -1; + } + else if ((u32)Selected > id) + { + Selected -= 1; + selectTime = (u32)StkTime::getTimeSinceEpoch(); + } - Items.erase(id); + Items.erase(id); - recalculateItemHeight(); + recalculateItemHeight(); } s32 CGUISTKListBox::getItemAt(s32 xpos, s32 ypos) const { - if ( xpos < AbsoluteRect.UpperLeftCorner.X || xpos >= AbsoluteRect.LowerRightCorner.X - || ypos < AbsoluteRect.UpperLeftCorner.Y || ypos >= AbsoluteRect.LowerRightCorner.Y - ) - return -1; + if ( xpos < AbsoluteRect.UpperLeftCorner.X || xpos >= AbsoluteRect.LowerRightCorner.X + || ypos < AbsoluteRect.UpperLeftCorner.Y || ypos >= AbsoluteRect.LowerRightCorner.Y + ) + return -1; - if ( ItemHeight == 0 ) - return -1; + if ( ItemHeight == 0 ) + return -1; - s32 item = ((ypos - AbsoluteRect.UpperLeftCorner.Y - 1) + ScrollBar->getPos()) / ItemHeight; - if ( item < 0 || item >= (s32)Items.size()) - return -1; + s32 item = ((ypos - AbsoluteRect.UpperLeftCorner.Y - 1) + ScrollBar->getPos()) / ItemHeight; + if ( item < 0 || item >= (s32)Items.size()) + return -1; - return item; + return item; } //! clears the list void CGUISTKListBox::clear() { - Items.clear(); - ItemsIconWidth = 0; - Selected = -1; + Items.clear(); + ItemsIconWidth = 0; + Selected = -1; - if (ScrollBar) - ScrollBar->setPos(0); + if (ScrollBar) + ScrollBar->setPos(0); - recalculateItemHeight(); + recalculateItemHeight(); } void CGUISTKListBox::recalculateItemHeight() { - IGUISkin* skin = Environment->getSkin(); + IGUISkin* skin = Environment->getSkin(); - if (Font != skin->getFont()) - { - if (Font) - Font->drop(); + if (Font != skin->getFont()) + { + if (Font) + Font->drop(); - Font = skin->getFont(); - if ( 0 == ItemHeightOverride ) - ItemHeight = 0; + Font = skin->getFont(); + if ( 0 == ItemHeightOverride ) + ItemHeight = 0; - if (Font) - { - if ( 0 == ItemHeightOverride ) - ItemHeight = Font->getDimension(L"A").Height + 4; + if (Font) + { + if ( 0 == ItemHeightOverride ) + ItemHeight = Font->getDimension(L"A").Height + 4; - Font->grab(); - } - } + Font->grab(); + } + } - TotalItemHeight = ItemHeight * Items.size(); - ScrollBar->setMax( core::max_(0, TotalItemHeight - AbsoluteRect.getHeight()) ); - s32 minItemHeight = ItemHeight > 0 ? ItemHeight : 1; - ScrollBar->setSmallStep ( minItemHeight ); - ScrollBar->setLargeStep ( 2*minItemHeight ); + TotalItemHeight = ItemHeight * Items.size(); + ScrollBar->setMax( core::max_(0, TotalItemHeight - AbsoluteRect.getHeight()) ); + s32 minItemHeight = ItemHeight > 0 ? ItemHeight : 1; + ScrollBar->setSmallStep ( minItemHeight ); + ScrollBar->setLargeStep ( 2*minItemHeight ); - if ( TotalItemHeight <= AbsoluteRect.getHeight() ) - ScrollBar->setVisible(false); - else - ScrollBar->setVisible(true); + if ( TotalItemHeight <= AbsoluteRect.getHeight() ) + ScrollBar->setVisible(false); + else + ScrollBar->setVisible(true); } //! returns id of selected item. returns -1 if no item is selected. s32 CGUISTKListBox::getSelected() const { - return Selected; + return Selected; } //! sets the selected item. Set this to -1 if no item should be selected void CGUISTKListBox::setSelected(s32 id) { - if ((u32)id>=Items.size()) - Selected = -1; - else - Selected = id; + if ((u32)id>=Items.size()) + Selected = -1; + else + Selected = id; - selectTime = (u32)StkTime::getTimeSinceEpoch(); + selectTime = (u32)StkTime::getTimeSinceEpoch(); - recalculateScrollPos(); + recalculateScrollPos(); } s32 CGUISTKListBox::getRowByCellText(const wchar_t * text) @@ -249,184 +249,184 @@ s32 CGUISTKListBox::getRowByInternalName(const std::string & text) const //! called if an event happened. bool CGUISTKListBox::OnEvent(const SEvent& event) { - if (isEnabled()) - { - switch(event.EventType) - { - case EET_KEY_INPUT_EVENT: - if (event.KeyInput.PressedDown && - (event.KeyInput.Key == KEY_DOWN || - event.KeyInput.Key == KEY_UP || - event.KeyInput.Key == KEY_HOME || - event.KeyInput.Key == KEY_END || - event.KeyInput.Key == KEY_NEXT || - event.KeyInput.Key == KEY_PRIOR ) ) - { - s32 oldSelected = Selected; - switch (event.KeyInput.Key) - { - case KEY_DOWN: - Selected += 1; - break; - case KEY_UP: - Selected -= 1; - break; - case KEY_HOME: - Selected = 0; - break; - case KEY_END: - Selected = (s32)Items.size()-1; - break; - case KEY_NEXT: - Selected += AbsoluteRect.getHeight() / ItemHeight; - break; - case KEY_PRIOR: - Selected -= AbsoluteRect.getHeight() / ItemHeight; - break; - default: - break; - } - if (Selected >= (s32)Items.size()) - Selected = Items.size() - 1; - else - if (Selected<0) - Selected = 0; + if (isEnabled()) + { + switch(event.EventType) + { + case EET_KEY_INPUT_EVENT: + if (event.KeyInput.PressedDown && + (event.KeyInput.Key == KEY_DOWN || + event.KeyInput.Key == KEY_UP || + event.KeyInput.Key == KEY_HOME || + event.KeyInput.Key == KEY_END || + event.KeyInput.Key == KEY_NEXT || + event.KeyInput.Key == KEY_PRIOR ) ) + { + s32 oldSelected = Selected; + switch (event.KeyInput.Key) + { + case KEY_DOWN: + Selected += 1; + break; + case KEY_UP: + Selected -= 1; + break; + case KEY_HOME: + Selected = 0; + break; + case KEY_END: + Selected = (s32)Items.size()-1; + break; + case KEY_NEXT: + Selected += AbsoluteRect.getHeight() / ItemHeight; + break; + case KEY_PRIOR: + Selected -= AbsoluteRect.getHeight() / ItemHeight; + break; + default: + break; + } + if (Selected >= (s32)Items.size()) + Selected = Items.size() - 1; + else + if (Selected<0) + Selected = 0; - recalculateScrollPos(); + recalculateScrollPos(); - // post the news + // post the news - if (oldSelected != Selected && Parent && !Selecting && !MoveOverSelect) - { - SEvent e; - e.EventType = EET_GUI_EVENT; - e.GUIEvent.Caller = this; - e.GUIEvent.Element = 0; - e.GUIEvent.EventType = EGET_LISTBOX_CHANGED; - Parent->OnEvent(e); - } + if (oldSelected != Selected && Parent && !Selecting && !MoveOverSelect) + { + SEvent e; + e.EventType = EET_GUI_EVENT; + e.GUIEvent.Caller = this; + e.GUIEvent.Element = 0; + e.GUIEvent.EventType = EGET_LISTBOX_CHANGED; + Parent->OnEvent(e); + } - return true; - } - else - if (!event.KeyInput.PressedDown && ( event.KeyInput.Key == KEY_RETURN || event.KeyInput.Key == KEY_SPACE ) ) - { - if (Parent) - { - SEvent e; - e.EventType = EET_GUI_EVENT; - e.GUIEvent.Caller = this; - e.GUIEvent.Element = 0; - e.GUIEvent.EventType = EGET_LISTBOX_SELECTED_AGAIN; - Parent->OnEvent(e); - } - return true; - } - break; + return true; + } + else + if (!event.KeyInput.PressedDown && ( event.KeyInput.Key == KEY_RETURN || event.KeyInput.Key == KEY_SPACE ) ) + { + if (Parent) + { + SEvent e; + e.EventType = EET_GUI_EVENT; + e.GUIEvent.Caller = this; + e.GUIEvent.Element = 0; + e.GUIEvent.EventType = EGET_LISTBOX_SELECTED_AGAIN; + Parent->OnEvent(e); + } + return true; + } + break; - case EET_GUI_EVENT: - switch(event.GUIEvent.EventType) - { - case gui::EGET_SCROLL_BAR_CHANGED: - if (event.GUIEvent.Caller == ScrollBar) - return true; - break; - case gui::EGET_ELEMENT_FOCUS_LOST: - { - if (event.GUIEvent.Caller == this) - Selecting = false; - break; - } + case EET_GUI_EVENT: + switch(event.GUIEvent.EventType) + { + case gui::EGET_SCROLL_BAR_CHANGED: + if (event.GUIEvent.Caller == ScrollBar) + return true; + break; + case gui::EGET_ELEMENT_FOCUS_LOST: + { + if (event.GUIEvent.Caller == this) + Selecting = false; + break; + } - default: - break; - } - break; + default: + break; + } + break; - case EET_MOUSE_INPUT_EVENT: - { - core::position2d p(event.MouseInput.X, event.MouseInput.Y); + case EET_MOUSE_INPUT_EVENT: + { + core::position2d p(event.MouseInput.X, event.MouseInput.Y); - switch(event.MouseInput.Event) - { - case EMIE_MOUSE_WHEEL: - ScrollBar->setPos(ScrollBar->getPos() + (event.MouseInput.Wheel < 0 ? -1 : 1)*-ItemHeight/2); - return true; + switch(event.MouseInput.Event) + { + case EMIE_MOUSE_WHEEL: + ScrollBar->setPos(ScrollBar->getPos() + (event.MouseInput.Wheel < 0 ? -1 : 1)*-ItemHeight/2); + return true; - case EMIE_LMOUSE_PRESSED_DOWN: - { - Selecting = true; - return true; - } + case EMIE_LMOUSE_PRESSED_DOWN: + { + Selecting = true; + return true; + } - case EMIE_LMOUSE_LEFT_UP: - { - Selecting = false; + case EMIE_LMOUSE_LEFT_UP: + { + Selecting = false; - if (isPointInside(p)) - selectNew(event.MouseInput.Y); + if (isPointInside(p)) + selectNew(event.MouseInput.Y); - return true; - } + return true; + } - case EMIE_MOUSE_MOVED: - if (Selecting || MoveOverSelect) - { - if (isPointInside(p)) - { - selectNew(event.MouseInput.Y, true); - return true; - } - } - default: - break; - } - } - break; - case EET_LOG_TEXT_EVENT: - case EET_USER_EVENT: - case EET_JOYSTICK_INPUT_EVENT: - case EGUIET_FORCE_32_BIT: - break; - } - } + case EMIE_MOUSE_MOVED: + if (Selecting || MoveOverSelect) + { + if (isPointInside(p)) + { + selectNew(event.MouseInput.Y, true); + return true; + } + } + default: + break; + } + } + break; + case EET_LOG_TEXT_EVENT: + case EET_USER_EVENT: + case EET_JOYSTICK_INPUT_EVENT: + case EGUIET_FORCE_32_BIT: + break; + } + } - return IGUIElement::OnEvent(event); + return IGUIElement::OnEvent(event); } void CGUISTKListBox::selectNew(s32 ypos, bool onlyHover) { - u32 now = (u32)StkTime::getTimeSinceEpoch(); - s32 oldSelected = Selected; + u32 now = (u32)StkTime::getTimeSinceEpoch(); + s32 oldSelected = Selected; - Selected = getItemAt(AbsoluteRect.UpperLeftCorner.X, ypos); - if (Selected<0 && !Items.empty()) - Selected = 0; + Selected = getItemAt(AbsoluteRect.UpperLeftCorner.X, ypos); + if (Selected<0 && !Items.empty()) + Selected = 0; - recalculateScrollPos(); + recalculateScrollPos(); - gui::EGUI_EVENT_TYPE eventType = (Selected == oldSelected && now < selectTime + 500) ? EGET_LISTBOX_SELECTED_AGAIN : EGET_LISTBOX_CHANGED; - selectTime = now; - // post the news - if (Parent && !onlyHover) - { - SEvent event; - event.EventType = EET_GUI_EVENT; - event.GUIEvent.Caller = this; - event.GUIEvent.Element = 0; - event.GUIEvent.EventType = eventType; - Parent->OnEvent(event); - } + gui::EGUI_EVENT_TYPE eventType = (Selected == oldSelected && now < selectTime + 500) ? EGET_LISTBOX_SELECTED_AGAIN : EGET_LISTBOX_CHANGED; + selectTime = now; + // post the news + if (Parent && !onlyHover) + { + SEvent event; + event.EventType = EET_GUI_EVENT; + event.GUIEvent.Caller = this; + event.GUIEvent.Element = 0; + event.GUIEvent.EventType = eventType; + Parent->OnEvent(event); + } } //! Update the position and size of the listbox, and update the scrollbar void CGUISTKListBox::updateAbsolutePosition() { - IGUIElement::updateAbsolutePosition(); + IGUIElement::updateAbsolutePosition(); - recalculateItemHeight(); + recalculateItemHeight(); } @@ -563,10 +563,10 @@ void CGUISTKListBox::draw() //! adds an list item with an icon u32 CGUISTKListBox::addItem(const ListItem & item) { - Items.push_back(item); - recalculateItemHeight(); - recalculateIconWidth(); - return Items.size() - 1; + Items.push_back(item); + recalculateItemHeight(); + recalculateIconWidth(); + return Items.size() - 1; } @@ -574,44 +574,44 @@ void CGUISTKListBox::setSpriteBank(IGUISpriteBank* bank) { if ( bank == IconBank ) return; - if (IconBank) - IconBank->drop(); + if (IconBank) + IconBank->drop(); - IconBank = bank; - if (IconBank) - IconBank->grab(); + IconBank = bank; + if (IconBank) + IconBank->grab(); } void CGUISTKListBox::recalculateScrollPos() { - if (!AutoScroll) - return; + if (!AutoScroll) + return; - const s32 selPos = (Selected == -1 ? TotalItemHeight : Selected * ItemHeight) - ScrollBar->getPos(); + const s32 selPos = (Selected == -1 ? TotalItemHeight : Selected * ItemHeight) - ScrollBar->getPos(); - if (selPos < 0) - { - ScrollBar->setPos(ScrollBar->getPos() + selPos); - } - else - if (selPos > AbsoluteRect.getHeight() - ItemHeight) - { - ScrollBar->setPos(ScrollBar->getPos() + selPos - AbsoluteRect.getHeight() + ItemHeight); - } + if (selPos < 0) + { + ScrollBar->setPos(ScrollBar->getPos() + selPos); + } + else + if (selPos > AbsoluteRect.getHeight() - ItemHeight) + { + ScrollBar->setPos(ScrollBar->getPos() + selPos - AbsoluteRect.getHeight() + ItemHeight); + } } void CGUISTKListBox::setAutoScrollEnabled(bool scroll) { - AutoScroll = scroll; + AutoScroll = scroll; } bool CGUISTKListBox::isAutoScrollEnabled() const { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return AutoScroll; + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return AutoScroll; } void CGUISTKListBox::recalculateIconWidth() @@ -619,128 +619,128 @@ void CGUISTKListBox::recalculateIconWidth() for(int x = 0; x < (int)Items.getLast().m_contents.size(); ++x) { s32 icon = Items.getLast().m_contents[x].m_icon; - if (IconBank && icon > -1 && - IconBank->getSprites().size() > (u32)icon && - IconBank->getSprites()[(u32)icon].Frames.size()) - { - u32 rno = IconBank->getSprites()[(u32)icon].Frames[0].rectNumber; - if (IconBank->getPositions().size() > rno) - { - const s32 w = IconBank->getPositions()[rno].getWidth(); - if (w > ItemsIconWidth) - ItemsIconWidth = w; - } - } + if (IconBank && icon > -1 && + IconBank->getSprites().size() > (u32)icon && + IconBank->getSprites()[(u32)icon].Frames.size()) + { + u32 rno = IconBank->getSprites()[(u32)icon].Frames[0].rectNumber; + if (IconBank->getPositions().size() > rno) + { + const s32 w = IconBank->getPositions()[rno].getWidth(); + if (w > ItemsIconWidth) + ItemsIconWidth = w; + } + } } } void CGUISTKListBox::setCell(u32 row_num, u32 col_num, const wchar_t* text, s32 icon) { - if ( row_num >= Items.size() ) - return; + if ( row_num >= Items.size() ) + return; if ( col_num >= Items[row_num].m_contents.size() ) return; Items[row_num].m_contents[col_num].m_text = text; Items[row_num].m_contents[col_num].m_icon = icon; - recalculateItemHeight(); - recalculateIconWidth(); + recalculateItemHeight(); + recalculateIconWidth(); } void CGUISTKListBox::swapItems(u32 index1, u32 index2) { - if ( index1 >= Items.size() || index2 >= Items.size() ) - return; + if ( index1 >= Items.size() || index2 >= Items.size() ) + return; - ListItem dummmy = Items[index1]; - Items[index1] = Items[index2]; - Items[index2] = dummmy; + ListItem dummmy = Items[index1]; + Items[index1] = Items[index2]; + Items[index2] = dummmy; } void CGUISTKListBox::setItemOverrideColor(u32 index, video::SColor color) { - for ( u32 c=0; c < EGUI_LBC_COUNT; ++c ) - { - Items[index].OverrideColors[c].Use = true; - Items[index].OverrideColors[c].Color = color; - } + for ( u32 c=0; c < EGUI_LBC_COUNT; ++c ) + { + Items[index].OverrideColors[c].Use = true; + Items[index].OverrideColors[c].Color = color; + } } void CGUISTKListBox::setItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType, video::SColor color) { - if ( index >= Items.size() || colorType < 0 || colorType >= EGUI_LBC_COUNT ) - return; + if ( index >= Items.size() || colorType < 0 || colorType >= EGUI_LBC_COUNT ) + return; - Items[index].OverrideColors[colorType].Use = true; - Items[index].OverrideColors[colorType].Color = color; + Items[index].OverrideColors[colorType].Use = true; + Items[index].OverrideColors[colorType].Color = color; } void CGUISTKListBox::clearItemOverrideColor(u32 index) { - for (u32 c=0; c < (u32)EGUI_LBC_COUNT; ++c ) - { - Items[index].OverrideColors[c].Use = false; - } + for (u32 c=0; c < (u32)EGUI_LBC_COUNT; ++c ) + { + Items[index].OverrideColors[c].Use = false; + } } void CGUISTKListBox::clearItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) { - if ( index >= Items.size() || colorType < 0 || colorType >= EGUI_LBC_COUNT ) - return; + if ( index >= Items.size() || colorType < 0 || colorType >= EGUI_LBC_COUNT ) + return; - Items[index].OverrideColors[colorType].Use = false; + Items[index].OverrideColors[colorType].Use = false; } bool CGUISTKListBox::hasItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) const { - if ( index >= Items.size() || colorType < 0 || colorType >= EGUI_LBC_COUNT ) - return false; + if ( index >= Items.size() || colorType < 0 || colorType >= EGUI_LBC_COUNT ) + return false; - return Items[index].OverrideColors[colorType].Use; + return Items[index].OverrideColors[colorType].Use; } video::SColor CGUISTKListBox::getItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) const { - if ( (u32)index >= Items.size() || colorType < 0 || colorType >= EGUI_LBC_COUNT ) - return video::SColor(); + if ( (u32)index >= Items.size() || colorType < 0 || colorType >= EGUI_LBC_COUNT ) + return video::SColor(); - return Items[index].OverrideColors[colorType].Color; + return Items[index].OverrideColors[colorType].Color; } video::SColor CGUISTKListBox::getItemDefaultColor(EGUI_LISTBOX_COLOR colorType) const { - IGUISkin* skin = Environment->getSkin(); - if ( !skin ) - return video::SColor(); + IGUISkin* skin = Environment->getSkin(); + if ( !skin ) + return video::SColor(); - switch ( colorType ) - { - case EGUI_LBC_TEXT: - return skin->getColor(EGDC_BUTTON_TEXT); - case EGUI_LBC_TEXT_HIGHLIGHT: - return skin->getColor(EGDC_HIGH_LIGHT_TEXT); - case EGUI_LBC_ICON: - return skin->getColor(EGDC_ICON); - case EGUI_LBC_ICON_HIGHLIGHT: - return skin->getColor(EGDC_ICON_HIGH_LIGHT); - default: - return video::SColor(); - } + switch ( colorType ) + { + case EGUI_LBC_TEXT: + return skin->getColor(EGDC_BUTTON_TEXT); + case EGUI_LBC_TEXT_HIGHLIGHT: + return skin->getColor(EGDC_HIGH_LIGHT_TEXT); + case EGUI_LBC_ICON: + return skin->getColor(EGDC_ICON); + case EGUI_LBC_ICON_HIGHLIGHT: + return skin->getColor(EGDC_ICON_HIGH_LIGHT); + default: + return video::SColor(); + } } //! set global itemHeight void CGUISTKListBox::setItemHeight( s32 height ) { - ItemHeight = height; - ItemHeightOverride = 1; + ItemHeight = height; + ItemHeightOverride = 1; } diff --git a/src/guiengine/widgets/CGUISTKListBox.h b/src/guiengine/widgets/CGUISTKListBox.h index 7b2c2a72a..444b69c92 100644 --- a/src/guiengine/widgets/CGUISTKListBox.h +++ b/src/guiengine/widgets/CGUISTKListBox.h @@ -17,12 +17,12 @@ namespace irr { namespace gui { - class IGUIFont; - class IGUIScrollBar; + class IGUIFont; + class IGUIScrollBar; - class CGUISTKListBox : public IGUIElement - { - public: + class CGUISTKListBox : public IGUIElement + { + public: struct ListItem { @@ -163,7 +163,7 @@ namespace irr //! Sets whether to draw the background virtual void setDrawBackground(bool draw); - private: + private: void recalculateItemHeight(); void selectNew(s32 ypos, bool onlyHover=false); @@ -189,7 +189,7 @@ namespace irr bool MoveOverSelect; bool AutoScroll; bool HighlightWhenNotFocused; - }; + }; } // end namespace gui diff --git a/src/guiengine/widgets/bubble_widget.hpp b/src/guiengine/widgets/bubble_widget.hpp index f476311f7..ee3f1e92f 100644 --- a/src/guiengine/widgets/bubble_widget.hpp +++ b/src/guiengine/widgets/bubble_widget.hpp @@ -27,7 +27,7 @@ namespace GUIEngine { const int BUBBLE_MARGIN_ON_RIGHT = 15; - + /** * A text widget that can expand when focused * \ingroup widgetsgroup @@ -35,36 +35,36 @@ namespace GUIEngine class BubbleWidget : public Widget { friend class Skin; - + /** shrinked size of this widget (size allowed in layout; internal text may be bigger than that). * If the text all fits in the allowed layout space, m_shrinked_size == m_expanded_size. */ irr::core::rect m_shrinked_size; - + /** Expanded size of this widget (size to see all text inside the bubble). * If the text all fits in the allowed layout space, m_shrinked_size == m_expanded_size. */ irr::core::rect m_expanded_size; - + /** Text shrinked to fit into the allowed layout space (will be same as m_text if all text fits) */ irr::core::stringw m_shrinked_text; - + /** For the skin to create the zooming effect */ float m_zoom; - + /** Will add/replace text in the bubble. If it doesn't fit, the text will get shrinked. **/ void replaceText(); public: - + LEAK_CHECK() - + BubbleWidget(); - + virtual void add(); - + virtual EventPropagation focused(const int playerID); - + void updateSize(); void setText(const irr::core::stringw &s); diff --git a/src/guiengine/widgets/button_widget.hpp b/src/guiengine/widgets/button_widget.hpp index 9c32e1e0d..98141bdc4 100644 --- a/src/guiengine/widgets/button_widget.hpp +++ b/src/guiengine/widgets/button_widget.hpp @@ -33,37 +33,37 @@ namespace GUIEngine { - /** + /** * \brief A text button widget. * \ingroup widgetsgroup */ class ButtonWidget : public Widget { public: - + LEAK_CHECK() - + ButtonWidget(); virtual ~ButtonWidget() {} - + /** \brief Implement callback from base class Widget */ void add(); - - /** + + /** * \brief Change the label on the button * \pre This should only be called after a widget has been add()ed (changing the label * before the widget is added can be done by editing the 'text' property of Widget). */ void setLabel(const irr::core::stringw &label); - + /** When inferring widget size from its label length, this method will be called to * if/how much space must be added to the raw label's size for the widget to be large enough */ virtual int getWidthNeededAroundLabel() const { return 35; } - + /** When inferring widget size from its label length, this method will be called to * if/how much space must be added to the raw label's size for the widget to be large enough */ virtual int getHeightNeededAroundLabel() const { return 4; } - }; + }; } #endif diff --git a/src/guiengine/widgets/check_box_widget.hpp b/src/guiengine/widgets/check_box_widget.hpp index a81643093..e982fa113 100644 --- a/src/guiengine/widgets/check_box_widget.hpp +++ b/src/guiengine/widgets/check_box_widget.hpp @@ -33,31 +33,31 @@ namespace GUIEngine class CheckBoxWidget : public Widget { bool m_state; - EventPropagation transmitEvent(Widget* w, - const std::string& originator, + EventPropagation transmitEvent(Widget* w, + const std::string& originator, const int playerID); - + public: - + LEAK_CHECK() - + CheckBoxWidget(); virtual ~CheckBoxWidget() {} - + /** \brief Implement callback from parent class Widget */ void add(); - + /** Get whether the checkbox is checked */ bool getState() const { return m_state; } - + /** Set whether the checkbox is checked */ void setState(const bool checked) { m_state = checked; } - - + + /** When inferring widget size from its label length, this method will be called to * if/how much space must be added to the raw label's size for the widget to be large enough */ virtual int getHeightNeededAroundLabel() const { return 10; } - }; + }; } #endif diff --git a/src/guiengine/widgets/dynamic_ribbon_widget.hpp b/src/guiengine/widgets/dynamic_ribbon_widget.hpp index 367d2d027..3b7796ef9 100644 --- a/src/guiengine/widgets/dynamic_ribbon_widget.hpp +++ b/src/guiengine/widgets/dynamic_ribbon_widget.hpp @@ -30,7 +30,7 @@ namespace GUIEngine { class IconButtonWidget; - + /** * Even if you have a ribbon that only acts on click/enter, you may wish to know which * item is currently highlighted. In this case, create a listener and pass it to the ribbon. @@ -39,12 +39,12 @@ namespace GUIEngine { public: virtual ~DynamicRibbonHoverListener() {} - virtual void onSelectionChanged(DynamicRibbonWidget* theWidget, + virtual void onSelectionChanged(DynamicRibbonWidget* theWidget, const std::string& selectionID, const irr::core::stringw& selectionText, const int playerID) = 0; }; - + /** The description of an item added to a DynamicRibbonWidget */ struct ItemDescription { @@ -52,17 +52,17 @@ namespace GUIEngine std::string m_code_name; std::string m_sshot_file; IconButtonWidget::IconPathType m_image_path_type; - + bool m_animated; /** used instead of 'm_sshot_file' if m_animated is true */ std::vector m_all_images; float m_curr_time; float m_time_per_frame; - + unsigned int m_badges; }; - - /** + + /** * \brief An extended version of RibbonWidget, with more capabilities. * A dynamic ribbon builds upon RibbonWidget, adding dynamic contents creation and sizing, * scrolling, multiple-row layouts. @@ -73,55 +73,55 @@ namespace GUIEngine class DynamicRibbonWidget : public Widget, public RibbonWidget::IRibbonListener { friend class RibbonWidget; - + /** A list of all listeners that registered to be notified on hover/selection */ PtrVector m_hover_listeners; - + virtual ~DynamicRibbonWidget(); - + /** Used for ribbon grids that have a label at the bottom */ bool m_has_label; irr::gui::IGUIStaticText* m_label; - + /** Height of ONE label text line (if label is multiline only one line is measured here). * If there is no label, will be 0. */ int m_label_height; - + /** Whether this ribbon contains at least one animated item */ bool m_animated_contents; - + /** Whether there are more items than can fit in a single screen; arrows will then appear * on each side of the ribbon to scroll the contents */ bool m_scrolling_enabled; - + /** Used to keep track of item count changes */ int m_previous_item_count; - + /** List of items in the ribbon */ std::vector m_items; - + /** Width of the scrolling arrows on each side */ int m_arrows_w; - + /** Current scroll offset within items */ int m_scroll_offset; - + /** Width and height of children as declared in the GUI file */ int m_child_width, m_child_height; - + /** Number of rows and columns. Number of columns can dynamically change, number of row is determined at creation */ int m_row_amount; int m_col_amount; - + /** The total number of columns given item count and row count (even counting not visible with current scrolling) */ int m_needed_cols; - + /** Whether this ribbon can have multiple rows (i.e. ribbon grid) or is a single line */ bool m_multi_row; - + /** irrlicht relies on consecutive IDs to perform keyboard navigation between widgets. However, since this widget is dynamic, irrlicht widgets are not created as early as all others, so by the time we're ready to create the full contents of this widget, the ID generator is already incremented, thus messing up @@ -129,65 +129,65 @@ namespace GUIEngine number of IDs (the number of rows) and store them here. Then, when we're finally ready to create the contents dynamically, we can re-use these IDs and get correct navigation order. */ std::vector m_ids; - + /** Whether this is a "combo" style ribbon grid widget */ bool m_combo; - + /* reference pointers only, the actual instances are owned by m_children */ IconButtonWidget* m_left_widget; IconButtonWidget* m_right_widget; - + /** Returns the currently selected row */ RibbonWidget* getSelectedRibbon(const int playerID); - + /** Returns the row */ RibbonWidget* getRowContaining(Widget* w); - + /** Updates the visible label to match the currently selected item */ void updateLabel(RibbonWidget* from_this_ribbon=NULL); - + /** Even though the ribbon grid widget looks like a grid, it is really a vertical stack of independant ribbons. When moving selection horizontally, this method is used to notify other rows above and below of which column is selected, so that moving vertically to another row keeps the same selected column. */ void propagateSelection(); - + /** Callback called widget is focused */ EventPropagation focused(const int playerID); - + /** Removes all previously added contents icons, and re-adds them (calculating the new amount) */ void buildInternalStructure(); /** Call this to scroll within a scrollable ribbon */ void scroll(const int x_delta); - + /** Used for combo ribbons, to contain the ID of the currently selected item for each player */ int m_selected_item[MAX_PLAYER_COUNT]; - + /** Callbacks */ virtual void add(); virtual EventPropagation mouseHovered(Widget* child, const int playerID); virtual EventPropagation transmitEvent(Widget* w, const std::string& originator, const int playerID); - + bool findItemInRows(const char* name, int* p_row, int* p_id); - + int m_item_count_hint; - + public: - + LEAK_CHECK() - + /** * \param combo Whether this is a "combo" ribbon, i.e. whether there is always one selected item. * If set to false, will behave more like a toolbar. * \param multi_row Whether this ribbon can have more than one row */ DynamicRibbonWidget(const bool combo, const bool multi_row); - + /** Reference pointers only, the actual instances are owned by m_children. Used to create mtultiple-row ribbons (what appears to be a grid of icons is actually a vector of stacked basic ribbons) */ PtrVector m_rows; - + /** Dynamically add an item to the ribbon's list of items (will not be visible until you * call 'updateItemDisplay' or 'add'). * @@ -200,7 +200,7 @@ namespace GUIEngine void addItem( const irr::core::stringw& user_name, const std::string& code_name, const std::string& image_file, const unsigned int badge=0, IconButtonWidget::IconPathType image_path_type=IconButtonWidget::ICON_PATH_TYPE_RELATIVE); - + /** Dynamically add an animated item to the ribbon's list of items (will not be visible until you * call 'updateItemDisplay' or 'add'). Animated means it has many images that will be shown in * a slideshown fashion. @@ -220,70 +220,70 @@ namespace GUIEngine /** Clears all items added through 'addItem'. You can then add new items with 'addItem' and call 'updateItemDisplay' to update the display. */ void clearItems(); - - /** + + /** * \brief Register a listener to be notified of selection changes within the ribbon. * \note The ribbon takes ownership of this listener and will delete it. * \note The listener will be deleted upon leaving the screen, so you will likely * want to add a listener in the "init" callback of your screen. */ void registerHoverListener(DynamicRibbonHoverListener* listener); - + /** Called when right key is pressed */ EventPropagation rightPressed(const int playerID); - + /** Called when left key is pressed */ EventPropagation leftPressed(const int playerID); - + /** Updates icons/labels given current items and scrolling offset, taking care of resizing the dynamic ribbon if the number of items changed */ void updateItemDisplay(); - + /** Get the internal name (ID) of the selected item */ const std::string& getSelectionIDString(const int playerID); - + /** Get the user-visible text of the selected item */ irr::core::stringw getSelectionText(const int playerID); - + /** Returns a read-only list of items added to this ribbon */ const std::vector& getItems() const { return m_items; } - - /** + + /** * \brief Select an item from its numerical ID. Only for [1-row] combo ribbons. * * \param item_id In range [0 .. number of items added through 'addItem' - 1] * \return Whether setting the selection was successful (whether the item exists) */ bool setSelection(int item_id, const int playerID, const bool focusIt, bool evenIfDeactivated=false); - + /** * \brief Select an item from its codename. * * \return Whether setting the selection was successful (whether the item exists) */ - bool setSelection(const std::string &item_codename, - const int playerID, const bool focusIt, + bool setSelection(const std::string &item_codename, + const int playerID, const bool focusIt, bool evenIfDeactivated=false); - + /** \brief Callback from parent class Widget. */ virtual void elementRemoved(); - + /** \brief callback from IRibbonListener */ virtual void onRibbonWidgetScroll(const int delta_x); - + /** \brief callback from IRibbonListener */ virtual void onRibbonWidgetFocus(RibbonWidget* emitter, const int playerID); - + /** \brief callback from IRibbonListener */ virtual void onSelectionChange(){} virtual void update(float delta); - + /** Set approximately how many items are expected to be in this ribbon; will help the layout * algorithm next time add() is called */ void setItemCountHint(int hint) { m_item_count_hint = hint; } }; - + } #endif diff --git a/src/guiengine/widgets/icon_button_widget.hpp b/src/guiengine/widgets/icon_button_widget.hpp index 4024d41bd..b7eb446a8 100644 --- a/src/guiengine/widgets/icon_button_widget.hpp +++ b/src/guiengine/widgets/icon_button_widget.hpp @@ -54,42 +54,42 @@ namespace GUIEngine * the path type as it currently is */ ICON_PATH_TYPE_NO_CHANGE }; - + protected: - + IconPathType m_icon_path_type; - + friend class Skin; - + irr::gui::IGUIStaticText* m_label; irr::video::ITexture* m_texture; irr::video::ITexture* m_highlight_texture; int m_texture_w, m_texture_h; - + ScaleMode m_scale_mode; float m_custom_aspect_ratio; - + public: LEAK_CHECK() - + /** Whether to make the widget included in keyboard navigation order when adding */ bool m_tab_stop; IconButtonWidget(ScaleMode scale_mode=SCALE_MODE_KEEP_TEXTURE_ASPECT_RATIO, const bool tab_stop=true, const bool focusable=true, IconPathType pathType=ICON_PATH_TYPE_RELATIVE); virtual ~IconButtonWidget() {} - + /** \brief Implement callback from base class Widget */ virtual void add(); - + /** * \brief Call this if scale mode is SCALE_MODE_KEEP_CUSTOM_ASPECT_RATIO. * \param custom_aspect_ratio The width/height aspect ratio */ void setCustomAspectRatio(float custom_aspect_ratio) { m_custom_aspect_ratio = custom_aspect_ratio; } - + /** * \brief Temporarily change the text label if there is a label (next time this screen is * visited, the previous label will be back. For a permanent change, edit the 'text' @@ -99,7 +99,7 @@ namespace GUIEngine * \note Calling this method on a button without label will have no effect */ void setLabel(irr::core::stringw new_label); - + /** * Change the texture used for this icon. * \pre At the moment, the new texture must have the same aspct ratio @@ -107,11 +107,11 @@ namespace GUIEngine * be resized to fit a different aspect ratio. * \note May safely be called no matter if the widget is add()ed or not */ - void setImage(const char* path_to_texture, + void setImage(const char* path_to_texture, IconPathType path_type=ICON_PATH_TYPE_NO_CHANGE); - + /** Convenience function taking std::string. */ - void setImage(const std::string &path_to_texture, + void setImage(const std::string &path_to_texture, IconPathType path_type=ICON_PATH_TYPE_NO_CHANGE) { setImage(path_to_texture.c_str(), path_type); @@ -125,15 +125,15 @@ namespace GUIEngine * \note May safely be called no matter if the widget is add()ed or not */ void setImage(irr::video::ITexture* texture); - + void setHighlightedImage(irr::video::ITexture* texture) { m_highlight_texture = texture; } - + /** \brief override from base class */ virtual EventPropagation focused(const int playerID); - + /** \brief override from base class */ virtual void unfocused(const int playerID, Widget* new_focus); }; diff --git a/src/guiengine/widgets/label_widget.hpp b/src/guiengine/widgets/label_widget.hpp index 44ded5174..674c4e641 100644 --- a/src/guiengine/widgets/label_widget.hpp +++ b/src/guiengine/widgets/label_widget.hpp @@ -40,23 +40,23 @@ namespace GUIEngine /** Scroll speed in characters/seconds (0 if no scrolling). */ float m_scroll_speed; - + /** Current scroll offset. */ float m_scroll_offset; - + public: - + LEAK_CHECK() - + /** Constructs the label widget. Parameter: * \param title True if the special title font should be used. * \param bright True if a bright color should be used * \note \c title and \c bright are mutually exclusive */ LabelWidget(bool title=false, bool bright=false); - + virtual ~LabelWidget() {} - + /** \brief Callback from base class Widget */ virtual void add(); @@ -65,10 +65,10 @@ namespace GUIEngine void setColor(const irr::video::SColor& color); void setErrorColor(); void setDefaultColor(); - + /** \brief Callback from base class Widget */ virtual void update(float dt); - + /** * \brief Sets the text in the label. * @@ -84,21 +84,21 @@ namespace GUIEngine * only be passed after the widget has been add()ed. */ virtual void setText(const wchar_t *text, bool expandAsNeeded); - + /** Overloaded function which takes a stringw. */ virtual void setText(const irr::core::stringw &s, bool expandAsNeeded) { - setText(s.c_str(), expandAsNeeded); + setText(s.c_str(), expandAsNeeded); } // -------------------------------------------------------------------- - + /** Sets horizontal scroll speed. */ void setScrollSpeed(float speed); - + // -------------------------------------------------------------------- - - /** + + /** * \brief Check if the current has been fully scrolled * \return true if the text has completely scrolled off * \pre May only be called after this widget has been add()ed diff --git a/src/guiengine/widgets/list_widget.hpp b/src/guiengine/widgets/list_widget.hpp index 38ac9b8ec..6e864ecea 100644 --- a/src/guiengine/widgets/list_widget.hpp +++ b/src/guiengine/widgets/list_widget.hpp @@ -38,10 +38,10 @@ namespace GUIEngine { public: virtual ~IListWidgetHeaderListener(){} - + virtual void onColumnClicked(int columnId) = 0; }; - + /** \brief A vertical list widget with text entries * \ingroup widgetsgroup * \note items you add to a list are not kept after the the list is in was removed @@ -50,62 +50,62 @@ namespace GUIEngine class ListWidget : public Widget { friend class Skin; - + /** \brief whether this list has icons */ bool m_use_icons; - + /** \brief if m_use_icons is true, this will contain the icon bank */ irr::gui::STKModifiedSpriteBank* m_icons; - + PtrVector< ButtonWidget > m_header_elements; - + ButtonWidget* m_selected_column; - + /** \brief whether this list is sorted in descending order */ bool m_sort_desc; - + /** true when deault sorting is enabled */ bool m_sort_default; - + /** index of column*/ int m_sort_col; - + struct Column { irr::core::stringw m_text; int m_proportion; - + Column(irr::core::stringw text, int proportion) { m_text = text; m_proportion = proportion; } }; - + /** Leave empty for no header */ std::vector< Column > m_header; - + IListWidgetHeaderListener* m_listener; public: typedef irr::gui::CGUISTKListBox::ListItem ListItem; typedef ListItem::ListCell ListCell; - + LEAK_CHECK() - + ListWidget(); - + SkinWidgetContainer m_selection_skin_info; - + /** \brief implement add method from base class GUIEngine::Widget */ virtual void add(); - + /** \brief implement callback from base class GUIEngine::Widget */ virtual void unfocused(const int playerID, Widget* new_focus); - + /** \brief implement callback from base class GUIEngine::Widget */ virtual void elementRemoved(); - + /** \brief set the icon bank to use for list entries. * * The height of list entries will be ajusted to the size of the highest icon. @@ -116,10 +116,10 @@ namespace GUIEngine * \pre may only be called after the widget has been added to the screen with add() */ void setIcons(irr::gui::STKModifiedSpriteBank* icons, int size=-1); - - + + // ---- contents management - + /** * \brief add an item to the list * \param name user-visible, potentially translated, name of the item @@ -133,53 +133,53 @@ namespace GUIEngine void addItem( const std::string& internal_name, const std::vector& contents); - + /** * \brief erases all items in the list * \pre may only be called after the widget has been added to the screen with add() */ void clear(); - + /** * \return the number of items in the list * \pre may only be called after the widget has been added to the screen with add() */ int getItemCount() const; - + /** * \return the index of the selected element within the list, or -1 if none * \pre may only be called after the widget has been added to the screen with add() */ int getSelectionID() const; - + /** * \return the text of the selected item * \pre may only be called after the widget has been added to the screen with add() */ std::string getSelectionInternalName(); - + irr::core::stringw getSelectionLabel(const int cell = 0) const; - + void selectItemWithLabel(const irr::core::stringw& name); - + /** * \brief Finds the ID of the item that has a given internal name */ int getItemID(const std::string internalName) const; - + /** * \brief change the selected item * \param index the index of the element to select within the list, or -1 to select nothing * \pre may only be called after the widget has been added to the screen with add() */ void setSelectionID(const int index); - + /** * \brief rename an item and/or change its icon based on its ID * \pre may only be called after the widget has been added to the screen with add() */ void renameCell(const int row_num, const int col_num, const irr::core::stringw newName, const int icon=-1); - + /** * renames first cell only */ @@ -197,18 +197,18 @@ namespace GUIEngine assert(id != -1); renameCell( id, col_num, newName, icon ); } - + /** * \brief Make an item red to mark an error, for instance * \pre may only be called after the widget has been added to the screen with add() */ void markItemRed(const int id, bool red=true); void markItemBlue(const int id, bool blue=true); - + /** * \brief Make an item red to mark an error, for instance * \pre may only be called after the widget has been added to the screen with add() - */ + */ void markItemRed(const std::string internalName, bool red=true) { const int id = getItemID(internalName); @@ -224,21 +224,21 @@ namespace GUIEngine } /** Override callback from Widget */ - virtual EventPropagation transmitEvent(Widget* w, - const std::string& originator, + virtual EventPropagation transmitEvent(Widget* w, + const std::string& originator, const int playerID); - + void setColumnListener(IListWidgetHeaderListener* listener) { if (m_listener) delete m_listener; m_listener = listener; } - + /** To be called before Widget::add(); columns are persistent across multiple add/remove cycles * \param proportion A column with proportion 2 will be twice as large as a column with proportion 1 */ void addColumn(irr::core::stringw col, int proportion=1) { m_header.push_back( Column(col, proportion) ); } - + void clearColumns() { m_header.clear(); } }; } diff --git a/src/guiengine/widgets/model_view_widget.hpp b/src/guiengine/widgets/model_view_widget.hpp index 16c33ad9d..b1ad7163d 100644 --- a/src/guiengine/widgets/model_view_widget.hpp +++ b/src/guiengine/widgets/model_view_widget.hpp @@ -44,53 +44,53 @@ namespace GUIEngine RotationMode m_rotation_mode; float m_rotation_speed; float m_rotation_target; - + PtrVector m_models; AlignedArray m_model_location; AlignedArray m_model_scale; std::vector m_model_frames; - + video::ITexture* m_texture; - + IrrDriver::RTTProvider* m_rtt_provider; - + float angle; - + bool m_rtt_unsupported; - + public: - + LEAK_CHECK() - + ModelViewWidget(); virtual ~ModelViewWidget(); - + void add(); void clearModels(); void addModel(irr::scene::IMesh* mesh, const Vec3& location = Vec3(0,0,0), const Vec3& scale = Vec3(1,1,1), const int frame=-1); - + void update(float delta); - + virtual void elementRemoved(); - + /** Disables any model rotation */ void setRotateOff(); - + /** Makes the model rotate at given speed (in degrees per second) */ void setRotateContinuously(float speed); - + /** Rotate to 'targetAngle' in degrees at given speed (in degrees per second) */ void setRotateTo(float targetAngle, float speed); - + /** Returns information if currently kart is rotating */ bool isRotating(); - + void clearRttProvider(); }; - + } #endif diff --git a/src/guiengine/widgets/progress_bar_widget.hpp b/src/guiengine/widgets/progress_bar_widget.hpp index cadb4c03d..88dd7dd88 100644 --- a/src/guiengine/widgets/progress_bar_widget.hpp +++ b/src/guiengine/widgets/progress_bar_widget.hpp @@ -28,7 +28,7 @@ namespace GUIEngine { - /** + /** * \brief A progress bar widget. * \ingroup widgetsgroup */ @@ -37,32 +37,32 @@ namespace GUIEngine /** When inferring widget size from its label length, this method will be called to * if/how much space must be added to the raw label's size for the widget to be large enough */ virtual int getWidthNeededAroundLabel() const { return 35; } - + /** When inferring widget size from its label length, this method will be called to * if/how much space must be added to the raw label's size for the widget to be large enough */ virtual int getHeightNeededAroundLabel() const { return 4; } - + /** Change the label on the widget */ void setLabel(const irr::core::stringw label); int m_value; - + public: - + LEAK_CHECK() - + ProgressBarWidget(); virtual ~ProgressBarWidget() {} - + /** Change the value of the widget, it must be a percent. */ void setValue(int value); - - + + void add(); - + /** Get the current value of the widget. */ int getValue() {return m_value; }; - - }; + + }; } #endif diff --git a/src/guiengine/widgets/rating_bar_widget.cpp b/src/guiengine/widgets/rating_bar_widget.cpp index 2a58cccdd..e6135d0f4 100644 --- a/src/guiengine/widgets/rating_bar_widget.cpp +++ b/src/guiengine/widgets/rating_bar_widget.cpp @@ -56,7 +56,7 @@ void RatingBarWidget::add() // ----------------------------------------------------------------------------- /** Get the current step of the star - * + * * \param index The index of the star. * \return The current step of the star. */ diff --git a/src/guiengine/widgets/rating_bar_widget.hpp b/src/guiengine/widgets/rating_bar_widget.hpp index 56d1cf09d..3f94493c7 100644 --- a/src/guiengine/widgets/rating_bar_widget.hpp +++ b/src/guiengine/widgets/rating_bar_widget.hpp @@ -29,7 +29,7 @@ namespace GUIEngine { - /** + /** * \brief A rating bar widget. * \ingroup widgetsgroup */ @@ -47,28 +47,28 @@ namespace GUIEngine void setStepValues(float rating); public: - + LEAK_CHECK() - + RatingBarWidget(); virtual ~RatingBarWidget() {} - + void add(); - + /** Change the rating value of the widget. */ void setRating(float rating); - + /** Get the current value of the widget. */ float getRating() {return m_rating; }; - + /** Change the number of stars of the widget. */ void setStarNumber(int star_number) { m_stars = star_number; }; - + /** Get the current number of stars of the widget. */ int getStarNumber() {return m_stars; }; - + int getStepsOfStar(int index); void setStepValuesByMouse(const core::position2di & mouse_position, const core::recti & stars_rect); @@ -76,7 +76,7 @@ namespace GUIEngine virtual void onClick(); void allowVoting() { m_allow_voting = true; } - }; + }; } #endif diff --git a/src/guiengine/widgets/ribbon_widget.cpp b/src/guiengine/widgets/ribbon_widget.cpp index f73315ff4..a3dbb0d24 100644 --- a/src/guiengine/widgets/ribbon_widget.cpp +++ b/src/guiengine/widgets/ribbon_widget.cpp @@ -305,7 +305,7 @@ void RibbonWidget::add() (float)m_active_children[i].m_w / (float)m_active_children[i].m_h; // calculate the size of the image - std::string filename = + std::string filename = file_manager->getAsset(m_active_children[i].m_properties[PROP_ICON]); video::ITexture* image = irr_driver->getTexture((filename).c_str()); diff --git a/src/guiengine/widgets/ribbon_widget.hpp b/src/guiengine/widgets/ribbon_widget.hpp index 2aefb6a2c..77d23c05e 100644 --- a/src/guiengine/widgets/ribbon_widget.hpp +++ b/src/guiengine/widgets/ribbon_widget.hpp @@ -42,8 +42,8 @@ namespace GUIEngine /** \brief A static text/icons/tabs bar widget. * The contents of this ribbon are static. * \ingroup widgetsgroup - * \note items you add to a list are kept after the the ribbon was in - * is removed (i.e. you don't need to add items everytime the + * \note items you add to a list are kept after the the ribbon was in + * is removed (i.e. you don't need to add items everytime the * screen is shown, only upon loading) */ class RibbonWidget : public Widget @@ -54,79 +54,79 @@ namespace GUIEngine public: virtual ~IRibbonListener(){} virtual void onRibbonWidgetScroll(const int delta_x) = 0; - virtual void onRibbonWidgetFocus(RibbonWidget* emitter, + virtual void onRibbonWidgetFocus(RibbonWidget* emitter, const int playerID) = 0; virtual void onSelectionChange() = 0; }; - + private: friend class DynamicRibbonWidget; friend class EventHandler; - + int m_selection[MAX_PLAYER_COUNT]; - + /** The type of this ribbon (toolbar, combo, tabs) */ RibbonType m_ribbon_type; - - /** Each item within the ribbon holds a flag saying whether it is - * selected or not. This method updates the flag in all of this + + /** Each item within the ribbon holds a flag saying whether it is + * selected or not. This method updates the flag in all of this * ribbon's children. Called everytime selection changes.*/ void updateSelection(); - + /** Callbacks */ virtual EventPropagation rightPressed(const int playerID=0); virtual EventPropagation leftPressed(const int playerID=0); - virtual EventPropagation mouseHovered(Widget* child, + virtual EventPropagation mouseHovered(Widget* child, const int playerID); - virtual EventPropagation transmitEvent(Widget* w, + virtual EventPropagation transmitEvent(Widget* w, const std::string& originator, const int playerID=0); virtual EventPropagation focused(const int playerID); virtual void unfocused(const int playerID, Widget* new_focus); - + PtrVector m_labels; - + IRibbonListener* m_listener; PtrVector m_active_children; - + public: - + LEAK_CHECK() - - /** Internal identifier of filler items that are added in a ribbon - * widget to filllines when the number of items cannot be divided - * by the number of rows in the grid (mostly used by dynamic ribbon + + /** Internal identifier of filler items that are added in a ribbon + * widget to filllines when the number of items cannot be divided + * by the number of rows in the grid (mostly used by dynamic ribbon * widgets, but the base ribbon needs to know about filler items) */ static const char NO_ITEM_ID[]; - + /** Contains which element within the ribbon is currently focused by - * player 0 (used by the skin to show mouse hovers over items that + * player 0 (used by the skin to show mouse hovers over items that * are not selected). Only used for COMBO and TAB ribbons. */ Widget* m_mouse_focus; - + RibbonWidget(const RibbonType type=RIBBON_COMBO); virtual ~RibbonWidget(); - + void add(); /** Sets a listener that will be notified of changes on this ribbon. * Does _not_ take ownership of the listener, i.e. will not delete it. - * You may call this with the listener parameter set to NULL to + * You may call this with the listener parameter set to NULL to * remove the listener. */ void setListener(IRibbonListener* listener) { m_listener = listener; } // -------------------------------------------------------------------- - /** Returns the type of this ribbon (see the GUI module overview page + /** Returns the type of this ribbon (see the GUI module overview page * for detailed descriptions) */ RibbonType getRibbonType() const { return m_ribbon_type; } // -------------------------------------------------------------------- /** Returns the numerical ID of the selected item within the ribbon */ - int getSelection(const int playerID) const + int getSelection(const int playerID) const { return m_selection[playerID]; } - // -------------------------------------------------------------------- + // -------------------------------------------------------------------- /** Returns the string ID (internal name) of the selection */ const std::string& getSelectionIDString(const int playerID); - // -------------------------------------------------------------------- + // -------------------------------------------------------------------- /** Returns the user-visible text of the selection */ irr::core::stringw getSelectionText(const int playerID) { @@ -134,15 +134,15 @@ namespace GUIEngine if (selection < 0 || selection >= int(m_children.size())) return ""; return m_children[selection].m_text; } - // -------------------------------------------------------------------- + // -------------------------------------------------------------------- /** Sets the ID of the selected item within the ribbon */ - void setSelection(const int i, const int playerID) + void setSelection(const int i, const int playerID) { m_selection[playerID] = i; updateSelection(); } - + /** Select an item in the ribbon by its internal name */ void select(std::string item, const int playerID); - + /** * \brief This method can be used to rename an item. * Has no effect for ribbons without individual labels. @@ -151,22 +151,22 @@ namespace GUIEngine * \param id The index of the item to rename, in range [0 .. item count - 1] */ void setLabel(const unsigned int id, irr::core::stringw new_name); - + /** Returns the ID of the item, or -1 if not found */ int findItemNamed(const char* internalName); - + /** Returns the the widget, or NULL if not found */ GUIEngine::Widget * findWidgetNamed(const char* interalName); /** \brief Dynamically (at runtime) add a text item to this ribbon - * \pre This must be called before RibbonWidget::add, while the + * \pre This must be called before RibbonWidget::add, while the * widget is not yet displayed - * \pre only valid for ribbons that take text-only contents + * \pre only valid for ribbons that take text-only contents * (e.g. tab bars) */ void addTextChild(const wchar_t* text, const std::string id); - - + + /** \brief Dynamically (at runtime) add an icon item to this ribbon. * \pre this must be called before RibbonWidget::add, while the widget * is not yet displayed @@ -176,19 +176,19 @@ namespace GUIEngine const int w, const int h, const std::string &icon, const IconButtonWidget::IconPathType iconPathType= IconButtonWidget::ICON_PATH_TYPE_RELATIVE); - + /** * \brief clear all children of this ribbon (likely because new ones will be added soon after) * \pre this must be called before RibbonWidget::add, while the widget is not yet displayed */ void clearAllChildren(); - + /** * \brief clear one child from this ribbon * \pre this must be called before RibbonWidget::add, while the widget is not yet displayed */ void removeChildNamed(const char* name); - + PtrVector& getRibbonChildren() { return m_children; } }; diff --git a/src/guiengine/widgets/spinner_widget.cpp b/src/guiengine/widgets/spinner_widget.cpp index 036286192..86c3b7dbf 100644 --- a/src/guiengine/widgets/spinner_widget.cpp +++ b/src/guiengine/widgets/spinner_widget.cpp @@ -62,17 +62,17 @@ void SpinnerWidget::add() if (min_s.size() > 0) { - if (!StringUtils::parseString(min_s, &m_min)) + if (!StringUtils::parseString(min_s, &m_min)) { - Log::warn("invalid value for spinner widget minimum value : %s", min_s.c_str()); + Log::warn("invalid value for spinner widget minimum value : %s", min_s.c_str()); } } if (max_s.size() > 0) { - if (!StringUtils::parseString(max_s, &m_max)) - { - Log::warn("invalid value for spinner widget maximum value : %s", max_s.c_str()); + if (!StringUtils::parseString(max_s, &m_max)) + { + Log::warn("invalid value for spinner widget maximum value : %s", max_s.c_str()); } } @@ -160,7 +160,7 @@ void SpinnerWidget::add() { label->setText(m_labels[m_value].c_str() ); } - + } @@ -174,7 +174,7 @@ void SpinnerWidget::add() m_children[2].m_id = m_children[2].m_element->getID(); // refresh display - + setValue(m_value); } diff --git a/src/guiengine/widgets/spinner_widget.hpp b/src/guiengine/widgets/spinner_widget.hpp index a3623915c..f4fceab52 100644 --- a/src/guiengine/widgets/spinner_widget.hpp +++ b/src/guiengine/widgets/spinner_widget.hpp @@ -32,7 +32,7 @@ namespace irr namespace GUIEngine { - + /** \brief A spinner or gauge widget (to select numbers / percentages). * \ingroup widgetsgroup */ @@ -43,73 +43,73 @@ namespace GUIEngine { public: virtual ~ISpinnerConfirmListener() {} - + /** * \brief Invoked when the spinner is selected and "fire" is pressed * \return whether to block the event from further processing */ virtual EventPropagation onSpinnerConfirmed() = 0; }; - + protected: - + ISpinnerConfirmListener* m_listener; - + int m_value, m_min, m_max; - + int m_spinner_widget_player_id; bool m_use_background_color; - + /** If each value the spinner can take has an associated text, this vector will be non-empty */ std::vector m_labels; - + /** Whether the value of this spinner is displayed using an icon rather than with a plain label */ bool m_graphical; - + /** \brief Whether this widget is a gauge * the behaviour is the same but the look is a bit different, instead of displaying a number, * it displays how close the value is to the maximum by filling a line */ bool m_gauge; - - + + /** \brief Whether to wrap back to the first value when going "beyond" the last value */ bool m_wrap_around; - + /** \brief implementing method from base class Widget */ - virtual EventPropagation transmitEvent(Widget* w, - const std::string& originator, + virtual EventPropagation transmitEvent(Widget* w, + const std::string& originator, const int playerID); - + /** \brief implementing method from base class Widget */ virtual EventPropagation rightPressed(const int playerID); - + /** \brief implementing method from base class Widget */ virtual EventPropagation leftPressed(const int playerID); - + /** When inferring widget size from its label length, this method will be called to * if/how much space must be added to the raw label's size for the widget to be large enough */ virtual int getWidthNeededAroundLabel() const { return 25; } - + /** When inferring widget size from its label length, this method will be called to * if/how much space must be added to the raw label's size for the widget to be large enough */ virtual int getHeightNeededAroundLabel() const { return 8; } - + /** Call only if this spinner is graphical. Returns the current texture to display */ irr::video::ITexture* getTexture(); - + public: LEAK_CHECK() - + SpinnerWidget(const bool gauge=false); virtual ~SpinnerWidget() {} virtual void move(const int x, const int y, const int w, const int h); - + void addLabel(irr::core::stringw label); void clearLabels(); - // next four functions are for background colour behind playername in multikart screen selection + // next four functions are for background colour behind playername in multikart screen selection void setUseBackgroundColor() {m_use_background_color=true; } bool getUseBackgroundColor() {return m_use_background_color; } void setSpinnerWidgetPlayerID(int playerID) {m_spinner_widget_player_id=playerID;} @@ -128,26 +128,26 @@ namespace GUIEngine * \param new_value the new value that will be become the current value of this spinner. */ void setValue(const int new_value); - + /** * \brief sets the current value of the spinner * \pre the 'new_value' string passed must be the name of an item * (added through SpinnerWidget::addLabel)in the spinner */ void setValue(irr::core::stringw new_value); - + /** * \return whether this spinner is of "gauge" type */ bool isGauge() const { return m_gauge; } - - /** + + /** * \brief retrieve the current value of the spinner * \return the current value of the spinner, in a int form */ int getValue() const { return m_value; } - - /** + + /** * \brief retrieve the current value of the spinner * \return the current value of the spinner, in a string form */ @@ -165,15 +165,15 @@ namespace GUIEngine * \return the minimum value the spinner can take */ int getMin() const { return m_min; } - + void setMin(int n) { m_min = n; } - + /** Override method from base class Widget */ virtual void setActivated(); - + /** Override method from base class Widget */ virtual void setDeactivated(); - + bool isActivated() { return !m_deactivated; } /** Display custom text in spinner */ diff --git a/src/guiengine/widgets/text_box_widget.cpp b/src/guiengine/widgets/text_box_widget.cpp index 69d9f74e3..c0d199e62 100644 --- a/src/guiengine/widgets/text_box_widget.cpp +++ b/src/guiengine/widgets/text_box_widget.cpp @@ -154,7 +154,7 @@ void TextBoxWidget::unfocused(const int playerID, Widget* new_focus) assert(playerID == 0); // No support for multiple players in text areas! setWithinATextBox(false); - + GUIEngine::getGUIEnv()->removeFocus(m_element); } diff --git a/src/guiengine/widgets/text_box_widget.hpp b/src/guiengine/widgets/text_box_widget.hpp index 15109217b..78426c772 100644 --- a/src/guiengine/widgets/text_box_widget.hpp +++ b/src/guiengine/widgets/text_box_widget.hpp @@ -34,8 +34,8 @@ namespace GUIEngine virtual ~ITextBoxWidgetListener() {} virtual void onTextUpdated() = 0; }; - - /** \brief A text field widget. + + /** \brief A text field widget. * \ingroup widgetsgroup */ class TextBoxWidget : public Widget @@ -43,33 +43,33 @@ namespace GUIEngine /** When inferring widget size from its label length, this method will be called to * if/how much space must be added to the raw label's size for the widget to be large enough */ virtual int getWidthNeededAroundLabel() const { return 10; } - + /** When inferring widget size from its label length, this method will be called to * if/how much space must be added to the raw label's size for the widget to be large enough */ virtual int getHeightNeededAroundLabel() const { return 10; } - + public: - + LEAK_CHECK() - + TextBoxWidget(); ~TextBoxWidget() { setWithinATextBox(false); } - + void add(); void addItem(const char* item); - + virtual EventPropagation focused(const int playerID); virtual void unfocused(const int playerID, Widget* new_focus); void addListener(ITextBoxWidgetListener* listener); void clearListeners(); - + irr::core::stringw getText() const; void setPasswordBox(bool passwordBox, wchar_t passwordChar = L'*'); - + virtual void elementRemoved(); }; } diff --git a/src/input/binding.cpp b/src/input/binding.cpp index df9092246..dcac002ea 100644 --- a/src/input/binding.cpp +++ b/src/input/binding.cpp @@ -69,7 +69,7 @@ bool Binding::deserialize(irr::io::IrrXMLReader* xml) printf("WARNING: IT_STICKMOTION without direction, ignoring.\n"); return false; } - + // If the action is a stick motion & a range is defined if (range_string == NULL) { @@ -79,7 +79,7 @@ bool Binding::deserialize(irr::io::IrrXMLReader* xml) { m_range = (Input::AxisRange)atoi(range_string); } - + m_dir = (Input::AxisDirection)atoi(dir_string); } // if m_type!=stickmotion diff --git a/src/input/input_manager.cpp b/src/input/input_manager.cpp index 343f2f964..0c63f5bab 100644 --- a/src/input/input_manager.cpp +++ b/src/input/input_manager.cpp @@ -168,12 +168,12 @@ void InputManager::handleStaticAction(int key, int value) if (UserConfigParams::m_artist_debug_mode && world) { AbstractKart* kart = world->getLocalPlayerKart(0); - + if (control_is_pressed) kart->setPowerup(PowerupManager::POWERUP_SWATTER, 10000); else kart->setPowerup(PowerupManager::POWERUP_RUBBERBALL, 10000); - + #ifdef FORCE_RESCUE_ON_FIRST_KART // Can be useful for debugging places where the AI gets into // a rescue loop: rescue, drive, crash, rescue to same place @@ -185,7 +185,7 @@ void InputManager::handleStaticAction(int key, int value) if (UserConfigParams::m_artist_debug_mode && world) { AbstractKart* kart = world->getLocalPlayerKart(0); - + kart->setPowerup(PowerupManager::POWERUP_PLUNGER, 10000); } break; @@ -481,13 +481,13 @@ void InputManager::dispatchInput(Input::InputType type, int deviceID, m_mode == INPUT_SENSE_GAMEPAD) { // Do not pick disabled gamepads for input sensing - if (type == Input::IT_STICKBUTTON || type == Input::IT_STICKMOTION) + if (type == Input::IT_STICKBUTTON || type == Input::IT_STICKMOTION) { - GamePadDevice *gPad = m_device_manager->getGamePadFromIrrID(deviceID); - DeviceConfig *conf = gPad->getConfiguration(); - if (!conf->isEnabled()) - return; - } + GamePadDevice *gPad = m_device_manager->getGamePadFromIrrID(deviceID); + DeviceConfig *conf = gPad->getConfiguration(); + if (!conf->isEnabled()) + return; + } inputSensing(type, deviceID, button, axisDirection, value); return; diff --git a/src/io/utf_writer.cpp b/src/io/utf_writer.cpp index b5d3d7b76..a4a13b1d5 100644 --- a/src/io/utf_writer.cpp +++ b/src/io/utf_writer.cpp @@ -25,12 +25,12 @@ using namespace irr; // ---------------------------------------------------------------------------- -UTFWriter::UTFWriter(const char* dest) +UTFWriter::UTFWriter(const char* dest) : m_base(dest, std::ios::out | std::ios::binary) { if (!m_base.is_open()) { - throw std::runtime_error("Failed to open file for writing : " + + throw std::runtime_error("Failed to open file for writing : " + std::string(dest)); } diff --git a/src/io/xml_node.cpp b/src/io/xml_node.cpp index bcf135b02..092dde423 100644 --- a/src/io/xml_node.cpp +++ b/src/io/xml_node.cpp @@ -41,7 +41,7 @@ XMLNode::XMLNode(const std::string &filename) m_file_name = filename; io::IXMLReader *xml = file_manager->createXMLReader(filename); - + if (xml == NULL) { throw std::runtime_error("Cannot find file "+filename); diff --git a/src/items/attachment.cpp b/src/items/attachment.cpp index 32358d7ca..0c23c9e32 100644 --- a/src/items/attachment.cpp +++ b/src/items/attachment.cpp @@ -33,7 +33,7 @@ #include "karts/explosion_animation.hpp" #include "karts/kart_properties.hpp" #include "modes/three_strikes_battle.hpp" -#include "modes/world.hpp" +#include "modes/world.hpp" #include "physics/triangle_mesh.hpp" #include "tracks/track.hpp" #include "physics/triangle_mesh.hpp" @@ -81,7 +81,7 @@ Attachment::~Attachment() sfx_manager->deleteSFX(m_bomb_sound); m_bomb_sound = NULL; } - + if (m_bubble_explode_sound) { sfx_manager->deleteSFX(m_bubble_explode_sound); @@ -123,7 +123,7 @@ void Attachment::set(AttachmentType type, float time, clear(); m_node_scale = 0.3f; - + // If necessary create the appropriate plugin which encapsulates // the associated behavior switch(type) @@ -323,7 +323,7 @@ void Attachment::hitBanana(Item *item, int new_attachment) void Attachment::handleCollisionWithKart(AbstractKart *other) { Attachment *attachment_other=other->getAttachment(); - + if(getType()==Attachment::ATTACH_BOMB) { // Don't attach a bomb when the kart is shielded @@ -380,15 +380,15 @@ void Attachment::update(float dt) { if(m_type==ATTACH_NOTHING) return; m_time_left -=dt; - - + + bool is_shield = (m_type == ATTACH_BUBBLEGUM_SHIELD|| m_type == ATTACH_NOLOK_BUBBLEGUM_SHIELD); float m_wanted_node_scale = is_shield ? std::max(1.0f, m_kart->getHighestPoint()*1.1f) : 1.0f; - + if (m_node_scale < m_wanted_node_scale) { m_node_scale += dt*1.5f; - if (m_node_scale > m_wanted_node_scale) m_node_scale = m_wanted_node_scale; + if (m_node_scale > m_wanted_node_scale) m_node_scale = m_wanted_node_scale; m_node->setScale(core::vector3df(m_node_scale,m_node_scale,m_node_scale)); } @@ -416,7 +416,7 @@ void Attachment::update(float dt) if (f > 1.0f) f = 1.0f; // cap fraction if (m_kart->getSpeed() <= m_initial_speed * (stk_config->m_parachute_lbound_fraction + - f * ( stk_config->m_parachute_ubound_fraction + f * ( stk_config->m_parachute_ubound_fraction - stk_config->m_parachute_lbound_fraction))) { m_time_left = -1; @@ -471,7 +471,7 @@ void Attachment::update(float dt) m_bubble_explode_sound = sfx_manager->createSoundSource("bubblegum_explode"); m_bubble_explode_sound->position(m_kart->getXYZ()); m_bubble_explode_sound->play(); - + // drop a small bubble gum Vec3 hit_point; Vec3 normal; @@ -488,7 +488,7 @@ void Attachment::update(float dt) normal.normalize(); pos.setY(hit_point.getY()-0.05f); - + ItemManager::get()->newItem(Item::ITEM_BUBBLEGUM, pos, normal, m_kart); } } diff --git a/src/items/attachment.hpp b/src/items/attachment.hpp index 0d7e0f77f..6fa469562 100644 --- a/src/items/attachment.hpp +++ b/src/items/attachment.hpp @@ -101,7 +101,7 @@ private: /** Soung for exploding bubble gum shield */ SFXBase *m_bubble_explode_sound; - + public: Attachment(AbstractKart* kart); ~Attachment(); diff --git a/src/items/flyable.hpp b/src/items/flyable.hpp index b15884f0e..8a400128c 100644 --- a/src/items/flyable.hpp +++ b/src/items/flyable.hpp @@ -3,7 +3,7 @@ // Copyright (C) 2007-2013 Joerg Henrichs // // Linear item-kart intersection function written by -// Copyright (C) 2009-2013 David Mikos. +// Copyright (C) 2009-2013 David Mikos. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License diff --git a/src/items/item_manager.cpp b/src/items/item_manager.cpp index fb0c9e287..2072b1063 100644 --- a/src/items/item_manager.cpp +++ b/src/items/item_manager.cpp @@ -67,7 +67,7 @@ void ItemManager::destroy() void ItemManager::loadDefaultItemMeshes() { m_item_mesh.resize(Item::ITEM_LAST-Item::ITEM_FIRST+1, NULL); - m_glow_color.resize(Item::ITEM_LAST-Item::ITEM_FIRST+1, + m_glow_color.resize(Item::ITEM_LAST-Item::ITEM_FIRST+1, video::SColorf(255.0f, 255.0f, 255.0f) ); m_item_lowres_mesh.resize(Item::ITEM_LAST-Item::ITEM_FIRST+1, NULL); diff --git a/src/items/plunger.cpp b/src/items/plunger.cpp index 09129c6a2..8925ce1b7 100644 --- a/src/items/plunger.cpp +++ b/src/items/plunger.cpp @@ -3,7 +3,7 @@ // Copyright (C) 2007-2013 Joerg Henrichs // // Physics improvements and linear intersection algorithm by -// Copyright (C) 2009-2013 David Mikos. +// Copyright (C) 2009-2013 David Mikos. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -158,7 +158,7 @@ bool Plunger::updateAndDelete(float dt) bool Plunger::hit(AbstractKart *kart, PhysicalObject *obj) { if(isOwnerImmunity(kart)) return false; - + // pulling back makes no sense in battle mode, since this mode is not a race. // so in battle mode, always hide view if( m_reverse_mode || race_manager->isBattleMode() ) diff --git a/src/items/plunger.hpp b/src/items/plunger.hpp index 5ac873241..446c7c2ed 100644 --- a/src/items/plunger.hpp +++ b/src/items/plunger.hpp @@ -3,7 +3,7 @@ // Copyright (C) 2007-2013 Joerg Henrichs // // Physics improvements and linear intersection algorithm by -// Copyright (C) 2009-2013 David Mikos. +// Copyright (C) 2009-2013 David Mikos. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License diff --git a/src/items/projectile_manager.cpp b/src/items/projectile_manager.cpp index bf9b22569..091c64f97 100644 --- a/src/items/projectile_manager.cpp +++ b/src/items/projectile_manager.cpp @@ -109,7 +109,7 @@ void ProjectileManager::updateServer(float dt) else p++; } // while p!=m_active_projectiles.end() - + } // updateServer // ----------------------------------------------------------------------------- diff --git a/src/items/rubber_ball.cpp b/src/items/rubber_ball.cpp index 3b684effb..cc6f268e8 100644 --- a/src/items/rubber_ball.cpp +++ b/src/items/rubber_ball.cpp @@ -473,7 +473,7 @@ void RubberBall::interpolate(Vec3 *next_xyz, float dt) +4*m_control_points[2] - m_control_points[3])*m_t*m_t + (- m_control_points[0] + m_control_points[2])*m_t + 2*m_control_points[1] ); - + assert(!isnan((*next_xyz)[0])); assert(!isnan((*next_xyz)[1])); assert(!isnan((*next_xyz)[2])); diff --git a/src/karts/controller/ai_base_controller.hpp b/src/karts/controller/ai_base_controller.hpp index d27143833..a47339ec3 100644 --- a/src/karts/controller/ai_base_controller.hpp +++ b/src/karts/controller/ai_base_controller.hpp @@ -69,9 +69,9 @@ protected: /** Which of the successors of a node was selected by the AI. */ std::vector m_successor_index; /** For each node in the graph this list contains the chosen next node. - * For normal lap track without branches we always have + * For normal lap track without branches we always have * m_next_node_index[i] = (i+1) % size; - * but if a branch is possible, the AI will select one option here. + * but if a branch is possible, the AI will select one option here. * If the node is not used, m_next_node_index will be -1. */ std::vector m_next_node_index; /** For each graph node this list contains a list of the next X diff --git a/src/karts/controller/end_controller.hpp b/src/karts/controller/end_controller.hpp index 49c5461b9..3cb4d22f3 100644 --- a/src/karts/controller/end_controller.hpp +++ b/src/karts/controller/end_controller.hpp @@ -44,7 +44,7 @@ class EndController : public AIBaseController { private: /** Stores the type of the previous controller. This is necessary so that - * after the end of race ths kart (and its results) can still be + * after the end of race ths kart (and its results) can still be * identified to be from a player kart. */ bool m_was_player_controller; @@ -55,7 +55,7 @@ private: float m_max_handicap_accel; //The allowed maximum speed, in percentage, //from 0.0 to 1.0. Used only when //m_wait_for_players == true. - + /*General purpose variables*/ //The crash percentage is how much of the time the AI has been crashing, //if the AI has been crashing for some time, use the rescue. @@ -66,7 +66,7 @@ private: /** Stores a pointer to the original controller. */ Controller *m_previous_controller; - /** For debugging purpose: a sphere indicating where the AI + /** For debugging purpose: a sphere indicating where the AI * is targeting at. */ irr::scene::ISceneNode *m_debug_sphere; @@ -81,13 +81,13 @@ private: void findNonCrashingPoint(Vec3 *result); int calcSteps(); public: - EndController(AbstractKart *kart, - StateManager::ActivePlayer* player, + EndController(AbstractKart *kart, + StateManager::ActivePlayer* player, Controller *prev_controller); ~EndController(); virtual void update (float delta) ; virtual void reset (); - /** Returns if the original controller of the kart was a player + /** Returns if the original controller of the kart was a player * controller. This way e.g. highscores can still be assigned * to the right player. */ virtual bool isPlayerController () const {return m_player!=NULL;} diff --git a/src/karts/controller/kart_control.hpp b/src/karts/controller/kart_control.hpp index f820796c6..68cc312ff 100644 --- a/src/karts/controller/kart_control.hpp +++ b/src/karts/controller/kart_control.hpp @@ -20,7 +20,7 @@ #define HEADER_KART_CONTROL_HPP -/** +/** * \ingroup controller */ class KartControl @@ -37,13 +37,13 @@ public: /** The skidding control state: SC_NONE: not pressed; SC_NO_DIRECTION: pressed, but no steering; SC_LEFT/RIGHT: pressed in the specified direction. */ - enum SkidControl {SC_NONE, SC_NO_DIRECTION, SC_LEFT, SC_RIGHT} + enum SkidControl {SC_NONE, SC_NO_DIRECTION, SC_LEFT, SC_RIGHT} m_skid; /** True if rescue is selected. */ bool m_rescue; /** True if fire is selected. */ bool m_fire; - /** True if the kart looks (and shoots) backwards. */ + /** True if the kart looks (and shoots) backwards. */ bool m_look_back; KartControl() @@ -52,7 +52,7 @@ public: } // ------------------------------------------------------------------------ /** Resets all controls. */ - void reset() + void reset() { m_steer = 0.0f; m_accel = 0.0f; @@ -66,7 +66,7 @@ public: // ------------------------------------------------------------------------ void uncompress(char *c) { - m_steer = ((float*)c)[0]; + m_steer = ((float*)c)[0]; m_accel = ((float*)c)[1]; setButtonsCompressed(c[8]); } // uncompress diff --git a/src/karts/controller/player_controller.hpp b/src/karts/controller/player_controller.hpp index 1e75ac8e5..56c44e292 100644 --- a/src/karts/controller/player_controller.hpp +++ b/src/karts/controller/player_controller.hpp @@ -55,7 +55,7 @@ private: void steer(float, int); public: - PlayerController (AbstractKart *kart, + PlayerController (AbstractKart *kart, StateManager::ActivePlayer *_player, unsigned int player_index); ~PlayerController (); diff --git a/src/karts/controller/skidding_ai.cpp b/src/karts/controller/skidding_ai.cpp index 39ce0f26d..5db0c83c3 100644 --- a/src/karts/controller/skidding_ai.cpp +++ b/src/karts/controller/skidding_ai.cpp @@ -1223,12 +1223,12 @@ void SkiddingAI::handleItems(const float dt) break; } - // If this kart is in its last lap, drop bubble gums at every + // If this kart is in its last lap, drop bubble gums at every // opportunity, since this kart won't envounter them anymore. LinearWorld *lin_world = dynamic_cast(World::getWorld()); - if(m_time_since_last_shot > 3.0f && - lin_world && - lin_world->getKartLaps(m_kart->getWorldKartId()) + if(m_time_since_last_shot > 3.0f && + lin_world && + lin_world->getKartLaps(m_kart->getWorldKartId()) == race_manager->getNumLaps()-1) { m_controls->m_fire = true; diff --git a/src/karts/controller/skidding_ai.hpp b/src/karts/controller/skidding_ai.hpp index 42235feba..11ef347cf 100644 --- a/src/karts/controller/skidding_ai.hpp +++ b/src/karts/controller/skidding_ai.hpp @@ -40,7 +40,7 @@ namespace irr } } -/** +/** \brief This is the actual racing AI. The main entry point, called once per frame for each AI, is update(). @@ -49,7 +49,7 @@ the AI does the following steps: - compute nearest karts (one ahead and one behind) - check if the kart is about to crash with another kart or the track. This is done by simply testing a certain number of timesteps - ahead and estimating the future position of any kart by using + ahead and estimating the future position of any kart by using current_position + velocity * time (so turns are not taken into account). It also checks if the kart would be outside the quad graph, which indicates a 'collision with @@ -104,7 +104,7 @@ private: void clear() {m_road = false; m_kart = -1;} } m_crashes; - RaceManager::AISuperPower m_superpower; + RaceManager::AISuperPower m_superpower; /*General purpose variables*/ @@ -123,15 +123,15 @@ private: float m_distance_behind; /** The actual start delay used. */ - float m_start_delay; - + float m_start_delay; + /** Time an item has been collected and not used. */ float m_time_since_last_shot; - + float m_time_since_stuck; /** Direction of crash: -1 = left, 1 = right, 0 = no crash. */ - int m_start_kart_crash_direction; + int m_start_kart_crash_direction; /** The direction of the track where the kart is on atm. */ GraphNode::DirectionType m_current_track_direction; @@ -140,7 +140,7 @@ private: * when being on a straigt section. */ float m_current_curve_radius; - /** Stores the center of the curve (if the kart is in a curve, + /** Stores the center of the curve (if the kart is in a curve, * otherwise undefined). */ Vec3 m_curve_center; @@ -185,12 +185,12 @@ private: /** \brief Determines the algorithm to use to select the point-to-aim-for * There are three different Point Selection Algorithms: - * 1. findNonCrashingPoint() is the default (which is actually slightly - * buggy, but so far best one after handling of 90 degree turns was + * 1. findNonCrashingPoint() is the default (which is actually slightly + * buggy, but so far best one after handling of 90 degree turns was * added). * 2. findNonCrashingPointFixed() which fixes the bugs of the default * algorithm. - * 3. findNonCrashingPointNew() A newly designed algorithm, which is + * 3. findNonCrashingPointNew() A newly designed algorithm, which is * faster than the standard one, but does not give as good results * as the 'buggy' one. * @@ -203,11 +203,11 @@ private: /** For skidding debugging: shows the estimated turn shape. */ ShowCurve **m_curve; - /** For debugging purpose: a sphere indicating where the AI + /** For debugging purpose: a sphere indicating where the AI * is targeting at. */ irr::scene::ISceneNode *m_debug_sphere[4]; - /** For item debugging: set to the item that is selected to + /** For item debugging: set to the item that is selected to * be collected. */ irr::scene::ISceneNode *m_item_sphere; #endif @@ -226,15 +226,15 @@ private: void handleBraking(); void handleNitroAndZipper(); void computeNearestKarts(); - void handleItemCollectionAndAvoidance(Vec3 *aim_point, + void handleItemCollectionAndAvoidance(Vec3 *aim_point, int last_node); bool handleSelectedItem(float kart_aim_angle, Vec3 *aim_point); bool steerToAvoid(const std::vector &items_to_avoid, const core::line2df &line_to_target, Vec3 *aim_point); - bool hitBadItemWhenAimAt(const Item *item, + bool hitBadItemWhenAimAt(const Item *item, const std::vector &items_to_avoid); - void evaluateItems(const Item *item, float kart_aim_angle, + void evaluateItems(const Item *item, float kart_aim_angle, std::vector *items_to_avoid, std::vector *items_to_collect); diff --git a/src/karts/explosion_animation.cpp b/src/karts/explosion_animation.cpp index d36d4eba9..53cb0e198 100644 --- a/src/karts/explosion_animation.cpp +++ b/src/karts/explosion_animation.cpp @@ -39,7 +39,7 @@ ExplosionAnimation *ExplosionAnimation::create(AbstractKart *kart, bool direct_hit) { if(kart->isInvulnerable()) return NULL; - + float r = kart->getKartProperties()->getExplosionRadius(); // Ignore explosion that are too far away. diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index 71c7af5af..f3f6aaba9 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -128,7 +128,7 @@ Kart::Kart (const std::string& ident, unsigned int world_kart_id, m_is_jumping = false; m_min_nitro_time = 0.0f; m_fire_clicked = 0; - + m_view_blocked_by_plunger = 0; m_has_caught_nolok_bubblegum = false; @@ -355,7 +355,7 @@ void Kart::reset() // In case that the kart was in the air, in which case its // linear damping is 0 - if(m_body) + if(m_body) m_body->setDamping(m_kart_properties->getChassisLinearDamping(), m_kart_properties->getChassisAngularDamping() ); @@ -894,15 +894,15 @@ void Kart::collectedItem(Item *item, int add_info) break; } case Item::ITEM_BUBBLEGUM: - m_has_caught_nolok_bubblegum = (item->getEmitter() != NULL && + m_has_caught_nolok_bubblegum = (item->getEmitter() != NULL && item->getEmitter()->getIdent() == "nolok"); // slow down m_bubblegum_time = m_kart_properties->getBubblegumTime(); - m_bubblegum_torque = (rand()%2) + m_bubblegum_torque = (rand()%2) ? m_kart_properties->getBubblegumTorque() : -m_kart_properties->getBubblegumTorque(); - m_max_speed->setSlowdown(MaxSpeed::MS_DECREASE_BUBBLE, + m_max_speed->setSlowdown(MaxSpeed::MS_DECREASE_BUBBLE, m_kart_properties->getBubblegumSpeedFraction(), m_kart_properties->getBubblegumFadeInTime(), m_bubblegum_time); @@ -1107,7 +1107,7 @@ void Kart::update(float dt) // When really on air, free fly, when near ground, try to glide / // adjust for landing. If zipped, be stable, so ramp+zipper can // allow nice jumps without scripting the fly - // Also disable he upright constraint when gravity is changed by + // Also disable he upright constraint when gravity is changed by // the terrain if( (!isNearGround() && m_max_speed->getSpeedIncreaseTimeLeft(MaxSpeed::MS_INCREASE_ZIPPER)<=0.0f ) || @@ -1157,7 +1157,7 @@ void Kart::update(float dt) if (m_collision_particles) m_collision_particles->update(dt); updatePhysics(dt); - + if(!m_controls.m_fire) m_fire_clicked = 0; if(m_controls.m_fire && !m_fire_clicked && !m_kart_animation) @@ -1182,13 +1182,13 @@ void Kart::update(float dt) m_skid_sound->position ( getXYZ() ); m_boing_sound->position ( getXYZ() ); - // Check if a kart is (nearly) upside down and not moving much --> + // Check if a kart is (nearly) upside down and not moving much --> // automatic rescue // But only do this if auto-rescue is enabled (i.e. it will be disabled in // battle mode), and the material the kart is driving on does not have - // gravity (which can + // gravity (which can if(World::getWorld()->getTrack()->isAutoRescueEnabled() && - (!m_terrain_info->getMaterial() || + (!m_terrain_info->getMaterial() || !m_terrain_info->getMaterial()->hasGravity()) && !getKartAnimation() && fabs(getRoll())>60*DEGREE_TO_RAD && fabs(getSpeed())<3.0f ) @@ -1244,7 +1244,7 @@ void Kart::update(float dt) float g = World::getWorld()->getTrack()->getGravity(); Vec3 gravity(0.0f, -g, 0.0f); btRigidBody *body = getVehicle()->getRigidBody(); - // If the material should overwrite the gravity, + // If the material should overwrite the gravity, if (material->hasGravity()) { Vec3 normal = m_terrain_info->getNormal(); @@ -1339,7 +1339,7 @@ void Kart::update(float dt) { // Kart touched ground again m_is_jumping = false; - HitEffect *effect = new Explosion(getXYZ(), "jump", + HitEffect *effect = new Explosion(getXYZ(), "jump", "jump_explosion.xml"); projectile_manager->addHitEffect(effect); m_kart_model->setAnimation(KartModel::AF_DEFAULT); @@ -1359,7 +1359,7 @@ void Kart::update(float dt) if(!m_shadow_enabled && isOnGround() && !emergency) { m_shadow->enableShadow(); - m_shadow_enabled = true; + m_shadow_enabled = true; } } // update @@ -1394,7 +1394,7 @@ void Kart::setSquash(float time, float slowdown) return; } m_node->setScale(core::vector3df(1.0f, 0.5f, 1.0f)); - m_max_speed->setSlowdown(MaxSpeed::MS_DECREASE_SQUASH, slowdown, + m_max_speed->setSlowdown(MaxSpeed::MS_DECREASE_SQUASH, slowdown, 0.1f, time); m_squash_time = time; } // setSquash @@ -1458,14 +1458,14 @@ void Kart::handleMaterialSFX(const Material *material) sfx_manager->deleteSFX(m_previous_terrain_sound); m_previous_terrain_sound = NULL; } - - bool m_schedule_pause = m_flying || + + bool m_schedule_pause = m_flying || dynamic_cast(getKartAnimation()) || dynamic_cast(getKartAnimation()); // terrain sound is not necessarily a looping sound so check its status before // setting its speed, to avoid 'ressuscitating' sounds that had already stopped - if(m_terrain_sound && + if(m_terrain_sound && (m_terrain_sound->getStatus()==SFXManager::SFX_PLAYING || m_terrain_sound->getStatus()==SFXManager::SFX_PAUSED)) { @@ -1666,13 +1666,13 @@ void Kart::updateNitro(float dt) if (m_min_nitro_time > 0.0f) { m_min_nitro_time -= dt; - + // when pressing the key, don't allow the min time to go under zero. // If it went under zero, it would be reset if (m_controls.m_nitro && m_min_nitro_time <= 0.0f) m_min_nitro_time = 0.1f; } - + bool increase_speed = (m_controls.m_nitro && isOnGround()); if (!increase_speed && m_min_nitro_time <= 0.0f) { @@ -1684,7 +1684,7 @@ void Kart::updateNitro(float dt) m_collected_energy = 0; return; } - + if (increase_speed) { m_max_speed->increaseMaxSpeed(MaxSpeed::MS_INCREASE_NITRO, @@ -2060,13 +2060,13 @@ void Kart::updatePhysics(float dt) //at low velocity, forces on kart push it back and forth so we ignore this if(fabsf(m_speed) < 0.2f) // quick'n'dirty workaround for bug 1776883 m_speed = 0; - + if (dynamic_cast(getKartAnimation()) || dynamic_cast(getKartAnimation())) { m_speed = 0; } - + updateEngineSFX(); #ifdef XX Log::info("Kart","forward %f %f %f %f side %f %f %f %f angVel %f %f %f heading %f" @@ -2411,10 +2411,10 @@ void Kart::applyEngineForce(float force) void Kart::updateGraphics(float dt, const Vec3& offset_xyz, const btQuaternion& rotation) { - // Upate particle effects (creation rate, and emitter size + // Upate particle effects (creation rate, and emitter size // depending on speed) // -------------------------------------------------------- - if ( (m_controls.m_nitro || m_min_nitro_time > 0.0f) && + if ( (m_controls.m_nitro || m_min_nitro_time > 0.0f) && isOnGround() && m_collected_energy > 0 ) { // fabs(speed) is important, otherwise the negative number will @@ -2434,7 +2434,7 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz, m_kart_gfx->setCreationRateAbsolute(KartGFX::KGFX_NITRO2, 0); m_kart_gfx->setCreationRateAbsolute(KartGFX::KGFX_NITROSMOKE1, 0); m_kart_gfx->setCreationRateAbsolute(KartGFX::KGFX_NITROSMOKE2, 0); - + } m_kart_gfx->resizeBox(KartGFX::KGFX_NITRO1, getSpeed(), dt); m_kart_gfx->resizeBox(KartGFX::KGFX_NITRO2, getSpeed(), dt); @@ -2500,7 +2500,7 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz, } // Now determine graphical chassis and wheel position depending on - // the physics result. The center of gravity of the chassis is at the + // the physics result. The center of gravity of the chassis is at the // bottom of the chassis, but the position of the graphical chassis is at // the bottom of the wheels (i.e. in blender the kart is positioned on // the horizonal plane through (0,0,0)). So first determine how far @@ -2514,7 +2514,7 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz, for(unsigned int i=0; i<4; i++) { // Set the suspension length - height_above_terrain[i] = + height_above_terrain[i] = ( m_vehicle->getWheelInfo(i).m_raycastInfo.m_hardPointWS - m_vehicle->getWheelInfo(i).m_raycastInfo.m_contactPointWS).length() - m_vehicle->getWheelInfo(i).m_chassisConnectionPointCS.getY(); @@ -2531,7 +2531,7 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz, height_above_terrain[i] -= chassis_delta; } - m_kart_model->update(dt, m_wheel_rotation_dt, getSteerPercent(), + m_kart_model->update(dt, m_wheel_rotation_dt, getSteerPercent(), height_above_terrain, m_speed); @@ -2541,7 +2541,7 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz, Vec3 center_shift = m_kart_properties->getGravityCenterShift(); - center_shift.setY(m_skidding->getGraphicalJumpOffset() + lean_height + center_shift.setY(m_skidding->getGraphicalJumpOffset() + lean_height - m_kart_model->getLowestPoint() -chassis_delta ); float heading = m_skidding->getVisualSkidRotation(); Moveable::updateGraphics(dt, center_shift, @@ -2595,7 +2595,7 @@ void Kart::setOnScreenText(const wchar_t *text) // FIXME: Titlefont is the only font guaranteed to be loaded if STK // is started without splash screen (since "Loading" is shown even in this // case). A smaller font would be better - // TODO: Add support in the engine for BillboardText or find a replacement + // TODO: Add support in the engine for BillboardText or find a replacement /*scene::ISceneManager* sm = irr_driver->getSceneManager(); sm->addBillboardTextSceneNode(GUIEngine::getFont() ? GUIEngine::getFont() : GUIEngine::getTitleFont(), diff --git a/src/karts/kart.hpp b/src/karts/kart.hpp index 13f6ba4a1..eaf7e835c 100644 --- a/src/karts/kart.hpp +++ b/src/karts/kart.hpp @@ -135,7 +135,7 @@ private: /** The torque to apply after hitting a bubble gum. */ float m_bubblegum_torque; - + /** True if fire button was pushed and not released */ bool m_fire_clicked; @@ -156,10 +156,10 @@ private: // ----------------- /** Time a kart is jumping. */ float m_jump_time; - + /** Is time flying activated */ bool m_is_jumping; - + /** The shadow of a kart. */ Shadow *m_shadow; @@ -207,7 +207,7 @@ private: SFXBase *m_goo_sound; SFXBase *m_boing_sound; float m_time_last_crash; - + /** To prevent using nitro in too short bursts */ float m_min_nitro_time; diff --git a/src/karts/kart_gfx.cpp b/src/karts/kart_gfx.cpp index 21890f11f..42a5c94f6 100644 --- a/src/karts/kart_gfx.cpp +++ b/src/karts/kart_gfx.cpp @@ -49,7 +49,7 @@ KartGFX::KartGFX(const AbstractKart *kart) Vec3 rear_center(0, kart->getKartHeight()*0.35f, -kart->getKartLength()*0.35f); - + Vec3 rear_nitro_center(0, kart->getKartHeight()*0.2f, -kart->getKartLength()*0.1f); diff --git a/src/karts/kart_model.cpp b/src/karts/kart_model.cpp index 11e6c1a8b..bcb3f224a 100644 --- a/src/karts/kart_model.cpp +++ b/src/karts/kart_model.cpp @@ -169,7 +169,7 @@ void KartModel::loadInfo(const XMLNode &node) loadWheelInfo(*wheels_node, "rear-right", 2); loadWheelInfo(*wheels_node, "rear-left", 3); } - + m_nitro_emitter_position[0] = Vec3 (0,0.1f,0); m_nitro_emitter_position[1] = Vec3 (0,0.1f,0); m_has_nitro_emitter = false; @@ -287,11 +287,11 @@ KartModel* KartModel::makeCopy() km->m_animated_node = NULL; km->m_hat_offset = m_hat_offset; km->m_hat_name = m_hat_name; - + km->m_nitro_emitter_position[0] = m_nitro_emitter_position[0]; km->m_nitro_emitter_position[1] = m_nitro_emitter_position[1]; km->m_has_nitro_emitter = m_has_nitro_emitter; - + for(unsigned int i=0; i<4; i++) { km->m_wheel_model[i] = m_wheel_model[i]; @@ -305,7 +305,7 @@ KartModel* KartModel::makeCopy() km->m_max_suspension[i] = m_max_suspension[i]; km->m_dampen_suspension_amplitude[i]= m_dampen_suspension_amplitude[i]; } - + km->m_speed_weighted_objects.resize(m_speed_weighted_objects.size()); for(size_t i=0; igrabAllTextures(m_mesh); Vec3 kart_min, kart_max; - MeshTools::minMax3D(m_mesh->getMesh(m_animation_frame[AF_STRAIGHT]), + MeshTools::minMax3D(m_mesh->getMesh(m_animation_frame[AF_STRAIGHT]), &kart_min, &kart_max); #undef MOVE_KART_MESHES @@ -480,7 +480,7 @@ bool KartModel::loadModels(const KartProperties &kart_properties) core::matrix4 translate(core::matrix4::EM4CONST_IDENTITY); translate.setTranslation(offset_from_center.toIrrVector()); mani->transform(m_mesh, translate); - MeshTools::minMax3D(m_mesh->getMesh(m_animation_frame[AF_STRAIGHT]), + MeshTools::minMax3D(m_mesh->getMesh(m_animation_frame[AF_STRAIGHT]), &kart_min, &kart_max); #endif m_kart_highest_point = kart_max.getY(); @@ -578,7 +578,7 @@ void KartModel::loadSpeedWeightedInfo(const XMLNode* speed_weighted_node, const SpeedWeightedObject obj; obj.m_properties = fallback_properties; obj.m_properties.loadFromXMLNode(speed_weighted_node); - + speed_weighted_node->get("position", &obj.m_position); speed_weighted_node->get("model", &obj.m_name); @@ -770,7 +770,7 @@ void KartModel::OnAnimationEnd(scene::IAnimatedMeshSceneNode *node) * \param suspension Suspension height for all four wheels. * \param speed The speed of the kart in meters/sec, used for the speed-weighted objects' animations */ -void KartModel::update(float dt, float rotation_dt, float steer, +void KartModel::update(float dt, float rotation_dt, float steer, const float height_above_terrain[4], float speed) { core::vector3df wheel_steer(0, steer*30.0f, 0); @@ -789,7 +789,7 @@ void KartModel::update(float dt, float rotation_dt, float steer, } #endif core::vector3df pos = m_wheel_graphics_position[i].toIrrVector(); - pos.Y = m_kart_lowest_point - height_above_terrain[i] + pos.Y = m_kart_lowest_point - height_above_terrain[i] + m_wheel_graphics_radius[i]; m_wheel_node[i]->setPosition(pos); @@ -825,7 +825,7 @@ void KartModel::update(float dt, float rotation_dt, float steer, btClamp(strength, 0.0f, 1.0f); } obj.m_node->setAnimationStrength(strength); - + // Animation speed const float speed_factor = GET_VALUE(obj, m_speed_factor); if(speed_factor >= 0.0f) @@ -843,7 +843,7 @@ void KartModel::update(float dt, float rotation_dt, float steer, obj.m_texture_cur_offset += speed * tex_speed * dt; if(obj.m_texture_cur_offset.X > 1.0f) obj.m_texture_cur_offset.X = fmod(obj.m_texture_cur_offset.X, 1.0f); if(obj.m_texture_cur_offset.Y > 1.0f) obj.m_texture_cur_offset.Y = fmod(obj.m_texture_cur_offset.Y, 1.0f); - + for(unsigned int i=0; igetMaterialCount(); i++) { video::SMaterial &irrMaterial=obj.m_node->getMaterial(i); @@ -854,7 +854,7 @@ void KartModel::update(float dt, float rotation_dt, float steer, core::matrix4 *m = &irrMaterial.getTextureMatrix(j); m->setTextureTranslate(obj.m_texture_cur_offset.X, obj.m_texture_cur_offset.Y); } // for jgetSpeed() < 0.001f && + if(m_kart->getSpeed() < 0.001f && m_skid_state != SKID_NONE && m_skid_state != SKID_BREAK) { m_skid_state = SKID_BREAK; @@ -414,7 +414,7 @@ void Skidding::update(float dt, bool is_on_ground, bonus_speed, bonus_speed, bonus_force, bonus_time, /*fade-out-time*/ 1.0f); - + StateManager::ActivePlayer *c = m_kart->getController()->getPlayer(); if (c && c->getConstProfile() == PlayerManager::get()->getCurrentPlayer()) { diff --git a/src/main.cpp b/src/main.cpp index 461eb9fc1..8a3a4db32 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -367,7 +367,7 @@ void handleXmasMode() bool xmas = false; switch(UserConfigParams::m_xmas_mode) { - case 0: + case 0: { int day, month; StkTime::getDate(&day, &month); @@ -514,7 +514,7 @@ int handleCmdLinePreliminary() UserConfigParams::m_log_errors_to_console=true; } - if(CommandLine::has("--screensize", &s) || + if(CommandLine::has("--screensize", &s) || CommandLine::has("-s", &s) ) { //Check if fullscreen and new res is blacklisted @@ -522,7 +522,7 @@ int handleCmdLinePreliminary() if (sscanf(s.c_str(), "%dx%d", &width, &height) == 2) { // Reassemble the string in case that the original width or - // height contained a leading 0 + // height contained a leading 0 std::ostringstream o; o << width << "x" << height; std::string res = o.str(); @@ -584,7 +584,7 @@ int handleCmdLinePreliminary() IRRLICHT_VERSION_REVISION, IRRLICHT_SDK_VERSION ); Log::info("main", "=============================="); } // --verbose or -v - + // Enable loading GP's from local directory if(CommandLine::has("--add-gp-dir", &s)) { @@ -836,7 +836,7 @@ int handleCmdLine() (int)UserConfigParams::m_num_karts); } // --numkarts - if(CommandLine::has( "--no-start-screen") || + if(CommandLine::has( "--no-start-screen") || CommandLine::has("-N") ) UserConfigParams::m_no_start_screen = true; if(CommandLine::has("--race-now") || CommandLine::has("-R")) @@ -986,7 +986,7 @@ void initUserConfig() irr_driver = new IrrDriver(); file_manager = new FileManager(); user_config = new UserConfig(); // needs file_manager - user_config->loadConfig(); + user_config->loadConfig(); if (UserConfigParams::m_language.toString() != "system") { #ifdef WIN32 @@ -1054,7 +1054,7 @@ void initRest() track_manager->loadTrackList(); music_manager->addMusicToTracks(); - GUIEngine::addLoadingIcon(irr_driver->getTexture(FileManager::GUI, + GUIEngine::addLoadingIcon(irr_driver->getTexture(FileManager::GUI, "notes.png" ) ); grand_prix_manager = new GrandPrixManager (); @@ -1127,7 +1127,7 @@ int main(int argc, char *argv[] ) srand(( unsigned ) time( 0 )); - try + try { std::string s; if(CommandLine::has("--root", &s)) @@ -1138,7 +1138,7 @@ int main(int argc, char *argv[] ) // Init the minimum managers so that user config exists, then // handle all command line options that do not need (or must // not have) other managers initialised: - initUserConfig(); + initUserConfig(); handleCmdLinePreliminary(); @@ -1173,7 +1173,7 @@ int main(int argc, char *argv[] ) // and the AchievementsManager to initialise the AchievementsStatus. PlayerManager::create(); - GUIEngine::addLoadingIcon( irr_driver->getTexture(FileManager::GUI, + GUIEngine::addLoadingIcon( irr_driver->getTexture(FileManager::GUI, "gui_lock.png" ) ); projectile_manager->loadData(); @@ -1225,7 +1225,7 @@ int main(int argc, char *argv[] ) // Load addons.xml to get info about addons even when not // allowed to access the internet - if (UserConfigParams::m_internet_status != + if (UserConfigParams::m_internet_status != Online::RequestManager::IPERM_ALLOWED) { std::string xml_file = file_manager->getAddonsFile("addons.xml"); @@ -1253,7 +1253,7 @@ int main(int argc, char *argv[] ) // displayed (if necessary), so we have to make sure there is // a current player PlayerManager::get()->enforceCurrentPlayer(); - + InputDevice *device; // Use keyboard 0 by default in --no-start-screen @@ -1385,7 +1385,7 @@ int main(int argc, char *argv[] ) // ============================================================================ #ifdef WIN32 //routine for running under windows -int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, +int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { return main(__argc, __argv); diff --git a/src/main_loop.cpp b/src/main_loop.cpp index a6d9a55d2..ace649423 100644 --- a/src/main_loop.cpp +++ b/src/main_loop.cpp @@ -145,7 +145,7 @@ void MainLoop::run() #ifdef ENABLE_WIIUSE wiimote_manager->update(); #endif - + GUIEngine::update(dt); PROFILER_POP_CPU_MARKER(); diff --git a/src/modes/cutscene_world.hpp b/src/modes/cutscene_world.hpp index 2c4f7ec6c..db76d182a 100644 --- a/src/modes/cutscene_world.hpp +++ b/src/modes/cutscene_world.hpp @@ -80,7 +80,7 @@ public: // ------------------------------------------------------------------------ virtual bool raceHasLaps() OVERRIDE { return false; } // ------------------------------------------------------------------------ - virtual unsigned int getNumberOfRescuePositions() const OVERRIDE + virtual unsigned int getNumberOfRescuePositions() const OVERRIDE { return 0; } // getNumberOfRescuePositions diff --git a/src/modes/follow_the_leader.cpp b/src/modes/follow_the_leader.cpp index 9a7a03b11..f9c4b2f94 100644 --- a/src/modes/follow_the_leader.cpp +++ b/src/modes/follow_the_leader.cpp @@ -79,7 +79,7 @@ void FollowTheLeaderRace::reset() stk_config->m_leader_time_per_kart*race_manager->getNumberOfKarts(); WorldStatus::setClockMode(WorldStatus::CLOCK_COUNTDOWN, m_leader_intervals[0]); - + m_is_over_delay = 2.0f; } // reset diff --git a/src/modes/linear_world.cpp b/src/modes/linear_world.cpp index 2ea03bf05..af33e6a6e 100644 --- a/src/modes/linear_world.cpp +++ b/src/modes/linear_world.cpp @@ -610,7 +610,7 @@ float LinearWorld::estimateFinishTimeForKart(AbstractKart* kart) } // estimateFinishTimeForKart // ------------------------------------------------------------------------ -/** Returns the number of rescue positions on a given track, which in +/** Returns the number of rescue positions on a given track, which in * linear races is just the number of driveline quads. */ unsigned int LinearWorld::getNumberOfRescuePositions() const diff --git a/src/modes/overworld.cpp b/src/modes/overworld.cpp index 926410bc7..1d72f2d47 100644 --- a/src/modes/overworld.cpp +++ b/src/modes/overworld.cpp @@ -155,7 +155,7 @@ void OverWorld::update(float dt) s->setMultiplayer(false); s->setFromOverworld(true); StateManager::get()->resetAndGoToScreen(s); - } + } } // update //----------------------------------------------------------------------------- diff --git a/src/modes/three_strikes_battle.cpp b/src/modes/three_strikes_battle.cpp index b9d21470e..185c74598 100644 --- a/src/modes/three_strikes_battle.cpp +++ b/src/modes/three_strikes_battle.cpp @@ -336,7 +336,7 @@ void ThreeStrikesBattle::update(float dt) m_tire_rotation *RAD_TO_DEGREE + 180); core::vector3df tire_scale(scale,scale,scale); - PhysicalObject::Settings physics_settings(body_shape, + PhysicalObject::Settings physics_settings(body_shape, radius, /*mass*/15.0f); TrackObjectPresentationMesh* tire_presentation = @@ -513,7 +513,7 @@ unsigned int ThreeStrikesBattle::getRescuePositionIndex(AbstractKart *kart) accumulated_distance += sqrt(abs_distance2); } - if(accumulated_distance > largest_accumulated_distance_found && + if(accumulated_distance > largest_accumulated_distance_found && spawn_point_clear) { furthest_id_found = n; diff --git a/src/modes/tutorial_world.cpp b/src/modes/tutorial_world.cpp index 5113dc64d..d94d154a0 100644 --- a/src/modes/tutorial_world.cpp +++ b/src/modes/tutorial_world.cpp @@ -25,4 +25,4 @@ TutorialWorld::TutorialWorld() { m_stop_music_when_dialog_open = false; -} // TutorialWorld +} // TutorialWorld \ No newline at end of file diff --git a/src/modes/tutorial_world.hpp b/src/modes/tutorial_world.hpp index 4f7088ec4..e18adc6b4 100644 --- a/src/modes/tutorial_world.hpp +++ b/src/modes/tutorial_world.hpp @@ -29,7 +29,7 @@ public: TutorialWorld(); virtual unsigned int getNumberOfRescuePositions() const OVERRIDE { - // Don't use LinearWorld's function, but WorldWithRank, since the + // Don't use LinearWorld's function, but WorldWithRank, since the // latter is based on rescuing to start positions return WorldWithRank::getNumberOfRescuePositions(); } @@ -37,7 +37,7 @@ public: /** Determines the rescue position index of the specified kart. */ virtual unsigned int getRescuePositionIndex(AbstractKart *kart) OVERRIDE { - // Don't use LinearWorld's function, but WorldWithRank, since the + // Don't use LinearWorld's function, but WorldWithRank, since the // latter is based on rescuing to start positions return WorldWithRank::getRescuePositionIndex(kart); } @@ -45,7 +45,7 @@ public: /** Returns the bullet transformation for the specified rescue index. */ virtual btTransform getRescueTransform(unsigned int index) const OVERRIDE { - // Don't use LinearWorld's function, but WorldWithRank, since the + // Don't use LinearWorld's function, but WorldWithRank, since the // latter is based on rescuing to start positions return WorldWithRank::getRescueTransform(index); } diff --git a/src/modes/world.cpp b/src/modes/world.cpp index ea0b8efee..9b985938f 100644 --- a/src/modes/world.cpp +++ b/src/modes/world.cpp @@ -453,7 +453,7 @@ void World::terminateRace() PlayerManager::increaseAchievement(AchievementInfo::ACHIEVE_MARATHONER, "laps", race_manager->getNumLaps()); } - + Achievement *achiev = PlayerManager::getCurrentAchievementsStatus()->getAchievement(AchievementInfo::ACHIEVE_GOLD_DRIVER); if (achiev) { @@ -483,9 +483,9 @@ void World::terminateRace() mode_name, 1); } } - } // for i < kart_amount + } // for i < kart_amount } // if (achiev) - + Achievement *win = PlayerManager::getCurrentAchievementsStatus()->getAchievement(AchievementInfo::ACHIEVE_UNSTOPPABLE); //if achivement has been unlocked if (win->getValue("wins") < 5 ) @@ -504,7 +504,7 @@ void World::terminateRace() "wins", 1); } else - { + { //Set number of consecutive wins to 0 win->reset(); } diff --git a/src/modes/world_with_rank.cpp b/src/modes/world_with_rank.cpp index 2f64b3d3d..ef9ddfce1 100644 --- a/src/modes/world_with_rank.cpp +++ b/src/modes/world_with_rank.cpp @@ -135,7 +135,7 @@ unsigned int WorldWithRank::getNumberOfRescuePositions() const // ---------------------------------------------------------------------------- /** Finds the starting position which is closest to the kart. * \param kart The kart for which a rescue position needs to be determined. - */ + */ unsigned int WorldWithRank::getRescuePositionIndex(AbstractKart *kart) { // find closest point to drop kart on diff --git a/src/network/client_network_manager.hpp b/src/network/client_network_manager.hpp index fff6ba30f..422d08dc0 100644 --- a/src/network/client_network_manager.hpp +++ b/src/network/client_network_manager.hpp @@ -52,7 +52,7 @@ class ClientNetworkManager : public NetworkManager * \param reliable : If set to true, ENet will ensure that the packet is received. */ virtual void sendPacket(const NetworkString& data, bool reliable = true); - + /*! \brief Get the peer (the server) * \return The peer with whom we're connected (if it exists). NULL elseway. */ diff --git a/src/network/game_setup.hpp b/src/network/game_setup.hpp index b5fc84f3a..171160278 100644 --- a/src/network/game_setup.hpp +++ b/src/network/game_setup.hpp @@ -61,7 +61,7 @@ class GameSetup void setPlayerKart(uint8_t id, std::string kart_name); //!< Set the kart of a player void bindKartsToProfiles(); //!< Sets the right world_kart_id in profiles - /** \brief Get the players that are in the game + /** \brief Get the players that are in the game * \return A vector containing pointers on the players profiles. */ std::vector getPlayers() { return m_players; } diff --git a/src/network/network_manager.hpp b/src/network/network_manager.hpp index 82ff902fb..40ec66971 100644 --- a/src/network/network_manager.hpp +++ b/src/network/network_manager.hpp @@ -38,8 +38,8 @@ * \brief Gives the general functions to use network communication. * This class is in charge of storing the peers connected to this host. * It also stores the host, and brings the functions to send messages to peers. - * It automatically dispatches the events or packets it receives. This class - * also stores the public address when known and the player login. + * It automatically dispatches the events or packets it receives. This class + * also stores the public address when known and the player login. * Here are defined some functions that will be specifically implemented by * the ServerNetworkManager and the ClientNetworkManager. */ @@ -67,7 +67,7 @@ class NetworkManager : public Singleton virtual bool connect(TransportAddress peer); /** \brief Changes the socket working mode. * Sockets can be in two modes : The ENet mode and a mode we will call - * the 'Raw' mode. In the ENet mode, the socket will be read as + * the 'Raw' mode. In the ENet mode, the socket will be read as * \param peer : The transport address which you want to connect to. * \return True if we're successfully connected. False elseway. */ @@ -75,13 +75,13 @@ class NetworkManager : public Singleton // message/packets related functions virtual void notifyEvent(Event* event); - virtual void sendPacket(const NetworkString& data, + virtual void sendPacket(const NetworkString& data, bool reliable = true) = 0; - virtual void sendPacket(STKPeer* peer, - const NetworkString& data, + virtual void sendPacket(STKPeer* peer, + const NetworkString& data, bool reliable = true); - virtual void sendPacketExcept(STKPeer* peer, - const NetworkString& data, + virtual void sendPacketExcept(STKPeer* peer, + const NetworkString& data, bool reliable = true); // Game related functions diff --git a/src/network/protocol_manager.hpp b/src/network/protocol_manager.hpp index d4921e6e6..b0e55cf1b 100644 --- a/src/network/protocol_manager.hpp +++ b/src/network/protocol_manager.hpp @@ -107,7 +107,7 @@ class ProtocolManager : public Singleton friend class Singleton; friend void* protocolManagerAsynchronousUpdate(void* data); public: - + /*! \brief Stops the protocol manager. */ virtual void abort(); /*! diff --git a/src/network/protocols/get_public_address.cpp b/src/network/protocols/get_public_address.cpp index 3fe92501c..b42208b06 100644 --- a/src/network/protocols/get_public_address.cpp +++ b/src/network/protocols/get_public_address.cpp @@ -106,7 +106,7 @@ void GetPublicAddress::asynchronousUpdate() RandomGenerator random_gen; int rand_result = random_gen.get(stun_servers.size()); - Log::verbose("GetPublicAddress", "Using STUN server %s", + Log::verbose("GetPublicAddress", "Using STUN server %s", stun_servers[rand_result].c_str()); // resolve the name into an IP address diff --git a/src/network/stk_host.cpp b/src/network/stk_host.cpp index aef89c96f..a6d82edfc 100644 --- a/src/network/stk_host.cpp +++ b/src/network/stk_host.cpp @@ -121,10 +121,10 @@ void STKHost::setupServer(uint32_t address, uint16_t port, int peer_count, addr->port = port; #ifdef WIN32/* - addr->host = 0; - addr->host += ((unsigned int)(192)<<0); // 192.168.0.11 - addr->host += ((unsigned int)(168)<<8); // 192.168.0.11 - addr->host += ((unsigned int)(11)<<24); // 192.168.0.11*/ + addr->host = 0; + addr->host += ((unsigned int)(192)<<0); // 192.168.0.11 + addr->host += ((unsigned int)(168)<<8); // 192.168.0.11 + addr->host += ((unsigned int)(11)<<24); // 192.168.0.11*/ #endif m_host = enet_host_create(addr, peer_count, channel_limit, @@ -235,10 +235,10 @@ uint8_t* STKHost::receiveRawPacket(TransportAddress* sender) len = recvfrom(m_host->socket, (char*)buffer, 2048, 0, (struct sockaddr*)(&addr), &from_len); StkTime::sleep(1); // wait 1 millisecond between two checks } - if (len == SOCKET_ERROR) - { - Log::error("STKHost", "Problem with the socket. Please contact the dev team."); - } + if (len == SOCKET_ERROR) + { + Log::error("STKHost", "Problem with the socket. Please contact the dev team."); + } // we received the data sender->ip = ntohl((uint32_t)(addr.sin_addr.s_addr)); sender->port = ntohs(addr.sin_port); @@ -272,8 +272,8 @@ uint8_t* STKHost::receiveRawPacket(TransportAddress sender, int max_tries) while(len < 0 || addr.sin_addr.s_addr == sender.ip) { i++; - if (len>=0) - { + if (len>=0) + { Log::info("STKHost", "Message received but the ip address didn't match the expected one."); } len = recvfrom(m_host->socket, (char*)buffer, 2048, 0, (struct sockaddr*)(&addr), &from_len); @@ -281,10 +281,10 @@ uint8_t* STKHost::receiveRawPacket(TransportAddress sender, int max_tries) if (i >= max_tries && max_tries != -1) { Log::verbose("STKHost", "No answer from the server on %u.%u.%u.%u:%u", (m_host->address.host&0xff), - (m_host->address.host>>8&0xff), - (m_host->address.host>>16&0xff), - (m_host->address.host>>24&0xff), - (m_host->address.port)); + (m_host->address.host>>8&0xff), + (m_host->address.host>>16&0xff), + (m_host->address.host>>24&0xff), + (m_host->address.port)); return NULL; } } diff --git a/src/network/stk_host.hpp b/src/network/stk_host.hpp index 9a1a6abc1..97cc96dad 100644 --- a/src/network/stk_host.hpp +++ b/src/network/stk_host.hpp @@ -63,7 +63,7 @@ class STKHost STKHost(); /*! \brief Destructor */ virtual ~STKHost(); - + /*! \brief Log packets into a file * \param ns : The data in the packet * \param incoming : True if the packet comes from a peer. diff --git a/src/network/stk_peer.cpp b/src/network/stk_peer.cpp index 35ad08860..55763f692 100644 --- a/src/network/stk_peer.cpp +++ b/src/network/stk_peer.cpp @@ -51,7 +51,7 @@ STKPeer::~STKPeer() m_peer = NULL; if (m_player_profile) delete m_player_profile; - m_player_profile = NULL; + m_player_profile = NULL; if (m_client_server_token) delete m_client_server_token; m_client_server_token = NULL; diff --git a/src/online/current_user.cpp b/src/online/current_user.cpp index 782f826d7..50466e27b 100644 --- a/src/online/current_user.cpp +++ b/src/online/current_user.cpp @@ -100,7 +100,7 @@ namespace Online request->setServerURL("client-user.php"); request->addParameter("action","saved-session"); request->addParameter("userid", UserConfigParams::m_saved_user); - request->addParameter("token", + request->addParameter("token", UserConfigParams::m_saved_token.c_str()); request->queue(); m_state = US_SIGNING_IN; @@ -158,7 +158,7 @@ namespace Online /** Checks the server respond after a login attempt. If the login * was successful, it marks the user as logged in, and (if requested) * saves data to be able to login next time. - * \param success If the answer from the server indicated a + * \param success If the answer from the server indicated a * successful login attemp. * \param input Xml tree with the complete server response. */ @@ -184,7 +184,7 @@ namespace Online std::string achieved_string(""); if(input->get("achieved", &achieved_string) == 1) { - std::vector achieved_ids = + std::vector achieved_ids = StringUtils::splitToUInt(achieved_string, ' '); PlayerManager::getCurrentAchievementsStatus()->sync(achieved_ids); } @@ -234,7 +234,7 @@ namespace Online } // signOut // ------------------------------------------------------------------------ - CurrentUser::ServerJoinRequest* + CurrentUser::ServerJoinRequest* CurrentUser::requestServerJoin(uint32_t server_id, bool request_now) { @@ -263,7 +263,7 @@ namespace Online } // ServerJoinRequest::callback // ------------------------------------------------------------------------ - const XMLRequest* + const XMLRequest* CurrentUser::requestGetAddonVote(const std::string & addon_id) const { assert(m_state == US_SIGNED_IN); @@ -381,7 +381,7 @@ namespace Online void CurrentUser::requestRemoveFriend(const uint32_t friend_id) const { assert(m_state == US_SIGNED_IN); - CurrentUser::RemoveFriendRequest * request = + CurrentUser::RemoveFriendRequest * request = new CurrentUser::RemoveFriendRequest(friend_id); request->setServerURL("client-user.php"); request->addParameter("action", "remove-friend"); @@ -408,7 +408,7 @@ namespace Online } else info_text = getInfo(); - UserInfoDialog *info = new UserInfoDialog(m_id, info_text,!isSuccess(), + UserInfoDialog *info = new UserInfoDialog(m_id, info_text,!isSuccess(), true); GUIEngine::DialogQueue::get()->pushDialog(info, true); @@ -437,14 +437,14 @@ namespace Online request->queue(); } // requestPasswordChange // ------------------------------------------------------------------------ - /** Callback for the change password request. If the matching dialog is + /** Callback for the change password request. If the matching dialog is * still open, show a confirmation message. */ void CurrentUser::ChangePasswordRequest::callback() { if(GUIEngine::ModalDialog::isADialogActive()) { - ChangePasswordDialog * dialog = + ChangePasswordDialog * dialog = dynamic_cast(GUIEngine::ModalDialog ::getCurrent()); if(dialog != NULL) @@ -487,10 +487,10 @@ namespace Online std::string online_friends_string(""); if(getXMLData()->get("online", &online_friends_string) == 1) { - std::vector online_friends = + std::vector online_friends = StringUtils::splitToUInt(online_friends_string, ' '); bool went_offline = false; - std::vector friends = + std::vector friends = CurrentUser::get()->getProfile()->getFriends(); std::vector to_notify; for(unsigned int i = 0; i < friends.size(); ++i) @@ -506,7 +506,7 @@ namespace Online } OnlineProfile * profile = ProfileManager::get()->getProfileByID(friends[i]); - OnlineProfile::RelationInfo * relation_info = + OnlineProfile::RelationInfo * relation_info = profile->getRelationInfo(); if( relation_info->isOnline() ) { @@ -524,7 +524,7 @@ namespace Online relation_info->setOnline(true); // Do this because a user might have accepted // a pending friend request. - profile->setFriend(); + profile->setFriend(); to_notify.push_back(profile->getUserName()); } } @@ -550,10 +550,10 @@ namespace Online } else if(to_notify.size() > 3) { - message = _("%d friends are now online.", + message = _("%d friends are now online.", to_notify.size()); } - NotificationDialog *dia = + NotificationDialog *dia = new NotificationDialog(NotificationDialog::T_Friends, message); GUIEngine::DialogQueue::get()->pushDialog(dia, false); @@ -576,7 +576,7 @@ namespace Online const XMLNode * node = getXMLData()->getNode(i); if(node->getName() == "new_friend_request") { - OnlineProfile::RelationInfo * ri = + OnlineProfile::RelationInfo * ri = new OnlineProfile::RelationInfo("New", false, true, true); OnlineProfile * p = new OnlineProfile(node); p->setRelationInfo(ri); @@ -597,7 +597,7 @@ namespace Online message = _("You have a new friend request!"); } NotificationDialog *dia = - new NotificationDialog(NotificationDialog::T_Friends, + new NotificationDialog(NotificationDialog::T_Friends, message); GUIEngine::DialogQueue::get()->pushDialog(dia, false); OnlineProfileFriends::getInstance()->refreshFriendsList(); @@ -659,7 +659,7 @@ namespace Online // ------------------------------------------------------------------------ /** \return the online id, or 0 if the user is not signed in. - */ + */ uint32_t CurrentUser::getID() const { if((m_state == US_SIGNED_IN )) diff --git a/src/online/current_user.hpp b/src/online/current_user.hpp index 0178a1200..de553f6ff 100644 --- a/src/online/current_user.hpp +++ b/src/online/current_user.hpp @@ -60,7 +60,7 @@ namespace Online { virtual void callback (); public: - SignInRequest(bool manage_memory = false) + SignInRequest(bool manage_memory = false) : XMLRequest(manage_memory, /*priority*/10) {} }; // SignInRequest diff --git a/src/online/http_request.cpp b/src/online/http_request.cpp index d5a15d443..2e52075c1 100644 --- a/src/online/http_request.cpp +++ b/src/online/http_request.cpp @@ -32,11 +32,11 @@ namespace Online { - /** Creates a HTTP(S) request that will have a raw string as result. (Can + /** Creates a HTTP(S) request that will have a raw string as result. (Can * of course be used if the result doesn't matter.) * \param manage_memory whether or not the RequestManager should take care of * deleting the object after all callbacks have been done. - * \param priority by what priority should the RequestManager take care of + * \param priority by what priority should the RequestManager take care of * this request. */ HTTPRequest::HTTPRequest(bool manage_memory, int priority) @@ -50,15 +50,15 @@ namespace Online * \param filename Name of the file to save the data to. * \param manage_memory whether or not the RequestManager should take care of * deleting the object after all callbacks have been done. - * \param priority by what priority should the RequestManager take care of + * \param priority by what priority should the RequestManager take care of * this request. */ - HTTPRequest::HTTPRequest(const std::string &filename, bool manage_memory, + HTTPRequest::HTTPRequest(const std::string &filename, bool manage_memory, int priority) : Request(manage_memory, priority, 0) { // A http request should not even be created when internet is disabled - assert(UserConfigParams::m_internet_status == + assert(UserConfigParams::m_internet_status == RequestManager::IPERM_ALLOWED); assert(filename.size()>0); init(); @@ -69,12 +69,12 @@ namespace Online /** Char * needs a separate constructor, otherwise it will be considered * to be the no-filename constructor (char* -> bool). */ - HTTPRequest::HTTPRequest(const char* const filename, bool manage_memory, + HTTPRequest::HTTPRequest(const char* const filename, bool manage_memory, int priority) : Request(manage_memory, priority, 0) { // A http request should not even be created when internet is disabled - assert(UserConfigParams::m_internet_status == + assert(UserConfigParams::m_internet_status == RequestManager::IPERM_ALLOWED); init(); m_filename = file_manager->getAddonsFile(filename); @@ -94,7 +94,7 @@ namespace Online } // init // ------------------------------------------------------------------------ - /** A handy shortcut that appends the given path to the URL of the + /** A handy shortcut that appends the given path to the URL of the * mutiplayer server. * \param path The path to add to the server. */ @@ -151,7 +151,7 @@ namespace Online struct curl_slist *chunk = NULL; chunk = curl_slist_append(chunk, "Host: api.stkaddons.net"); curl_easy_setopt(m_curl_session, CURLOPT_HTTPHEADER, chunk); - curl_easy_setopt(m_curl_session, CURLOPT_CAINFO, + curl_easy_setopt(m_curl_session, CURLOPT_CAINFO, file_manager->getAsset("web.tuxfamily.org.pem").c_str()); curl_easy_setopt(m_curl_session, CURLOPT_SSL_VERIFYPEER, 1L); curl_easy_setopt(m_curl_session, CURLOPT_SSL_VERIFYHOST, 0L); @@ -183,13 +183,13 @@ namespace Online } else { - curl_easy_setopt(m_curl_session, CURLOPT_WRITEDATA, + curl_easy_setopt(m_curl_session, CURLOPT_WRITEDATA, &m_string_buffer); - curl_easy_setopt(m_curl_session, CURLOPT_WRITEFUNCTION, + curl_easy_setopt(m_curl_session, CURLOPT_WRITEFUNCTION, &HTTPRequest::writeCallback); } - // All parameters added have a '&' added + // All parameters added have a '&' added if(m_parameters.size()>0) { m_parameters.erase(m_parameters.size()-1); @@ -254,7 +254,7 @@ namespace Online "Could not removed existing addons.xml file."); m_curl_code = CURLE_WRITE_ERROR; } - int ret = rename((m_filename+".part").c_str(), + int ret = rename((m_filename+".part").c_str(), m_filename.c_str() ); // In case of an error, set the status to indicate this if(ret!=0) @@ -268,7 +268,7 @@ namespace Online } // operation // ------------------------------------------------------------------------ - /** Cleanup once the download is finished. The value of progress is + /** Cleanup once the download is finished. The value of progress is * guaranteed to be >=0 and <1 while the download is in progress, and * will only be set to 1 on a successfull finish here. */ diff --git a/src/online/http_request.hpp b/src/online/http_request.hpp index e60b66851..2875ebce8 100644 --- a/src/online/http_request.hpp +++ b/src/online/http_request.hpp @@ -78,13 +78,13 @@ namespace Online void init(); public : - HTTPRequest(bool manage_memory = false, + HTTPRequest(bool manage_memory = false, int priority = 1); HTTPRequest(const std::string &filename, - bool manage_memory = false, + bool manage_memory = false, int priority = 1); HTTPRequest(const char * const filename, - bool manage_memory = false, + bool manage_memory = false, int priority = 1); virtual ~HTTPRequest() {}; virtual bool isAllowedToAdd() const OVERRIDE; @@ -99,7 +99,7 @@ namespace Online * \pre m_curl_code!=CURLE_OK */ const char* getDownloadErrorMessage() const - { + { assert(hadDownloadError()); return curl_easy_strerror(m_curl_code); } // getDownloadErrorMessage @@ -126,7 +126,7 @@ namespace Online // -------------------------------------------------------------------- /** Sets a parameter to 'value' (stringw). */ - void addParameter(const std::string & name, + void addParameter(const std::string & name, const irr::core::stringw &value) { core::stringc s = core::stringc(value.c_str()); @@ -142,7 +142,7 @@ namespace Online { assert(isPreparing()); std::string s = StringUtils::toString(value); - char *s1 = curl_easy_escape(m_curl_session, name.c_str(), + char *s1 = curl_easy_escape(m_curl_session, name.c_str(), name.size() ); char *s2 = curl_easy_escape(m_curl_session, s.c_str(), s.size()); m_parameters.append(std::string(s1)+"="+s2+"&"); @@ -159,9 +159,9 @@ namespace Online const std::string & getURL() const { assert(isBusy()); return m_url;} // -------------------------------------------------------------------- /** Sets the URL for this request. */ - void setURL(const std::string & url) + void setURL(const std::string & url) { - assert(isPreparing()); + assert(isPreparing()); m_url = url; } // setURL diff --git a/src/online/online_profile.cpp b/src/online/online_profile.cpp index 49a93a02b..8405c3e59 100644 --- a/src/online/online_profile.cpp +++ b/src/online/online_profile.cpp @@ -35,7 +35,7 @@ using namespace Online; namespace Online { -OnlineProfile::RelationInfo::RelationInfo(const irr::core::stringw & date, +OnlineProfile::RelationInfo::RelationInfo(const irr::core::stringw & date, bool is_online, bool is_pending, bool is_asker) { @@ -319,9 +319,9 @@ void OnlineProfile::merge(OnlineProfile *profile) if (this->m_relation_info == NULL && profile->m_relation_info != NULL) { this->m_relation_info = profile->m_relation_info; - // We don't want the destructor of the profile instance to destroy + // We don't want the destructor of the profile instance to destroy // the relation info - profile->m_relation_info = NULL; + profile->m_relation_info = NULL; } delete profile; } // merge diff --git a/src/online/online_profile.hpp b/src/online/online_profile.hpp index 01bcb975d..f36ee8d62 100644 --- a/src/online/online_profile.hpp +++ b/src/online/online_profile.hpp @@ -55,7 +55,7 @@ public: bool m_is_asker; irr::core::stringw m_date; public: - RelationInfo(const irr::core::stringw & date, bool is_online, + RelationInfo(const irr::core::stringw & date, bool is_online, bool is_pending, bool is_asker = false); void setOnline(bool online); // -------------------------------------------------------------------- @@ -91,7 +91,7 @@ private: bool m_has_fetched_friends; /** List of user id's that are friends with the user of this profile. - * In case this profile is of the current user, this list also contains + * In case this profile is of the current user, this list also contains * any id's of users that still have a friend request pending. */ std::vector m_friends; @@ -139,7 +139,7 @@ public: // ------------------------------------------------------------------------ void setRelationInfo(RelationInfo * r) { - delete m_relation_info; m_relation_info = r; + delete m_relation_info; m_relation_info = r; } // setRelationInfo // ------------------------------------------------------------------------ /** Sets the cache bit of this profile. Used by the cache eviction diff --git a/src/online/profile_manager.cpp b/src/online/profile_manager.cpp index 6e31f9e9c..b4850b43c 100644 --- a/src/online/profile_manager.cpp +++ b/src/online/profile_manager.cpp @@ -124,7 +124,7 @@ void ProfileManager::addDirectToCache(OnlineProfile* profile) assert(profile != NULL); if (m_profiles_cache.size() == m_max_cache_size) { - // We have to replace a cached entry, find one entry that + // We have to replace a cached entry, find one entry that // doesn't have its used bit set ProfilesMap::iterator iter; for (iter = m_profiles_cache.begin(); iter != m_profiles_cache.end();) @@ -203,7 +203,7 @@ bool ProfileManager::inPersistent(const uint32_t id) } // inPersistent // ------------------------------------------------------------------------ -/** Adds a profile to the persistent map. If a profile with the same id +/** Adds a profile to the persistent map. If a profile with the same id * is already in there, the profiles are "merged" with the goal to save as * much information (i.e. one profile instance could have already fetched * the friends, while the other could have fetched the achievements.) @@ -244,7 +244,7 @@ void ProfileManager::deleteFromPersistent(const uint32_t id) void ProfileManager::clearPersistent() { ProfilesMap::iterator it; - for (it = m_profiles_persistent.begin(); + for (it = m_profiles_persistent.begin(); it != m_profiles_persistent.end(); ++it) { delete it->second; @@ -266,7 +266,7 @@ void ProfileManager::moveToCache(const uint32_t id) addToCache(profile); } else - Log::warn("ProfileManager", + Log::warn("ProfileManager", "Tried to move profile with id %d from persistent to " "cache while not present", id); } // moveToCache diff --git a/src/online/profile_manager.hpp b/src/online/profile_manager.hpp index c13f16bea..1a461c074 100644 --- a/src/online/profile_manager.hpp +++ b/src/online/profile_manager.hpp @@ -32,12 +32,12 @@ namespace Online class OnlineProfile; -/** Class that manages all online profiles. Profiles are used for storing +/** Class that manages all online profiles. Profiles are used for storing * online information from local users, but also to store information about * remote users (e.g. if you want to see the achievements of another user * a Profile for this user is created, the server is then queried for * the information and the result is stored in that profile). - * The profile manager has two + * The profile manager has two * \ingroup online. */ class ProfileManager @@ -58,7 +58,7 @@ private: ProfilesMap m_profiles_persistent; /** Any profiles that don't go into the persistent map, go here. This - * uses a pseudo-LRU algorithm with age bits to remove entries when + * uses a pseudo-LRU algorithm with age bits to remove entries when * the max size is reached. */ ProfilesMap m_profiles_cache; @@ -66,7 +66,7 @@ private: * e.g. its data is shown in a gui. */ OnlineProfile* m_currently_visiting; - /** The max size of the m_profiles cache. Its default size can be + /** The max size of the m_profiles cache. Its default size can be * inrceased when necessary (e.g. when too many search results are * loaded, to make sure they can be all stored). */ unsigned int m_max_cache_size; diff --git a/src/online/request.hpp b/src/online/request.hpp index 6250b8cee..4ddec7387 100644 --- a/src/online/request.hpp +++ b/src/online/request.hpp @@ -36,28 +36,28 @@ namespace Online { - /** Stores a request for the HTTP Manager. They will be sorted by + /** Stores a request for the HTTP Manager. They will be sorted by * prioritiy. Requests have four different states they can be in, and * this state determines which thread can access it. This allows * the use of threading without adding more synchronisation overhead * and code to the main thread. The states are: - * - Preparing\n The request is created, and parameter are set. + * - Preparing\n The request is created, and parameter are set. * Only the main thread can access this object. * - Busy\n The request is put into the request_manager queue. It remains * in this states till its operation is finished. No more changes * to this object by the main thread are allowed, only the manager * thread can change it now. - * - Executed\n The request was executed (its operation called and + * - Executed\n The request was executed (its operation called and * finished), but callbacks still need to be done by the manager * thread (main reason for this state is to have asserts in * function accessing data). - * - Done\n All callbacks are done (they will be executed by the main + * - Done\n All callbacks are done (they will be executed by the main * thread), the request was moved from the manager's request queue * to its finished queue, executed its callbacks and was removed * from the queue. The manager thread will not access this object * anymore, and the main thread is now able to access the request * object again. - * + * * \ingroup online */ class Request : public NoCopy @@ -81,7 +81,7 @@ namespace Online /** The different state of the requst: * - S_PREPARING:\n The request is created and can be configured, it * is not yet started. - * - S_BUSY:\n The request is added to the execution queue of the + * - S_BUSY:\n The request is added to the execution queue of the * request_manager (and potentially executing). This implies that * now only the request_manager thread should access the requests's * data structures. @@ -110,7 +110,7 @@ namespace Online Synchronised m_state; // -------------------------------------------------------------------- - /** The actual operation to be executed. Empty as default, which + /** The actual operation to be executed. Empty as default, which * allows to create a 'quit' request without any additional code. */ virtual void operation() {} // -------------------------------------------------------------------- @@ -158,16 +158,16 @@ namespace Online // -------------------------------------------------------------------- /** Sets the request state to busy. */ void setBusy() - { + { assert(m_state.getAtomic()==S_PREPARING); - m_state.setAtomic(S_BUSY); + m_state.setAtomic(S_BUSY); } // setBusy // -------------------------------------------------------------------- /** Sets the request to be completed. */ - void setExecuted() + void setExecuted() { assert(m_state.getAtomic()==S_BUSY); - m_state.setAtomic(S_EXECUTED); + m_state.setAtomic(S_EXECUTED); } // setExecuted // -------------------------------------------------------------------- /** Should only be called by the manager */ @@ -187,20 +187,20 @@ namespace Online bool isBusy() const { return m_state.getAtomic() == S_BUSY; } // -------------------------------------------------------------------- /** Checks if the request has completed or done (i.e. callbacks were - * executed). + * executed). */ - bool hasBeenExecuted() const + bool hasBeenExecuted() const { State s = m_state.getAtomic(); return s==S_EXECUTED || s==S_DONE; } // hasBeenExecuted // -------------------------------------------------------------------- - /** Virtual method to check if a request has initialized all needed + /** Virtual method to check if a request has initialized all needed * members to a valid value. */ virtual bool isAllowedToAdd() const { return isPreparing(); } // ==================================================================== - /** This class is used by the priority queue to sort requests by + /** This class is used by the priority queue to sort requests by * priority. */ class Compare diff --git a/src/online/request_manager.cpp b/src/online/request_manager.cpp index 664547cb9..14be63b88 100644 --- a/src/online/request_manager.cpp +++ b/src/online/request_manager.cpp @@ -155,7 +155,7 @@ namespace Online void RequestManager::cancelAllDownloads() { m_abort.setAtomic(true); - // FIXME doesn't get called at the moment. When using this again, + // FIXME doesn't get called at the moment. When using this again, // be sure that HTTP_MAX_PRIORITY requests still get executed. } // cancelAllDownloads @@ -189,7 +189,7 @@ namespace Online me->m_current_request = NULL; me->m_request_queue.lock(); - while( me->m_request_queue.getData().empty() || + while( me->m_request_queue.getData().empty() || me->m_request_queue.getData().top()->getType() != Request::RT_QUIT) { bool empty = me->m_request_queue.getData().empty(); diff --git a/src/online/xml_request.cpp b/src/online/xml_request.cpp index d7058dcd6..ffa145b06 100644 --- a/src/online/xml_request.cpp +++ b/src/online/xml_request.cpp @@ -62,7 +62,7 @@ namespace Online { m_xml_data = file_manager->createXMLTreeFromString(getData()); if(hadDownloadError()) - Log::error("XMLRequest::afterOperation", + Log::error("XMLRequest::afterOperation", "curl_easy_perform() failed: %s", getDownloadErrorMessage()); m_success = false; diff --git a/src/online/xml_request.hpp b/src/online/xml_request.hpp index 5fbfb961e..120bb1691 100644 --- a/src/online/xml_request.hpp +++ b/src/online/xml_request.hpp @@ -68,7 +68,7 @@ namespace Online } // getXMLData // ------------------------------------------------------------------------ - /** Returns the additional information (or error message) contained in + /** Returns the additional information (or error message) contained in * a finished request. * \pre request had to be executed. * \return get the info from the request reply @@ -83,10 +83,10 @@ namespace Online /** Returns whether the request was successfully executed on the server. * \pre request had to be executed. * \return whether or not the request was a success. */ - bool isSuccess() const + bool isSuccess() const { assert(hasBeenExecuted()); - return m_success; + return m_success; } // isSuccess }; // class XMLRequest diff --git a/src/physics/btKart.cpp b/src/physics/btKart.cpp index 141c32baf..2647c8756 100644 --- a/src/physics/btKart.cpp +++ b/src/physics/btKart.cpp @@ -212,7 +212,7 @@ void btKart::updateWheelTransformsWS(btWheelInfo& wheel, } // updateWheelTransformsWS // ---------------------------------------------------------------------------- -/** +/** */ btScalar btKart::rayCast(unsigned int index) { @@ -350,7 +350,7 @@ btScalar btKart::rayCast(unsigned int index) void* object = m_vehicleRaycaster->castRay(source,target,rayResults); m_visual_contact_point[index] = rayResults.m_hitPointInWorld; m_visual_contact_point[index-2] = source; - m_visual_wheels_touch_ground &= (object!=NULL); + m_visual_wheels_touch_ground &= (object!=NULL); } } #endif diff --git a/src/physics/btKart.hpp b/src/physics/btKart.hpp index a799f0575..268836a4a 100644 --- a/src/physics/btKart.hpp +++ b/src/physics/btKart.hpp @@ -183,11 +183,11 @@ public: // ------------------------------------------------------------------------ /** Returns true if both rear visual wheels touch the ground. */ bool visualWheelsTouchGround() const - { - return m_visual_wheels_touch_ground; + { + return m_visual_wheels_touch_ground; } // visualWheelsTouchGround // ------------------------------------------------------------------------ - /** Returns the contact point of a visual wheel. + /** Returns the contact point of a visual wheel. * \param n Index of the wheel, must be 2 or 3 since only the two rear * wheels define the visual position */ @@ -257,7 +257,7 @@ public: float getCentralImpulseTime() const { return m_time_additional_impulse; } // ------------------------------------------------------------------------ /** Sets a visual rotation to be applied, which the physics use to provide - * the location where the graphical wheels touch the ground (for + * the location where the graphical wheels touch the ground (for * skidmarks). */ void setVisualRotation(float angle) { diff --git a/src/physics/physical_object.cpp b/src/physics/physical_object.cpp index 7f0e1e01a..1e9ebb9f4 100644 --- a/src/physics/physical_object.cpp +++ b/src/physics/physical_object.cpp @@ -78,8 +78,8 @@ PhysicalObject::Settings::Settings(const XMLNode &xml_node) else if(shape=="sphere" ) m_body_type = MP_SPHERE; else if(shape=="exact" ) m_body_type = MP_EXACT; - else - Log::error("PhysicalObject", "Unknown shape type : %s.", + else + Log::error("PhysicalObject", "Unknown shape type : %s.", shape.c_str()); } // Settings(XMLNode) @@ -554,7 +554,7 @@ void PhysicalObject::handleExplosion(const Vec3& pos, bool direct_hit) */ bool PhysicalObject::isSoccerBall() const { - return m_object->isSoccerBall(); + return m_object->isSoccerBall(); } // is SoccerBall // ---------------------------------------------------------------------------- @@ -565,7 +565,7 @@ bool PhysicalObject::isSoccerBall() const */ void PhysicalObject::hit(const Material *m, const Vec3 &normal) { - if(isSoccerBall() && m != NULL && + if(isSoccerBall() && m != NULL && m->getCollisionReaction() == Material::PUSH_SOCCER_BALL) { m_body->applyCentralImpulse(normal * 1000.0f); diff --git a/src/physics/physical_object.hpp b/src/physics/physical_object.hpp index f3886c377..0cb52df59 100644 --- a/src/physics/physical_object.hpp +++ b/src/physics/physical_object.hpp @@ -62,7 +62,7 @@ public: /** Reset the object when it falls under the track (useful * e.g. for a boulder rolling down a hill). */ bool m_reset_when_too_low; - /** If the item is below that height, it is reset (when + /** If the item is below that height, it is reset (when * m_reset_when_too_low is true). */ float m_reset_height; private: diff --git a/src/physics/physics.cpp b/src/physics/physics.cpp index a5adab012..dbbedd1ca 100644 --- a/src/physics/physics.cpp +++ b/src/physics/physics.cpp @@ -277,7 +277,7 @@ void Physics::update(float dt) target_kart->getIdent(), 1); if (type == PowerupManager::POWERUP_BOWLING) { - PlayerManager::increaseAchievement(AchievementInfo::ACHIEVE_STRIKE, + PlayerManager::increaseAchievement(AchievementInfo::ACHIEVE_STRIKE, "ball", 1); } // is bowling ball } // if target_kart != kart && is a player kart and is current player diff --git a/src/race/race_manager.cpp b/src/race/race_manager.cpp index c406921b2..3b29c01db 100644 --- a/src/race/race_manager.cpp +++ b/src/race/race_manager.cpp @@ -340,7 +340,7 @@ void RaceManager::startNew(bool from_overworld) } m_track_number = 0; - if(m_major_mode==MAJOR_MODE_GRAND_PRIX && + if(m_major_mode==MAJOR_MODE_GRAND_PRIX && !NetworkWorld::getInstance()->isRunning()) // offline mode only { //We look if Player 1 has a saved version of this GP. @@ -752,7 +752,7 @@ void RaceManager::rerunRace() //----------------------------------------------------------------------------- -void RaceManager::startGP(const GrandPrixData* gp, bool from_overworld, +void RaceManager::startGP(const GrandPrixData* gp, bool from_overworld, bool continue_saved_gp) { assert(gp != NULL); diff --git a/src/race/race_manager.hpp b/src/race/race_manager.hpp index 0ac664ce6..20a2a2b90 100644 --- a/src/race/race_manager.hpp +++ b/src/race/race_manager.hpp @@ -344,7 +344,7 @@ private: bool m_have_kart_last_position_on_overworld; Vec3 m_kart_last_position_on_overworld; - + /** Determines if saved GP should be continued or not*/ bool m_continue_saved_gp; @@ -682,7 +682,7 @@ public: * \brief Higher-level method to start a GP without having to care about * the exact startup sequence */ - void startGP(const GrandPrixData* gp, bool from_overworld, + void startGP(const GrandPrixData* gp, bool from_overworld, bool continue_saved_gp); /** diff --git a/src/states_screens/addons_screen.cpp b/src/states_screens/addons_screen.cpp index 63a9ed7af..ccd131d58 100644 --- a/src/states_screens/addons_screen.cpp +++ b/src/states_screens/addons_screen.cpp @@ -95,7 +95,7 @@ void AddonsScreen::loadedFromFile() GUIEngine::ListWidget* w_list = getWidget("list_addons"); w_list->setColumnListener(this); - + } // loadedFromFile @@ -109,13 +109,13 @@ void AddonsScreen::beforeAddingWidget() w_list->clearColumns(); w_list->addColumn( _("Add-on name"), 3 ); w_list->addColumn( _("Updated date"), 1 ); - + GUIEngine::SpinnerWidget* w_filter_date = getWidget("filter_date"); w_filter_date->m_properties[GUIEngine::PROP_MIN_VALUE] = "0"; - w_filter_date->m_properties[GUIEngine::PROP_MAX_VALUE] = + w_filter_date->m_properties[GUIEngine::PROP_MAX_VALUE] = StringUtils::toString(m_date_filters.size() - 1); - + for (unsigned int n = 0; n < m_date_filters.size(); n++) { w_filter_date->addLabel(m_date_filters[n].label); @@ -125,7 +125,7 @@ void AddonsScreen::beforeAddingWidget() getWidget("filter_rating"); w_filter_rating->m_properties[GUIEngine::PROP_MIN_VALUE] = "0"; w_filter_rating->m_properties[GUIEngine::PROP_MAX_VALUE] = "6"; - + for (int n = 0; n < 7; n++) { w_filter_rating->addLabel(StringUtils::toWString(n / 2.0)); @@ -211,9 +211,9 @@ void AddonsScreen::loadList() getWidget("filter_date"); int date_index = w_filter_date->getValue(); StkTime::TimeType date = StkTime::getTimeSinceEpoch(); - date = StkTime::addInterval(date, - -m_date_filters[date_index].year, - -m_date_filters[date_index].month, + date = StkTime::addInterval(date, + -m_date_filters[date_index].year, + -m_date_filters[date_index].month, -m_date_filters[date_index].day); // Get the filter by rating. @@ -397,16 +397,16 @@ void AddonsScreen::onColumnClicked(int column_id) if (!m_sort_default) m_sort_desc = !m_sort_desc; m_sort_default = !m_sort_desc && !m_sort_default; } - + m_sort_col = column_id; switch(column_id) { - case 0: - Addon::setSortOrder(m_sort_default ? Addon::SO_DEFAULT : Addon::SO_NAME); + case 0: + Addon::setSortOrder(m_sort_default ? Addon::SO_DEFAULT : Addon::SO_NAME); break; case 1: - Addon::setSortOrder(m_sort_default ? Addon::SO_DEFAULT : Addon::SO_DATE); + Addon::setSortOrder(m_sort_default ? Addon::SO_DEFAULT : Addon::SO_DATE); break; default: assert(0); break; } // switch diff --git a/src/states_screens/addons_screen.hpp b/src/states_screens/addons_screen.hpp index 826858f3a..460543aa5 100644 --- a/src/states_screens/addons_screen.hpp +++ b/src/states_screens/addons_screen.hpp @@ -78,7 +78,7 @@ private: bool m_sort_desc; bool m_sort_default; - + int m_sort_col; /** List of date filters **/ diff --git a/src/states_screens/dialogs/add_device_dialog.hpp b/src/states_screens/dialogs/add_device_dialog.hpp index 3b614e4cf..8bac559ff 100644 --- a/src/states_screens/dialogs/add_device_dialog.hpp +++ b/src/states_screens/dialogs/add_device_dialog.hpp @@ -31,10 +31,10 @@ class AddDeviceDialog : public GUIEngine::ModalDialog public: AddDeviceDialog(); - + void onEnterPressedInternal(); GUIEngine::EventPropagation processEvent(const std::string& eventSource); }; - + #endif diff --git a/src/states_screens/dialogs/addons_loading.cpp b/src/states_screens/dialogs/addons_loading.cpp index 64448d078..6878193c2 100644 --- a/src/states_screens/dialogs/addons_loading.cpp +++ b/src/states_screens/dialogs/addons_loading.cpp @@ -208,7 +208,7 @@ GUIEngine::EventPropagation AddonsLoading::processEvent(const std::string& event { const std::string& selection = actions_ribbon->getSelectionIDString(PLAYER_ID_GAME_MASTER); - + if(selection == "back") { stopDownload(); @@ -307,7 +307,7 @@ void AddonsLoading::startDownload() { std::string save = "tmp/" + StringUtils::getBasename(m_addon.getZipFileName()); - m_download_request = new Online::HTTPRequest(save, /*manage mem*/false, + m_download_request = new Online::HTTPRequest(save, /*manage mem*/false, /*priority*/5); m_download_request->setURL(m_addon.getZipFileName()); m_download_request->queue(); diff --git a/src/states_screens/dialogs/addons_loading.hpp b/src/states_screens/dialogs/addons_loading.hpp index 16cec6cef..76e05cfa4 100644 --- a/src/states_screens/dialogs/addons_loading.hpp +++ b/src/states_screens/dialogs/addons_loading.hpp @@ -40,7 +40,7 @@ private: GUIEngine::IconButtonWidget *m_install_button; GUIEngine::IconButtonWidget *m_icon; - + /** The addon to load. */ Addon m_addon; void startDownload(); @@ -65,14 +65,14 @@ public: virtual GUIEngine::EventPropagation processEvent(const std::string& event_source); virtual void beforeAddingWidgets(); virtual void init(); - + /** This function is called by the GUI, all the frame (or somthing like * that). It checks the flags (m_can_load_icon and * and do the necessary. * */ void onUpdate(float delta); void voteClicked(); - + }; // AddonsLoading #endif diff --git a/src/states_screens/dialogs/change_password_dialog.hpp b/src/states_screens/dialogs/change_password_dialog.hpp index 0279fa04d..cc699c51d 100644 --- a/src/states_screens/dialogs/change_password_dialog.hpp +++ b/src/states_screens/dialogs/change_password_dialog.hpp @@ -63,7 +63,7 @@ private: GUIEngine::RibbonWidget * m_options_widget; GUIEngine::IconButtonWidget * m_submit_widget; GUIEngine::IconButtonWidget * m_cancel_widget; - + void submit(); }; diff --git a/src/states_screens/dialogs/confirm_resolution_dialog.hpp b/src/states_screens/dialogs/confirm_resolution_dialog.hpp index c5476abce..5a03bfc72 100644 --- a/src/states_screens/dialogs/confirm_resolution_dialog.hpp +++ b/src/states_screens/dialogs/confirm_resolution_dialog.hpp @@ -30,7 +30,7 @@ class ConfirmResolutionDialog : public GUIEngine::ModalDialog { /** number of seconds left before resolution is considered unplayable */ float m_remaining_time; - + /** updates countdown message */ void updateMessage(); public: @@ -38,9 +38,9 @@ public: ConfirmResolutionDialog(); void onEnterPressedInternal(); GUIEngine::EventPropagation processEvent(const std::string& eventSource); - + virtual void onUpdate(float dt); }; - + #endif diff --git a/src/states_screens/dialogs/custom_video_settings.cpp b/src/states_screens/dialogs/custom_video_settings.cpp index c7517b64a..36b66ab01 100644 --- a/src/states_screens/dialogs/custom_video_settings.cpp +++ b/src/states_screens/dialogs/custom_video_settings.cpp @@ -96,7 +96,7 @@ void CustomVideoSettingsialog::beforeAddingWidgets() shadows->addLabel( _("low") ); // 1 shadows->addLabel( _("high") ); // 2 shadows->setValue( UserConfigParams::m_shadows ); - + getWidget("motionblur")->setState( UserConfigParams::m_motionblur ); getWidget("mlaa")->setState( UserConfigParams::m_mlaa ); getWidget("pixelshaders")->setState(UserConfigParams::m_pixel_shaders); diff --git a/src/states_screens/dialogs/custom_video_settings.hpp b/src/states_screens/dialogs/custom_video_settings.hpp index 30a0ba8e8..75175c39d 100644 --- a/src/states_screens/dialogs/custom_video_settings.hpp +++ b/src/states_screens/dialogs/custom_video_settings.hpp @@ -27,7 +27,7 @@ */ class CustomVideoSettingsialog : public GUIEngine::ModalDialog { - + public: /** * Creates a modal dialog with given percentage of screen width and height @@ -38,7 +38,7 @@ public: virtual void beforeAddingWidgets(); GUIEngine::EventPropagation processEvent(const std::string& eventSource); - + }; #endif diff --git a/src/states_screens/dialogs/enter_player_name_dialog.hpp b/src/states_screens/dialogs/enter_player_name_dialog.hpp index bda3be42d..deb811a0d 100644 --- a/src/states_screens/dialogs/enter_player_name_dialog.hpp +++ b/src/states_screens/dialogs/enter_player_name_dialog.hpp @@ -37,23 +37,23 @@ namespace GUIEngine */ class EnterPlayerNameDialog : public GUIEngine::ModalDialog//, public GUIEngine::ITextBoxWidgetListener { - + public: - + class INewPlayerListener { public: virtual void onNewPlayerWithName(const irr::core::stringw& newName) = 0; virtual ~INewPlayerListener(){} }; - + private: - + INewPlayerListener* m_listener; bool m_self_destroy; - + public: - + /** * Creates a modal dialog with given percentage of screen width and height */ @@ -63,7 +63,7 @@ public: void onEnterPressedInternal(); GUIEngine::EventPropagation processEvent(const std::string& eventSource); - + virtual void onUpdate(float dt); //virtual void onTextUpdated(); }; diff --git a/src/states_screens/dialogs/gp_info_dialog.cpp b/src/states_screens/dialogs/gp_info_dialog.cpp index d362b6b71..ecc7568f4 100644 --- a/src/states_screens/dialogs/gp_info_dialog.cpp +++ b/src/states_screens/dialogs/gp_info_dialog.cpp @@ -178,14 +178,14 @@ GPInfoDialog::GPInfoDialog(const std::string& gpIdent, const float w, const floa continueBtn->add(); continueBtn->getIrrlichtElement()->setTabStop(true); continueBtn->getIrrlichtElement()->setTabGroup(false); - + okBtn->m_x = m_area.getWidth()/2 - 310; } else { okBtn->m_x = m_area.getWidth()/2 - 200; } - + okBtn->m_y = y2; okBtn->m_w = 400; okBtn->m_h = m_area.getHeight() - y2 - 15; @@ -196,7 +196,7 @@ GPInfoDialog::GPInfoDialog(const std::string& gpIdent, const float w, const floa okBtn->getIrrlichtElement()->setTabGroup(false); okBtn->setFocusForPlayer( PLAYER_ID_GAME_MASTER ); - + } // ------------------------------------------------------------------------------------------------------ diff --git a/src/states_screens/dialogs/gp_info_dialog.hpp b/src/states_screens/dialogs/gp_info_dialog.hpp index 2050af207..b8959bf2d 100644 --- a/src/states_screens/dialogs/gp_info_dialog.hpp +++ b/src/states_screens/dialogs/gp_info_dialog.hpp @@ -34,19 +34,19 @@ class GPInfoDialog : public GUIEngine::ModalDialog { std::string m_gp_ident; GUIEngine::IconButtonWidget* m_screenshot_widget; - + float m_curr_time; - + public: /** * Creates a modal dialog with given percentage of screen width and height */ GPInfoDialog(const std::string& gpIdent, const float percentWidth, const float percentHeight); virtual ~GPInfoDialog(); - + void onEnterPressedInternal(); GUIEngine::EventPropagation processEvent(const std::string& eventSource); - + virtual void onUpdate(float dt); }; diff --git a/src/states_screens/dialogs/message_dialog.cpp b/src/states_screens/dialogs/message_dialog.cpp index c012dcd86..4d66c4942 100644 --- a/src/states_screens/dialogs/message_dialog.cpp +++ b/src/states_screens/dialogs/message_dialog.cpp @@ -29,7 +29,7 @@ using namespace GUIEngine; // ------------------------------------------------------------------------------------------------------ -MessageDialog::MessageDialog(const irr::core::stringw &msg, MessageDialogType type, +MessageDialog::MessageDialog(const irr::core::stringw &msg, MessageDialogType type, IConfirmDialogListener* listener, bool own_listener) : ModalDialog(0.6f, 0.6f) { diff --git a/src/states_screens/dialogs/message_dialog.hpp b/src/states_screens/dialogs/message_dialog.hpp index 375785a2e..3b56cc8f6 100644 --- a/src/states_screens/dialogs/message_dialog.hpp +++ b/src/states_screens/dialogs/message_dialog.hpp @@ -29,7 +29,7 @@ class MessageDialog : public GUIEngine::ModalDialog { public: - + /** * \brief Listener interface to get notified of whether the user chose to confirm or cancel * \ingroup states_screens @@ -37,24 +37,24 @@ public: class IConfirmDialogListener { public: - + LEAK_CHECK() - + IConfirmDialogListener() {} virtual ~IConfirmDialogListener() {} - + /** \brief Implement to be notified of dialog confirmed. * \note The dialog is not closed automatically, close it in the callback if this * behavior is desired. */ virtual void onConfirm() { ModalDialog::dismiss(); }; - + /** \brief Implement to be notified of dialog cancelled. * \note The default implementation is to close the modal dialog, but you may override * this method to change the behavior. */ virtual void onCancel() { ModalDialog::dismiss(); }; - + /** * \brief Optional callback */ @@ -63,13 +63,13 @@ public: enum MessageDialogType { MESSAGE_DIALOG_OK, MESSAGE_DIALOG_CONFIRM, MESSAGE_DIALOG_OK_CANCEL }; - + private: - + IConfirmDialogListener* m_listener; bool m_own_listener; irr::core::stringw m_msg; - void doInit(MessageDialogType type, IConfirmDialogListener* listener, + void doInit(MessageDialogType type, IConfirmDialogListener* listener, bool own_listener); public: @@ -80,17 +80,17 @@ public: * \param If set to true, 'listener' will be owned by this dialog and deleted * along with the dialog. */ - MessageDialog(const irr::core::stringw &msg, MessageDialogType type, + MessageDialog(const irr::core::stringw &msg, MessageDialogType type, IConfirmDialogListener* listener, bool delete_listener); - + /** * Variant of MessageDialog where cancelling is not possible (i.e. just shows a message box with OK) * \param msg Message to display in the dialog */ MessageDialog(const irr::core::stringw &msg, bool from_queue = false); - + ~MessageDialog(); - + virtual void onEnterPressedInternal(); virtual void onUpdate(float dt); virtual void load(); diff --git a/src/states_screens/dialogs/player_info_dialog.hpp b/src/states_screens/dialogs/player_info_dialog.hpp index 329f5d548..63c7077c2 100644 --- a/src/states_screens/dialogs/player_info_dialog.hpp +++ b/src/states_screens/dialogs/player_info_dialog.hpp @@ -36,7 +36,7 @@ class PlayerInfoDialog : public GUIEngine::ModalDialog { GUIEngine::TextBoxWidget* textCtrl; PlayerProfile* m_player; - + void showRegularDialog(); void showConfirmDialog(); public: @@ -45,12 +45,12 @@ public: */ PlayerInfoDialog(PlayerProfile* PlayerInfoDialog, const float percentWidth, const float percentHeight); - + virtual ~PlayerInfoDialog(); - + void onEnterPressedInternal(); GUIEngine::EventPropagation processEvent(const std::string& eventSource); }; - + #endif diff --git a/src/states_screens/dialogs/race_paused_dialog.hpp b/src/states_screens/dialogs/race_paused_dialog.hpp index afa9f08ef..854e1a1fe 100644 --- a/src/states_screens/dialogs/race_paused_dialog.hpp +++ b/src/states_screens/dialogs/race_paused_dialog.hpp @@ -31,7 +31,7 @@ namespace GUIEngine */ class RacePausedDialog : public GUIEngine::ModalDialog { - + protected: virtual void loadedFromFile(); @@ -39,12 +39,12 @@ public: /** * Creates a modal dialog with given percentage of screen width and height */ - RacePausedDialog(const float percentWidth, const float percentHeight); + RacePausedDialog(const float percentWidth, const float percentHeight); virtual ~RacePausedDialog(); - + void onEnterPressedInternal(); GUIEngine::EventPropagation processEvent(const std::string& eventSource); - + }; #endif diff --git a/src/states_screens/dialogs/recovery_dialog.cpp b/src/states_screens/dialogs/recovery_dialog.cpp index a8c656b59..e18f52152 100644 --- a/src/states_screens/dialogs/recovery_dialog.cpp +++ b/src/states_screens/dialogs/recovery_dialog.cpp @@ -80,7 +80,7 @@ void RecoveryDialog::showRecoveryInput() } // showRecoveryInput // ----------------------------------------------------------------------------- -/** Informs the user that an email will be sent. +/** Informs the user that an email will be sent. */ void RecoveryDialog::showRecoveryInfo() { @@ -112,7 +112,7 @@ void RecoveryDialog::processInput() { const core::stringw username = m_username_widget->getText().trim(); const core::stringw email = m_email_widget->getText().trim(); - if (username.size() < 4 || username.size() > 30 || + if (username.size() < 4 || username.size() > 30 || email.size() < 4 || email.size() > 50 ) { sfx_manager->quickSound("anvil"); @@ -136,12 +136,12 @@ void RecoveryDialog::processInput() // ----------------------------------------------------------------------------- /** Handle a user event. */ -GUIEngine::EventPropagation +GUIEngine::EventPropagation RecoveryDialog::processEvent(const std::string& eventSource) { std::string selection; if (eventSource == m_options_widget->m_properties[PROP_ID]) - selection = + selection = m_options_widget->getSelectionIDString(PLAYER_ID_GAME_MASTER); else selection = eventSource; diff --git a/src/states_screens/dialogs/recovery_dialog.hpp b/src/states_screens/dialogs/recovery_dialog.hpp index 02e584471..fdb6dd062 100644 --- a/src/states_screens/dialogs/recovery_dialog.hpp +++ b/src/states_screens/dialogs/recovery_dialog.hpp @@ -42,7 +42,7 @@ public: void onEnterPressedInternal(); GUIEngine::EventPropagation processEvent(const std::string& eventSource); - + virtual void onUpdate(float dt); virtual bool onEscapePressed(); diff --git a/src/states_screens/dialogs/select_challenge.hpp b/src/states_screens/dialogs/select_challenge.hpp index 5a009bb78..2a39a17e1 100644 --- a/src/states_screens/dialogs/select_challenge.hpp +++ b/src/states_screens/dialogs/select_challenge.hpp @@ -29,11 +29,11 @@ class SelectChallengeDialog : public GUIEngine::ModalDialog { std::string m_challenge_id; public: - + SelectChallengeDialog(const float percentWidth, const float percentHeight, std::string challenge_id); virtual ~SelectChallengeDialog(); - + virtual GUIEngine::EventPropagation processEvent(const std::string& eventSource); }; diff --git a/src/states_screens/dialogs/track_info_dialog.hpp b/src/states_screens/dialogs/track_info_dialog.hpp index 73aeb0446..3367ac5c2 100644 --- a/src/states_screens/dialogs/track_info_dialog.hpp +++ b/src/states_screens/dialogs/track_info_dialog.hpp @@ -39,16 +39,16 @@ class TrackInfoDialog : public GUIEngine::ModalDialog { std::string m_track_ident; std::string m_ribbon_item; - + // When there is no need to tab through / click on images/labels, we can add directly // irrlicht labels (more complicated uses require the use of our widget set) GUIEngine::SpinnerWidget* m_spinner; GUIEngine::CheckBoxWidget* m_checkbox; GUIEngine::IconButtonWidget* m_kart_icons[HIGHSCORE_COUNT]; GUIEngine::LabelWidget* m_highscore_entries[HIGHSCORE_COUNT]; - + void updateHighScores(); - + public: /** * \brief Creates a track info modal dialog with given percentage of screen width and height @@ -62,7 +62,7 @@ public: const irr::core::stringw& trackName, irr::video::ITexture* screenshot, const float percentWidth, const float percentHeight); virtual ~TrackInfoDialog(); - + void onEnterPressedInternal(); GUIEngine::EventPropagation processEvent(const std::string& eventSource); }; diff --git a/src/states_screens/dialogs/tutorial_message_dialog.cpp b/src/states_screens/dialogs/tutorial_message_dialog.cpp index fdda11e2d..3eda7e0cb 100644 --- a/src/states_screens/dialogs/tutorial_message_dialog.cpp +++ b/src/states_screens/dialogs/tutorial_message_dialog.cpp @@ -49,7 +49,7 @@ TutorialMessageDialog::TutorialMessageDialog(irr::core::stringw msg, bool stopGa ButtonWidget* cancelbtn = getWidget("continue"); cancelbtn->setFocusForPlayer(PLAYER_ID_GAME_MASTER); - + World::getWorld()->getKart(0)->getControls().reset(); } diff --git a/src/states_screens/dialogs/tutorial_message_dialog.hpp b/src/states_screens/dialogs/tutorial_message_dialog.hpp index 9e71ba78b..d8468788c 100644 --- a/src/states_screens/dialogs/tutorial_message_dialog.hpp +++ b/src/states_screens/dialogs/tutorial_message_dialog.hpp @@ -37,13 +37,13 @@ public: TutorialMessageDialog(irr::core::stringw msg, bool stopGame); - + ~TutorialMessageDialog(); - + virtual void onEnterPressedInternal() OVERRIDE; virtual void onUpdate(float dt) OVERRIDE; - + GUIEngine::EventPropagation processEvent(const std::string& eventSource); }; diff --git a/src/states_screens/dialogs/user_info_dialog.cpp b/src/states_screens/dialogs/user_info_dialog.cpp index bf9622ae1..b89aee79d 100644 --- a/src/states_screens/dialogs/user_info_dialog.cpp +++ b/src/states_screens/dialogs/user_info_dialog.cpp @@ -187,7 +187,7 @@ void UserInfoDialog::acceptFriendRequest() { // ---------------------------------------------------------------- class AcceptFriendRequest : public XMLRequest - { + { /** Callback for the request to accept a friend invitation. Shows a * confirmation message and takes care of updating all the cached * information. @@ -199,7 +199,7 @@ void UserInfoDialog::acceptFriendRequest() core::stringw info_text(""); if (isSuccess()) { - OnlineProfile * profile = + OnlineProfile * profile = ProfileManager::get()->getProfileByID(id); profile->setFriend(); OnlineProfile::RelationInfo *info = @@ -322,7 +322,7 @@ GUIEngine::EventPropagation UserInfoDialog::processEvent(const std::string& even } else if(selection == m_remove_widget->m_properties[PROP_ID]) { - if (m_profile->getRelationInfo() && + if (m_profile->getRelationInfo() && m_profile->getRelationInfo()->isPending() ) removePendingFriend(); else diff --git a/src/states_screens/easter_egg_screen.cpp b/src/states_screens/easter_egg_screen.cpp index 6cd2c6a2d..cc78d4b2a 100644 --- a/src/states_screens/easter_egg_screen.cpp +++ b/src/states_screens/easter_egg_screen.cpp @@ -85,7 +85,7 @@ void EasterEggScreen::eventCallback(Widget* widget, const std::string& name, con if (clickedTrack != NULL) { - ITexture* screenshot = + ITexture* screenshot = irr_driver->getTexture( clickedTrack->getScreenshotFile(), "While loading screenshot for track '%s':", clickedTrack->getFilename() ); @@ -108,7 +108,7 @@ void EasterEggScreen::eventCallback(Widget* widget, const std::string& name, con Track* clickedTrack = track_manager->getTrack(selection); if (clickedTrack != NULL) { - ITexture* screenshot = + ITexture* screenshot = irr_driver->getTexture( clickedTrack->getScreenshotFile(), "While loading screenshot for track '%s'", clickedTrack->getFilename()); @@ -166,7 +166,7 @@ void EasterEggScreen::beforeAddingWidget() // try to translate the group name tabs->addTextChild( _(groups[n].c_str()), groups[n] ); } - + int num_of_arenas=0; for (unsigned int n=0; ngetNumberOfTracks(); n++) //iterate through tracks to find how many are arenas { diff --git a/src/states_screens/grand_prix_lose.cpp b/src/states_screens/grand_prix_lose.cpp index ad83e608e..9d74d95c1 100644 --- a/src/states_screens/grand_prix_lose.cpp +++ b/src/states_screens/grand_prix_lose.cpp @@ -277,7 +277,7 @@ void GrandPrixLose::eventCallback(GUIEngine::Widget* widget, // un-set the GP mode so that after unlocking, it doesn't try to continue the GP race_manager->setMajorMode (RaceManager::MAJOR_MODE_SINGLE); - std::vector unlocked = + std::vector unlocked = PlayerManager::get()->getCurrentPlayer()->getRecentlyCompletedChallenges(); if (unlocked.size() > 0) { diff --git a/src/states_screens/grand_prix_win.cpp b/src/states_screens/grand_prix_win.cpp index 4a01a3ea1..ca40a0f3b 100644 --- a/src/states_screens/grand_prix_win.cpp +++ b/src/states_screens/grand_prix_win.cpp @@ -260,7 +260,7 @@ void GrandPrixWin::tearDown() delete m_unlocked_label; m_unlocked_label = NULL; } - + if (m_finish_sound != NULL && m_finish_sound->getStatus() == SFXManager::SFX_PLAYING) { diff --git a/src/states_screens/guest_login_screen.cpp b/src/states_screens/guest_login_screen.cpp index 338fb4373..3052b9ba2 100644 --- a/src/states_screens/guest_login_screen.cpp +++ b/src/states_screens/guest_login_screen.cpp @@ -44,12 +44,12 @@ void GuestLoginScreen::init() // ----------------------------------------------------------------------------- -void GuestLoginScreen::eventCallback(Widget* widget, const std::string& name, +void GuestLoginScreen::eventCallback(Widget* widget, const std::string& name, const int playerID) { if (name == "login_tabs") { - const std::string selection = + const std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER); if (selection == "tab_login") StateManager::get()->replaceTopMostScreen(LoginScreen::getInstance()); @@ -58,7 +58,7 @@ void GuestLoginScreen::eventCallback(Widget* widget, const std::string& name, } else if (name=="options") { - const std::string button = + const std::string button = getWidget("options") ->getSelectionIDString(PLAYER_ID_GAME_MASTER); if(button=="sign_in") diff --git a/src/states_screens/kart_selection.cpp b/src/states_screens/kart_selection.cpp index c4d29102d..1091a4e40 100644 --- a/src/states_screens/kart_selection.cpp +++ b/src/states_screens/kart_selection.cpp @@ -127,7 +127,7 @@ static FocusDispatcher* g_dispatcher = NULL; /** A small extension to the spinner widget to add features like player ID * management or badging */ -PlayerNameSpinner::PlayerNameSpinner(KartSelectionScreen* parent, +PlayerNameSpinner::PlayerNameSpinner(KartSelectionScreen* parent, const int player_id) { m_player_id = player_id; @@ -142,7 +142,7 @@ void PlayerNameSpinner::setID(const int m_player_id) { PlayerNameSpinner::m_player_id = m_player_id; setSpinnerWidgetPlayerID(m_player_id); -} // setID +} // setID // ------------------------------------------------------------------------ /** Add a red mark on the spinner to mean "invalid choice" */ void PlayerNameSpinner::markAsIncorrect() @@ -272,7 +272,7 @@ PlayerKartWidget::PlayerKartWidget(KartSelectionScreen* parent, //m_player_ident_spinner->m_event_handler = this; m_children.push_back(m_player_ident_spinner); - + // ----- Kart model view @@ -485,7 +485,7 @@ void PlayerKartWidget::add() const int player_amount = PlayerManager::get()->getNumPlayers(); for (int n=0; ngetPlayer(n)->getName(); + core::stringw name = PlayerManager::get()->getPlayer(n)->getName(); m_player_ident_spinner->addLabel( translations->fribidize(name) ); } @@ -1692,7 +1692,7 @@ void KartSelectionScreen::allPlayersDone() if(UserConfigParams::logGUI()) { Log::info("[KartSelectionScreen]", "players : %d",players.size()); - + for (unsigned int n=0; n("password"); password_widget->setPasswordBox(true,L'*'); - + m_options_widget = getWidget("options"); assert(m_options_widget); m_options_widget->setActivated(); @@ -85,7 +85,7 @@ void LoginScreen::login() const core::stringw password = getWidget("password") ->getText().trim(); - if (username.size() < 4 || username.size() > 30 || + if (username.size() < 4 || username.size() > 30 || password.size() < 8 || password.size() > 30 ) { sfx_manager->quickSound("anvil"); @@ -98,7 +98,7 @@ void LoginScreen::login() m_options_widget->setDeactivated(); info_widget->setDefaultColor(); bool remember = getWidget("remember")->getState(); - Online::CurrentUser::get()->requestSignIn(username,password, + Online::CurrentUser::get()->requestSignIn(username,password, remember ); } } // login @@ -140,7 +140,7 @@ void LoginScreen::onUpdate(float dt) // Login was successful, so put the online main menu on the screen if(m_success) { - StateManager::get()->replaceTopMostScreen(OnlineScreen::getInstance()); + StateManager::get()->replaceTopMostScreen(OnlineScreen::getInstance()); } } // onUpdate @@ -150,23 +150,23 @@ void LoginScreen::onUpdate(float dt) * \param name Name of the widget. * \param playerID The id of the player who clicked the item. */ -void LoginScreen::eventCallback(Widget* widget, const std::string& name, +void LoginScreen::eventCallback(Widget* widget, const std::string& name, const int playerID) { if (name == "login_tabs") { StateManager *sm = StateManager::get(); - const std::string selection = + const std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER); if (selection == "tab_guest_login") - sm->replaceTopMostScreen(GuestLoginScreen::getInstance()); + sm->replaceTopMostScreen(GuestLoginScreen::getInstance()); else if (selection == "tab_register") sm->replaceTopMostScreen(RegisterScreen::getInstance()); } else if (name=="options") { - const std::string button = + const std::string button = getWidget("options") ->getSelectionIDString(PLAYER_ID_GAME_MASTER); if(button=="sign_in") diff --git a/src/states_screens/login_screen.hpp b/src/states_screens/login_screen.hpp index b86fd5c57..57e25969c 100644 --- a/src/states_screens/login_screen.hpp +++ b/src/states_screens/login_screen.hpp @@ -21,7 +21,7 @@ #include "guiengine/screen.hpp" namespace GUIEngine { class LabelWidget; - class RibbonWidget; + class RibbonWidget; class Widget; } /** diff --git a/src/states_screens/online_profile_achievements.cpp b/src/states_screens/online_profile_achievements.cpp index 7d2c16e38..9651fdca4 100644 --- a/src/states_screens/online_profile_achievements.cpp +++ b/src/states_screens/online_profile_achievements.cpp @@ -46,7 +46,7 @@ DEFINE_SCREEN_SINGLETON( OnlineProfileAchievements ); // ----------------------------------------------------------------------------- /** Constructor. */ -OnlineProfileAchievements::OnlineProfileAchievements() +OnlineProfileAchievements::OnlineProfileAchievements() : OnlineProfileBase("online/profile_achievements.stkgui") { m_selected_achievement_index = -1; @@ -73,7 +73,7 @@ void OnlineProfileAchievements::beforeAddingWidget() m_achievements_list_widget->addColumn( _("Name"), 2 ); // For the current player (even if not logged in, i.e. m_visiting_profile - // = NULL) user achievement progress will also be displayed + // = NULL) user achievement progress will also be displayed if(!m_visiting_profile || m_visiting_profile->isCurrentUser()) { m_achievements_list_widget->addColumn( _("Progress"), 1 ); @@ -86,7 +86,7 @@ void OnlineProfileAchievements::beforeAddingWidget() void OnlineProfileAchievements::init() { OnlineProfileBase::init(); - m_profile_tabs->select( m_achievements_tab->m_properties[PROP_ID], + m_profile_tabs->select( m_achievements_tab->m_properties[PROP_ID], PLAYER_ID_GAME_MASTER ); // For current user add the progrss information. @@ -121,21 +121,21 @@ void OnlineProfileAchievements::init() m_waiting_for_achievements = true; m_visiting_profile->fetchAchievements(); m_achievements_list_widget->clear(); - m_achievements_list_widget->addItem("loading", + m_achievements_list_widget->addItem("loading", Messages::fetchingAchievements()); } } // init // ----------------------------------------------------------------------------- -void OnlineProfileAchievements::eventCallback(Widget* widget, +void OnlineProfileAchievements::eventCallback(Widget* widget, const std::string& name, const int playerID) { OnlineProfileBase::eventCallback( widget, name, playerID); if (name == m_achievements_list_widget->m_properties[GUIEngine::PROP_ID]) { - m_selected_achievement_index = + m_selected_achievement_index = m_achievements_list_widget->getSelectionID(); int id; @@ -171,7 +171,7 @@ void OnlineProfileAchievements::onUpdate(float delta) const OnlineProfile::IDList &a = m_visiting_profile->getAchievements(); for (unsigned int i = 0; i < a.size(); i++) { - AchievementInfo *info = + AchievementInfo *info = AchievementsManager::get()->getAchievementInfo(a[i]); m_achievements_list_widget->addItem(StringUtils::toString(info->getID()), info->getTitle() ); diff --git a/src/states_screens/online_profile_base.cpp b/src/states_screens/online_profile_base.cpp index c9f6abde7..38937648e 100644 --- a/src/states_screens/online_profile_base.cpp +++ b/src/states_screens/online_profile_base.cpp @@ -52,16 +52,16 @@ void OnlineProfileBase::loadedFromFile() m_header = getWidget("title"); assert(m_header != NULL); - m_overview_tab = + m_overview_tab = (IconButtonWidget *)m_profile_tabs->findWidgetNamed("tab_overview"); assert(m_overview_tab != NULL); m_friends_tab = (IconButtonWidget *) m_profile_tabs->findWidgetNamed("tab_friends"); assert(m_friends_tab != NULL); - m_achievements_tab = + m_achievements_tab = (IconButtonWidget*)m_profile_tabs->findWidgetNamed("tab_achievements"); assert(m_achievements_tab != NULL); - m_settings_tab = + m_settings_tab = (IconButtonWidget *) m_profile_tabs->findWidgetNamed("tab_settings"); assert(m_settings_tab != NULL); } // loadedFromFile @@ -111,7 +111,7 @@ void OnlineProfileBase::init() // ----------------------------------------------------------------------------- /** Called when an event occurs (i.e. user clicks on something). */ -void OnlineProfileBase::eventCallback(Widget* widget, const std::string& name, +void OnlineProfileBase::eventCallback(Widget* widget, const std::string& name, const int playerID) { if (name == m_profile_tabs->m_properties[PROP_ID]) @@ -125,7 +125,7 @@ void OnlineProfileBase::eventCallback(Widget* widget, const std::string& name, sm->replaceTopMostScreen(OnlineProfileFriends::getInstance()); else if (selection == m_achievements_tab->m_properties[PROP_ID]) sm->replaceTopMostScreen(OnlineProfileAchievements::getInstance()); - else if (selection == m_settings_tab->m_properties[PROP_ID]) + else if (selection == m_settings_tab->m_properties[PROP_ID]) sm->replaceTopMostScreen(OnlineProfileSettings::getInstance()); } else if (name == "back") diff --git a/src/states_screens/online_profile_base.hpp b/src/states_screens/online_profile_base.hpp index 94bcac23a..034ce2ccb 100644 --- a/src/states_screens/online_profile_base.hpp +++ b/src/states_screens/online_profile_base.hpp @@ -57,7 +57,7 @@ public: /** \brief implement callback from parent class GUIEngine::Screen */ virtual void eventCallback(GUIEngine::Widget* widget, - const std::string& name, + const std::string& name, const int playerID) OVERRIDE; /** \brief implement callback from parent class GUIEngine::Screen */ diff --git a/src/states_screens/online_profile_friends.cpp b/src/states_screens/online_profile_friends.cpp index 4ffe2c1f3..1c6c70021 100644 --- a/src/states_screens/online_profile_friends.cpp +++ b/src/states_screens/online_profile_friends.cpp @@ -39,7 +39,7 @@ DEFINE_SCREEN_SINGLETON( OnlineProfileFriends ); // ----------------------------------------------------------------------------- /** Constructor for a display of all friends. */ -OnlineProfileFriends::OnlineProfileFriends() +OnlineProfileFriends::OnlineProfileFriends() : OnlineProfileBase("online/profile_friends.stkgui") { } // OnlineProfileFriends @@ -79,7 +79,7 @@ void OnlineProfileFriends::beforeAddingWidget() void OnlineProfileFriends::init() { OnlineProfileBase::init(); - m_profile_tabs->select( m_friends_tab->m_properties[PROP_ID], + m_profile_tabs->select( m_friends_tab->m_properties[PROP_ID], PLAYER_ID_GAME_MASTER ); assert(m_visiting_profile != NULL); m_visiting_profile->fetchFriends(); @@ -92,7 +92,7 @@ void OnlineProfileFriends::init() /** Called when an event occurs (i.e. user clicks on something). */ void OnlineProfileFriends::eventCallback(Widget* widget, - const std::string& name, + const std::string& name, const int playerID) { OnlineProfileBase::eventCallback( widget, name, playerID); @@ -111,7 +111,7 @@ void OnlineProfileFriends::eventCallback(Widget* widget, } // eventCallback // ---------------------------------------------------------------------------- -/** Displays the friends from a given profile. +/** Displays the friends from a given profile. */ void OnlineProfileFriends::displayResults() { @@ -120,7 +120,7 @@ void OnlineProfileFriends::displayResults() for (unsigned int i = 0; i < friends.size(); i++) { std::vector row; - OnlineProfile* friend_profile = + OnlineProfile* friend_profile = ProfileManager::get()->getProfileByID(friends[i]); // When looking at friends of a friend those profiles are not @@ -135,18 +135,18 @@ void OnlineProfileFriends::displayResults() -1, 2) ); if (m_visiting_profile->isCurrentUser()) { - OnlineProfile::RelationInfo * relation_info = + OnlineProfile::RelationInfo * relation_info = friend_profile->getRelationInfo(); row.push_back(ListWidget::ListCell(relation_info->getDate(), -1, 1, true) ); irr::core::stringw status(""); if (relation_info->isPending()) { - status = (relation_info->isAsker() ? _("New Request") + status = (relation_info->isAsker() ? _("New Request") : _("Pending") ); } else - status = (relation_info->isOnline() ? _("Online") + status = (relation_info->isOnline() ? _("Online") : _("Offline") ); row.push_back(ListWidget::ListCell(status, -1, 2, true)); } @@ -170,7 +170,7 @@ void OnlineProfileFriends::onUpdate(float delta) } else { - m_friends_list_widget->renameItem("loading", + m_friends_list_widget->renameItem("loading", Messages::fetchingFriends()); } } diff --git a/src/states_screens/online_profile_friends.hpp b/src/states_screens/online_profile_friends.hpp index 319f97a7e..f7bcc3195 100644 --- a/src/states_screens/online_profile_friends.hpp +++ b/src/states_screens/online_profile_friends.hpp @@ -31,7 +31,7 @@ namespace GUIEngine { class Widget; } -/** Online profile overview screen. +/** Online profile overview screen. * \ingroup states_screens */ class OnlineProfileFriends : public OnlineProfileBase, public GUIEngine::ScreenSingleton @@ -54,8 +54,8 @@ public: virtual void loadedFromFile() OVERRIDE; /** \brief implement callback from parent class GUIEngine::Screen */ - virtual void eventCallback(GUIEngine::Widget* widget, - const std::string& name, + virtual void eventCallback(GUIEngine::Widget* widget, + const std::string& name, const int playerID) OVERRIDE; /** \brief implement callback from parent class GUIEngine::Screen */ diff --git a/src/states_screens/online_screen.cpp b/src/states_screens/online_screen.cpp index af9f24577..4c9d13b84 100644 --- a/src/states_screens/online_screen.cpp +++ b/src/states_screens/online_screen.cpp @@ -111,8 +111,8 @@ void OnlineScreen::beforeAddingWidget() m_bottom_menu_widget->setVisible(true); m_top_menu_widget->setVisible(true); hasStateChanged(); - if (m_recorded_state == CurrentUser::US_SIGNED_OUT || - m_recorded_state == CurrentUser::US_SIGNING_IN || + if (m_recorded_state == CurrentUser::US_SIGNED_OUT || + m_recorded_state == CurrentUser::US_SIGNING_IN || m_recorded_state == CurrentUser::US_SIGNING_OUT ) { m_quick_play_widget->setDeactivated(); diff --git a/src/states_screens/online_user_search.cpp b/src/states_screens/online_user_search.cpp index 06bc41c02..7ff93d8b7 100644 --- a/src/states_screens/online_user_search.cpp +++ b/src/states_screens/online_user_search.cpp @@ -184,7 +184,7 @@ void OnlineUserSearch::showList() // ---------------------------------------------------------------------------- /** Called when a search is triggered. When it is a new search (and not just - * searching for the same string again), a request will be queued to + * searching for the same string again), a request will be queued to * receive the search results */ void OnlineUserSearch::search() @@ -244,7 +244,7 @@ void OnlineUserSearch::setLastSelected() //FIXME actually use this here and in s } // setLastSelected // ---------------------------------------------------------------------------- -/** Called every frame. It queries the search request for results and +/** Called every frame. It queries the search request for results and * displays them if necessary. */ void OnlineUserSearch::onUpdate(float dt) diff --git a/src/states_screens/options_screen_ui.cpp b/src/states_screens/options_screen_ui.cpp index e96f94a61..77c59489d 100644 --- a/src/states_screens/options_screen_ui.cpp +++ b/src/states_screens/options_screen_ui.cpp @@ -147,7 +147,7 @@ void OptionsScreenUI::init() } if (!currSkinFound) { - Log::warn("OptionsScreenUI", + Log::warn("OptionsScreenUI", "Couldn't find current skin in the list of skins!"); skinSelector->setValue(0); GUIEngine::reloadSkin(); @@ -162,7 +162,7 @@ void OptionsScreenUI::init() const std::vector* lang_list = translations->getLanguageList(); const int amount = lang_list->size(); - // The names need to be sorted alphabetically. Store the 2-letter + // The names need to be sorted alphabetically. Store the 2-letter // language names in a mapping, to be able to get them from the // user visible full name. std::vector nice_lang_list; @@ -177,7 +177,7 @@ void OptionsScreenUI::init() std::sort(nice_lang_list.begin(), nice_lang_list.end()); for(unsigned int i=0; iaddItem(nice_name_2_id[nice_lang_list[i]], + list_widget->addItem(nice_name_2_id[nice_lang_list[i]], nice_lang_list[i].c_str()); } @@ -235,7 +235,7 @@ void OptionsScreenUI::eventCallback(Widget* widget, const std::string& name, con UserConfigParams::m_internet_status = internet->getState() ? RequestManager::IPERM_ALLOWED : RequestManager::IPERM_NOT_ALLOWED; - // If internet gets enabled, re-initialise the addon manager (which + // If internet gets enabled, re-initialise the addon manager (which // happens in a separate thread) so that news.xml etc can be // downloaded if necessary. if(internet->getState()) diff --git a/src/states_screens/race_gui.cpp b/src/states_screens/race_gui.cpp index 296c7854f..36d0ec87b 100644 --- a/src/states_screens/race_gui.cpp +++ b/src/states_screens/race_gui.cpp @@ -65,7 +65,7 @@ RaceGUI::RaceGUI() // Marker texture has to be power-of-two for (old) OpenGL compliance m_marker_rendered_size = 2 << ((int) ceil(1.0 + log(32.0 * scaling))); m_marker_ai_size = (int)( 14.0f * scaling); - m_marker_player_size = (int)( 16.0f * scaling); + m_marker_player_size = (int)( 16.0f * scaling); m_map_width = (int)(100.0f * scaling); m_map_height = (int)(100.0f * scaling); m_map_left = (int)( 10.0f * scaling); @@ -173,7 +173,7 @@ void RaceGUI::renderGlobal(float dt) //stop displaying timer as soon as race is over if (world->getPhase()getPhase() == WorldStatus::GO_PHASE || world->getPhase() == WorldStatus::MUSIC_PHASE) { @@ -183,7 +183,7 @@ void RaceGUI::renderGlobal(float dt) drawGlobalMiniMap(); - if (!m_is_tutorial) drawGlobalPlayerIcons(m_map_height); + if (!m_is_tutorial) drawGlobalPlayerIcons(m_map_height); if(world->getTrack()->isSoccer()) drawScores(); } // renderGlobal @@ -254,7 +254,7 @@ void RaceGUI::drawScores() position.LowerRightCorner.Y + string_height); font->draw(score.c_str(),pos,color); - + switch(numLeader) { case 1: team_icon = red_team; break; diff --git a/src/states_screens/race_gui_base.cpp b/src/states_screens/race_gui_base.cpp index ed3527fc4..bcb2f83eb 100644 --- a/src/states_screens/race_gui_base.cpp +++ b/src/states_screens/race_gui_base.cpp @@ -723,7 +723,7 @@ void RaceGUIBase::drawGlobalReadySetGo() UserConfigParams::m_height>>1); //gui::IGUIFont* font = irr_driver->getRaceFont(); gui::IGUIFont* font = GUIEngine::getTitleFont(); - + if (race_manager->getCoinTarget() > 0) font->draw(_("Collect nitro!"), pos, color, true, true); else if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER) diff --git a/src/states_screens/race_gui_overworld.cpp b/src/states_screens/race_gui_overworld.cpp index 5136b1c21..d2233d6b7 100644 --- a/src/states_screens/race_gui_overworld.cpp +++ b/src/states_screens/race_gui_overworld.cpp @@ -460,7 +460,7 @@ void RaceGUIOverworld::drawGlobalMiniMap() continue; } - const ChallengeData* challenge = + const ChallengeData* challenge = unlock_manager->getChallengeData(challenges[n].m_challenge_id); if (challenge == NULL) diff --git a/src/states_screens/race_setup_screen.cpp b/src/states_screens/race_setup_screen.cpp index f9be5d19e..dce58717a 100644 --- a/src/states_screens/race_setup_screen.cpp +++ b/src/states_screens/race_setup_screen.cpp @@ -162,7 +162,7 @@ void RaceSetupScreen::assignDifficulty() RibbonWidget* difficulty = getWidget("difficulty"); assert(difficulty != NULL); const std::string& difficultySelection = difficulty->getSelectionIDString(PLAYER_ID_GAME_MASTER); - + if (difficultySelection == "novice") { UserConfigParams::m_difficulty = RaceManager::DIFFICULTY_EASY; diff --git a/src/states_screens/register_screen.cpp b/src/states_screens/register_screen.cpp index 9b0f6b017..2281d0524 100644 --- a/src/states_screens/register_screen.cpp +++ b/src/states_screens/register_screen.cpp @@ -151,7 +151,7 @@ void RegisterScreen::onUpdate(float dt) new MessageDialog( _("You will receive an email with further instructions " "regarding account activation. Please be patient and be " - "sure to check your spam folder."), + "sure to check your spam folder."), MessageDialog::MESSAGE_DIALOG_OK, NULL, false); // Set the flag that the message was shown, which will triger // a pop of this menu and so a return to the main menu @@ -177,18 +177,18 @@ void RegisterScreen::onUpdate(float dt) // ----------------------------------------------------------------------------- -void RegisterScreen::eventCallback(Widget* widget, const std::string& name, +void RegisterScreen::eventCallback(Widget* widget, const std::string& name, const int playerID) { if (name == "login_tabs") { - const std::string selection = + const std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER); StateManager *sm = StateManager::get(); if (selection == "tab_login") sm->replaceTopMostScreen(LoginScreen::getInstance()); else if (selection == "tab_guest_login") - sm->replaceTopMostScreen(GuestLoginScreen::getInstance()); + sm->replaceTopMostScreen(GuestLoginScreen::getInstance()); } else if (name=="options") { diff --git a/src/states_screens/soccer_setup_screen.cpp b/src/states_screens/soccer_setup_screen.cpp index e4a93940f..e8470073f 100644 --- a/src/states_screens/soccer_setup_screen.cpp +++ b/src/states_screens/soccer_setup_screen.cpp @@ -54,7 +54,7 @@ void SoccerSetupScreen::loadedFromFile() } // ---------------------------------------------------------------------------- -void SoccerSetupScreen::eventCallback(Widget* widget, const std::string& name, +void SoccerSetupScreen::eventCallback(Widget* widget, const std::string& name, const int playerID) { if(m_schedule_continue) @@ -64,7 +64,7 @@ void SoccerSetupScreen::eventCallback(Widget* widget, const std::string& name, { int nb_players = m_kart_view_info.size(); - if (getNumKartsInTeam(SOCCER_TEAM_RED) == 0 || + if (getNumKartsInTeam(SOCCER_TEAM_RED) == 0 || getNumKartsInTeam(SOCCER_TEAM_BLUE) == 0) { for(int i=0 ; i < nb_players ; i++) @@ -77,7 +77,7 @@ void SoccerSetupScreen::eventCallback(Widget* widget, const std::string& name, sfx_manager->quickSound( "anvil" ); return; } - else if(!areAllKartsConfirmed()) + else if(!areAllKartsConfirmed()) { for(int i=0 ; i < nb_players ; i++) { @@ -198,10 +198,10 @@ void SoccerSetupScreen::init() m_schedule_continue = false; Screen::init(); - + if (UserConfigParams::m_num_goals <= 0) UserConfigParams::m_num_goals = 3; - + if (UserConfigParams::m_soccer_time_limit <= 0) UserConfigParams::m_soccer_time_limit = 3; @@ -236,7 +236,7 @@ void SoccerSetupScreen::tearDown() // Reset the 'map fire to select' option of the device manager input_manager->getDeviceList()->mapFireToSelect(false); - + UserConfigParams::m_num_goals = getWidget("goalamount")->getValue(); UserConfigParams::m_soccer_time_limit = getWidget("timeamount")->getValue(); @@ -303,20 +303,20 @@ GUIEngine::EventPropagation SoccerSetupScreen::filterActions(PlayerAction action break; case PA_MENU_SELECT: { - if (!bt_continue->isFocusedForPlayer(PLAYER_ID_GAME_MASTER) || + if (!bt_continue->isFocusedForPlayer(PLAYER_ID_GAME_MASTER) || areAllKartsConfirmed()) { return result; } - if (bt_continue->isFocusedForPlayer(PLAYER_ID_GAME_MASTER) && + if (bt_continue->isFocusedForPlayer(PLAYER_ID_GAME_MASTER) && m_kart_view_info[playerId].confirmed) { return EVENT_BLOCK; } - if (getNumConfirmedKarts() > nb_players-2 && - (getNumKartsInTeam(SOCCER_TEAM_RED) == 0 || + if (getNumConfirmedKarts() > nb_players-2 && + (getNumKartsInTeam(SOCCER_TEAM_RED) == 0 || getNumKartsInTeam(SOCCER_TEAM_BLUE) == 0)) { sfx_manager->quickSound( "anvil" ); @@ -356,14 +356,14 @@ GUIEngine::EventPropagation SoccerSetupScreen::filterActions(PlayerAction action default: break; } - + if(team_switch != SOCCER_TEAM_NONE) // A player wants to change his team? { race_manager->setLocalKartSoccerTeam(playerId, team_switch); m_kart_view_info[playerId].team = team_switch; updateKartViewsLayout(); } - + return result; @@ -373,7 +373,7 @@ GUIEngine::EventPropagation SoccerSetupScreen::filterActions(PlayerAction action void SoccerSetupScreen::onUpdate(float delta) { int nb_players = m_kart_view_info.size(); - + if(m_schedule_continue) { for(int i=0 ; i < nb_players ; i++) diff --git a/src/states_screens/soccer_setup_screen.hpp b/src/states_screens/soccer_setup_screen.hpp index bb1631240..c8fe50a9f 100644 --- a/src/states_screens/soccer_setup_screen.hpp +++ b/src/states_screens/soccer_setup_screen.hpp @@ -44,7 +44,7 @@ class SoccerSetupScreen : public GUIEngine::Screen, public GUIEngine::ScreenSing }; AlignedArray m_kart_view_info; - + bool m_schedule_continue; public: diff --git a/src/states_screens/state_manager.cpp b/src/states_screens/state_manager.cpp index f601846d4..b71ab6d02 100644 --- a/src/states_screens/state_manager.cpp +++ b/src/states_screens/state_manager.cpp @@ -102,7 +102,7 @@ void StateManager::updateActivePlayerIDs() // ---------------------------------------------------------------------------- int StateManager::createActivePlayer(PlayerProfile *profile, - InputDevice *device, + InputDevice *device, Online::OnlineProfile* user) { ActivePlayer *p; diff --git a/src/states_screens/state_manager.hpp b/src/states_screens/state_manager.hpp index f315c614d..56c777bfb 100644 --- a/src/states_screens/state_manager.hpp +++ b/src/states_screens/state_manager.hpp @@ -197,7 +197,7 @@ public: */ const PlayerProfile* getActivePlayerProfile(const int id); - int createActivePlayer(PlayerProfile *profile, InputDevice *device, + int createActivePlayer(PlayerProfile *profile, InputDevice *device, Online::OnlineProfile* use); void removeActivePlayer(int id); diff --git a/src/states_screens/tracks_screen.cpp b/src/states_screens/tracks_screen.cpp index 4f75eab4b..a9772556e 100644 --- a/src/states_screens/tracks_screen.cpp +++ b/src/states_screens/tracks_screen.cpp @@ -88,7 +88,7 @@ void TracksScreen::eventCallback(Widget* widget, const std::string& name, const if (clickedTrack != NULL) { - ITexture* screenshot = + ITexture* screenshot = irr_driver->getTexture( clickedTrack->getScreenshotFile(), "While loading screenshot for track '%s':", clickedTrack->getFilename() ); @@ -111,7 +111,7 @@ void TracksScreen::eventCallback(Widget* widget, const std::string& name, const Track* clickedTrack = track_manager->getTrack(selection); if (clickedTrack != NULL) { - ITexture* screenshot = + ITexture* screenshot = irr_driver->getTexture( clickedTrack->getScreenshotFile(), "While loading screenshot for track '%s'", clickedTrack->getFilename()); diff --git a/src/tracks/check_goal.cpp b/src/tracks/check_goal.cpp index 736859cbf..cfa7a23aa 100644 --- a/src/tracks/check_goal.cpp +++ b/src/tracks/check_goal.cpp @@ -91,7 +91,7 @@ void CheckGoal::trigger(unsigned int kart_index) SoccerWorld* world = dynamic_cast(World::getWorld()); if(!world) { - Log::warn("CheckGoal", + Log::warn("CheckGoal", "No soccer world found, cannot count the points."); return; } diff --git a/src/tracks/quad_graph.cpp b/src/tracks/quad_graph.cpp index 528519058..17eea0ff1 100644 --- a/src/tracks/quad_graph.cpp +++ b/src/tracks/quad_graph.cpp @@ -638,7 +638,7 @@ void QuadGraph::computeDistanceFromStart(unsigned int node, float new_distance) * distance from start. * \param indx Index of the node for which to increase the distance. * \param delta Amount by which to increase the distance. - * \param recursive_count Counts how often this function was called + * \param recursive_count Counts how often this function was called * recursively in order to catch incorrect graphs that contain loops. */ void QuadGraph::updateDistancesForAllSuccessors(unsigned int indx, float delta, @@ -669,7 +669,7 @@ void QuadGraph::updateDistancesForAllSuccessors(unsigned int indx, float delta, if(g.getDistanceFromStart()+g.getDistanceToSuccessor(i) > g_next.getDistanceFromStart()) { - updateDistancesForAllSuccessors(g.getSuccessor(i), delta, + updateDistancesForAllSuccessors(g.getSuccessor(i), delta, recursive_count); } } diff --git a/src/tracks/quad_graph.hpp b/src/tracks/quad_graph.hpp index e4e58b260..43eaebb5d 100644 --- a/src/tracks/quad_graph.hpp +++ b/src/tracks/quad_graph.hpp @@ -123,7 +123,7 @@ public: const video::SColor &fill_color =video::SColor(127, 255, 255, 255) ); void mapPoint2MiniMap(const Vec3 &xyz, Vec3 *out) const; - void updateDistancesForAllSuccessors(unsigned int indx, + void updateDistancesForAllSuccessors(unsigned int indx, float delta, unsigned int count); void setupPaths(); diff --git a/src/tracks/track.cpp b/src/tracks/track.cpp index 97fabd02e..4fa477b5c 100644 --- a/src/tracks/track.cpp +++ b/src/tracks/track.cpp @@ -441,21 +441,21 @@ void Track::loadTrackInfo() std::string dir = StringUtils::getPath(m_filename); std::string easter_name = dir+"/easter_eggs.xml"; - XMLNode *easter = file_manager->createXMLTree(easter_name); - - if(easter) + XMLNode *easter = file_manager->createXMLTree(easter_name); + + if(easter) { - for(unsigned int i=0; igetNumNodes(); i++) - { - const XMLNode *eggs = easter->getNode(i); - if(eggs->getNumNodes() > 0) - { - m_has_easter_eggs = true; - break; - } - } + for(unsigned int i=0; igetNumNodes(); i++) + { + const XMLNode *eggs = easter->getNode(i); + if(eggs->getNumNodes() > 0) + { + m_has_easter_eggs = true; + break; + } + } delete easter; - } + } } // loadTrackInfo //----------------------------------------------------------------------------- @@ -969,7 +969,7 @@ bool Track::loadMainTrack(const XMLNode &root) assert(GUIEngine::getHighresDigitFont() != NULL); - // TODO: Add support in the engine for BillboardText or find a replacement + // TODO: Add support in the engine for BillboardText or find a replacement /* scene::ISceneManager* sm = irr_driver->getSceneManager(); scene::ISceneNode* sn = sm->addBillboardTextSceneNode(GUIEngine::getHighresDigitFont(), @@ -978,7 +978,7 @@ bool Track::loadMainTrack(const XMLNode &root) core::dimension2df(textsize.Width/45.0f, textsize.Height/45.0f), xyz, - -1, // id + -1, // id video::SColor(255, 255, 225, 0), video::SColor(255, 255, 89, 0)); m_all_nodes.push_back(sn);*/ @@ -1581,7 +1581,7 @@ void Track::loadTrackModel(bool reverse_track, unsigned int mode_id) // Sky dome and boxes support // -------------------------- - irr_driver->suppressSkyBox(); + irr_driver->suppressSkyBox(); if(m_sky_type==SKY_DOME && m_sky_textures.size() > 0) { scene::ISceneNode *node = irr_driver->addSkyDome(m_sky_textures[0], @@ -1780,7 +1780,7 @@ void Track::loadObjects(const XMLNode* root, const std::string& path, LodNodeLoa libroot = library_nodes[name]; create_lod_definitions = false; // LOD definitions are already created, don't create them again } - + scene::ISceneNode* parent = irr_driver->getSceneManager()->addEmptySceneNode(); parent->setPosition(xyz); parent->setRotation(hpr); diff --git a/src/tracks/track.hpp b/src/tracks/track.hpp index 438847cc5..a4eb87989 100644 --- a/src/tracks/track.hpp +++ b/src/tracks/track.hpp @@ -206,7 +206,7 @@ private: /** True if this track (textures and track data) should be cached. Used * for the overworld. */ bool m_cache_track; - + #ifdef DEBUG /** A list of textures that were cached before the track is loaded. @@ -382,8 +382,8 @@ private: float m_displacement_speed; float m_caustics_speed; - - /** The levels for color correction + + /** The levels for color correction * m_color_inlevel(black, gamma, white) * m_color_outlevel(black, white)*/ core::vector3df m_color_inlevel; @@ -597,7 +597,7 @@ public: bool getBloom() const { return m_bloom; } float getBloomThreshold() const { return m_bloom_threshold; } - + /** Return the color levels for color correction shader */ core::vector3df getColorLevelIn() const { return m_color_inlevel; } core::vector2df getColorLevelOut() const { return m_color_outlevel; } @@ -605,7 +605,7 @@ public: bool hasLensFlare() const { return m_lensflare; } bool hasGodRays() const { return m_godrays; } bool hasShadows() const { return m_shadows; } - + float getDisplacementSpeed() const { return m_displacement_speed; } float getCausticsSpeed() const { return m_caustics_speed; } diff --git a/src/tracks/track_object.cpp b/src/tracks/track_object.cpp index b14e537ea..aecc10df0 100644 --- a/src/tracks/track_object.cpp +++ b/src/tracks/track_object.cpp @@ -105,7 +105,7 @@ void TrackObject::init(const XMLNode &xml_node, scene::ISceneNode* parent, m_soccer_ball = false; xml_node.get("soccer_ball", &m_soccer_ball); - + m_garage = false; m_distance = 0; @@ -159,7 +159,7 @@ void TrackObject::init(const XMLNode &xml_node, scene::ISceneNode* parent, if (lod_instance) { m_type = "lod"; - TrackObjectPresentationLOD* lod_node = + TrackObjectPresentationLOD* lod_node = new TrackObjectPresentationLOD(xml_node, parent, lod_loader); m_presentation = lod_node; @@ -177,7 +177,7 @@ void TrackObject::init(const XMLNode &xml_node, scene::ISceneNode* parent, std::string render_pass; xml_node.get("renderpass", &render_pass); - if (m_interaction != "ghost" && m_interaction != "none" && + if (m_interaction != "ghost" && m_interaction != "none" && render_pass != "skybox" ) { m_physical_object = PhysicalObject::fromXML(type == "movable", @@ -272,7 +272,7 @@ void TrackObject::move(const core::vector3df& xyz, const core::vector3df& hpr, const core::vector3df& scale, bool update_rigid_body) { if (m_presentation != NULL) m_presentation->move(xyz, hpr, scale); - if (update_rigid_body && m_physical_object != NULL) + if (update_rigid_body && m_physical_object != NULL) { // If we set a bullet position from an irrlicht position, we need to // get the absolute transform from the presentation object (as set in diff --git a/src/tracks/track_object.hpp b/src/tracks/track_object.hpp index da591fcf7..5cbccc77c 100644 --- a/src/tracks/track_object.hpp +++ b/src/tracks/track_object.hpp @@ -73,15 +73,15 @@ protected: std::string m_type; bool m_soccer_ball; - + bool m_garage; - + float m_distance; PhysicalObject* m_physical_object; ThreeDAnimation* m_animator; - + void init(const XMLNode &xml_node, scene::ISceneNode* parent, LodNodeLoader& lod_loader); public: @@ -112,7 +112,7 @@ public: bool isSoccerBall() const { return m_soccer_ball; } bool isGarage() const { return m_garage; } float getDistance() const { return m_distance; } - + const PhysicalObject* getPhysicalObject() const { return m_physical_object; } PhysicalObject* getPhysicalObject() { return m_physical_object; } diff --git a/src/tracks/track_object_manager.cpp b/src/tracks/track_object_manager.cpp index c85e67afe..f4a49b81c 100644 --- a/src/tracks/track_object_manager.cpp +++ b/src/tracks/track_object_manager.cpp @@ -222,4 +222,4 @@ void TrackObjectManager::assingLodNodes(const std::vector& lod_nodes) m_lod_objects.clear(); } -*/ +*/ \ No newline at end of file diff --git a/src/tracks/track_object_presentation.cpp b/src/tracks/track_object_presentation.cpp index e0f6d266b..64016359e 100644 --- a/src/tracks/track_object_presentation.cpp +++ b/src/tracks/track_object_presentation.cpp @@ -80,7 +80,7 @@ const core::vector3df TrackObjectPresentationSceneNode::getAbsolutePosition() co return m_node->getAbsolutePosition(); } - + const core::vector3df& TrackObjectPresentationSceneNode::getRotation() const { if (m_node == NULL) return m_init_hpr; @@ -182,15 +182,15 @@ TrackObjectPresentationMesh::TrackObjectPresentationMesh(const XMLNode& xml_node bool tangent = false; xml_node.get("tangents", &tangent); - + //std::string full_path = // World::getWorld()->getTrack()->getTrackFile(model_name); bool animated = skeletal_animation && (UserConfigParams::m_graphical_effects || World::getWorld()->getIdent() == IDENT_CUTSCENE); - bool displacing = false; - xml_node.get("displacing", &displacing); - animated &= !displacing; + bool displacing = false; + xml_node.get("displacing", &displacing); + animated &= !displacing; if (animated) { @@ -256,10 +256,10 @@ void TrackObjectPresentationMesh::init(const XMLNode* xml_node, scene::ISceneNod bool animated = skeletal_animation && (UserConfigParams::m_graphical_effects || World::getWorld()->getIdent() == IDENT_CUTSCENE); - bool displacing = false; - if(xml_node) + bool displacing = false; + if(xml_node) xml_node->get("displacing", &displacing); - animated &= !displacing; + animated &= !displacing; m_mesh->grab(); irr_driver->grabAllTextures(m_mesh); @@ -542,7 +542,7 @@ TrackObjectPresentationParticles::TrackObjectPresentationParticles(const XMLNode std::string path; xml_node.get("kind", &path); - + int clip_distance = -1; xml_node.get("clip_distance", &clip_distance); @@ -732,7 +732,7 @@ void TrackObjectPresentationActionTrigger::onTriggerItemApproached(Item* who) InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice(); DeviceConfig* config = device->getConfiguration(); irr::core::stringw fire = config->getBindingAsString(PA_FIRE); - + new TutorialMessageDialog(_("Press to look behind, to fire the weapon with <%s> while pressing to to fire behind!", fire), true); } diff --git a/src/utils/command_line.cpp b/src/utils/command_line.cpp index 55252791e..f4dee8dfc 100644 --- a/src/utils/command_line.cpp +++ b/src/utils/command_line.cpp @@ -24,7 +24,7 @@ std::vector CommandLine::m_argv; std::string CommandLine::m_exec_name=""; -/** The constructor takes the standard C arguments argc and argv and +/** The constructor takes the standard C arguments argc and argv and * stores the information internally. * \param argc Number of arguments (in argv). * \param argv Array of char* with all command line arguments. diff --git a/src/utils/command_line.hpp b/src/utils/command_line.hpp index 9557762fd..84ef176c8 100644 --- a/src/utils/command_line.hpp +++ b/src/utils/command_line.hpp @@ -25,7 +25,7 @@ #include #include -/** A small class to manage the 'argv' parameters of a program. That includes +/** A small class to manage the 'argv' parameters of a program. That includes * the name of the executable (argv[0]) and all command line parameters. * Example usage * \code @@ -38,8 +38,8 @@ * ... * CommandLine::reportInvalidParameters(); * \endcode - * The two 'has' functions will remove a parameter from the list of all - * parameters, so any parameters remaining at the end are invalid + * The two 'has' functions will remove a parameter from the list of all + * parameters, so any parameters remaining at the end are invalid * parameters, which will be listed by reportInvalidParameters. */ class CommandLine @@ -55,7 +55,7 @@ private: /** Searches for an option 'option=XX'. If found, *t will contain 'XX'. * If the value was found, the entry is removed from the list of all * command line arguments. - * \param option The option (must include '-' or '--' as required). + * \param option The option (must include '-' or '--' as required). * \param t Address of a variable to store the value. * \param format The '%' format to sscanf the value in t with. * \return true if the value was found, false otherwise. @@ -86,7 +86,7 @@ public: * If the value was found, the entry is removed from the list of all * command line arguments. This is the interface for any integer * values (i.e. using %d as format while scanning). - * \param option The option (must include '-' or '--' as required). + * \param option The option (must include '-' or '--' as required). * \param t Address of a variable to store the value. * \param format The '%' format to sscanf the value in t with. * \return true if the value was found, false otherwise. @@ -99,7 +99,7 @@ public: /** Searches for an option 'option=XX'. If found, *t will contain 'XX'. * If the value was found, the entry is removed from the list of all * command line arguments. This is the interface for a std::string - * \param option The option (must include '-' or '--' as required). + * \param option The option (must include '-' or '--' as required). * \param t Address of a variable to store the value. * \param format The '%' format to sscanf the value in t with. * \return true if the value was found, false otherwise. diff --git a/src/utils/crash_reporting.cpp b/src/utils/crash_reporting.cpp index c251f5947..09115ad77 100644 --- a/src/utils/crash_reporting.cpp +++ b/src/utils/crash_reporting.cpp @@ -76,7 +76,7 @@ _In_ DWORD maxStringLength, _In_ DWORD flags ); - + namespace CrashReporting { void getCallStackWithContext(std::string& callstack, PCONTEXT pContext); @@ -88,7 +88,7 @@ getCallStackWithContext(callstack, pContext); else getCallStack(callstack); - + std::string msg = "SuperTuxKart crashed!\n" "Please hit Ctrl+C to copy to clipboard and signal the problem\n" "to the developers on our forum: http://forum.freegamedev.net/viewforum.php?f=16\n" @@ -164,7 +164,7 @@ FreeLibrary(hImageHlpDll); \ return; \ } - + GET_FUNC_PTR(SymCleanup ) GET_FUNC_PTR(SymFunctionTableAccess64 ) GET_FUNC_PTR(SymGetLineFromAddr64 ) @@ -223,7 +223,7 @@ STACKFRAME64 stackframe; memset(&stackframe, 0, sizeof(stackframe)); stackframe.AddrPC.Offset = pContext->Eip; - stackframe.AddrPC.Mode = AddrModeFlat; + stackframe.AddrPC.Mode = AddrModeFlat; stackframe.AddrStack.Offset = pContext->Esp; stackframe.AddrStack.Mode = AddrModeFlat; stackframe.AddrFrame.Offset = pContext->Ebp; @@ -294,7 +294,7 @@ FreeLibrary(hImageHlpDll); } - + void getCallStack(std::string& callstack) { // Get the current CONTEXT diff --git a/src/utils/debug.cpp b/src/utils/debug.cpp index bc20226ce..fee8af37f 100644 --- a/src/utils/debug.cpp +++ b/src/utils/debug.cpp @@ -1,409 +1,409 @@ -// -// SuperTuxKart - a fun racing game with go-kart -// Copyright (C) 2013 Lionel Fuentes -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 3 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include "debug.hpp" -#include "config/user_config.hpp" -#include "karts/controller/controller.hpp" -#include "karts/abstract_kart.hpp" -#include "graphics/irr_driver.hpp" -#include "items/powerup_manager.hpp" +// +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2013 Lionel Fuentes +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 3 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "debug.hpp" +#include "config/user_config.hpp" +#include "karts/controller/controller.hpp" +#include "karts/abstract_kart.hpp" +#include "graphics/irr_driver.hpp" +#include "items/powerup_manager.hpp" #include "items/attachment.hpp" -#include "modes/world.hpp" -#include "physics/irr_debug_drawer.hpp" -#include "physics/physics.hpp" -#include "race/history.hpp" -#include "main_loop.hpp" -#include "replay/replay_recorder.hpp" -#include "utils/log.hpp" -#include "utils/profiler.hpp" -#include -#include -using namespace irr; -using namespace gui; - -namespace Debug { - -/** This is to let mouse input events go through when the debug menu is visible, otherwise - GUI events would be blocked while in a race... */ -static bool g_debug_menu_visible = false; - -// ----------------------------------------------------------------------------- -// Commands for the debug menu -enum DebugMenuCommand -{ - //! graphics commands - DEBUG_GRAPHICS_RELOAD_SHADERS, - DEBUG_GRAPHICS_RESET, - DEBUG_GRAPHICS_WIREFRAME, - DEBUG_GRAPHICS_MIPMAP_VIZ, - DEBUG_GRAPHICS_NORMALS_VIZ, - DEBUG_GRAPHICS_SSAO_VIZ, - DEBUG_GRAPHICS_SHADOW_VIZ, - DEBUG_GRAPHICS_LIGHT_VIZ, - DEBUG_GRAPHICS_DISTORT_VIZ, - DEBUG_GRAPHICS_BULLET_1, - DEBUG_GRAPHICS_BULLET_2, - DEBUG_PROFILER, - DEBUG_PROFILER_GENERATE_REPORT, - DEBUG_FPS, - DEBUG_SAVE_REPLAY, - DEBUG_SAVE_HISTORY, - DEBUG_POWERUP_BOWLING, - DEBUG_POWERUP_BUBBLEGUM, - DEBUG_POWERUP_CAKE, - DEBUG_POWERUP_PARACHUTE, - DEBUG_POWERUP_PLUNGER, - DEBUG_POWERUP_RUBBERBALL, - DEBUG_POWERUP_SWATTER, - DEBUG_POWERUP_SWITCH, - DEBUG_POWERUP_ZIPPER, - DEBUG_POWERUP_NITRO, +#include "modes/world.hpp" +#include "physics/irr_debug_drawer.hpp" +#include "physics/physics.hpp" +#include "race/history.hpp" +#include "main_loop.hpp" +#include "replay/replay_recorder.hpp" +#include "utils/log.hpp" +#include "utils/profiler.hpp" +#include +#include +using namespace irr; +using namespace gui; + +namespace Debug { + +/** This is to let mouse input events go through when the debug menu is visible, otherwise + GUI events would be blocked while in a race... */ +static bool g_debug_menu_visible = false; + +// ----------------------------------------------------------------------------- +// Commands for the debug menu +enum DebugMenuCommand +{ + //! graphics commands + DEBUG_GRAPHICS_RELOAD_SHADERS, + DEBUG_GRAPHICS_RESET, + DEBUG_GRAPHICS_WIREFRAME, + DEBUG_GRAPHICS_MIPMAP_VIZ, + DEBUG_GRAPHICS_NORMALS_VIZ, + DEBUG_GRAPHICS_SSAO_VIZ, + DEBUG_GRAPHICS_SHADOW_VIZ, + DEBUG_GRAPHICS_LIGHT_VIZ, + DEBUG_GRAPHICS_DISTORT_VIZ, + DEBUG_GRAPHICS_BULLET_1, + DEBUG_GRAPHICS_BULLET_2, + DEBUG_PROFILER, + DEBUG_PROFILER_GENERATE_REPORT, + DEBUG_FPS, + DEBUG_SAVE_REPLAY, + DEBUG_SAVE_HISTORY, + DEBUG_POWERUP_BOWLING, + DEBUG_POWERUP_BUBBLEGUM, + DEBUG_POWERUP_CAKE, + DEBUG_POWERUP_PARACHUTE, + DEBUG_POWERUP_PLUNGER, + DEBUG_POWERUP_RUBBERBALL, + DEBUG_POWERUP_SWATTER, + DEBUG_POWERUP_SWITCH, + DEBUG_POWERUP_ZIPPER, + DEBUG_POWERUP_NITRO, DEBUG_ATTACHMENT_PARACHUTE, DEBUG_ATTACHMENT_BOMB, DEBUG_ATTACHMENT_ANVIL, - DEBUG_TOGGLE_GUI, - DEBUG_THROTTLE_FPS -}; - -// ----------------------------------------------------------------------------- -// Add powerup selected from debug menu for all player karts -void addPowerup(PowerupManager::PowerupType powerup) -{ - World* world = World::getWorld(); - if (world == NULL) return; - for(unsigned int i = 0; i < race_manager->getNumLocalPlayers(); i++) - { - AbstractKart* kart = world->getLocalPlayerKart(i); - kart->setPowerup(powerup, 10000); - } -} - + DEBUG_TOGGLE_GUI, + DEBUG_THROTTLE_FPS +}; + +// ----------------------------------------------------------------------------- +// Add powerup selected from debug menu for all player karts +void addPowerup(PowerupManager::PowerupType powerup) +{ + World* world = World::getWorld(); + if (world == NULL) return; + for(unsigned int i = 0; i < race_manager->getNumLocalPlayers(); i++) + { + AbstractKart* kart = world->getLocalPlayerKart(i); + kart->setPowerup(powerup, 10000); + } +} + void addAttachment(Attachment::AttachmentType type) { - World* world = World::getWorld(); - if (world == NULL) return; - for(unsigned int i = 0; i < world->getNumKarts(); i++) - { - AbstractKart *kart = world->getKart(i); - if (kart->getController()->isPlayerController()) { - if (type == Attachment::ATTACH_ANVIL) - { - kart->getAttachment() - ->set(type, stk_config->m_anvil_time); - kart->adjustSpeed(stk_config->m_anvil_speed_factor); - kart->updateWeight(); - } - else if (type == Attachment::ATTACH_PARACHUTE) - { - kart->getAttachment() - ->set(type, stk_config->m_parachute_time); - } - else if (type == Attachment::ATTACH_BOMB) - { - kart->getAttachment() - ->set(type, stk_config->m_bomb_time); - } - } - } + World* world = World::getWorld(); + if (world == NULL) return; + for(unsigned int i = 0; i < world->getNumKarts(); i++) + { + AbstractKart *kart = world->getKart(i); + if (kart->getController()->isPlayerController()) { + if (type == Attachment::ATTACH_ANVIL) + { + kart->getAttachment() + ->set(type, stk_config->m_anvil_time); + kart->adjustSpeed(stk_config->m_anvil_speed_factor); + kart->updateWeight(); + } + else if (type == Attachment::ATTACH_PARACHUTE) + { + kart->getAttachment() + ->set(type, stk_config->m_parachute_time); + } + else if (type == Attachment::ATTACH_BOMB) + { + kart->getAttachment() + ->set(type, stk_config->m_bomb_time); + } + } + } } -// ----------------------------------------------------------------------------- -// Debug menu handling -bool onEvent(const SEvent &event) -{ - // Only activated in artist debug mode - if(!UserConfigParams::m_artist_debug_mode) - return true; // keep handling the events - - if(event.EventType == EET_MOUSE_INPUT_EVENT) - { - // Create the menu (only one menu at a time) - if(event.MouseInput.Event == EMIE_RMOUSE_PRESSED_DOWN && !g_debug_menu_visible) - { - // root menu - gui::IGUIEnvironment* guienv = irr_driver->getGUI(); - IGUIContextMenu* mnu = guienv->addContextMenu( - core::rect(event.MouseInput.X, event.MouseInput.Y, event.MouseInput.Y+100, event.MouseInput.Y+100),NULL); - int graphicsMenuIndex = mnu->addItem(L"Graphics >",-1,true,true); - - // graphics menu - IGUIContextMenu* sub = mnu->getSubMenu(graphicsMenuIndex); - - sub->addItem(L"Reload shaders", DEBUG_GRAPHICS_RELOAD_SHADERS ); - sub->addItem(L"Reset debug views", DEBUG_GRAPHICS_RESET ); - sub->addItem(L"Wireframe", DEBUG_GRAPHICS_WIREFRAME ); - sub->addItem(L"Mipmap viz", DEBUG_GRAPHICS_MIPMAP_VIZ ); - sub->addItem(L"Normals viz", DEBUG_GRAPHICS_NORMALS_VIZ ); - sub->addItem(L"SSAO viz", DEBUG_GRAPHICS_SSAO_VIZ ); - sub->addItem(L"Shadow viz", DEBUG_GRAPHICS_SHADOW_VIZ ); - sub->addItem(L"Light viz", DEBUG_GRAPHICS_LIGHT_VIZ ); - sub->addItem(L"Distort viz", DEBUG_GRAPHICS_DISTORT_VIZ ); - sub->addItem(L"Physics debug", DEBUG_GRAPHICS_BULLET_1); - sub->addItem(L"Physics debug (no kart)", DEBUG_GRAPHICS_BULLET_2); - - mnu->addItem(L"Items >",-1,true,true); - sub = mnu->getSubMenu(1); - sub->addItem(L"Basketball", DEBUG_POWERUP_RUBBERBALL ); - sub->addItem(L"Bowling", DEBUG_POWERUP_BOWLING ); - sub->addItem(L"Bubblegum", DEBUG_POWERUP_BUBBLEGUM ); - sub->addItem(L"Cake", DEBUG_POWERUP_CAKE ); - sub->addItem(L"Parachute", DEBUG_POWERUP_PARACHUTE ); - sub->addItem(L"Plunger", DEBUG_POWERUP_PLUNGER ); - sub->addItem(L"Swatter", DEBUG_POWERUP_SWATTER ); - sub->addItem(L"Switch", DEBUG_POWERUP_SWITCH ); - sub->addItem(L"Zipper", DEBUG_POWERUP_ZIPPER ); - sub->addItem(L"Nitro", DEBUG_POWERUP_NITRO ); - +// ----------------------------------------------------------------------------- +// Debug menu handling +bool onEvent(const SEvent &event) +{ + // Only activated in artist debug mode + if(!UserConfigParams::m_artist_debug_mode) + return true; // keep handling the events + + if(event.EventType == EET_MOUSE_INPUT_EVENT) + { + // Create the menu (only one menu at a time) + if(event.MouseInput.Event == EMIE_RMOUSE_PRESSED_DOWN && !g_debug_menu_visible) + { + // root menu + gui::IGUIEnvironment* guienv = irr_driver->getGUI(); + IGUIContextMenu* mnu = guienv->addContextMenu( + core::rect(event.MouseInput.X, event.MouseInput.Y, event.MouseInput.Y+100, event.MouseInput.Y+100),NULL); + int graphicsMenuIndex = mnu->addItem(L"Graphics >",-1,true,true); + + // graphics menu + IGUIContextMenu* sub = mnu->getSubMenu(graphicsMenuIndex); + + sub->addItem(L"Reload shaders", DEBUG_GRAPHICS_RELOAD_SHADERS ); + sub->addItem(L"Reset debug views", DEBUG_GRAPHICS_RESET ); + sub->addItem(L"Wireframe", DEBUG_GRAPHICS_WIREFRAME ); + sub->addItem(L"Mipmap viz", DEBUG_GRAPHICS_MIPMAP_VIZ ); + sub->addItem(L"Normals viz", DEBUG_GRAPHICS_NORMALS_VIZ ); + sub->addItem(L"SSAO viz", DEBUG_GRAPHICS_SSAO_VIZ ); + sub->addItem(L"Shadow viz", DEBUG_GRAPHICS_SHADOW_VIZ ); + sub->addItem(L"Light viz", DEBUG_GRAPHICS_LIGHT_VIZ ); + sub->addItem(L"Distort viz", DEBUG_GRAPHICS_DISTORT_VIZ ); + sub->addItem(L"Physics debug", DEBUG_GRAPHICS_BULLET_1); + sub->addItem(L"Physics debug (no kart)", DEBUG_GRAPHICS_BULLET_2); + + mnu->addItem(L"Items >",-1,true,true); + sub = mnu->getSubMenu(1); + sub->addItem(L"Basketball", DEBUG_POWERUP_RUBBERBALL ); + sub->addItem(L"Bowling", DEBUG_POWERUP_BOWLING ); + sub->addItem(L"Bubblegum", DEBUG_POWERUP_BUBBLEGUM ); + sub->addItem(L"Cake", DEBUG_POWERUP_CAKE ); + sub->addItem(L"Parachute", DEBUG_POWERUP_PARACHUTE ); + sub->addItem(L"Plunger", DEBUG_POWERUP_PLUNGER ); + sub->addItem(L"Swatter", DEBUG_POWERUP_SWATTER ); + sub->addItem(L"Switch", DEBUG_POWERUP_SWITCH ); + sub->addItem(L"Zipper", DEBUG_POWERUP_ZIPPER ); + sub->addItem(L"Nitro", DEBUG_POWERUP_NITRO ); + mnu->addItem(L"Attachments >",-1,true, true); sub = mnu->getSubMenu(2); sub->addItem(L"Bomb", DEBUG_ATTACHMENT_BOMB); sub->addItem(L"Anvil", DEBUG_ATTACHMENT_ANVIL); sub->addItem(L"Parachute", DEBUG_ATTACHMENT_PARACHUTE); - mnu->addItem(L"Profiler",DEBUG_PROFILER); - if (UserConfigParams::m_profiler_enabled) - mnu->addItem(L"Toggle capture profiler report", DEBUG_PROFILER_GENERATE_REPORT); - mnu->addItem(L"Do not limit FPS", DEBUG_THROTTLE_FPS); - mnu->addItem(L"FPS",DEBUG_FPS); - mnu->addItem(L"Save replay", DEBUG_SAVE_REPLAY); - mnu->addItem(L"Save history", DEBUG_SAVE_HISTORY); - mnu->addItem(L"Toggle GUI", DEBUG_TOGGLE_GUI); - - - g_debug_menu_visible = true; - irr_driver->showPointer(); - } - - // Let Irrlicht handle the event while the menu is visible - otherwise in a race the GUI events won't be generated - if(g_debug_menu_visible) - return false; - } - - if (event.EventType == EET_GUI_EVENT) - { - if (event.GUIEvent.Caller != NULL && event.GUIEvent.Caller->getType() == EGUIET_CONTEXT_MENU ) - { - IGUIContextMenu *menu = (IGUIContextMenu*)event.GUIEvent.Caller; - s32 cmdID = menu->getItemCommandId(menu->getSelectedItem()); - - if(event.GUIEvent.EventType == EGET_ELEMENT_CLOSED) - { - g_debug_menu_visible = false; - } - - if (event.GUIEvent.EventType == gui::EGET_MENU_ITEM_SELECTED) - { - if(cmdID == DEBUG_GRAPHICS_RELOAD_SHADERS) - { - Log::info("Debug", "Reloading shaders..."); - irr_driver->updateShaders(); - } - else if (cmdID == DEBUG_GRAPHICS_RESET) - { - World* world = World::getWorld(); - if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE); - - irr_driver->resetDebugModes(); - } - else if (cmdID == DEBUG_GRAPHICS_WIREFRAME) - { - World* world = World::getWorld(); - if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE); - - irr_driver->resetDebugModes(); - irr_driver->toggleWireframe(); - } - else if (cmdID == DEBUG_GRAPHICS_MIPMAP_VIZ) - { - World* world = World::getWorld(); - if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE); - - irr_driver->resetDebugModes(); - irr_driver->toggleMipVisualization(); - } - else if (cmdID == DEBUG_GRAPHICS_NORMALS_VIZ) - { - World* world = World::getWorld(); - if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE); - - irr_driver->resetDebugModes(); - irr_driver->toggleNormals(); - } - else if (cmdID == DEBUG_GRAPHICS_SSAO_VIZ) - { - World* world = World::getWorld(); - if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE); - - irr_driver->resetDebugModes(); - irr_driver->toggleSSAOViz(); - } - else if (cmdID == DEBUG_GRAPHICS_SHADOW_VIZ) - { - World* world = World::getWorld(); - if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE); - - irr_driver->resetDebugModes(); - irr_driver->toggleShadowViz(); - } - else if (cmdID == DEBUG_GRAPHICS_LIGHT_VIZ) - { - World* world = World::getWorld(); - if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE); - - irr_driver->resetDebugModes(); - irr_driver->toggleLightViz(); - } - else if (cmdID == DEBUG_GRAPHICS_DISTORT_VIZ) - { - World* world = World::getWorld(); - if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE); - - irr_driver->resetDebugModes(); - irr_driver->toggleDistortViz(); - } - else if (cmdID == DEBUG_GRAPHICS_BULLET_1) - { - irr_driver->resetDebugModes(); - - World* world = World::getWorld(); - if (world == NULL) return false; - world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_KARTS_PHYSICS); - } - else if (cmdID == DEBUG_GRAPHICS_BULLET_2) - { - irr_driver->resetDebugModes(); - - World* world = World::getWorld(); - if (world == NULL) return false; - world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NO_KARTS_GRAPHICS); - } - else if (cmdID == DEBUG_PROFILER) - { - UserConfigParams::m_profiler_enabled = - !UserConfigParams::m_profiler_enabled; - } - else if (cmdID == DEBUG_PROFILER_GENERATE_REPORT) - { - profiler.setCaptureReport(!profiler.getCaptureReport()); - } - else if (cmdID == DEBUG_THROTTLE_FPS) - { - main_loop->setThrottleFPS(false); - } - else if (cmdID == DEBUG_FPS) - { - UserConfigParams::m_display_fps = - !UserConfigParams::m_display_fps; - } - else if (cmdID == DEBUG_SAVE_REPLAY) - { - ReplayRecorder::get()->Save(); - } - else if (cmdID == DEBUG_SAVE_HISTORY) - { - history->Save(); - } - else if (cmdID == DEBUG_POWERUP_BOWLING) - { - addPowerup(PowerupManager::POWERUP_BOWLING); - } - else if (cmdID == DEBUG_POWERUP_BUBBLEGUM) - { - addPowerup(PowerupManager::POWERUP_BUBBLEGUM); - } - else if (cmdID == DEBUG_POWERUP_CAKE) - { - addPowerup(PowerupManager::POWERUP_CAKE); - } - else if (cmdID == DEBUG_POWERUP_PARACHUTE) - { - addPowerup(PowerupManager::POWERUP_PARACHUTE); - } - else if (cmdID == DEBUG_POWERUP_PLUNGER) - { - addPowerup(PowerupManager::POWERUP_PLUNGER); - } - else if (cmdID == DEBUG_POWERUP_RUBBERBALL) - { - addPowerup(PowerupManager::POWERUP_RUBBERBALL); - } - else if (cmdID == DEBUG_POWERUP_SWATTER) - { - addPowerup(PowerupManager::POWERUP_SWATTER); - } - else if (cmdID == DEBUG_POWERUP_SWITCH) - { - addPowerup(PowerupManager::POWERUP_SWITCH); - } - else if (cmdID == DEBUG_POWERUP_ZIPPER) - { - addPowerup(PowerupManager::POWERUP_ZIPPER); - } - else if (cmdID == DEBUG_POWERUP_NITRO) - { - World* world = World::getWorld(); - if (world == NULL) return false; - for(unsigned int i = 0; i < race_manager->getNumLocalPlayers(); i++) - { - AbstractKart* kart = world->getLocalPlayerKart(i); - kart->setEnergy(100.0f); - } - } + mnu->addItem(L"Profiler",DEBUG_PROFILER); + if (UserConfigParams::m_profiler_enabled) + mnu->addItem(L"Toggle capture profiler report", DEBUG_PROFILER_GENERATE_REPORT); + mnu->addItem(L"Do not limit FPS", DEBUG_THROTTLE_FPS); + mnu->addItem(L"FPS",DEBUG_FPS); + mnu->addItem(L"Save replay", DEBUG_SAVE_REPLAY); + mnu->addItem(L"Save history", DEBUG_SAVE_HISTORY); + mnu->addItem(L"Toggle GUI", DEBUG_TOGGLE_GUI); + + + g_debug_menu_visible = true; + irr_driver->showPointer(); + } + + // Let Irrlicht handle the event while the menu is visible - otherwise in a race the GUI events won't be generated + if(g_debug_menu_visible) + return false; + } + + if (event.EventType == EET_GUI_EVENT) + { + if (event.GUIEvent.Caller != NULL && event.GUIEvent.Caller->getType() == EGUIET_CONTEXT_MENU ) + { + IGUIContextMenu *menu = (IGUIContextMenu*)event.GUIEvent.Caller; + s32 cmdID = menu->getItemCommandId(menu->getSelectedItem()); + + if(event.GUIEvent.EventType == EGET_ELEMENT_CLOSED) + { + g_debug_menu_visible = false; + } + + if (event.GUIEvent.EventType == gui::EGET_MENU_ITEM_SELECTED) + { + if(cmdID == DEBUG_GRAPHICS_RELOAD_SHADERS) + { + Log::info("Debug", "Reloading shaders..."); + irr_driver->updateShaders(); + } + else if (cmdID == DEBUG_GRAPHICS_RESET) + { + World* world = World::getWorld(); + if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE); + + irr_driver->resetDebugModes(); + } + else if (cmdID == DEBUG_GRAPHICS_WIREFRAME) + { + World* world = World::getWorld(); + if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE); + + irr_driver->resetDebugModes(); + irr_driver->toggleWireframe(); + } + else if (cmdID == DEBUG_GRAPHICS_MIPMAP_VIZ) + { + World* world = World::getWorld(); + if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE); + + irr_driver->resetDebugModes(); + irr_driver->toggleMipVisualization(); + } + else if (cmdID == DEBUG_GRAPHICS_NORMALS_VIZ) + { + World* world = World::getWorld(); + if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE); + + irr_driver->resetDebugModes(); + irr_driver->toggleNormals(); + } + else if (cmdID == DEBUG_GRAPHICS_SSAO_VIZ) + { + World* world = World::getWorld(); + if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE); + + irr_driver->resetDebugModes(); + irr_driver->toggleSSAOViz(); + } + else if (cmdID == DEBUG_GRAPHICS_SHADOW_VIZ) + { + World* world = World::getWorld(); + if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE); + + irr_driver->resetDebugModes(); + irr_driver->toggleShadowViz(); + } + else if (cmdID == DEBUG_GRAPHICS_LIGHT_VIZ) + { + World* world = World::getWorld(); + if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE); + + irr_driver->resetDebugModes(); + irr_driver->toggleLightViz(); + } + else if (cmdID == DEBUG_GRAPHICS_DISTORT_VIZ) + { + World* world = World::getWorld(); + if (world != NULL) world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NONE); + + irr_driver->resetDebugModes(); + irr_driver->toggleDistortViz(); + } + else if (cmdID == DEBUG_GRAPHICS_BULLET_1) + { + irr_driver->resetDebugModes(); + + World* world = World::getWorld(); + if (world == NULL) return false; + world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_KARTS_PHYSICS); + } + else if (cmdID == DEBUG_GRAPHICS_BULLET_2) + { + irr_driver->resetDebugModes(); + + World* world = World::getWorld(); + if (world == NULL) return false; + world->getPhysics()->setDebugMode(IrrDebugDrawer::DM_NO_KARTS_GRAPHICS); + } + else if (cmdID == DEBUG_PROFILER) + { + UserConfigParams::m_profiler_enabled = + !UserConfigParams::m_profiler_enabled; + } + else if (cmdID == DEBUG_PROFILER_GENERATE_REPORT) + { + profiler.setCaptureReport(!profiler.getCaptureReport()); + } + else if (cmdID == DEBUG_THROTTLE_FPS) + { + main_loop->setThrottleFPS(false); + } + else if (cmdID == DEBUG_FPS) + { + UserConfigParams::m_display_fps = + !UserConfigParams::m_display_fps; + } + else if (cmdID == DEBUG_SAVE_REPLAY) + { + ReplayRecorder::get()->Save(); + } + else if (cmdID == DEBUG_SAVE_HISTORY) + { + history->Save(); + } + else if (cmdID == DEBUG_POWERUP_BOWLING) + { + addPowerup(PowerupManager::POWERUP_BOWLING); + } + else if (cmdID == DEBUG_POWERUP_BUBBLEGUM) + { + addPowerup(PowerupManager::POWERUP_BUBBLEGUM); + } + else if (cmdID == DEBUG_POWERUP_CAKE) + { + addPowerup(PowerupManager::POWERUP_CAKE); + } + else if (cmdID == DEBUG_POWERUP_PARACHUTE) + { + addPowerup(PowerupManager::POWERUP_PARACHUTE); + } + else if (cmdID == DEBUG_POWERUP_PLUNGER) + { + addPowerup(PowerupManager::POWERUP_PLUNGER); + } + else if (cmdID == DEBUG_POWERUP_RUBBERBALL) + { + addPowerup(PowerupManager::POWERUP_RUBBERBALL); + } + else if (cmdID == DEBUG_POWERUP_SWATTER) + { + addPowerup(PowerupManager::POWERUP_SWATTER); + } + else if (cmdID == DEBUG_POWERUP_SWITCH) + { + addPowerup(PowerupManager::POWERUP_SWITCH); + } + else if (cmdID == DEBUG_POWERUP_ZIPPER) + { + addPowerup(PowerupManager::POWERUP_ZIPPER); + } + else if (cmdID == DEBUG_POWERUP_NITRO) + { + World* world = World::getWorld(); + if (world == NULL) return false; + for(unsigned int i = 0; i < race_manager->getNumLocalPlayers(); i++) + { + AbstractKart* kart = world->getLocalPlayerKart(i); + kart->setEnergy(100.0f); + } + } else if (cmdID == DEBUG_ATTACHMENT_ANVIL) { - addAttachment(Attachment::ATTACH_ANVIL); + addAttachment(Attachment::ATTACH_ANVIL); } else if (cmdID == DEBUG_ATTACHMENT_BOMB) { - addAttachment(Attachment::ATTACH_BOMB); + addAttachment(Attachment::ATTACH_BOMB); } else if (cmdID == DEBUG_ATTACHMENT_PARACHUTE) { - addAttachment(Attachment::ATTACH_PARACHUTE); + addAttachment(Attachment::ATTACH_PARACHUTE); } - else if (cmdID == DEBUG_TOGGLE_GUI) - { - World* world = World::getWorld(); - if (world == NULL) return false; - RaceGUIBase* gui = world->getRaceGUI(); - if (gui != NULL) gui->m_enabled = !gui->m_enabled; - - const int count = World::getWorld()->getNumKarts(); - for (int n=0; ngetKart(n); - if (kart->getController()->isPlayerController()) - kart->getNode()->setVisible(gui->m_enabled); - } - } - } - - return false; // event has been handled - } - } - return true; // continue event handling -} - -bool isOpen() -{ - return g_debug_menu_visible; -} -} + else if (cmdID == DEBUG_TOGGLE_GUI) + { + World* world = World::getWorld(); + if (world == NULL) return false; + RaceGUIBase* gui = world->getRaceGUI(); + if (gui != NULL) gui->m_enabled = !gui->m_enabled; + + const int count = World::getWorld()->getNumKarts(); + for (int n=0; ngetKart(n); + if (kart->getController()->isPlayerController()) + kart->getNode()->setVisible(gui->m_enabled); + } + } + } + + return false; // event has been handled + } + } + return true; // continue event handling +} + +bool isOpen() +{ + return g_debug_menu_visible; +} +} diff --git a/src/utils/helpers.cpp b/src/utils/helpers.cpp index c0c9ee301..fba721f6f 100644 --- a/src/utils/helpers.cpp +++ b/src/utils/helpers.cpp @@ -76,99 +76,99 @@ THE SOFTWARE. */ static inline float mod289(float x) { -// return x - floorf(x * (1.0 / 289.0)) * 289.0; - return fmodf(x, 289); +// return x - floorf(x * (1.0 / 289.0)) * 289.0; + return fmodf(x, 289); } static inline float permute(float x) { - return mod289(((x*34.0f)+1.0f)*x); + return mod289(((x*34.0f)+1.0f)*x); } // Vectorized 2d simplex noise. float noise2d(float v1, float v2) { - const float C[] = { - 0.211324865405187f, - 0.366025403784439f, - -0.577350269189626f, - 0.024390243902439f }; + const float C[] = { + 0.211324865405187f, + 0.366025403784439f, + -0.577350269189626f, + 0.024390243902439f }; - // First corner - float i[2]; - i[0] = floorf(v1 + v1*C[1] + v2*C[1]); - i[1] = floorf(v2 + v1*C[1] + v2*C[1]); + // First corner + float i[2]; + i[0] = floorf(v1 + v1*C[1] + v2*C[1]); + i[1] = floorf(v2 + v1*C[1] + v2*C[1]); - float x0[2]; - x0[0] = v1 - i[0] + i[0]*C[0] + i[1]*C[0]; - x0[1] = v2 - i[1] + i[0]*C[0] + i[1]*C[0]; + float x0[2]; + x0[0] = v1 - i[0] + i[0]*C[0] + i[1]*C[0]; + x0[1] = v2 - i[1] + i[0]*C[0] + i[1]*C[0]; - // Other corners - float i1[2]; - if (x0[0] > x0[1]) { - i1[0] = 1; - i1[1] = 0; - } else { - i1[0] = 0; - i1[1] = 1; - } + // Other corners + float i1[2]; + if (x0[0] > x0[1]) { + i1[0] = 1; + i1[1] = 0; + } else { + i1[0] = 0; + i1[1] = 1; + } - float x12[4]; - x12[0] = x0[0] + C[0] - i1[0]; - x12[1] = x0[1] + C[0] - i1[1]; - x12[2] = x0[0] + C[2]; - x12[3] = x0[1] + C[2]; + float x12[4]; + x12[0] = x0[0] + C[0] - i1[0]; + x12[1] = x0[1] + C[0] - i1[1]; + x12[2] = x0[0] + C[2]; + x12[3] = x0[1] + C[2]; - // Permutations - i[0] = mod289(i[0]); - i[1] = mod289(i[1]); + // Permutations + i[0] = mod289(i[0]); + i[1] = mod289(i[1]); - float p[3]; - p[0] = permute(permute(i[1]) + i[0]); - p[1] = permute(permute(i[1] + i1[1]) + i[0] + i1[0]); - p[2] = permute(permute(i[1] + 1) + i[0] + 1); + float p[3]; + p[0] = permute(permute(i[1]) + i[0]); + p[1] = permute(permute(i[1] + i1[1]) + i[0] + i1[0]); + p[2] = permute(permute(i[1] + 1) + i[0] + 1); - float m[3]; - m[0] = std::max(0.5f - x0[0]*x0[0] - x0[1]*x0[1], 0); - m[1] = std::max(0.5f - x12[0]*x12[0] - x12[1]*x12[1], 0); - m[2] = std::max(0.5f - x12[2]*x12[2] - x12[3]*x12[3], 0); + float m[3]; + m[0] = std::max(0.5f - x0[0]*x0[0] - x0[1]*x0[1], 0); + m[1] = std::max(0.5f - x12[0]*x12[0] - x12[1]*x12[1], 0); + m[2] = std::max(0.5f - x12[2]*x12[2] - x12[3]*x12[3], 0); - m[0] = m[0] * m[0] * m[0] * m[0]; - m[1] = m[1] * m[1] * m[1] * m[1]; - m[2] = m[2] * m[2] * m[2] * m[2]; + m[0] = m[0] * m[0] * m[0] * m[0]; + m[1] = m[1] * m[1] * m[1] * m[1]; + m[2] = m[2] * m[2] * m[2] * m[2]; - // Gradients - float tmp; + // Gradients + float tmp; - float x[3]; - x[0] = 2 * modff(p[0] * C[3], &tmp) - 1; - x[1] = 2 * modff(p[1] * C[3], &tmp) - 1; - x[2] = 2 * modff(p[2] * C[3], &tmp) - 1; + float x[3]; + x[0] = 2 * modff(p[0] * C[3], &tmp) - 1; + x[1] = 2 * modff(p[1] * C[3], &tmp) - 1; + x[2] = 2 * modff(p[2] * C[3], &tmp) - 1; - float h[3]; - h[0] = fabsf(x[0]) - 0.5f; - h[1] = fabsf(x[1]) - 0.5f; - h[2] = fabsf(x[2]) - 0.5f; + float h[3]; + h[0] = fabsf(x[0]) - 0.5f; + h[1] = fabsf(x[1]) - 0.5f; + h[2] = fabsf(x[2]) - 0.5f; - float ox[3]; - ox[0] = floorf(x[0] + 0.5f); - ox[1] = floorf(x[1] + 0.5f); - ox[2] = floorf(x[2] + 0.5f); + float ox[3]; + ox[0] = floorf(x[0] + 0.5f); + ox[1] = floorf(x[1] + 0.5f); + ox[2] = floorf(x[2] + 0.5f); - float a0[3]; - a0[0] = x[0] - ox[0]; - a0[1] = x[1] - ox[1]; - a0[2] = x[2] - ox[2]; + float a0[3]; + a0[0] = x[0] - ox[0]; + a0[1] = x[1] - ox[1]; + a0[2] = x[2] - ox[2]; - // Normalize - m[0] *= 1.79284291400159f - 0.85373472095314f * (a0[0]*a0[0] + h[0]*h[0]); - m[1] *= 1.79284291400159f - 0.85373472095314f * (a0[1]*a0[1] + h[1]*h[1]); - m[2] *= 1.79284291400159f - 0.85373472095314f * (a0[2]*a0[2] + h[2]*h[2]); + // Normalize + m[0] *= 1.79284291400159f - 0.85373472095314f * (a0[0]*a0[0] + h[0]*h[0]); + m[1] *= 1.79284291400159f - 0.85373472095314f * (a0[1]*a0[1] + h[1]*h[1]); + m[2] *= 1.79284291400159f - 0.85373472095314f * (a0[2]*a0[2] + h[2]*h[2]); - // Compute final value - float g[3]; - g[0] = a0[0] * x0[0] + h[0] * x0[1]; - g[1] = a0[1] * x12[0] + h[1] * x12[1]; - g[2] = a0[2] * x12[2] + h[2] * x12[3]; + // Compute final value + float g[3]; + g[0] = a0[0] * x0[0] + h[0] * x0[1]; + g[1] = a0[1] * x12[0] + h[1] * x12[1]; + g[2] = a0[2] * x12[2] + h[2] * x12[3]; - return 130 * (m[0] * g[0] + m[1] * g[1] + m[2] * g[2]); + return 130 * (m[0] * g[0] + m[1] * g[1] + m[2] * g[2]); } diff --git a/src/utils/log.cpp b/src/utils/log.cpp index af43d8fd1..59d9d8ad4 100644 --- a/src/utils/log.cpp +++ b/src/utils/log.cpp @@ -195,7 +195,7 @@ void Log::printMessage(int level, const char *component, const char *format, OutputDebugString(szBuff); OutputDebugString("\r\n"); #endif - + if(m_file_stdout) { diff --git a/src/utils/log.hpp b/src/utils/log.hpp index d04f6f071..65fd1d2c4 100644 --- a/src/utils/log.hpp +++ b/src/utils/log.hpp @@ -67,7 +67,7 @@ public: static void printMessage(int level, const char *component, const char *format, VALIST va_list); // ------------------------------------------------------------------------ - /** A simple macro to define the various log functions. + /** A simple macro to define the various log functions. * Note that an assert is added so that a debugger is triggered * when debugging. */ #define LOG(NAME, LEVEL) \ diff --git a/src/utils/no_copy.hpp b/src/utils/no_copy.hpp index d23c3edf2..3011698eb 100644 --- a/src/utils/no_copy.hpp +++ b/src/utils/no_copy.hpp @@ -1,17 +1,17 @@ // SuperTuxKart - a fun racing game with go-kart // // Copyright (C) 2003 Matthias-2013 Braun -// +// // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA diff --git a/src/utils/string_utils.cpp b/src/utils/string_utils.cpp index 8c61bc40b..ae413d1ef 100644 --- a/src/utils/string_utils.cpp +++ b/src/utils/string_utils.cpp @@ -195,7 +195,7 @@ namespace StringUtils } catch (std::exception& e) { - Log::error("StringUtils", + Log::error("StringUtils", "Error in split(std::string) : %s @ line %i : %s.", __FILE__, __LINE__, e.what()); Log::error("StringUtils", "Splitting '%s'.", s.c_str()); @@ -325,7 +325,7 @@ namespace StringUtils catch (std::exception& e) { (void)e; // avoid warning about unused variable - Log::fatal("StringUtils", + Log::fatal("StringUtils", "Fatal error in splitPath : %s @ line %i: '%s'.", __FILE__, __LINE__, path.c_str()); exit(1); @@ -356,7 +356,7 @@ namespace StringUtils { if (insertValID >= all_vals.size()) { - Log::warn("StringUtils", + Log::warn("StringUtils", "insertValues: " "Invalid number of arguments in '%s'.", s.c_str()); @@ -395,7 +395,7 @@ namespace StringUtils catch (std::exception& e) { (void)e; // avoid warning about unused variable - Log::fatal("StringUtils", + Log::fatal("StringUtils", "Fatal error in insertValues(std::string) : %s @ " "line %i: '%s'", __FILE__, __LINE__, s.c_str()); exit(1); diff --git a/src/utils/string_utils.hpp b/src/utils/string_utils.hpp index b1e70eeec..084140589 100644 --- a/src/utils/string_utils.hpp +++ b/src/utils/string_utils.hpp @@ -124,7 +124,7 @@ namespace StringUtils * and this is in the best case very confusing for translators (which get * to see two strings instead of one sentence, see xgettext manual * for why this is a bad idea) - * In order to accomodate translations even more, you can use formats + * In order to accomodate translations even more, you can use formats * %0, %1, %2, etc..., where %0 is replaced by the first argument, %1 by * the second argument, etc... This allows translated strings to not * necessarily insert the words in the same order as in English. diff --git a/src/utils/time.cpp b/src/utils/time.cpp index 94ec42f14..68a0e24b2 100644 --- a/src/utils/time.cpp +++ b/src/utils/time.cpp @@ -41,7 +41,7 @@ void StkTime::getDate(int *day, int *month, int *year) { std::time_t t = std::time(0); // get time now std::tm * now = std::localtime(&t); - + if(day) *day = now->tm_mday; if(month) *month = now->tm_mon + 1; if(year) *year = now->tm_year + 1900; diff --git a/src/utils/utf8/core.h b/src/utils/utf8/core.h index e32fa4d8c..fcd1e666b 100644 --- a/src/utils/utf8/core.h +++ b/src/utils/utf8/core.h @@ -341,7 +341,7 @@ namespace internal ); } - //Deprecated in release 2.3 + //Deprecated in release 2.3 template inline bool is_bom (octet_iterator it) {