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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Abysmal

Pages: [1]
1
Graphics / Re: Weird crash when drawing sprite
« on: November 28, 2013, 02:57:25 am »
Wait wth, the code must've been switched with something else while I was working on the minimal version. Anyway, the OS is Windows 7 x64 Professional, and the code is compiled with Microsoft Visual Studio 2012 Ultimate. The program crashes with this message "R6025 - pure virtual function call" and three buttons: "Break", "Retry" and "Ignore". When I press "Break" the debugger gives some obscure file which differs from time to time.

Anyway, I updated the minimal version above with what I have open in Visual Studio right now.

Edit:

Interesting update. This morning I tested it again, and it didn't crash, but later on the day it came back again. So the last hour I've been wondering what could cause this. The only constant is that I also happen to have the PSX emulator running in the background when it crashes. Could be some memory issues with either one.

2
Graphics / Re: Weird crash when drawing sprite
« on: November 27, 2013, 11:36:25 pm »
This line
this->sprite = Sprite(tex);
is purely for creating a new Sprite instance with that texture. As for the other comments, the code above is purely a minimal example of crashing code and does not represent my actual code. In the actual code the member is private. Also, main() functions tend to return an exit code, i.e an int. At least in C.

3
Graphics / Re: Weird crash when drawing sprite
« on: November 27, 2013, 11:00:26 pm »
Minimal example (crashes for me)
#include <SFML\Graphics.hpp>

using namespace sf;

class MyClass
{
public:
    Sprite sprite;

    int Run(RenderWindow &window);
};

int MyClass::Run(RenderWindow &window)
{
    Texture tex;
    if (!tex.loadFromFile("Image.png"))
        return EXIT_FAILURE;

    this->sprite = Sprite(tex);
    while (window.isOpen())
    {
        Event event;
        while (window.pollEvent(event))
        {
            if (event.type == Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(this->sprite);
        window.display();
    }

    return EXIT_SUCCESS;
}

int main(void)
{
    RenderWindow window(VideoMode(600, 480), "test");

    MyClass test = MyClass();
    return test.Run(window);
}

4
Graphics / Weird crash when drawing sprite
« on: November 27, 2013, 06:56:37 pm »
Hi, I'm getting a really strange crash when trying to draw a sprite that is also a member of a class.
If I try this the program crashes with message "R6025 - pure virtual function call":
int MyClass::Run(void)
{
    Texture tex;
    if (!tex.loadFromFile("Image.png"))
        return EXIT_FAILURE;

    this->sprite = Sprite(tex);
    while (window.isOpen())
    {
        //Ignore the lack of event-handling
        window.clear();
        window.draw(this->sprite);
        window.display();
    }

    return EXIT_SUCCESS;
}
 
Commenting out this line "window.draw(sprite);" prevents it from crashing, but the window remains black as expected.

Additionally, if I simply replace this line "this->sprite = Sprite(tex);" with this line "Sprite sprite = Sprite(tex);" and update the draw call to match, the image is drawn successfully. It also works if I simply do this afterwards "Sprite sprite = this->sprite".
I really don't get why it crashes. It is the same sprite in all cases, the only difference is whether I use a local variable or a member variable in the draw call itself.

Pages: [1]