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

Author Topic: Window resizing problem  (Read 7106 times)

0 Members and 1 Guest are viewing this topic.

dips

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
Window resizing problem
« on: February 21, 2019, 10:52:03 am »
Hallo people!
I'm newbie in SFML, and sorry for my english.
I'm use Windows.
My problem is resizing of window by it's edge. Picture in window not updated while left mouse button hold down.
Tell me please how can I do content updating of window when I drag the edge of window.

I guess problem is additional event handling inside SFML. Yet another event queue? Why? OS made all jobs.
sf::Event is redundant entity. In general I made fork that uses direct calls from platform event processing subroutine. I.e. you make descendant of sf::Window and in overriden methods do your job. Additionally you must create MessageLoop object in 'main' function and call 'Run' method.
After this all works fine and fast.
https://github.com/vgui/SFML/tree/noevents It is my fork, 'noevents' branch.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Window resizing problem
« Reply #1 on: February 21, 2019, 11:09:27 am »
It seems that you already know why this happens, and have found one solution to this problem. Other (simpler) solutions can be found in the other similar threads on this forum (use the search box).

If you want to discuss the design of event handling in SFML, and possibly submit new ideas for SFML 3, don't hesitate to post in the relevant sub-forum ;)
Laurent Gomila - SFML developer

dips

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
Re: Window resizing problem
« Reply #2 on: February 21, 2019, 11:11:16 am »
Anyway, I want to make new branch, last is just proof of concept.
I want remove sf::Event at all. But I think community will not understand me. And I can do compromise
variant when sf::Event is still used with virtual handlers.
« Last Edit: February 22, 2019, 06:45:23 am by dips »

Rosme

  • Full Member
  • ***
  • Posts: 169
  • Proud member of the shoe club
    • View Profile
    • Code-Concept
Re: Window resizing problem
« Reply #3 on: February 21, 2019, 03:00:40 pm »
What would you replace sf::Event with? The idea behind sf::Event is that it abstract the OS behind and you can use the same event code on whichever platform you want and it will behave the same way. Going native means you need to write custom code for every platform you want to support. Maybe your need is only Windows, but a lot of people want to support Linux and macOS too.
GitHub
Code Concept
Twitter
Rosme on IRC/Discord

dips

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
Re: Window resizing problem
« Reply #4 on: February 22, 2019, 07:02:02 am »
Yes, it is hard work. Of corse, first I'm will make working version for my platform. And I can make it for Linux, although X11 is dark forest for me. May'be Android. But not Apple company.
sf::Events replaced by direct handler call from process event  method.
I will post example in nearly future.
PR is no plan for me now.I'm need working version now.

Rosme

  • Full Member
  • ***
  • Posts: 169
  • Proud member of the shoe club
    • View Profile
    • Code-Concept
Re: Window resizing problem
« Reply #5 on: February 22, 2019, 03:23:35 pm »
sf::Events replaced by direct handler call from process event  method.

I wonder how you can do that in a cross and uniform way... Maybe a class that wraps the call and the features? Something akin to... sf::Events maybe?

Good luck in your thing, but the fact you refuse to do anything Apple, and that you don't seem keen on doing a PR, I doubt any of this might be brought into SFML itself.
GitHub
Code Concept
Twitter
Rosme on IRC/Discord

dips

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
Re: Window resizing problem
« Reply #6 on: February 22, 2019, 06:16:02 pm »
I should test my code before make PR. How long will it take? I don't know.
I don't have any Apple device, therefore I can't programming for this devices.
Anyway, my githab repo url you can see above. 'noevents2' branch is mix of sf::Events and virtual handlers. 'noevents3' will be branch without events at all.

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Window resizing problem
« Reply #7 on: February 22, 2019, 06:39:23 pm »
He is using callbacks instead of events. SFML and SDL have events, GLFW has callbacks. I prefer events myself too. If you really want one over the other you can easily implement it yourself in own code in all these libraries without modifying them.
Back to C++ gamedev with SFML in May 2023

