Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imgui not letting specific text be drawn by SFML #238

Open
ojasmaheshwari opened this issue Mar 28, 2023 · 3 comments
Open

Imgui not letting specific text be drawn by SFML #238

ojasmaheshwari opened this issue Mar 28, 2023 · 3 comments

Comments

@ojasmaheshwari
Copy link

ojasmaheshwari commented Mar 28, 2023

#include <SFML/Graphics.hpp>
#include <imgui-SFML.h>
#include <imgui.h>

#define SCREEN_WIDTH 1000

int main(int argc, char *argv[]) {

  sf::RenderWindow window(sf::VideoMode(1000, 550), "Trajectory Simulator");

  ImGui::SFML::Init(window);

  sf::Clock deltaClock;

  sf::Font headingFont;
  headingFont.loadFromFile("assets/font/font.ttf");
  sf::Text heading("Trajectory Simulator", headingFont);
  heading.setCharacterSize(50);
  heading.setStyle(sf::Text::Regular);
  heading.setFillColor(sf::Color::Blue);
  float headingWidth = heading.getLocalBounds().width / 2;
  heading.setPosition(sf::Vector2f(SCREEN_WIDTH / 2.0 - headingWidth, 200));

  while (window.isOpen()) {
    sf::Event event;
    while (window.pollEvent(event)) {

      ImGui::SFML::ProcessEvent(window, event);

      if (event.type == sf::Event::Closed)
        window.close();
    }

    ImGui::SFML::Update(window, deltaClock.restart());
    ImGui::Begin("Testing");
    ImGui::Text("Hello world");
    ImGui::End();

    window.clear();
    window.draw(heading);
    ImGui::SFML::Render(window);
    window.display();
  }

  ImGui::SFML::Shutdown();
  return 0;
}

Before adding ImGui, the program was working perfectly fine and heading was being displayed. However, when I run this code it does not render the heading. It does for the 1st frame but after that nothing is rendered. Not even the imgui window.

I don't know what might be causing the issue. Heading is just a simple sf::Text object.

@eliasdaler
Copy link
Contributor

Try making a minimal repro - try taking out unnecessary detail until you're left with "heading" rendering and Dear ImGui rendering. See if the issue is reproducible even after that.

@ojasmaheshwari
Copy link
Author

@eliasdaler done, updated the original issue. Does not seem to work either.

@eliasdaler
Copy link
Contributor

Sorry it took me half a year to respond, but I can't repro this - I see the text
So, needs more info - which OS/desktop environment, which ImGui-SFML version, which ImGui version do you use?

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants