diff --git a/Shooter.cpp b/Shooter.cpp index 4e86fa3..c95514f 100644 --- a/Shooter.cpp +++ b/Shooter.cpp @@ -182,7 +182,6 @@ void Shooter::update() { } void Shooter::gui() { - sf::Sprite sprite; sprite.setTexture(*ResourceManager::loadTexture(ShooterConsts::MAIN_MENU_GUI)); sprite.setTextureRect(sf::IntRect(243, 3, 9, 9)); diff --git a/Source.cpp b/Source.cpp index 1737a7f..6525480 100644 --- a/Source.cpp +++ b/Source.cpp @@ -10,7 +10,7 @@ using namespace std; int main() { Shooter game; - game.create(1280, 720, ShooterConsts::PROJECT_NAME, true); + game.create(1280, 720, ShooterConsts::PROJECT_NAME, false); //game.create(1920, 1080, ShooterConsts::PROJECT_NAME, true, Consts::BACKGROUND_COLOR, sf::Style::Fullscreen); //game.create(2048, 1152, ShooterConsts::PROJECT_NAME, false); diff --git a/engine/Engine.cpp b/engine/Engine.cpp index 87e332b..c3ecc63 100644 --- a/engine/Engine.cpp +++ b/engine/Engine.cpp @@ -84,14 +84,15 @@ void Engine::create(int screenWidth, int screenHeight, const std::string &name, } Time::stopTimer("d projections"); + screen->pushGLStates(); if (Consts::SHOW_FPS_COUNTER) { screen->drawText(std::to_string(Time::fps()) + " fps", Vec2D(static_cast(screen->width()) - 100.0, 10.0), 25, sf::Color(100, 100, 100)); } - printDebugInfo(); gui(); + screen->popGLStates(); } screen->display(); @@ -162,7 +163,7 @@ void Engine::printDebugInfo() const { Vec2D{xPos, yPos + height + height * i}, {static_cast(255.0 * static_cast(width) / timerWidth), static_cast(255.0 * (1.0 - static_cast(width) / timerWidth)), - 0, 150}); + 0, 100}); screen->drawText( @@ -170,7 +171,7 @@ void Engine::printDebugInfo() const { std::to_string((int) (1.0 / timer.elapsedMilliseconds())) + " / s \t (" + std::to_string((int) (100 * timer.elapsedMilliseconds() / totalTime)) + "%)", Vec2D{xPos + 10, yPos + height * i + 5}, 30, - sf::Color(0, 0, 0, 200)); + sf::Color(0, 0, 0, 150)); i++; timeSum += timer.elapsedMilliseconds(); @@ -183,13 +184,13 @@ void Engine::printDebugInfo() const { Vec2D{xPos, yPos + height + height * i}, {static_cast(255.0 * static_cast(width) / timerWidth), static_cast(255.0 * (1.0 - static_cast(width) / timerWidth)), - 0, 150}); + 0, 100}); screen->drawText("other:\t" + std::to_string((int) (1.0 / (totalTime - timeSum))) + " / s \t (" + std::to_string((int) (100 * (totalTime - timeSum) / totalTime)) + "%)", Vec2D{xPos + 10, yPos + height * i + 5}, 30, - sf::Color(0, 0, 0, 200)); + sf::Color(0, 0, 0, 150)); } } diff --git a/engine/Screen.cpp b/engine/Screen.cpp index 7ced20c..f1d0f05 100644 --- a/engine/Screen.cpp +++ b/engine/Screen.cpp @@ -57,9 +57,7 @@ void Screen::drawTriangle(const Triangle &triangle) { triangle.color()) }; - _window->pushGLStates(); _window->draw(tris, 3, sf::Triangles); - _window->popGLStates(); } void Screen::setTitle(const std::string &title) { @@ -87,9 +85,7 @@ void Screen::drawTetragon(const Vec2D &p1, const Vec2D &p2, const Vec2D &p3, con polygon.setPoint(3, sf::Vector2f(static_cast(p4.x()), static_cast(p4.y()))); polygon.setFillColor(color); - _window->pushGLStates(); _window->draw(polygon); - _window->popGLStates(); } void Screen::drawText(const std::string &string, const Vec2D &position, int size, sf::Color color) { @@ -104,21 +100,15 @@ void Screen::drawText(const std::string &string, const Vec2D &position, int size text.setString(string); - _window->pushGLStates(); _window->draw(text); - _window->popGLStates(); } void Screen::drawSprite(const sf::Sprite &sprite) { - _window->pushGLStates(); _window->draw(sprite); - _window->popGLStates(); } void Screen::drawText(const sf::Text &text) { - _window->pushGLStates(); _window->draw(text); - _window->popGLStates(); } // OpenGL functions diff --git a/engine/Screen.h b/engine/Screen.h index d1616df..dbda99b 100644 --- a/engine/Screen.h +++ b/engine/Screen.h @@ -65,6 +65,9 @@ public: static GLfloat *glMeshToGLfloatArray(std::shared_ptr mesh); [[nodiscard]] std::shared_ptr renderWindow() { return _window; } + + void pushGLStates() { _window->pushGLStates(); }; + void popGLStates() { _window->popGLStates(); }; };