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

Author Topic: No sf::RenderWindow.setStyle() or sf::RenderWindow.setFullscreen()  (Read 6226 times)

0 Members and 1 Guest are viewing this topic.

Weeve

  • Jr. Member
  • **
  • Posts: 87
  • C++ Programmer (Intermediate), 3D Artist (Skilled)
    • View Profile
    • Email
I need to be able to let the user change whether the window is fullscreen or not, via an options menu, after finding no function existed, I tried creating a new window, and replacing the old one, but got an 'sf::NonCopyable' complaint

A solution on how to avoid NonCopyable, or how to change the style, or setFullscreen would be greatly beloved  ;D

If there is no way around either, can you make a setStyle() or a setFullscreen()?

this is semi-project-halting, ie: I can finish this section until this is resolved, but I have other things I could work on, and leave this hanging
Long live rapid project development! -- Kestrel3D Game-Engine nearing completion

Halsys

  • Jr. Member
  • **
  • Posts: 66
  • Halsys like Hal.sys
    • View Profile
    • Email
Re: No sf::RenderWindow.setStyle() or sf::RenderWindow.setFullscreen()
« Reply #1 on: February 17, 2013, 05:42:23 am »
I have a system where the window I use is a pointer to a window I use to draw... If I want to draw to another window I make a new window, swap the 2 windows through my pointer and its drawing to the new one.

Here's What I do in code:
void Game::GoFullscreen(int Width,int Height)
{
    Game::Graphics->terminate();
    delete Game::Window;
    Game::Window = new tgui::Window(sf::VideoMode(Width,Height,32),"Project Red",sf::Style::Fullscreen);
    Game::Window->globalFont = *Game::GameFont;
    Game::Window->setActive(false);
    Game::Fullscreen = true;
    Game::Graphics->launch();
}

Code could need some work because I lose my GUI but that's not going to be hard to retrieve.
But it does work, and you are welcome.
If you notice I put "....", in my sentences way too much... I'm sorry.

Weeve

  • Jr. Member
  • **
  • Posts: 87
  • C++ Programmer (Intermediate), 3D Artist (Skilled)
    • View Profile
    • Email
Re: No sf::RenderWindow.setStyle() or sf::RenderWindow.setFullscreen()
« Reply #2 on: February 17, 2013, 05:47:31 am »
Ty :D messy but works  ;)  (until I move the code from my temp project to my main project Kestrel3D, then I will need something more intuitive to work with)

As a side note, why isn't there a setStyle in sfml anyway?

Long live rapid project development! -- Kestrel3D Game-Engine nearing completion

Halsys

  • Jr. Member
  • **
  • Posts: 66
  • Halsys like Hal.sys
    • View Profile
    • Email
Re: No sf::RenderWindow.setStyle() or sf::RenderWindow.setFullscreen()
« Reply #3 on: February 17, 2013, 06:02:58 am »
I'm guessing Laurent thought that we lowly, not really amazing, people wont need such a thing.
Nah... I'm sure if he thought if we wanted it a certain way we would do it ahead of time but as a lazy person I too expect the game to restart for me or just swap to fullscreen. So I kinda did it this way... Refusing to make the person restart the game to load the settings file, Just to go into fullscreen but do it for them.... Without restarting the main thread.

Also I want to note that my engine uses a graphics thread and I did have to pause(Turn it off then on) but if your game is single thread(Not using any thread), You may or may not have a problem.
If you notice I put "....", in my sentences way too much... I'm sorry.

Weeve

  • Jr. Member
  • **
  • Posts: 87
  • C++ Programmer (Intermediate), 3D Artist (Skilled)
    • View Profile
    • Email
Re: No sf::RenderWindow.setStyle() or sf::RenderWindow.setFullscreen()
« Reply #4 on: February 17, 2013, 06:24:42 am »
single thread :) but like I said, when I move the code over to Kestrel, ill have to have a cleaner way of doing things, as I would be unsure of _everything_ the programmer may/may-not be doing

current implementation of your code:
void Window::DeleteWindow(){
        if (_App != NULL){
                delete _App;
                _App = NULL;
        }
}

Window::~Window(){
        DeleteWindow();
}

void Window::SetFullscreen(bool Fullscreen){
        if (Fullscreen){
                if (!_Fullscreen){
                        DeleteWindow();
                        _App = new sf::RenderWindow(sf::VideoMode(1280,1024), "Biggest Fish",sf::Style::Fullscreen);
                }
        }else{
                if (_Fullscreen){
                        DeleteWindow();
                        _App = new sf::RenderWindow(sf::VideoMode(640,480), "Biggest Fish");
                        sf::View Viewport( sf::Rect<float> (0,0,1280,1024) );
                        _App->setView(Viewport);
                }
        }
}
 

