SFML community forums
Help => Window => Topic started by: ncarrasco on January 30, 2010, 06:10:15 pm
-
Hi,
I followed all the instructions to setup Visual Studio 2008 and the project to link the static libraries,
the release mode to the release libraries:
sfml-system-s.lib sfml-graphics-s.lib sfml-window-s.lib sfml-audio-s.lib sfml-network-s.lib
debug mode:
sfml-system-s-d.lib sfml-graphics-s-d.lib sfml-window-s-d.lib sfml-audio-s-d.lib sfml-network-s-d.lib
The project complies successfully but it crashes when it runs: saying "Game.exe stopped working".
Any help would be appreciated.
Thanks in advance,
Nicolas.
The code is:
(it also doesn't work with the first example of Window tutorial).
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>
#include <iostream>
////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////
int main()
{
// Create main window
sf::RenderWindow App(sf::VideoMode(800, 600), "SFML Shapes");
// 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 screen
App.Clear();
// Draw predefined shapes
App.Draw(sf::Shape::Line(10, 10, 710, 100, 15, sf::Color::Red));
App.Draw(sf::Shape::Circle(200, 200, 100, sf::Color::Yellow, 10, sf::Color::Blue));
App.Draw(sf::Shape::Rectangle(350, 200, 600, 350, sf::Color::Green));
// Build a custom convex shape
sf::Shape Polygon;
Polygon.AddPoint(0, -50, sf::Color(255, 0, 0), sf::Color(0, 128, 128));
Polygon.AddPoint(50, 0, sf::Color(255, 85, 85), sf::Color(0, 128, 128));
Polygon.AddPoint(50, 50, sf::Color(255, 170, 170), sf::Color(0, 128, 128));
Polygon.AddPoint(0, 100, sf::Color(255, 255, 255), sf::Color(0, 128, 128));
Polygon.AddPoint(-50, 50, sf::Color(255, 170, 170), sf::Color(0, 128, 128));
Polygon.AddPoint(-50, 0, sf::Color(255, 85, 85), sf::Color(0, 128, 128));
// Define an outline width
Polygon.SetOutlineWidth(10);
// Disable filling and enable the outline
Polygon.EnableFill(false);
Polygon.EnableOutline(true);
// We can still use the functions common to all SFML drawable objects
Polygon.SetColor(sf::Color(255, 255, 255, 200));
Polygon.Move(300, 300);
Polygon.Scale(3, 2);
Polygon.Rotate(45);
// Draw it
App.Draw(Polygon);
// Finally, display the rendered frame on screen
App.Display();
}
return EXIT_SUCCESS;
}
-
Compile in debug mode, then run the debugger (F5). It will tell you where exactly the crash happens.
-
Many thanks, Laurent!
The line which is the error is : App.Clear();
I don't have idea of what can be.
Thanks again,
Nicolas.
-
What is the error message? Can you show us the callstack?
-
Hi,
Is says:
Unhandled exception at 0x045e1300 in Game.exe: 0xC0000005: Access violation.
The call stack is:
045e1300()
atioglxx.dll!690d80e2()
[Frames below may be incorrect and/or missing, no symbols loaded for atioglxx.dll]
atioglxx.dll!6908d2b5()
atioglxx.dll!6908d165()
atioglxx.dll!6908227c()
atioglxx.dll!6907b0ff()
atioglxx.dll!6907b055()
atioglxx.dll!6907b18f()
Game.exe!sf::RenderTarget::Clear() + 0x17a bytes
0024f90c()
kernel32.dll!76344911()
ntdll.dll!77c8e4b6()
ntdll.dll!77c8e489()
Please let me know if you need more information.
Nicolas.
-
Are you in debug mode?
-
Yes.
-
Are your drivers up-to-date?
-
Hi Laurent,
I am not very sure I have the latest ATI drivers. Independently of that I found very strange the error, I run a lot of software at my computer without that crashes.
Do you think that it can be a Driver issue?
Thanks in advance,
Nicolas.
-
Have you tried to run the precompiled samples from the SFML SDK?
-
Hi,
Now I tried running the precompiled samples and work fine :).
Do you think I should recompile the libraries with my Visual 2008 version?
Thanks in advance!
Nicolas.
-
Ok, now you can try to recompile those samples and test them again. :)
-
Im having the Exact same problems on my laptop that is running Vista, same exact code runs on my XP Desktop fine, was the issue ever found?
-
No, I'm still waiting for the results of compiling and testing again the samples.
-
When something crash with my Visual Studio projects and SFML is because I update from SVN and dont compile the dlls or libs.
-
In my programme, setting:
#define _HAS_ITERATOR_DEBUGGING 0
gives a crash when calling:
rendertarget::clear(const Color& FillColor = Color(0, 0, 0)).
No idea why. Removing the define seemed to fix the issue.
-
Because it makes STL containers have (or not) additional members, and their definition doesn't match the one they had when SFML was compiled. You can see it easily by comparing sizeof(std::vector<int>) when _HAS_ITERATOR_DEBUGGING is defined to 0 and when it is not.
I have no idea why it happens on a call to RenderTarget::Clear though, it doesn't seem to involve any STL container.
-
I have no idea why it happens on a call to RenderTarget::Clear though, it doesn't seem to involve any STL container.
Probably the inconsistent libraries result in undefined behaviour (anywhere in the code), which manifests only at Clear().
Such errors are really evil because they're very hard to find. Some of them have already cost me hours of debugging... ;)
-
Hi,
I had to format my computer and then I installed Windows 7 instead of Vista, I had recompiled the libraries and worked fine, haven't tested if it works with the ones that came originally as now I have Windows 7 it could work without doing a recompilation.
Many thanks and sorry for my delay, I could't chech this before.
Nicolas.
-
so it works on Windows 7? thats good because im gonna build a new computer soon with windows 7 64 bit and was wondering if SFML would still work with it, Still stuck working on my game only at school in the mean time :/