Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - dogunbound

Pages: [1]
1
On ArchLinux kde plasma + x11, I noticed that if you call setSize, then poll for events, a Resized event gets polled.

I was just curious if it is guaranteed that this will happen. I'm pretty sure it's a side-effect of the event being propagated from the underlying API (window's API, x11, etc...). Is there some sense of guarantee this will happen?

2
A simple question just reworded:

Is it possible for a MouseButtonPressed event to have different x, and y positions for the mouse's coordinates than the previous MouseMove event?




Answer: Yes

3
I wrote this small bit of code to familiarize myself with C++ again:

int main() {
  // Crashes if font fails to load
  const sf::Font font = load_font().value();
  sf::RenderWindow window(sf::VideoMode(800, 600), "Game Of Life");
  window.setVerticalSyncEnabled(false);
  const sf::Vector2u window_size = window.getSize();

  // UI
  sf::Text title = center_text_origin(sf::Text("Game of Life", font, FONT_SIZE));
  title.setStyle(sf::Text::Bold);
  const auto set_title_position = [](sf::Text &title, sf::Vector2u window_size) {
    float amt_push_downwards = title.getLocalBounds().height / 2 + 10;
    sf::Vector2f pos = sf::Vector2f(
        window_size.x / 2.0,
        amt_push_downwards
        );
    title.setPosition(pos);
  };

  while (window.isOpen()) {
    sf::Event event;
    while (window.pollEvent(event)) {
      switch (event.type) {
        case sf::Event::Closed:
          window.close();
          break;
        case sf::Event::Resized:
          {
            const sf::FloatRect new_window_area(0.f, 0.f, event.size.width, event.size.height);
            const sf::Vector2u new_window_size(rect_size(new_window_area));
            window.setView(sf::View(new_window_area));

            set_title_position(title, new_window_size);
          }
          break;
        default:
          break;
      }
    }

    window.clear();
    window.draw(title);
    window.display();
  }

  return 0;
}
 

I noticed that my title text does not need to have an initialized position set, as the resize event gets triggered when RenderWindow is initialized. Is this guaranteed? Is this a quirk that may or may not be prevalent in future versions of SFML?

4
C / When will setSmooth be implemented for Fonts?
« on: July 04, 2022, 08:21:18 am »
What I want is the ability to disable set_smooth in rust-sfml. That's three jumps away from the main repository, but the main repository, thankfully, already has the setSmooth functionality for Fonts https://github.com/SFML/SFML/pull/1690

I read into CSFML, and I'll be honest. I have no clue what is going on. I want to know how doable it is to possibly implement setSmooth for CSFML that way I can help move it to rust-sfml.

Thank you.

5
Graphics / What is sfml sprite default behavior with undefined texture rect
« on: December 30, 2021, 05:51:04 am »
Here is the example code of what I am curious about:
sprite = sf::Sprite(*assets::missingTexture));
sprite.getLocalBounds();

sprite.getLocalBounds() should return a FloatRect with a width and height corresponding to the size of the missingTexture, correct?
Wiki doesn't explain something as specific as this, so I want some confirmation whether this is true or false.

Thank you.

Pages: [1]
anything