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

Author Topic: Separating event generation and the window.  (Read 8852 times)

0 Members and 1 Guest are viewing this topic.

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Separating event generation and the window.
« on: November 15, 2014, 02:41:57 pm »
Hi, with SFML this is the window which produce events, but what if the application have no window.

We are forced to create an invisible window to get events and if we have multiple windows we are forced to call the pollEvent function twice instead of once.

You intend to manage multiple windows screens, so, I think it should be good to separate events generation and the window like SDL does.


« Last Edit: November 15, 2014, 02:44:00 pm by Lolilolight »

Lo-X

  • Hero Member
  • *****
  • Posts: 618
    • View Profile
    • My personal website, with CV, portfolio and projects
Re: Separating event generation and the window.
« Reply #1 on: November 15, 2014, 02:54:38 pm »
I don't get why you need events if you have no windows. I don't even see how such a thing is possible. An event without a related window is just like pedals if you don't have a bike.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
AW: Separating event generation and the window.
« Reply #2 on: November 15, 2014, 02:56:53 pm »
All events are related to a window. Mouse or keyboard events only happen within the window. Resize and focus events are only for the window.
As such, this suggestion makes no sense.
That the joystick events act slightly different has its own reason.

For keyboard, mouse and joystick we have dedicated classes.

If you want a callback system, then this an entirely different request.

Better state what you actually want, instead of the useless "like library XYZ does".
« Last Edit: November 15, 2014, 03:33:24 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: Separating event generation and the window.
« Reply #3 on: November 15, 2014, 08:47:43 pm »
No, you can use your keyboard on a console to type commands, you can also use your mouse to copy or past text for exemple, they are not related to the window so. x)
Only resize, close, lostFocus, gaignedFocus, mouseEntered, mouseLeft, ... are related to the window.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Separating event generation and the window.
« Reply #4 on: November 15, 2014, 09:46:29 pm »
Quote
No, you can use your keyboard on a console to type commands, you can also use your mouse to copy or past text for exemple, they are not related to the window so
These events are related to the console window... Typing or pasting text only makes sense in a window.

Anyway, instead of arguing, explain why you request this feature.
Laurent Gomila - SFML developer

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: Separating event generation and the window.
« Reply #5 on: November 16, 2014, 09:02:29 am »
I want to get events from the console.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Separating event generation and the window.
« Reply #6 on: November 16, 2014, 10:03:38 am »
And...? Please explain what you want to do.
Laurent Gomila - SFML developer

Gambit

  • Sr. Member
  • ****
  • Posts: 283
    • View Profile
Re: Separating event generation and the window.
« Reply #7 on: November 16, 2014, 10:22:17 am »
Provide usage cases. You could very well be wanting a feature that you do not need, nor would benefit SFML as a whole.

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: Separating event generation and the window.
« Reply #8 on: November 16, 2014, 01:30:56 pm »
I've a game with no window (for exemple) just the console, a snake by example, and I want that if I press a key, the snake change of direction.

PS : It can be a console or another window type from another os, no matter what.
The only thing we can do  now is to recreate another classe for window and events. (I think event's are depending on the OS, not on the window or the console, right ?)

So I suggest to get event directly from the os and not from the window to have only one responsability for the window and one responsability for the event collector.

« Last Edit: November 16, 2014, 01:42:32 pm by Lolilolight »

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Separating event generation and the window.
« Reply #9 on: November 16, 2014, 01:50:14 pm »
If you have a console you have a window.... SFML is not ncurses. Have a look at http://ndk-xx.sourceforge.net/ instead.
SFML / OS X developer

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Re: Separating event generation and the window.
« Reply #10 on: November 16, 2014, 03:35:20 pm »
Yeah, use a multimedia library to make a console game makes sense. If you want to make a console game with SFML, then make a custom console with a proper RenderWindow so you can leverage all SFML features.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Separating event generation and the window.
« Reply #11 on: November 16, 2014, 04:22:16 pm »
Quote
I've a game with no window (for exemple)
Ok so you don't have any use case for this feature, and opened this thread just to say something?

Quote
So I suggest to get event directly from the os
And how do you think you can get events from the OS? With a window.
Laurent Gomila - SFML developer

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: Separating event generation and the window.
« Reply #12 on: November 17, 2014, 11:46:37 am »
Ok so we always need a window to get events, you can't create two different classes for the window and for the events.

Arf. :/

I'm actually coding a engine and, I want to respect the principe of "single responsability for each class", so, I want to have two interfaces (instead of one), one to generate events and another to display the window.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Separating event generation and the window.
« Reply #13 on: November 17, 2014, 11:59:19 am »
I'm actually coding a engine and, I want to respect the principe of "single responsability for each class", so, I want to have two interfaces (instead of one), one to generate events and another to display the window.
If only the logical structure is the concern, you can still separate responsibilities:
// Your rendering interface
class Renderer
{
public:
    explicit Renderer(sf::RenderWindow& window);
    void Draw(const GameObject& obj);
};

// Your user-input interface
class Input
{
public:
    explicit Input(sf::Window& window);
    void PollEvents();
    void RegisterCallback(...);
};
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Separating event generation and the window.
« Reply #14 on: November 17, 2014, 12:08:05 pm »
You know, those theoretical principles are nice on paper but sometimes you have to put them aside if you don't want a super complex design. If you split every interface to an atomic set of operations you'll end up with huge interface boundaries and a lot of interdependencies.

Make yourself a treat for Christmas : http://www.amazon.com/The-Deadline-Novel-Project-Management/dp/0932633390
SFML / OS X developer