From 8a9b215259a0c05401847440e0499c74934e6693 Mon Sep 17 00:00:00 2001 From: Vectozavr <60608292+vectozavr@users.noreply.github.com> Date: Fri, 5 Nov 2021 16:34:46 +0700 Subject: [PATCH] add switching between opengl and pure programming render mode --- Shooter.cpp | 4 ++++ Source.cpp | 2 +- engine/Camera.h | 2 +- engine/Engine.h | 1 + engine/animation/Timeline.cpp | 5 +++++ 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Shooter.cpp b/Shooter.cpp index 0bccd1e..4e86fa3 100644 --- a/Shooter.cpp +++ b/Shooter.cpp @@ -158,6 +158,10 @@ void Shooter::update() { screen->setMouseCursorVisible(!inGame); } + if (keyboard->isKeyTapped(sf::Keyboard::O)) { + setGlEnable(!glEnable()); + } + if (keyboard->isKeyTapped(sf::Keyboard::Tab)) { setDebugInfo(!showDebugInfo()); } diff --git a/Source.cpp b/Source.cpp index 6525480..1737a7f 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, false); + game.create(1280, 720, ShooterConsts::PROJECT_NAME, true); //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/Camera.h b/engine/Camera.h index 4064792..4c82757 100644 --- a/engine/Camera.h +++ b/engine/Camera.h @@ -25,7 +25,7 @@ public: Camera(const Camera &camera) = delete; - void init(int width, int height, double fov = 110.0, double ZNear = 0.1, double ZFar = 5000.0); + void init(int width, int height, double fov = 90.0, double ZNear = 0.1, double ZFar = 5000.0); std::vector> project(std::shared_ptr mesh); diff --git a/engine/Engine.h b/engine/Engine.h index effdb19..e8e4f2b 100644 --- a/engine/Engine.h +++ b/engine/Engine.h @@ -41,6 +41,7 @@ protected: void setUpdateWorld(bool value) { _updateWorld = value; } void setGlEnable(bool value) { _useOpenGL = value; } + [[nodiscard]] bool glEnable() const { return _useOpenGL; } virtual void gui() {} diff --git a/engine/animation/Timeline.cpp b/engine/animation/Timeline.cpp index 8e01319..7109559 100644 --- a/engine/animation/Timeline.cpp +++ b/engine/animation/Timeline.cpp @@ -70,8 +70,13 @@ void Timeline::update() { return; } + // TODO: sometimes I catch an exception here: EXC_BAD_ACCESS (code=EXC_I386_GPFLT) for (auto&[listName, animationList] : _instance->_animations) { if (animationList.empty()) { + /* + * TODO If you delete this line you will not catch an exception. + * Maybe something wrong with std::map::erase() + */ _instance->_animations.erase(listName); continue; }