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.


Messages - MickeyKnox

Pages: [1] 2 3 4
1
Has anybody tried to reproduce this problem?

Could you kindly run above code snippet and post the output?

Is this happening on Windows too? Or just on Linux? Or is it just my machine doing something very weird?

2
Quote
Are you running wayland?
What's your window manager?

Gnome 46.5 on Wayland (Fedora 40 Workstation)

3
I've created this minimal example:

#include "SFML/Window.hpp"

int main()
{
    sf::Window window(sf::VideoMode(1280, 720), "piv", sf::Style::Default);

    bool fullscreen = false;

    sf::Event event;

    while (window.isOpen())
    {
        while (window.pollEvent(event))
        {
            switch (event.type)
            {
                case sf::Event::Closed:
                    window.close();
                    break;

                case sf::Event::KeyPressed:
                    switch (event.key.code)
                    {
                        case sf::Keyboard::Escape:
                            window.close();
                            break;

                        case sf::Keyboard::F:
                            printf("toggle fullscreen\n");
                            if (fullscreen)
                            {
                                window.create(sf::VideoMode(1280, 720), "piv", sf::Style::Default);
                                fullscreen = false;
                            }
                            else
                            {
                                window.create(sf::VideoMode::getDesktopMode(), "piv", sf::Style::Fullscreen);
                                fullscreen = true;
                            }
                            break;

                        default:
                            break;
                    }
                    break;

                case sf::Event::Resized:
                    printf("%d %d\n", event.size.width, event.size.height);
                    break;

                default:
                    break;
            }
        }
    }
}
 

And this is the output:

Quote
1280 720
toggle fullscreen
1920 1080
1920 1043
1920 1080
toggle fullscreen
1280 720
toggle fullscreen
1920 1080
1920 1043
1920 1080
toggle fullscreen
1280 720

Why are there three resize events when switching to fullscreen?

Why is there an event for this weird resolution of 1920x1043?

Am I doing something funny here?

SFML 2.6.1 on fedora linux.

4
Graphics / Re: origin relative to the Transformable
« on: September 06, 2024, 12:50:26 am »
Quote
The origin of a drawable should always be updated whenever the drawable is manipulated unless you can be sure that it doesn't need it for some reason. This is particularly important with texts that change string, fonts, styles, sizes etc..

I was proposing for SFML to handle this. Thus, when I set the origin of a text to its center, then update the string in the text, I wouldn't have to worry about updating the origin as well. Not a trivial thing, if this functionality is to be introduced to all Drawables...

5
Graphics / How to deal with textures in an animation?
« on: September 05, 2024, 11:54:05 pm »
I want to play animations that simply consist of images that should be updated after some delay. I see several ways to do this, but am uncertain if there is a preferred one.

Option 1:

I load all images of the animation into a texture each. During the animation I update the sprite with the correct texture.

One drawback I can think of is that I have a lot images in the graphics card memory that aren't currently drawn.

Option 2:

I have only one texture and update its pixels for each frame during the animation.

I think it was said that copying pixels to graphics memory is a costly operation. Does this outweight wasting lots of graphics memory with data currently not on screen?

Option 3:

I have a tilemap for the animation. Thus a single image with all the frames for the animation side by side. During the animation I update the rectangle of the sprite to where points to in the texture. This is just a variation of Option 1 I think.

Is there a general consensus that one is preffered over the other?

6
Graphics / Re: origin relative to the Transformable
« on: August 27, 2024, 07:42:14 pm »
I agree that the function itself would be trivial. However, when the Transformable is meant to preserve the relative origin (as in my example with setting a new string to the Text) it gets a bit trickier.

But if it doesn't fit with the rest of the API I have to accept that.

7
Graphics / Re: origin relative to the Transformable
« on: August 26, 2024, 09:01:56 pm »
Quote
I don't see us adding setRelativeOrigin

What do you mean by that? You're not willing to invest into the developement of that function? Or you wouldn't want that to be part of the API?

I'm asking as I might consider developing this function myself at some point; and, if that's appreciated, contribute it to SFML.

8
Graphics / origin relative to the Transformable
« on: August 26, 2024, 01:08:43 am »
I would like to set the origin of a Transformable to its center. So far I'm doing it like this:

text.setOrigin(text.getLocalBounds().width / 2, text.getLocalBounds().height / 2);

That's quite verbose I think. Moreover, once I set a new string to be displayed, I also need to calculate the origin again.

