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

Author Topic: Window not opening  (Read 3869 times)

0 Members and 1 Guest are viewing this topic.

Joecatshoe

  • Newbie
  • *
  • Posts: 2
    • View Profile
Window not opening
« on: May 21, 2011, 06:00:03 pm »
Hello

I've just started experimenting with SFML today, and I stumbled across a problem I can't seem to fix.

When trying out the example code of the "Opening a window" tutorial, the window won't open at all. Everything compiles without any problems, but when I open the executable nothing happens. There's no window popping up, the program just idles.
At first I thought it was because I was using a Win32 Console application project. The console window would just sit there idling, but when I switched to a Windows project, the window would still not pop up and the program would just idle in the background.

I'm using VS2010. I've set up the include and lib directories and linked the library files (sfml-window.lib, sfml-graphics.lib, sfml-system.lib) as described in the VS tutorial. I also placed the corresponding .dll files in my executable folder.

Here's the part I really can't seem to figure out:
When I use the example solution included in the SDK (SFML.sln) and paste my code in one of the projects, it compiles and runs just fine. The window pops up just like it's supposed to.
I've read through the tutorial a dozen of times trying to find what I missed but I can't seem to find it. I also can't find what distinguishes the example solution from my own.

Seeing as the code works in the example solution but not in my own solution, it's probably something in the settings of the project/solution. Anyone who knows what I'm missing? Thanks in advance.

For reference, here's the code
Code: [Select]
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Window");

    while (App.IsOpened())
    {
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            if ((Event.Type == sf::Event::Closed) ||
               ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape)))
            {
                App.Close();
                break;
            }
        }
        App.Clear();

App.Display();
    }

    return EXIT_SUCCESS;
}

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Window not opening
« Reply #1 on: May 21, 2011, 06:20:35 pm »
VC 2008 libraries are not compatible with VC 2010, you must recompile SFML.
Laurent Gomila - SFML developer

Joecatshoe

  • Newbie
  • *
  • Posts: 2
    • View Profile
Window not opening
« Reply #2 on: May 21, 2011, 09:03:04 pm »
That was indeed the problem, everything works fine now after recompiling the libraries.

Thanks for the quick reply!

Impervious

  • Newbie
  • *
  • Posts: 4
    • View Profile
Window not opening
« Reply #3 on: May 29, 2011, 12:04:54 am »
Sorry to have to ask a newbie question, but I have been trying to solve this problem by using google several times but I am finding many solutions that aren't working... possibly because I am not entirely sure what I am looking for, but I believe the problem mentioned here is the one I am having, however... I dont' know how to recompile the libraries.  After trying to google that as well, I haven't had too much luck.  

Is it at all possible that someone could give me a quick explanation of what I need to do to recompile?  Do I need to delete files and then simply compile my program?  If so, which ones... and would I have to compile a specific program?  (The point I am getting at here is that I will probably need some basic instructions... :( )

Also, once I recompile, do I have to do this for ever project I do, or just doing it once will solve it for good?

Thanks.

(BTW I am using VC++ 2010 on Vista 64 bit if it matters)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Window not opening
« Reply #4 on: May 29, 2011, 10:38:07 am »
Recompiling SFML is explained at the end of the tutorial for Visual C++.

The forum is also full of useful information, especially someone posted video tutorials. And maybe even precompiled libraries.
Laurent Gomila - SFML developer

Impervious

  • Newbie
  • *
  • Posts: 4
    • View Profile
Window not opening
« Reply #5 on: June 01, 2011, 10:25:41 am »
Quote from: "Laurent"
Recompiling SFML is explained at the end of the tutorial for Visual C++.

The forum is also full of useful information, especially someone posted video tutorials. And maybe even precompiled libraries.


Thanks for the response.

I had already moved on to the next tutorial as I did not have any problems by the time I had completed the first one, so I wasn't even looking at the correct tutorial at that point.  Also I searched quite a bit for recompiling, but I never came across that section as it isn't titled recompiling and nowhere does it have that word"recompile" or "recompiling" in it.  The point I am getting across is that while I tried searching ahead of time, I couldn't quite help myself because I wasn't too sure what I was looking for... I don't want to come across someone who is coming here to ask questions as soon as I have a basic one, but at the same time I have been stuck on what I know is very basic stuff without being able to figure it out and it is very frustrating for me. :(

(Hopefully I am not coming across as rude.  If I am in any way, I apologize and don't intend to be)

The problem I am having now is that there is no build folder in my SFML 1.6 folder which I downloaded from this site.  I have downloaded it a few times on different occasions to be sure, but still there is no build folder (I only have extlibs, include and lib).  I really just don't know what to do about this problem.  I've searched this site, I've googled... but I just don't know...

Also looking one step ahead if I can get past all this, you say to open SFML.sln (I assume you mean in Visual Studios) and then choose the configuration... how exactly do I choose?  Also, would choosing all of them be a good idea?  It may be obvious once I get there, but right now looking at the instructions it doesn't seem to explain it.  Maybe I will just worry about that when I get there though.

Thanks again for the help.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Window not opening
« Reply #6 on: June 01, 2011, 11:08:54 am »
Quote
The problem I am having now is that there is no build folder in my SFML 1.6 folder which I downloaded from this site. I have downloaded it a few times on different occasions to be sure, but still there is no build folder (I only have extlibs, include and lib). I really just don't know what to do about this problem. I've searched this site, I've googled... but I just don't know...

It's written in the tutorial:
Quote
To compile SFML libraries and samples, you must first download and install the full SDK

What you have is the development SDK (which doesn't contain sources and build files).

Quote
Also looking one step ahead if I can get past all this, you say to open SFML.sln (I assume you mean in Visual Studios) and then choose the configuration... how exactly do I choose?

There's a combobox in the toolbar, you can choose between "Debug DLL", "Debug static", "Release DLL" and "Release static".
Laurent Gomila - SFML developer

 

anything