dips

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
Re: Window resizing problem
« Reply #8 on: February 22, 2019, 08:18:08 pm »
Code is best judge. It is real code from my repo. Do you have spoilers?

Window.cpp file
/////////////////////////////////////
#include "Window.hpp"

int main()
{
    sf::EventLoop loop;

    sf::ContextSettings settings;
    settings.depthBits = 24;
    settings.majorVersion = 2;
    settings.minorVersion = 1;

    Window window(sf::VideoMode(800, 600), "SFML window", sf::Style::Default, settings);
    Window window2(sf::VideoMode(300, 300), "SFML window with OpenGL", sf::Style::Default, settings);
    window2.setVisible(true);

    return loop.Run();
}
///////////////////////////////////////////////////
Window.hpp file
//////////////////////////////////////////////////
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/OpenGL.hpp>


class Window : public sf::Window
{
public:

    Window(sf::VideoMode mode, const sf::String& title, sf::Uint32 style, const sf::ContextSettings& settings) :
        sf::Window(mode, title, style, settings)
    {
        useEvents(false);
    }

    void onKeyPressed() override
    {
    }

    void onResized(int x, int y, int width, int height) override
    {
    }

    void onDraw() override
    {
        display();
    }

    void onIdle() override
    {
        onDraw();
    }
};//class MainWindow

I hate switch/case operator. And event loop must be hided as much as possible.My code it is traditional C++ code for any GUI program. sf::Event is redundant entity, each kind of it replaced with approriate virtual handler method.
Switch/case/if noodles hided inside processEvent method of platform dependent class.
« Last Edit: February 23, 2019, 10:37:03 am by Laurent »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Window resizing problem
« Reply #9 on: February 23, 2019, 10:36:42 am »
Ok, I think we all understood that you prefer callbacks than explicit event polling ;) There's no "best" solution however, both designs have their pros and cons.

So what do you expect from us? Do you want this design to replace the current event system in SFML? Do you have any problem that you still need to solve?
Laurent Gomila - SFML developer

dips

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
Re: Window resizing problem
« Reply #10 on: February 23, 2019, 06:50:24 pm »
That is not 'explicit event polling', that is implicit, because you have additional layer as your own event queue processing. And it is not callbacks it is direct calls from swith/case noodles of processEvent method. And you uses yet another swith/case noodles in 'main' function.
Two performance pitfalls with sf::Events design: First - additional queue,  Second - additional switch/case in 'main'.

My variant is  'S'imple 'F'ast  :) :)  and more C++ idiomatic.
I'm not expect somthing from you, a have my fork. It's enough for me. But I advise to recall my words when you wil write SFML-3.
« Last Edit: February 23, 2019, 06:56:23 pm by dips »

Rosme

  • Full Member
  • ***
  • Posts: 169
  • Proud member of the shoe club
    • View Profile
    • Code-Concept
Re: Window resizing problem
« Reply #11 on: February 25, 2019, 03:37:52 pm »
I am not sure how callbacks are more idiomatic. Both anyway, both solution are valid solutions. You are welcomed to make your points as to why you believe callbacks are better and should be the way for SFML 3. So far, I have not seen an argument as to why it is a better solution. Remember that callbacks may also have a cost too. Anyway, that was my 2cents.
GitHub
Code Concept
Twitter
Rosme on IRC/Discord

dips

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
Re: Window resizing problem
« Reply #12 on: February 27, 2019, 03:30:13 pm »
First, I think you should see source code of the library, and after that offer your 2cents. Without it, it is just void talkings.I'm gave you concrette places of performans pitfalls,but you still solve philosophical problems.Didn't want to be rude.

dips

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
Re: Window resizing problem
« Reply #13 on: March 01, 2019, 05:32:59 pm »
It seems that you already know why this happens, and have found one solution to this problem. Other (simpler) solutions can be found in the other similar threads on this forum (use the search box).
Sorry, I can't find any decissions of that problem in forum.What do you mean?May be you can show me the concrette post?
 And I have one problem with fork, I can't normally destroy more than one window.

 

anything