add switching between opengl and pure programming render mode

master
Vectozavr 2021-11-05 16:34:46 +07:00
parent 5f05a7cb23
commit 8a9b215259
5 changed files with 12 additions and 2 deletions

View File

@ -158,6 +158,10 @@ void Shooter::update() {
screen->setMouseCursorVisible(!inGame); screen->setMouseCursorVisible(!inGame);
} }
if (keyboard->isKeyTapped(sf::Keyboard::O)) {
setGlEnable(!glEnable());
}
if (keyboard->isKeyTapped(sf::Keyboard::Tab)) { if (keyboard->isKeyTapped(sf::Keyboard::Tab)) {
setDebugInfo(!showDebugInfo()); setDebugInfo(!showDebugInfo());
} }

View File

@ -10,7 +10,7 @@ using namespace std;
int main() { int main() {
Shooter game; 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(1920, 1080, ShooterConsts::PROJECT_NAME, true, Consts::BACKGROUND_COLOR, sf::Style::Fullscreen);
//game.create(2048, 1152, ShooterConsts::PROJECT_NAME, false); //game.create(2048, 1152, ShooterConsts::PROJECT_NAME, false);

View File

@ -25,7 +25,7 @@ public:
Camera(const Camera &camera) = delete; 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<std::shared_ptr<Triangle>> project(std::shared_ptr<Mesh> mesh); std::vector<std::shared_ptr<Triangle>> project(std::shared_ptr<Mesh> mesh);

View File

@ -41,6 +41,7 @@ protected:
void setUpdateWorld(bool value) { _updateWorld = value; } void setUpdateWorld(bool value) { _updateWorld = value; }
void setGlEnable(bool value) { _useOpenGL = value; } void setGlEnable(bool value) { _useOpenGL = value; }
[[nodiscard]] bool glEnable() const { return _useOpenGL; }
virtual void gui() {} virtual void gui() {}

View File

@ -70,8 +70,13 @@ void Timeline::update() {
return; return;
} }
// TODO: sometimes I catch an exception here: EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
for (auto&[listName, animationList] : _instance->_animations) { for (auto&[listName, animationList] : _instance->_animations) {
if (animationList.empty()) { 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); _instance->_animations.erase(listName);
continue; continue;
} }