soon this temp project will be done, and ill post it on the projects part of the forum  ;D

the reason I make temp projects is so that I can see areas where Kestrel3D needs features/functionality/has-errors this temp project was for 2D support on Kestrel3D, which before was 0% :lol:

thanks for the help, is there anything I could help you with? I make 3D art that's pro quality, and I actively use OpenGL, and could offer help there
Long live rapid project development! -- Kestrel3D Game-Engine nearing completion

Halsys

  • Jr. Member
  • **
  • Posts: 66
  • Halsys like Hal.sys
    • View Profile
    • Email
Re: No sf::RenderWindow.setStyle() or sf::RenderWindow.setFullscreen()
« Reply #5 on: February 17, 2013, 06:44:32 am »
Quote
single thread  but like I said, when I move the code over to Kestrel, ill have to have a cleaner way of doing things, as I would be unsure of _everything_ the programmer may/may-not be doing
You would be the 3rd person who indirectly said my code looked sloppy. :P
Quote
the reason I make temp projects is so that I can see areas where Kestrel3D needs features/functionality/has-errors this temp project was for 2D support on Kestrel3D, which before was 0% :lol:
I actually do this too, I call that Project "research", and the main "Development". Get it... R&D :P
Quote
thanks for the help, is there anything I could help you with? I make 3D art that's pro quality, and I actively use OpenGL, and could offer help there
Kinda flattered that you asked, Well my game is purely 2D with 3D perspectives(Yes I'm making a engine for a 2D game), So I cant ask for anything but I wouldn't mind hitting you up when I need your help because after this one project I'm going to work on something 3D.
If you notice I put "....", in my sentences way too much... I'm sorry.


Weeve

  • Jr. Member
  • **
  • Posts: 87
  • C++ Programmer (Intermediate), 3D Artist (Skilled)
    • View Profile
    • Email
Re: No sf::RenderWindow.setStyle() or sf::RenderWindow.setFullscreen()
« Reply #7 on: February 17, 2013, 07:24:08 am »
Why would it be so oddly named :o , but I still feel dumb for not noticing it

Anyways, it works, ty :D
Long live rapid project development! -- Kestrel3D Game-Engine nearing completion

Halsys

  • Jr. Member
  • **
  • Posts: 66
  • Halsys like Hal.sys
    • View Profile
    • Email
Re: No sf::RenderWindow.setStyle() or sf::RenderWindow.setFullscreen()
« Reply #8 on: February 17, 2013, 07:56:28 am »
I too might want to change to that... But I needed to make a Full screen function anyway so everything turned out okay.
If you notice I put "....", in my sentences way too much... I'm sorry.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
AW: Re: No sf::RenderWindow.setStyle() or sf::RenderWindow.setFullscreen()
« Reply #9 on: February 17, 2013, 08:33:30 am »
Why would it be so oddly named
I don't see how it's an odd name. You both were talking about creating a new window, so create() seems to be quite intuitive.
What you might have missed, is the a switch from window mode to fullscreen mode, isn't just changing a boolean in background, but it needs a whole new setup and thus a recreation of the window is needed.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Halsys

  • Jr. Member
  • **
  • Posts: 66
  • Halsys like Hal.sys
    • View Profile
    • Email
Re: No sf::RenderWindow.setStyle() or sf::RenderWindow.setFullscreen()
« Reply #10 on: February 17, 2013, 09:09:58 am »
Way to kick me in the proverbial gonads, eXpl0it3r. Well yeah... your right, That is true. My point I want to shake is that some other games make this seamless with what we want to believe... one window. So how hard would it be to make a function that remove the border, keep the window always on top,and move it to the top left part of the screen? ?:\
If you notice I put "....", in my sentences way too much... I'm sorry.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
AW: Re: No sf::RenderWindow.setStyle() or sf::RenderWindow.setFullscreen()
« Reply #11 on: February 17, 2013, 11:47:15 am »
Way to kick me in the proverbial gonads, eXpl0it3r.
I didn't want to offend you, I'm sorry. :

So how hard would it be to make a function that remove the border, keep the window always on top,and move it to the top left part of the screen? ?:
But you are aware that borderless 'fullscreen' is not equal to real fullscreen? Since you'll have to share the GPU in window mode with the dedktop and other applications, your performance might slightly suffer.

To implement it with SFML should be quite easy , but you'll have to call create, since you want a window with different settings.
If it was a suggestion for SFML then I don't think it will get many votes, because it would only clutter the API and not give much more value, since you can already do it with the current API.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything