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

Author Topic: Help with creating a window?  (Read 4553 times)

0 Members and 1 Guest are viewing this topic.

AceDawg45

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Help with creating a window?
« on: June 06, 2014, 04:56:04 pm »
So, I finally got SFML to work, and I am trying to use the tutorials on the site
http://sfml-dev.org/tutorials/1.6/window-window.php

Well, the code at the top doesn't work for me. Am I missing something? My code:

#include <iostream>
#include <SFML/Window.hpp>
using namespace std;

int main(int argc, char** argv)
{
    sf::Window window(sf::VideoMode(800, 600, 32), "SFML Window");
   
    while(window.isOpen()){
        sf::Event event;
        while(window.pollEvent(event)){

            if(event.type == sf::Event::Closed){
                window.close();
            }
        }
    }

    return 0;
}


 

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Help with creating a window?
« Reply #1 on: June 06, 2014, 05:00:03 pm »
Am I missing something?
The link points to SFML version 1.6, which is massively outdated. But the shown code is for SFML 2.

Well, the code at the top doesn't work for me.
Read this.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

AceDawg45

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Help with creating a window?
« Reply #2 on: June 06, 2014, 05:24:15 pm »
Oh, I meant the code example at the top of the webpage I linked to. I am completely new to this. Anybody know how to fix the code?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Help with creating a window?
« Reply #3 on: June 06, 2014, 08:29:22 pm »
You apparently haven't read my answer, let alone the link I posted :(

The tutorial is about SFML 1.6, today we have version 2.1. Use the newer version.
And we can't magically know what your problem is. Describe it, as stated in the link.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

AceDawg45

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Help with creating a window?
« Reply #4 on: June 06, 2014, 08:39:25 pm »
Ok, well the Console window comes up, but I don't get anything for the SFML window. I looked at the SFML 2 tutorial, and I still couldn't get it fixed. The compiler also will say "cannot optain handle to inferior. Parameter incorrect". It doesn't come up as an error, though, it comes up as a warning.

AndreeU17

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
Re: Help with creating a window?
« Reply #5 on: June 14, 2014, 06:45:23 pm »
So, I finally got SFML to work, and I am trying to use the tutorials on the site
http://sfml-dev.org/tutorials/1.6/window-window.php

Well, the code at the top doesn't work for me. Am I missing something? My code:

#include <iostream>
#include <SFML/Window.hpp>
using namespace std;

int main(int argc, char** argv)
{
    sf::Window window(sf::VideoMode(800, 600, 32), "SFML Window");
   
    while(window.isOpen()){
        sf::Event event;
        while(window.pollEvent(event)){

            if(event.type == sf::Event::Closed){
                window.close();
            }
        }
    }

    return 0;
}


 

whatss wrong is that you didnt display the window. window.display();

AceDawg45

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Help with creating a window?
« Reply #6 on: June 16, 2014, 04:28:23 pm »
I added it in there (after the nested while loop, inside while(window.isOpen()) and still, nothing

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
Re: Help with creating a window?
« Reply #7 on: June 16, 2014, 10:24:05 pm »
works for me. opens a empty black window, of course.
are you using dynamic or static libs (and did you link them)? windows/linux/mac? sfml 2.1 or 1.6? which ide? these are important info...
Visit my game site (and hopefully help funding it? )
Website | IndieDB

AceDawg45

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Help with creating a window?
« Reply #8 on: June 17, 2014, 11:28:49 pm »
I have the dynamic files. Here is the .pro file:
Code: [Select]

TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt

SOURCES += main.cpp

LIBS += -LC:/SFML/lib

CONFIG(release, debug|release): LIBS += -lsfml-audio -lsfml-graphics -lsfml-main -lsfml-network -lsfml-window -lsfml-system
CONFIG(debug, debug|release): LIBS += -lsfml-audio-d -lsfml-graphics-d -lsfml-main-d -lsfml-network-d -llibsfml-window-d -lsfml-system-d
CONFIG += c++11
INCLUDEPATH += C:/SFML/include
DEPENDPATH += C:/SFML/include

Also, as I said somewhere at the top, I am using Qt Creator. SFML 2.1, and on Windows.
« Last Edit: June 18, 2014, 03:48:00 pm by AceDawg45 »

 

anything