Instead, I would like to do something simple like: setRelativeOrigin(.5f, .5f) (with 0, 0 being top left; 1, 1 being lower right, and thus the center at 0.5, 0.5.)

Is something like this already possible and I've missed it? Otherwise I'd like to request it as a feature :)

9
Ups my bad. I just realized that I'm still on SFML 2.5.1. Accoding to the changelog, the missing function was introduced in 2.6

10
From this code

sprite.getGlobalBounds().getPosition()

I get this error:

error: ‘sf::FloatRect’ {aka ‘class sf::Rect<float>’} has no member named ‘getPosition’
   26 |         info.setPosition(image->sprite.getGlobalBounds().getPosition());
      |                                                          ^~~~~~~~~~~


Accoding to the documentation Rect does have a member getPosition: https://www.sfml-dev.org/documentation/2.6.1/classsf_1_1Rect.php

What am I missing?

11
General / How to build SFML on linux with a custom build folder?
« on: September 08, 2021, 09:46:32 pm »
The guide for building SFML with cmake https://www.sfml-dev.org/tutorials/2.5/compile-with-cmake.php seems to be focused on Windows.

What I've tried so far:

$ cmake ./build
CMake Error: The source directory "/home/ingmar/src/SFML/build" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.

$ mkdir build
$ cmake ./build
CMake Error: The source directory "/home/ingmar/src/SFML/build" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.

Should I just just move CMakeLists.txt to build? Will pathes in there still be correct?

Running cmake . does work, but the guide explicitly suggest to specify a build folder. How do I do that?

12
Window / sf::Mouse::isButtonPressed returns always false for XButtons
« on: September 04, 2021, 06:45:03 pm »
Consider this minimal example to reproduce the problem:

int main()
{
    sf::Window window(sf::VideoMode(800, 600), "test");

    sf::Event event;

    while (window.isOpen())
    {
        while (window.pollEvent(event))
        {
            switch (event.type)
            {
                case sf::Event::Closed:
                    window.close();
                    break;

                case sf::Event::MouseButtonPressed:
                    switch (event.mouseButton.button)
                    {
                        case sf::Mouse::XButton1:
                        case sf::Mouse::XButton2:
                        case sf::Mouse::Left:
                            if (sf::Mouse::isButtonPressed(sf::Mouse::XButton1))
                                std::cout << "XButton1 pressed" << std::endl;
                            else if (sf::Mouse::isButtonPressed(sf::Mouse::XButton2))
                                std::cout << "XButton2 pressed" << std::endl;
                            else if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
                                std::cout << "Left button pressed" << std::endl;
                            else
                                std::cout << "No button pressed" << std::endl;
                            break;
                        default:
                            break;
                    }
                    break;
            }
        }
    }
}
 

The event for the XButtons is fired, yet sf::Mouse::isButtonPressed returns false; the output is "No button pressed". The problem doesn't occur for the left mouse button, the output is as expected "Left button pressed".

Have I found a bug? Or is there something funny with my mouse? Tested on Ubuntu 20.04.

13
Window / [SOLVED] Prolonged key press timeout
« on: August 30, 2021, 07:53:59 pm »
When pressing a key an Event is fired for that key being pressed. After that there is a timeout, in which no Event is fired for the same key still being pressed. The timeout seems to be about one second. After the timeout an Event is fired every frame.

Is it possible to control the lenght of this timeout, setting it to 0? Or is it possible to simply disable the timeout?

14
Ok, I decided to add that portion to the background to give the text a little frame:

sf::FloatRect bounds = text.getLocalBounds();
sf::Vector2f size(bounds.left * 2 + bounds.width, bounds.top * 2 + bounds.height);
sf::RectangleShape background(size);

Just out of curiosity, what is the reason for there being a hidden offset in sf::Text?

15
Graphics / How to interpret the local bounds .getLocalBounds() of sf::Text?
« on: November 10, 2020, 10:19:54 pm »
I'm drawing a background sf::RectangleShape for a sf::Text. After setting the Font, CharacterSize and the String I ask for its local bounds, to initialize the background rectangle:

sf::FloatRect textSize = text.getLocalBounds();
sf::RectangleShape background(sf::Vector2f(textSize.width, textSize.height));

Both the sf::Text and the sf::RectangleShape have the same position. But the background rectangle is always a little bit too small for the text. Top and Left are OK, but at the Bottom and the Right the text sticks out of the background rectangle.

Why is that so? What can I do about it?

Pages: [1] 2 3 4