0

I'm trying to test using SFML's full screen mode, however it crashes every time the window enters full screen mode. Here's my program:

#include <stdio.h>
#include <SFML/Graphics.hpp>

int main ( int argc, char** argv ) {
    sf::Window win( sf::VideoMode ( argc >= 3 ? atoi ( ( const *char ) argv[1] ) : 1280, argc >= 3 ? atoi ( ( const *char ) argv[2] ) ), "", sf::Style::Fullscreen );

    while ( win.IsOpened ( ) ) {
        sf::Event in;

        while ( win.GetEvent ( in ) ) {
            if ( in.Type == sf::Event::KeyPressed ) {
                switch ( in.Key.Code ) {
                    case sf::Key::Q:
                        win.Close ( );
                        break;

                    default:
                        break;

                }
            }
        }

        win.Display ( );
    }
}

I compile it with a makefile with this command:

g++ -o build/Test -lsfml-system -lsfml-window -lsfml-graphics src/main.cpp

It crashes when I run the program from a terminal as such:

build/Test 1440 900

build/Test

I'm running ubuntu linux 12.04 on an Apple Macbook Air (4, 2). I tried using both gdm and lightdm, and they both had the same results. Additionally, it works fine with gnome 2, unity, and openbox, just not with gnome 3.

I don't mind having to mess around with config files, but I want to stay with gnome shell, because it is currently my favorite DE.

jepugs
  • 445
  • 4
  • 10
  • 3
    You’re using an awful lot of unnecessary pointers there and – of course – leak their memory. The whole point of a library like SFML is that you *do not* use pointers. Now, you failed to mention *where* it crashes (have you debugged?) and what the error message on the terminal is. – Konrad Rudolph Jun 10 '12 at 15:16
  • 1
    @up is right, also, 1.6 is really outdated. I know that 2.0 isn't officialy out yet, but it might be worth giving it a try and compiling it from sources by yourself. I've found that this approach is generally less error-prone. – Bartek Banachewicz Jun 10 '12 at 15:18
  • 1
    But, but... aren't pointers cool and efficient? ;) – fredoverflow Jun 10 '12 at 15:19
  • All the cool kids use pointers. – Etienne de Martel Jun 10 '12 at 15:22
  • It crashes on the "Display ( )" function. I'll try compiling the next version, thank you. I made my code nice and pretty, just for you ;). – jepugs Jun 10 '12 at 16:10

1 Answers1

0

Switching to SFML 2.0 fixed the problem. Thank you to Konrad Rudolph for posting that in the comments.

jepugs
  • 445
  • 4
  • 10