Log window is now working.

master
Zed A. Shaw 3 months ago
parent 8707982907
commit e7a226f1db
  1. 40
      sfmltest.cpp

@ -16,18 +16,19 @@ constexpr int FPS=30;
constexpr int X_DIM = 1920 / 2;
constexpr int Y_DIM = 1080 / 2;
bool window_active_out = false;
bool show_build_log = false;
void ImGui_setup(sf::RenderWindow &window) {
bool res = SFML::Init(window);
fmt::println("IMGUI returned {}", res);
}
void ImGui_update(sf::RenderWindow &window, sf::Clock &deltaClock, sf::Time &tick) {
void ImGui_update(sf::RenderWindow &window, sf::Clock &deltaClock) {
sf::Vector2u size = window.getSize();
SFML::Update(window, deltaClock.restart());
SetNextWindowPos(ImVec2(0, size.y / 2));
SetNextWindowPos(ImVec2(0, 0));
SetNextWindowSize(ImVec2(size.x, size.y / 2));
Begin("Build Status", &window_active_out);
@ -44,8 +45,7 @@ void ImGui_update(sf::RenderWindow &window, sf::Clock &deltaClock, sf::Time &tic
void Window_update(sf::RenderWindow &window, sf::Sprite &background) {
window.clear();
window.draw(background);
if(window_active_out) {
fmt::println(">>>> RENDER");
if(show_build_log) {
SFML::Render(window);
}
window.display();
@ -56,8 +56,7 @@ void Handle_events(sf::RenderWindow &window) {
// is this a main event loop
while (window.pollEvent(event)) {
if(window_active_out) {
fmt::println(">>> EVENTS");
if(show_build_log) {
SFML::ProcessEvent(window, event);
}
@ -69,10 +68,13 @@ void Handle_events(sf::RenderWindow &window) {
break;
case sf::Event::KeyPressed:
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)) {
window.close();
if(show_build_log) {
window_active_out = false;
} else {
window.close();
}
} else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Space)) {
fmt::println(">>> SET TRUE");
window_active_out = true;
window_active_out = !window_active_out;
}
break;
default:
@ -82,21 +84,13 @@ void Handle_events(sf::RenderWindow &window) {
}
}
sf::Time Update_entities(sf::RenderWindow &window, sf::Sprite &background, sf::Clock &clock, sf::Clock &deltaClock, sf::Time &tick) {
sf::Vector2u winSize = window.getSize();
float timeStep = 1.0f / FPS;
sf::Time since = clock.getElapsedTime();
sf::Time nextTick = since - tick > sf::seconds(1) ? since : tick;
void Update_entities(sf::RenderWindow &window, sf::Sprite &background, sf::Clock &clock, sf::Clock &deltaClock) {
background.setPosition(0, 0);
if(window_active_out) {
fmt::println("<<< UPDATE");
ImGui_update(window, deltaClock, tick);
if(show_build_log) {
ImGui_update(window, deltaClock);
}
Window_update(window, background);
return nextTick;
}
@ -115,7 +109,6 @@ int main() {
sf::Clock deltaClock;
sf::Clock clock;
sf::Time tick = clock.getElapsedTime();
sf::Texture texture;
sf::Sprite background;
@ -127,11 +120,10 @@ int main() {
background.setTexture(texture);
while (window.isOpen()) {
fmt::println(">>>>>>>>>>>>>>>>>> WINDOW LOOP");
Handle_events(window);
// preparing for refactoring this into a class or struct for everything
tick = Update_entities(window, background, clock, deltaClock, tick);
fmt::println("<<<<<<<<<<<<<<<< EXIT WINDOW LOOP");
Update_entities(window, background, clock, deltaClock);
show_build_log = window_active_out;
}
SFML::Shutdown();

Loading…
Cancel
Save