SFML community forums
Help => General => Topic started by: Jean_Bob on June 15, 2009, 03:02:47 am
-
Anyone can explain me why I have this error when i execute the result of this code?
(http:// http://pages.videotron.com/drektar/pvfc.png )
/* Player.h*/
class Player
{
public:
/* Constructeur */
Player(int r_numero = 1);
/* Accesseur */
const sf::Sprite& Player::getSprite();
private:
/* Atributs */
int numero;
sf::Image image;
sf::Sprite sprite;
};
/* Playe.cpp */
Player::Player(int r_numero) : numero(r_numero)
{
image.LoadFromFile("bar.bmp");
sprite.SetImage(image);
sprite.SetPosition(200, 100);
}
const sf::Sprite& Player::getSprite()
{
return sprite;
}
/*balle.h */
class Balle
{
public:
/* Constructeur */
Balle();
/* Accesseur */
const sf::Sprite& Balle::getSprite();
private:
/* Atributs */
sf::Image image;
sf::Sprite sprite;
};
/*balle.h*/
#include "balle.h"
Balle::Balle()
{
image.LoadFromFile("balle.png");
sprite.SetImage(image);
sprite.SetPosition(400, 300);
}
const sf::Sprite& Balle::getSprite()
{
return sprite;
}
/* main.cpp */
#include <iostream>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include "Player.h"
#include "balle.h"
int main()
{
sf::RenderWindow App(sf::VideoMode(900, 575), "Pong!");
App.SetFramerateLimit(60);
sf::Event Event;
sf::Image imgFond;
imgFond.LoadFromFile("fond.png");
sf::Sprite fond;
fond.SetImage(imgFond);
fond.SetPosition(0,0);
Player player1(1);
Balle balle;
while (App.IsOpened())
{
while (App.GetEvent(Event))
{
if (Event.Type == sf::Event::Closed)
App.Close();
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
App.Close();
}
App.Clear();
App.Draw(fond);
App.Draw( player1.getSprite() );
App.Draw( balle.getSprite() );
App.Display();
}
return EXIT_SUCCESS;
}
-
Have you tried running it with a debugger?
-
Program received signal SIGSEGV, Segmentation fault.
In ig4icd32!DrvSetContext () (C:\Windows\system32\ig4icd32.dll)
the debuger show me that but i dont know how i can solve the problem
-
Which line causes this error?
-
When i close the window.
(http:// http://pages.videotron.com/drektar/ct.png )
-
This is strange, since you don't use any virtual functions in your own code (assuming this is your whole program).
Did you link SFML correctly? Maybe rebuilding helps...
-
Apparently, other people seem to have this issue with MinGW and SFML. That's really weird.
-
I think it's 3.4.5
-
With GCC 3.4.5 it builds and runs fine on my machine.
-
I think it is a bug.
I got that error, too, just earlier.
Happened when I created an Image without doing anything with it:
sf::Image imCursor;
imCursor.LoadFromFile(...);
Commenting it out relieves the issue.
Once I set a sprite to that image, then draw the sprite.... it also relieved the issue.
By the way, I was using VC++.
-
Hi, I belive this issue is still active, because I get the same error at the end of the application, it appears as e_barroga said, with sf::Image. But sadly I'm working with SFML-OpenGL and I'm using sf::Image with Image.bind() so I'm not setting a sprite. On the other hand it works fine on Mac OSX.
I'm using Code::Blocks (MinGW) on Windows.
Is there any way to avoid this Pure Virtual Function Call error, when the application ends?
Thanks
-
That is the problem I have in my thread (http://sfml-dev.org/forum/viewtopic.php?t=3349), but I use Visual Studio 2010 (SFML2 last revision, shared libraries).
Just happens when something related to sf::Context (sf::Window for example) is created and destroyed. Then, that message emerges at the end of the application.
EDIT: Maybe it's because I am using an integrated graphic card intel
-
That is the problem I have in my thread (http://sfml-dev.org/forum/viewtopic.php?t=3349), but I use Visual Studio 2010 (SFML2 last revision, shared libraries).
Just happens when something related to sf::Context (sf::Window for example) is created and destroyed. Then, that message emerges at the end of the application.
EDIT: Maybe it's because I am using an integrated graphic card intel
I have an integrated graphic card intel too :)
-
Anyone have any clue of what to do? Else, judging this post and my test:
I think it is a bug.
I got that error, too, just earlier.
Happened when I created an Image without doing anything with it:
sf::Image imCursor;
imCursor.LoadFromFile(...);
Commenting it out relieves the issue.
Once I set a sprite to that image, then draw the sprite.... it also relieved the issue.
By the way, I was using VC++.
Maybe I should not use sf::Image for images and use e.g. SOIL with OpenGL?
Because it works fine without sf::Image? Or does anyone have a better idea?