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

Author Topic: Just started; getting a glitchy window.  (Read 1294 times)

0 Members and 1 Guest are viewing this topic.

Unknown123

  • Newbie
  • *
  • Posts: 2
    • View Profile
Just started; getting a glitchy window.
« on: July 26, 2011, 05:02:50 am »
Hello.

I've been trying to get started with SFML today. I was planning to use the latest official release (1.6), but for some reason there isn't a Visual Studio 2010 SDK. A lot of people seemed to recommend just using the latest snapshot of 2.0, and since I would have to compile it myself anyway, I decided to go with that.

I downloaded CMake and used that to generate a Visual Studio 2010 (not x64) project for compiling dynamic libraries. I compiled it all, put those compiled files in a folder, and set up my own Visual Studio project to be linked with the release files.

I'm now trying to follow the "Opening a window" tutorial and the SFML 2.0 window usage example. Unfortunately, I'm having some problems...

Here is my code:

Code: [Select]
#include <SFML/System.hpp>
#include <SFML/Window.hpp>

int main() {

sf::Window app(sf::VideoMode(800, 600, 32), "SFML Window");
bool running = true;
while (running) {
app.Display();
}

return EXIT_SUCCESS;

}


When running in debug mode (but with the release SFML files), I get a console window appear, and then after several seconds (which seems like quite a long time), an SFML window appears. The window has a garbled title made up of a few random symbols ("8รต5" for example, but it changes every time), it cannot be focused, cannot be dragged, and cannot be closed. I have to kill the program from Task Manager or stop debugging in my IDE.

When running in release mode, it works exactly the same as above, except the window title is correct instead of being garbled.

So my question is as follows. What's up with the window? What am I doing wrong?
  • How can I get rid of the console window? I'm using an empty C++ project in Visual Studio 2010, and I have sfml-main.lib linked in.
Thanks a lot in advance!

Edit 1: Okay, I got rid of the console window. I'm still having trouble with the SFML window, though...

Edit 2: Fixed the garbled window title in debug mode by using the debug SFML files. I'm not quite sure why this is necessary, though. Can anyone explain this to me? Either way, I'm still having trouble with the unresponsive, almost frozen window.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Just started; getting a glitchy window.
« Reply #1 on: July 26, 2011, 07:42:49 am »
Quote
Fixed the garbled window title in debug mode by using the debug SFML files. I'm not quite sure why this is necessary, though. Can anyone explain this to me?

With VC++, debug and release modes are not compatible, so you must use debug libraries in debug mode (this is written in bold characters in the tutorial...).

Quote
Either way, I'm still having trouble with the unresponsive, almost frozen window

You need an event loop ;)
Laurent Gomila - SFML developer

Unknown123

  • Newbie
  • *
  • Posts: 2
    • View Profile
Just started; getting a glitchy window.
« Reply #2 on: July 26, 2011, 08:09:05 am »
Edit: Removed giant post; fixed that other problem myself. New message below.

Thank you very much for your response. It's all working now. I think it would have been helpful if the tutorial mentioned that, as I expected to get a working window as the final result, not an unresponsive one. It did say that we don't draw anything to the window, but not that it would work like that. I saw some event code in the SFML 2.0 window usage example, but I didn't want to add that until I had the basic code from the tutorial set up. I thought it was broken, but I guess it was working as the tutorial intended it to. Anyway, thanks! Now I can play with SFML some more.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Just started; getting a glitchy window.
« Reply #3 on: July 26, 2011, 08:37:49 am »
Quote
I think it would have been helpful if the tutorial mentioned that, as I expected to get a working window as the final result, not an unresponsive one.

Absolutely, that should be added to the tutorial.
Laurent Gomila - SFML developer

 

anything