Some lightning improvements:
- move OpenGL-related code to graphics directory, as it should be - solve issue with applying effect multiple times in multiplayer mode - remove old already disabled opengl code
This commit is contained in:
parent
94d5c19b7f
commit
9b3908cc62
@ -27,6 +27,7 @@
|
||||
#include "graphics/shaders.hpp"
|
||||
#include "graphics/shared_gpu_objects.hpp"
|
||||
#include "graphics/stk_mesh_scene_node.hpp"
|
||||
#include "graphics/weather.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "karts/abstract_kart.hpp"
|
||||
#include "karts/kart_model.hpp"
|
||||
@ -1635,6 +1636,17 @@ FrameBuffer *PostProcessing::render(scene::ICameraSceneNode * const camnode,
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
}
|
||||
|
||||
// Handle lightning rendering
|
||||
if (World::getWorld() != NULL)
|
||||
{
|
||||
Weather* m_weather = World::getWorld()->getWeather();
|
||||
|
||||
if (m_weather != NULL && m_weather->shouldLightning())
|
||||
{
|
||||
renderLightning(m_weather->getIntensity());
|
||||
}
|
||||
}
|
||||
|
||||
// Workaround a bug with srgb fbo on sandy bridge windows
|
||||
if (!CVS->isARBUniformBufferObjectUsable())
|
||||
return in_fbo;
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "graphics/weather.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "states_screens/race_gui.hpp"
|
||||
#include "utils/random_generator.hpp"
|
||||
|
||||
|
||||
@ -28,11 +27,12 @@
|
||||
|
||||
Weather::Weather(bool lightning, std::string sound)
|
||||
{
|
||||
m_lightning = lightning;
|
||||
m_lightning_enabled = lightning;
|
||||
m_thunder_sound = NULL;
|
||||
m_weather_sound = NULL;
|
||||
m_lightning = 0.0f;
|
||||
|
||||
if (m_lightning)
|
||||
if (m_lightning_enabled)
|
||||
{
|
||||
m_thunder_sound = SFXManager::get()->createSoundSource("thunder");
|
||||
}
|
||||
@ -61,27 +61,30 @@ Weather::~Weather()
|
||||
|
||||
void Weather::update(float dt)
|
||||
{
|
||||
if (m_lightning)
|
||||
{
|
||||
if (!m_lightning_enabled)
|
||||
return;
|
||||
|
||||
if (World::getWorld()->getRaceGUI() == NULL)
|
||||
return;
|
||||
|
||||
m_next_lightning -= dt;
|
||||
|
||||
if (m_next_lightning < 0.0f)
|
||||
{
|
||||
RaceGUIBase* gui_base = World::getWorld()->getRaceGUI();
|
||||
|
||||
if (gui_base != NULL)
|
||||
{
|
||||
gui_base->doLightning();
|
||||
startLightning();
|
||||
|
||||
if (m_thunder_sound)
|
||||
{
|
||||
m_thunder_sound->play();
|
||||
}
|
||||
}
|
||||
|
||||
RandomGenerator g;
|
||||
m_next_lightning = 35 + (float)g.get(35);
|
||||
}
|
||||
|
||||
if (m_lightning > 0.0f)
|
||||
{
|
||||
m_lightning -= dt;
|
||||
}
|
||||
} // update
|
||||
|
||||
@ -95,3 +98,12 @@ void Weather::playSound()
|
||||
m_weather_sound->play();
|
||||
}
|
||||
}
|
||||
|
||||
irr::core::vector3df Weather::getIntensity()
|
||||
{
|
||||
irr::core::vector3df value = {0.7f * m_lightning,
|
||||
0.7f * m_lightning,
|
||||
0.7f * std::min(1.0f, m_lightning * 1.5f)};
|
||||
|
||||
return value;
|
||||
}
|
||||
|
@ -19,12 +19,15 @@
|
||||
#ifndef HEADER_WEATHER_HPP
|
||||
#define HEADER_WEATHER_HPP
|
||||
|
||||
#include <vector3d.h>
|
||||
|
||||
class SFXBase;
|
||||
|
||||
class Weather
|
||||
{
|
||||
bool m_lightning;
|
||||
bool m_lightning_enabled;
|
||||
float m_next_lightning;
|
||||
float m_lightning;
|
||||
|
||||
SFXBase* m_thunder_sound;
|
||||
SFXBase* m_weather_sound;
|
||||
@ -35,6 +38,12 @@ public:
|
||||
|
||||
void update(float dt);
|
||||
void playSound();
|
||||
|
||||
/** Set the flag that a lightning should be shown. */
|
||||
void startLightning() { m_lightning = 1.0f; }
|
||||
bool shouldLightning() { return m_lightning > 0.0f; }
|
||||
|
||||
irr::core::vector3df getIntensity();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -59,7 +59,6 @@ namespace irr
|
||||
RaceGUIBase::RaceGUIBase()
|
||||
{
|
||||
m_ignore_unimportant_messages = false;
|
||||
m_lightning = 0.0f;
|
||||
m_max_font_height = GUIEngine::getFontHeight() + 10;
|
||||
m_small_font_max_height = GUIEngine::getSmallFontHeight() + 5;
|
||||
//I18N: as in "ready, set, go", shown at the beginning of the race
|
||||
@ -341,7 +340,6 @@ void RaceGUIBase::drawPowerupIcons(const AbstractKart* kart,
|
||||
*/
|
||||
void RaceGUIBase::renderGlobal(float dt)
|
||||
{
|
||||
if (m_lightning > 0.0f) m_lightning -= dt;
|
||||
|
||||
} // renderGlobal
|
||||
|
||||
@ -412,73 +410,7 @@ void RaceGUIBase::preRenderCallback(const Camera *camera)
|
||||
// ----------------------------------------------------------------------------
|
||||
void RaceGUIBase::renderPlayerView(const Camera *camera, float dt)
|
||||
{
|
||||
if (CVS->isGLSL())
|
||||
{
|
||||
if (m_lightning > 0.0f)
|
||||
{
|
||||
core::vector3df intensity = {0.7f * m_lightning,
|
||||
0.7f * m_lightning,
|
||||
0.7f * std::min(1.0f, m_lightning * 1.5f)};
|
||||
irr_driver->getPostProcessing()->renderLightning(intensity);
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
const core::recti &viewport = camera->getViewport();
|
||||
|
||||
if (m_lightning > 0.0f)
|
||||
{
|
||||
GLint glviewport[4];
|
||||
glviewport[0] = viewport.UpperLeftCorner.X;
|
||||
glviewport[1] = viewport.UpperLeftCorner.Y;
|
||||
glviewport[2] = viewport.LowerRightCorner.X;
|
||||
glviewport[3] = viewport.LowerRightCorner.Y;
|
||||
//glGetIntegerv(GL_VIEWPORT, glviewport);
|
||||
|
||||
if (!irr::video::useCoreContext)
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
glColor4f(0.7f*m_lightning, 0.7f*m_lightning, 0.7f*std::min(1.0f, m_lightning*1.5f), 1.0f);
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
glVertex3d(glviewport[0],glviewport[1],0);
|
||||
glVertex3d(glviewport[0],glviewport[3],0);
|
||||
glVertex3d(glviewport[2],glviewport[3],0);
|
||||
glVertex3d(glviewport[2],glviewport[1],0);
|
||||
glEnd();
|
||||
if (!irr::video::useCoreContext)
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
else
|
||||
{
|
||||
GLint glviewport[4];
|
||||
glGetIntegerv(GL_VIEWPORT, glviewport);
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glColor4f(0.0f, 0.0f, 0.0f, 0.4f);
|
||||
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
glVertex3d(glviewport[0],glviewport[1],0);
|
||||
glVertex3d(glviewport[0],glviewport[3],0);
|
||||
glVertex3d(glviewport[2],glviewport[3],0);
|
||||
glVertex3d(glviewport[2],glviewport[1],0);
|
||||
glEnd();
|
||||
glEnable(GL_BLEND);
|
||||
}
|
||||
#endif
|
||||
} // renderPlayerView
|
||||
|
||||
|
||||
|
@ -68,9 +68,6 @@ public:
|
||||
}; // KartIconDisplayInfo
|
||||
|
||||
private:
|
||||
/** Delight in seconds between lightnings. */
|
||||
float m_lightning;
|
||||
|
||||
/** True if unimportant messags (like item messages) should not
|
||||
* be displayed. */
|
||||
bool m_ignore_unimportant_messages;
|
||||
@ -239,9 +236,6 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void clearAllMessages() { m_messages.clear(); }
|
||||
|
||||
/** Set the flag that a lightning should be shown. */
|
||||
void doLightning() { m_lightning = 1.0f; }
|
||||
|
||||
void drawGlobalPlayerIcons(int bottom_margin);
|
||||
|
||||
}; // RaceGUIBase
|
||||
|
Loading…
x
Reference in New Issue
Block a user