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

Author Topic: Tutorial Issue: Using Render Windows  (Read 3693 times)

0 Members and 1 Guest are viewing this topic.

Zauren

  • Newbie
  • *
  • Posts: 3
    • View Profile
Tutorial Issue: Using Render Windows
« on: August 06, 2009, 02:59:43 am »
I'm an aspiring coder, and integrating SFML has been a new experience for me. I've managed to wrestle out all the speedbumps through searching and experimenting, but this one is a bit odd. I'm sure it's something simple but have little clue what the culprit is.

I took this code and slapped it in...

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

int main()
{
    // Create the main rendering window
    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics");
   
    // Start game loop
    while (App.IsOpened())
    {
        // Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();
        }

        // Clear the screen (fill it with black color)
        App.Clear();

        // Display window contents on screen
        App.Display();
    }

    return EXIT_SUCCESS;
}


And when I run it, it opens the new window as expected, but then immediately goes white and crashes. But the debug window says it worked normally.

 My eyes are presently ?_? I'm using Visual Studio 2008, if that matters.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Tutorial Issue: Using Render Windows
« Reply #1 on: August 06, 2009, 07:56:44 am »
Make sure that you're not mixing debug and release configurations.
Laurent Gomila - SFML developer

Zauren

  • Newbie
  • *
  • Posts: 3
    • View Profile
Tutorial Issue: Using Render Windows
« Reply #2 on: August 07, 2009, 01:20:48 am »
All I have is sfml-window.lib sfml-graphics.lib in my additional dependences, unless that means something beyond just using the linker...

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
Tutorial Issue: Using Render Windows
« Reply #3 on: August 07, 2009, 06:03:20 am »
Quote from: "Zauren"
All I have is sfml-window.lib sfml-graphics.lib in my additional dependences, unless that means something beyond just using the linker...
Here's your problem: You aren't linking to sfml-system.lib.
I use the latest build of SFML2

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Tutorial Issue: Using Render Windows
« Reply #4 on: August 07, 2009, 07:48:36 am »
Quote
All I have is sfml-window.lib sfml-graphics.lib in my additional dependences, unless that means something beyond just using the linker...

And you compile in debug configuration or release?
Laurent Gomila - SFML developer

forrestcupp

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Tutorial Issue: Using Render Windows
« Reply #5 on: August 07, 2009, 09:21:33 pm »
If it's debug, you have to put a -d at the end of the lib names.

Also, don't you have to define SFML_DYNAMIC in the preprocessor definitions?

Zauren

  • Newbie
  • *
  • Posts: 3
    • View Profile
Tutorial Issue: Using Render Windows
« Reply #6 on: August 08, 2009, 03:15:59 am »
system wasn't in since it wasn't needed, but I stuck it in anyway to be sure. Same error. Dynamic is also set, that was the first thing I tried.

Oh god, I see what the issue was. I WAS compiling in debug without the -d libraries using 'start without debugging', because for all my time with Visual Studio that's how I tested the program instead of building it.

...I toldja it was something stupid! Many thanks!

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
Tutorial Issue: Using Render Windows
« Reply #7 on: August 08, 2009, 08:12:41 am »
Quote from: "Zauren"
system wasn't in since it wasn't needed, but I stuck it in anyway to be sure. Same error. Dynamic is also set, that was the first thing I tried.

Oh god, I see what the issue was. I WAS compiling in debug without the -d libraries using 'start without debugging', because for all my time with Visual Studio that's how I tested the program instead of building it.

...I toldja it was something stupid! Many thanks!
I'm sorry, but reading the tutorials for setting up, it says that the Window Library depends on the System Library, meaning you cannot use the Window Library without the System Library. So how is it that you are able to run it without System?
I use the latest build of SFML2