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

Author Topic: [SOLVED] Toggling fullscreen / resolution changing  (Read 5137 times)

0 Members and 1 Guest are viewing this topic.

Brendon

  • Jr. Member
  • **
  • Posts: 83
    • View Profile
    • http://blendogames.com
[SOLVED] Toggling fullscreen / resolution changing
« on: May 06, 2010, 07:43:11 pm »
I'm having trouble with the syntax for toggling fullscreen and changing resolutions.

It seems in the C implementation of SFML, you would call: App.Create(...), but I can't find the equivalent call in the Dotnet implementation.

Here's my attempt at it, though all it does is create a separate empty  fullscreen window that doesn't receive any input. Any help would be appreciated!

Code: [Select]

using System;
using SFML;
using SFML.Window;
using SFML.Graphics;

namespace WindowTest
{
    public class Game1
    {
        static void Main()
        {
            RenderWindow App = new RenderWindow(new VideoMode(640, 480, 32), "Window test");

            App.Closed += new EventHandler(OnClosed);
            App.KeyPressed += new EventHandler<SFML.Window.KeyEventArgs>(OnKeyPressed);

            while (App.IsOpened())
            {
                App.DispatchEvents();
                App.Clear(Color.Cyan);
                App.Display();
            }
        }

        static void OnClosed(object sender, EventArgs e)
        {
            RenderWindow window = (RenderWindow)sender;
            window.Close();
        }

        static void OnKeyPressed(object sender, SFML.Window.KeyEventArgs e)
        {
            RenderWindow window = (RenderWindow)sender;
            if (e.Code == KeyCode.Return)
            {
                //go to fullscreen.
                window = new RenderWindow(new VideoMode(1024, 768, 32),
                    "New Title", Styles.Fullscreen);
            }
            if (e.Code == KeyCode.Escape)
            {
                window.Close();
            }
        }
    }
}

Brendon

  • Jr. Member
  • **
  • Posts: 83
    • View Profile
    • http://blendogames.com
[SOLVED] Toggling fullscreen / resolution changing
« Reply #1 on: May 20, 2010, 06:18:20 pm »
I got it up and running now.

I moved this call into the Main() loop and the game is now able to toggle between fullscreen/windowed and different resolutions:
Code: [Select]

App.Close()
App = new RenderWindow(new VideoMode(1024, 768, 32),  "New Title", Styles.Fullscreen);

bechill

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: [SOLVED] Toggling fullscreen / resolution changing
« Reply #2 on: May 27, 2012, 12:07:08 pm »
I'm having trouble with this too, it seems that when control is returned to the while (App.IsOpen()) if we've App.Close and then App = new, the while loop considers !App.IsOpen()...curious what you did exactly to fix this.

After pressing enter, my window closes, I briefly see a fullscreen window launch, and then the program terminates.