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

Author Topic: Pure Virtual Function call  (Read 6136 times)

0 Members and 1 Guest are viewing this topic.

Jean_Bob

  • Newbie
  • *
  • Posts: 8
    • View Profile
Pure Virtual Function call
« 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?



Code: [Select]

/* 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;
}


Code: [Select]

/*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;
}


Code: [Select]

/* 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;
}

K-Bal

  • Full Member
  • ***
  • Posts: 104
    • View Profile
    • pencilcase.bandcamp.com
    • Email
Pure Virtual Function call
« Reply #1 on: June 15, 2009, 01:21:27 pm »
Have you tried running it with a debugger?
Listen to my band: pencilcase.bandcamp.com

Jean_Bob

  • Newbie
  • *
  • Posts: 8
    • View Profile
Pure Virtual Function call
« Reply #2 on: June 15, 2009, 02:00:50 pm »
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

K-Bal

  • Full Member
  • ***
  • Posts: 104
    • View Profile
    • pencilcase.bandcamp.com
    • Email
Pure Virtual Function call
« Reply #3 on: June 15, 2009, 02:10:02 pm »
Which line causes this error?
Listen to my band: pencilcase.bandcamp.com

Jean_Bob

  • Newbie
  • *
  • Posts: 8
    • View Profile
Pure Virtual Function call
« Reply #4 on: June 15, 2009, 02:44:18 pm »
When i close the window.


Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Pure Virtual Function call
« Reply #5 on: June 15, 2009, 07:31:06 pm »
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...
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Pure Virtual Function call
« Reply #6 on: June 15, 2009, 08:50:13 pm »
Apparently, other people seem to have this issue with MinGW and SFML. That's really weird.
Laurent Gomila - SFML developer

Jean_Bob

  • Newbie
  • *
  • Posts: 8
    • View Profile
Pure Virtual Function call
« Reply #7 on: June 15, 2009, 10:53:45 pm »
I think it's 3.4.5

Gelu

  • Newbie
  • *
  • Posts: 2
    • View Profile
Pure Virtual Function call
« Reply #8 on: June 17, 2009, 09:23:36 pm »
With GCC 3.4.5 it builds and runs fine on my machine.

e_barroga

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
Pure Virtual Function call
« Reply #9 on: June 27, 2009, 04:06:35 pm »
I think it is a bug.

I got that error, too, just earlier.


Happened when I created an Image without doing anything with it:
Code: [Select]

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++.

Kamostomp

  • Newbie
  • *
  • Posts: 3
    • View Profile
Pure Virtual Function call
« Reply #10 on: October 10, 2010, 01:25:20 pm »
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

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
Pure Virtual Function call
« Reply #11 on: October 10, 2010, 06:15:12 pm »
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

Kamostomp

  • Newbie
  • *
  • Posts: 3
    • View Profile
Pure Virtual Function call
« Reply #12 on: October 11, 2010, 04:11:17 pm »
Quote from: "panithadrum"
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 :)

Kamostomp

  • Newbie
  • *
  • Posts: 3
    • View Profile
Pure Virtual Function call
« Reply #13 on: October 12, 2010, 12:05:15 pm »
Anyone have any clue of what to do? Else, judging this post and my test:

Quote from: "e_barroga"
I think it is a bug.

I got that error, too, just earlier.


Happened when I created an Image without doing anything with it:
Code: [Select]

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?

 

anything