Huge refactoring v3

master
Vectozavr 2021-10-30 16:39:44 +07:00
parent 30ff702609
commit 61341d1b05
6 changed files with 21 additions and 24 deletions

View File

@ -70,7 +70,6 @@ void Shooter::InitNetwork() {
void Shooter::start() { void Shooter::start() {
// This code executed once in the beginning: // This code executed once in the beginning:
setDebugText(false);
setUpdateWorld(false); setUpdateWorld(false);
screen->setMouseCursorVisible(true); screen->setMouseCursorVisible(true);

View File

@ -14,7 +14,8 @@ namespace Consts {
const std::string PROJECT_NAME = "engine"; const std::string PROJECT_NAME = "engine";
const bool USE_LOG_FILE = true; const bool USE_LOG_FILE = true;
const bool USE_OPEN_GL = true; const bool USE_OPEN_GL = true;
const bool SHOW_COORDINATES = true; const bool SHOW_DEBUG_INFO = false;
const bool SHOW_FPS_COUNTER = true;
const double PI = 3.14159265358979323846264338327950288; const double PI = 3.14159265358979323846264338327950288;
const double EPS = 0.000001; const double EPS = 0.000001;

View File

@ -69,6 +69,10 @@ void Engine::create(int screenWidth, int screenHeight, const std::string &name,
_triPerSec = camera->buffSize() * Time::fps(); _triPerSec = camera->buffSize() * Time::fps();
} }
if (Consts::SHOW_FPS_COUNTER) {
screen->drawText(std::to_string(Time::fps()) + " fps", Vec2D(screen->width() - 100, 10), 25, sf::Color(100,100,100));
}
printDebugText(); printDebugText();
gui(); gui();
} }
@ -91,8 +95,9 @@ void Engine::exit() {
} }
void Engine::printDebugText() const { void Engine::printDebugText() const {
if (_debugText) { if (_debugText) {
std::string str = _name + "\n\n X: " + std::string text = _name + "\n\n X: " +
std::to_string((camera->position().x())) + "\n Y: " + std::to_string((camera->position().x())) + "\n Y: " +
std::to_string((camera->position().y())) + "\n Z: " + std::to_string((camera->position().y())) + "\n Z: " +
std::to_string((camera->position().z())) + "\n\n" + std::to_string((camera->position().z())) + "\n\n" +
@ -100,10 +105,19 @@ void Engine::printDebugText() const {
std::to_string(screen->height()) + "\t" + std::to_string(screen->height()) + "\t" +
std::to_string(Time::fps()) + " fps"; std::to_string(Time::fps()) + " fps";
if(_useOpenGL) { if(_useOpenGL) {
str += "\n Using OpenGL acceleration"; text += "\n Using OpenGL acceleration";
} else { } else {
str += "\n" + std::to_string((int) _triPerSec) + " tris/s"; text += "\n" + std::to_string((int) _triPerSec) + " tris/s";
} }
screen->debugText(str);
sf::Text t;
t.setFont(*ResourceManager::loadFont(Consts::THIN_FONT));
t.setString(text);
t.setCharacterSize(30);
t.setFillColor(sf::Color::Black);
t.setPosition(screen->width() - 400, 10);
screen->drawText(t);
} }
} }

View File

@ -19,7 +19,7 @@ private:
double _triPerSec = 0; double _triPerSec = 0;
bool _updateWorld = true; bool _updateWorld = true;
bool _debugText = Consts::SHOW_COORDINATES; bool _debugText = Consts::SHOW_DEBUG_INFO;
bool _useOpenGL = Consts::USE_OPEN_GL; bool _useOpenGL = Consts::USE_OPEN_GL;
void printDebugText() const; void printDebugText() const;

View File

@ -72,21 +72,6 @@ void Screen::close() {
_window->close(); _window->close();
} }
void Screen::debugText(const std::string& text) {
sf::Text t;
t.setFont(*ResourceManager::loadFont(Consts::THIN_FONT));
t.setString(text);
t.setCharacterSize(30);
t.setFillColor(sf::Color::Black);
t.setPosition(10, 50);
_window->pushGLStates();
_window->draw(t);
_window->popGLStates();
}
void Screen::setMouseCursorVisible(bool visible) { void Screen::setMouseCursorVisible(bool visible) {
_window->setMouseCursorVisible(visible); _window->setMouseCursorVisible(visible);
} }

View File

@ -48,8 +48,6 @@ public:
void close(); void close();
void debugText(const std::string& text);
void setMouseCursorVisible(bool visible); void setMouseCursorVisible(bool visible);
// OpenGL functions // OpenGL functions