|
@@ -73,18 +73,22 @@ void IngameState::init()
|
|
_context->foreground = &_foreground;
|
|
_context->foreground = &_foreground;
|
|
|
|
|
|
_background.setTextureRect(sf::IntRect(0, 0, _foreground.getSize().x, _foreground.getSize().y));
|
|
_background.setTextureRect(sf::IntRect(0, 0, _foreground.getSize().x, _foreground.getSize().y));
|
|
|
|
+ _noshaders.setTextureRect(sf::IntRect(0, 0, _foreground.getSize().x, _foreground.getSize().y));
|
|
|
|
|
|
_pauseFrame.setFillColor(sf::Color(0, 0, 0, 155));
|
|
_pauseFrame.setFillColor(sf::Color(0, 0, 0, 155));
|
|
_pauseFrame.setPosition(0, 0);
|
|
_pauseFrame.setPosition(0, 0);
|
|
|
|
|
|
- _unshadowShader.loadFromFile("data/light/unshadowShader.frag", sf::Shader::Fragment);
|
|
|
|
- _lightOverShapeShader.loadFromFile("data/light/lightOverShapeShader.frag", sf::Shader::Fragment);
|
|
|
|
- _normalsShader.loadFromFile("data/light/normalsShader.frag", sf::Shader::Fragment);
|
|
|
|
- _penumbraTexture.loadFromFile("data/light/penumbraTexture.png");
|
|
|
|
- _penumbraTexture.setSmooth(true);
|
|
|
|
|
|
+ if(sf::Shader::isAvailable())
|
|
|
|
+ {
|
|
|
|
+ _unshadowShader.loadFromFile("data/light/unshadowShader.frag", sf::Shader::Fragment);
|
|
|
|
+ _lightOverShapeShader.loadFromFile("data/light/lightOverShapeShader.frag", sf::Shader::Fragment);
|
|
|
|
+ _normalsShader.loadFromFile("data/light/normalsShader.frag", sf::Shader::Fragment);
|
|
|
|
+ _penumbraTexture.loadFromFile("data/light/penumbraTexture.png");
|
|
|
|
+ _penumbraTexture.setSmooth(true);
|
|
|
|
|
|
- _blurV.loadFromFile("data/shaders/old_pi_blur/blur.vert", "data/shaders/old_pi_blur/blur-v.frag");
|
|
|
|
- _blurH.loadFromFile("data/shaders/old_pi_blur/blur.vert", "data/shaders/old_pi_blur/blur-h.frag");
|
|
|
|
|
|
+ _blurV.loadFromFile("data/shaders/old_pi_blur/blur.vert", "data/shaders/old_pi_blur/blur-v.frag");
|
|
|
|
+ _blurH.loadFromFile("data/shaders/old_pi_blur/blur.vert", "data/shaders/old_pi_blur/blur-h.frag");
|
|
|
|
+ }
|
|
|
|
|
|
_marioSound.setBuffer(_context->assets->loadSound("data/audio/Mario.ogg"));
|
|
_marioSound.setBuffer(_context->assets->loadSound("data/audio/Mario.ogg"));
|
|
_dotaSound.setBuffer(_context->assets->loadSound("data/audio/Victory.ogg"));
|
|
_dotaSound.setBuffer(_context->assets->loadSound("data/audio/Victory.ogg"));
|
|
@@ -116,10 +120,8 @@ void IngameState::init()
|
|
void IngameState::refresh()
|
|
void IngameState::refresh()
|
|
{
|
|
{
|
|
sf::Vector2u res = _context->window->getSize();
|
|
sf::Vector2u res = _context->window->getSize();
|
|
- //_background.setTextureRect(sf::IntRect(0, 0, _context->window->getSize().x, _context->window->getSize().y));
|
|
|
|
_camera.setSize(static_cast<sf::Vector2f>(_context->window->getSize()));
|
|
_camera.setSize(static_cast<sf::Vector2f>(_context->window->getSize()));
|
|
_camera.setTwilightViewport(_context->window->getSize().x / 2.f - 240.f/* * (bool) _czyWOgóleTwilightViewportMaByć*/, _context->window->getSize().y / 2.f - 240.f);
|
|
_camera.setTwilightViewport(_context->window->getSize().x / 2.f - 240.f/* * (bool) _czyWOgóleTwilightViewportMaByć*/, _context->window->getSize().y / 2.f - 240.f);
|
|
- //_camera.setTwilightViewport(0, 0);
|
|
|
|
_camera.setCenter(_player.getPosition());
|
|
_camera.setCenter(_player.getPosition());
|
|
_foreground.setResolution(res);
|
|
_foreground.setResolution(res);
|
|
|
|
|
|
@@ -134,13 +136,16 @@ void IngameState::refresh()
|
|
_backgroundH.create(_context->window->getSize().x, _context->window->getSize().y);
|
|
_backgroundH.create(_context->window->getSize().x, _context->window->getSize().y);
|
|
_backgroundV.create(_context->window->getSize().x, _context->window->getSize().y);
|
|
_backgroundV.create(_context->window->getSize().x, _context->window->getSize().y);
|
|
|
|
|
|
- _lightSystem.create(sf::FloatRect{{0.f, 0.f}, {0.f, 0.f}}, {_context->window->getSize().x, _context->window->getSize().y}, _penumbraTexture, _unshadowShader, _lightOverShapeShader, _normalsShader);
|
|
|
|
- _lightSystem.normalsEnabled(true);
|
|
|
|
- _lightSystem.addLight(_player.light());
|
|
|
|
- _lightSystem.addLight(_wormhole.light());
|
|
|
|
- unsigned k = _star.size();
|
|
|
|
- for(unsigned i = 0; i < k; ++i)
|
|
|
|
- _lightSystem.addLight(_star[i].light());
|
|
|
|
|
|
+ if(sf::Shader::isAvailable())
|
|
|
|
+ {
|
|
|
|
+ _lightSystem.create(sf::FloatRect{{0.f, 0.f}, {0.f, 0.f}}, {_context->window->getSize().x, _context->window->getSize().y}, _penumbraTexture, _unshadowShader, _lightOverShapeShader, _normalsShader);
|
|
|
|
+ _lightSystem.normalsEnabled(true);
|
|
|
|
+ _lightSystem.addLight(_player.light());
|
|
|
|
+ _lightSystem.addLight(_wormhole.light());
|
|
|
|
+ unsigned k = _star.size();
|
|
|
|
+ for(unsigned i = 0; i < k; ++i)
|
|
|
|
+ _lightSystem.addLight(_star[i].light());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
void IngameState::coreThink(const sf::Event& event)
|
|
void IngameState::coreThink(const sf::Event& event)
|
|
@@ -179,8 +184,11 @@ void IngameState::coreUpdate(sf::Time delta)
|
|
color.a = (int)_frameAlpha;
|
|
color.a = (int)_frameAlpha;
|
|
_pauseFrame.setFillColor(color);
|
|
_pauseFrame.setFillColor(color);
|
|
|
|
|
|
- _blurH.setParameter("blurSize", _blurSize / _context->window->getSize().x);
|
|
|
|
- _blurV.setParameter("blurSize", _blurSize / _context->window->getSize().y);
|
|
|
|
|
|
+ if(_context->shaders)
|
|
|
|
+ {
|
|
|
|
+ _blurH.setParameter("blurSize", _blurSize / _context->window->getSize().x);
|
|
|
|
+ _blurV.setParameter("blurSize", _blurSize / _context->window->getSize().y);
|
|
|
|
+ }
|
|
|
|
|
|
if((_wasted.getPosition().y > _context->window->getSize().y / 2.f)
|
|
if((_wasted.getPosition().y > _context->window->getSize().y / 2.f)
|
|
|| (_wasted.getPosition().y > -int(_context->window->getSize().y) / 2.f
|
|
|| (_wasted.getPosition().y > -int(_context->window->getSize().y) / 2.f
|
|
@@ -285,25 +293,29 @@ void IngameState::coreUpdate(sf::Time delta)
|
|
direction = false;
|
|
direction = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-void IngameState::coreRender(const bool shaders)
|
|
|
|
|
|
+void IngameState::coreRender()
|
|
{
|
|
{
|
|
- if(_player.isDead())
|
|
|
|
|
|
+ if(_player.isDead() && _context->shaders)
|
|
{
|
|
{
|
|
_backgroundH.draw(_background);
|
|
_backgroundH.draw(_background);
|
|
_backgroundH.setView(*_camera.getView());
|
|
_backgroundH.setView(*_camera.getView());
|
|
_backgroundH.draw(_foreground);
|
|
_backgroundH.draw(_foreground);
|
|
|
|
+ for(unsigned i = 0; i < _star.size(); ++i)
|
|
|
|
+ _backgroundH.draw(_star[i]);
|
|
_backgroundH.draw(_wormhole);
|
|
_backgroundH.draw(_wormhole);
|
|
_backgroundH.draw(_player);
|
|
_backgroundH.draw(_player);
|
|
sf::Sprite sprite3(_lightSystem.getLightingTexture());
|
|
sf::Sprite sprite3(_lightSystem.getLightingTexture());
|
|
|
|
+
|
|
sf::RenderStates lightRenderStates;
|
|
sf::RenderStates lightRenderStates;
|
|
lightRenderStates.blendMode = sf::BlendMultiply;
|
|
lightRenderStates.blendMode = sf::BlendMultiply;
|
|
_backgroundH.setView(_context->window->getDefaultView());
|
|
_backgroundH.setView(_context->window->getDefaultView());
|
|
_backgroundH.draw(sprite3, lightRenderStates);
|
|
_backgroundH.draw(sprite3, lightRenderStates);
|
|
-
|
|
|
|
|
|
+
|
|
sf::Sprite sprite(_backgroundH.getTexture());
|
|
sf::Sprite sprite(_backgroundH.getTexture());
|
|
sprite.setScale(1.f, -1.f);
|
|
sprite.setScale(1.f, -1.f);
|
|
sprite.setOrigin(0, _context->window->getSize().y);
|
|
sprite.setOrigin(0, _context->window->getSize().y);
|
|
sprite.setPosition(0.f, 0.f);
|
|
sprite.setPosition(0.f, 0.f);
|
|
|
|
+
|
|
_backgroundV.draw(sprite, &_blurH);
|
|
_backgroundV.draw(sprite, &_blurH);
|
|
|
|
|
|
sf::Sprite sprite2(_backgroundV.getTexture());
|
|
sf::Sprite sprite2(_backgroundV.getTexture());
|
|
@@ -312,6 +324,7 @@ void IngameState::coreRender(const bool shaders)
|
|
sprite2.setPosition(0.f, 0.f);
|
|
sprite2.setPosition(0.f, 0.f);
|
|
_context->window->draw(sprite2, &_blurH);
|
|
_context->window->draw(sprite2, &_blurH);
|
|
_context->window->draw(_pauseFrame);
|
|
_context->window->draw(_pauseFrame);
|
|
|
|
+
|
|
_context->window->draw(_wasted);
|
|
_context->window->draw(_wasted);
|
|
_context->window->draw(_statsTime);
|
|
_context->window->draw(_statsTime);
|
|
_context->window->draw(_statsHull);
|
|
_context->window->draw(_statsHull);
|
|
@@ -322,14 +335,15 @@ void IngameState::coreRender(const bool shaders)
|
|
_context->window->setView(_camera.getView());
|
|
_context->window->setView(_camera.getView());
|
|
_context->window->draw(_background);
|
|
_context->window->draw(_background);
|
|
|
|
|
|
-
|
|
|
|
- _foreground.renderNormals(true);
|
|
|
|
- _lightSystem.normalsTargetSetView(*_camera.getView());
|
|
|
|
- _lightSystem.normalsTargetClear();
|
|
|
|
- _lightSystem.normalsTargetDraw(_foreground);
|
|
|
|
- _lightSystem.normalsTargetDisplay();
|
|
|
|
- _lightSystem.render(*_camera.getView(), _unshadowShader, _lightOverShapeShader, _normalsShader);
|
|
|
|
-
|
|
|
|
|
|
+ if(_context->shaders)
|
|
|
|
+ {
|
|
|
|
+ _foreground.renderNormals(true);
|
|
|
|
+ _lightSystem.normalsTargetSetView(*_camera.getView());
|
|
|
|
+ _lightSystem.normalsTargetClear();
|
|
|
|
+ _lightSystem.normalsTargetDraw(_foreground);
|
|
|
|
+ _lightSystem.normalsTargetDisplay();
|
|
|
|
+ _lightSystem.render(*_camera.getView(), _unshadowShader, _lightOverShapeShader, _normalsShader);
|
|
|
|
+ }
|
|
|
|
|
|
_foreground.renderNormals(false);
|
|
_foreground.renderNormals(false);
|
|
_context->window->draw(_foreground);
|
|
_context->window->draw(_foreground);
|
|
@@ -337,15 +351,24 @@ void IngameState::coreRender(const bool shaders)
|
|
_context->window->draw(_star[i]);
|
|
_context->window->draw(_star[i]);
|
|
_context->window->draw(_wormhole);
|
|
_context->window->draw(_wormhole);
|
|
_context->window->draw(_player);
|
|
_context->window->draw(_player);
|
|
-
|
|
|
|
-
|
|
|
|
_context->window->setView();
|
|
_context->window->setView();
|
|
- sf::Sprite sprite(_lightSystem.getLightingTexture());
|
|
|
|
- sf::RenderStates lightRenderStates;
|
|
|
|
- lightRenderStates.blendMode = sf::BlendMultiply;
|
|
|
|
- _context->window->draw(sprite, lightRenderStates);
|
|
|
|
-
|
|
|
|
- if(_paused)
|
|
|
|
|
|
+
|
|
|
|
+ if(_context->shaders)
|
|
|
|
+ {
|
|
|
|
+ sf::Sprite sprite(_lightSystem.getLightingTexture());
|
|
|
|
+ sf::RenderStates lightRenderStates;
|
|
|
|
+ lightRenderStates.blendMode = sf::BlendMultiply;
|
|
|
|
+ _context->window->draw(sprite, lightRenderStates);
|
|
|
|
+ }
|
|
|
|
+ if(_player.isDead())
|
|
|
|
+ {
|
|
|
|
+ _context->window->draw(_pauseFrame);
|
|
|
|
+ _context->window->draw(_wasted);
|
|
|
|
+ _context->window->draw(_statsTime);
|
|
|
|
+ _context->window->draw(_statsHull);
|
|
|
|
+ _context->window->draw(_statsStars);
|
|
|
|
+ }
|
|
|
|
+ else if(_paused)
|
|
_context->window->draw(_pauseFrame);
|
|
_context->window->draw(_pauseFrame);
|
|
}
|
|
}
|
|
}
|
|
}
|