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

Author Topic: Windows Header Breaks Program  (Read 2606 times)

0 Members and 1 Guest are viewing this topic.

thejahooli

  • Newbie
  • *
  • Posts: 4
    • View Profile
Windows Header Breaks Program
« on: December 04, 2010, 12:21:08 am »
I am following the first tutorial on how to display a window, however when I run the program no window appeared.
Using breakpoints I found that not a single line of code in my main function was run, so I think it is to do with the header file not working.
If somebody could help then I would be grateful.

In case it is something wrong with my code:

Code: [Select]

#include <SFML/Window.hpp>

int main()
{
// The Program Doesn't execute this line or any afterwards.
sf::Window window(sf::VideoMode(800, 600, 32), "Test");

bool running = true;

while(running)
{
sf::Event e;
while(window.GetEvent(e))
{
if(e.Type == sf::Event::Closed)
running = false;

if(e.Type == sf::Event::KeyPressed && e.Key.Code == sf::Key::Escape)
running = false;
}

window.Display();
}

return EXIT_SUCCESS;
}

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Windows Header Breaks Program
« Reply #1 on: December 04, 2010, 09:21:29 am »
What OS/compiler/version of SFML?
Laurent Gomila - SFML developer

thejahooli

  • Newbie
  • *
  • Posts: 4
    • View Profile
Windows Header Breaks Program
« Reply #2 on: December 04, 2010, 01:58:37 pm »
Windows 7
Visual C++ 2008
SFML Version 1.6

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Windows Header Breaks Program
« Reply #3 on: December 04, 2010, 02:11:43 pm »
Do you link to debug libraries (-d suffix) in debug mode?
Laurent Gomila - SFML developer

thejahooli

  • Newbie
  • *
  • Posts: 4
    • View Profile
Windows Header Breaks Program
« Reply #4 on: December 04, 2010, 08:28:52 pm »
Yes.

P.S. I've just notice that my problem is identical to Ges' below in the forum, except that I'm using VS2008.

furrydice

  • Newbie
  • *
  • Posts: 9
    • View Profile
Windows Header Breaks Program
« Reply #5 on: December 24, 2010, 01:43:32 pm »
Hi,

I got the same thing, and now have working, thought this might help:

(ps my system: windows7 64-bit, VC++ Express 2008)

When using the dynamic libraries (sfml-window.lib or sfml-window-d.lib): the project compiles and runs, the console window appears, but get no application window, also when running it doesn't reach the main code (breakpoint on first line).

The static libraries worked (sfml-window-s.lib and sfml-window-s-d.lib). When compiling using the debug version, I got the warning "needs "vc90.pdb" for debug info", but seems to run fine, and have access to class debug info in debugger.

I also found my graphics card wasn't too keen on the hard coded videomode set-up in the example, so used the tutorial example to get a mode from the video card:

   unsigned int VideoModesCount = sf::VideoMode::GetModesCount();
   for (unsigned int i = 0; i < VideoModesCount; ++i)
   {
       sf::VideoMode Mode = sf::VideoMode::GetMode(i);
       // Mode is a valid video mode
   }
   //sf::RenderWindow App(sf::VideoMode::GetMode(0), "SFML Shapes");
   sf::RenderWindow App(sf::VideoMode::GetMode(0), "SFML Shapes", sf::Style::Fullscreen);

(+ you get full screen!)

If still having issues, recompile the libraries as described in tutorial 1 (open sfml.sln, change the configuration setting to desired build type in the main window tool bar, eg static debug (option box next to green run arrow), then right-click package you want to build in solution explorer window, clean the project then build libraries). New libraries can be found in lib\vc2008\, and copy them to the lib\ directory)

Hope this helps..

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Windows Header Breaks Program
« Reply #6 on: December 24, 2010, 01:47:43 pm »
You are experiencing the well-known ATI bug; fortunately you found the workaround which is to link statically ;)

Quote
I also found my graphics card wasn't too keen on the hard coded videomode set-up in the example

You mean that your graphics card doesn't support 800x600? Is it too low??
Laurent Gomila - SFML developer

furrydice

  • Newbie
  • *
  • Posts: 9
    • View Profile
Windows Header Breaks Program
« Reply #7 on: December 24, 2010, 01:53:01 pm »
Hi,

Ah, how did you know I had an ATI? :) It ran with 600,400,32, but gave a strange high pitched squeel, not sure why, so thought it safer using a retruned video mode (plus get full screen:)

(ps thanks for awesome library, am looking forward to making some great stuff..!)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Windows Header Breaks Program
« Reply #8 on: December 24, 2010, 02:03:38 pm »
Quote
Ah, how did you know I had an ATI?

Because the ATI crash doesn't occur on non-ATI cards :mrgreen: (except some Intel chipsets).

Quote
It ran with 600,400,32, but gave a strange high pitched squeel, not sure why, so thought it safer using a retruned video mode (plus get full screen:)

600x400 is not a common video mode, the SFML examples all use 800x600. But as long as you are not running in fullscreen mode, it shouldn't matter anyway.
Laurent Gomila - SFML developer