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 - Camble

Pages: [1]
1
Graphics / Re: Inherited sf::Drawable crashing
« on: January 22, 2013, 11:46:10 pm »
Worked a treat ;D (of course it did ::))

Thanks again for everyone's help. No RTFMs here anyway.

2
Graphics / Re: Inherited sf::Drawable crashing
« on: January 22, 2013, 09:46:05 pm »
No wonder the errors were inconsistent.

Thanks for the help :)

3
Graphics / Re: Inherited sf::Drawable crashing
« on: January 22, 2013, 09:42:21 pm »
2.0 RC is incompatible with MinGW 4.7.x onwards? So the 4.7.1 bundled with CodeBlocks will still cause issues.

I'll recompile SFML.

4
Graphics / Re: Inherited sf::Drawable crashing
« on: January 22, 2013, 09:37:52 pm »
... which are incompatible. ;)

*twitch*

That'll be why my code worked fine with the version of MinGW bundled with CodeBlocks. This is the version I used when I first posted though. Since then I've changed and updated so much. I'll revert back to the older version of MinGW and see how I get on.

I think my original issue was my own fault, using low level pointers etc.

5
Graphics / Re: Inherited sf::Drawable crashing
« on: January 22, 2013, 09:35:27 pm »
What exact SFML version are you using or from where did you get it?
What exact MinGW version are you using?

I'm using SFML 2.0 RC, from this website.
Latest version of MinGW.

I should add that I've been trying different versions in an attempt to get it working. That's why I created a new VM so I could have a clean slate to test it.

Last week, I had a RenderWindow with sprites displayed. Not any more.

6
Graphics / Re: Inherited sf::Drawable crashing
« on: January 22, 2013, 09:33:53 pm »
Even the follow example gives me a segfault when creating an sf::RenderWindow

#include <memory>
#include <SFML/Graphics.hpp>

using namespace std;

int main() {
       
    sf::Event event;
        sf::RenderWindow testWindow(sf::VideoMode(800, 600, 32), "Test");

        while(testWindow.isOpen()) {
                sf::Event event;
                while(testWindow.pollEvent(event)) {
                        if(event.type == sf::Event::Closed || event.key.code == sf::Keyboard::Escape)
                                testWindow.close();
                }

                testWindow.clear();

                testWindow.display();
        }

        return 0;
}
 

7
Graphics / Re: Inherited sf::Drawable crashing
« on: January 22, 2013, 09:28:31 pm »
I'll do that now, but it doesn't seem to matter what I do. I've taken working examples from elsewhere and get the same issue.

8
Graphics / Re: Inherited sf::Drawable crashing
« on: January 22, 2013, 09:23:33 pm »
Debugging now shows up sf::VideoMode in D:\developpement\sfml-master\src\SFML\Window\VideoMode.cpp:50, but I have SFML under C:\SFML-2.0

I've tried both the release candidate and the latest snapshot (120).

9
Graphics / Re: Inherited sf::Drawable crashing
« on: January 22, 2013, 09:06:11 pm »
I actually to test this a little more. It was working, but am getting various segfaults even under 32bit. I may have jumped to conclusions.

10
Graphics / Re: Inherited sf::Drawable crashing
« on: January 22, 2013, 12:46:35 am »
I replaced standard pointers with unique_ptr, which I was unaware even existed until now, and the program still crashed. I think the issue is that I'm running Windows 7 (64bit) and compiling with MinGW. I've just finished testing the same code under a Windows XP (32bit) VM and it runs absolutely fine.

Thanks for the pointers. No pun intended. I have a fair amount of catching up to do!

11
Graphics / Re: Inherited sf::Drawable with SFML 2.0
« on: January 19, 2013, 08:22:54 pm »
What do you mean by same syntax?

If I store the sprites in an array declared in main(), as opposed to within my SpriteSheet class, it works fine.

ie. window.draw(*pSprites[0][0]);

So yes, [0 ][0 ] contains a valid sprite.

My error:
Program received signal SIGSEGV, Segmentation fault.
In sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&) () (C:\Windows\sfml-graphics-2.dll)
 

12
Graphics / Re: Inherited sf::Drawable with SFML 2.0
« on: January 19, 2013, 06:23:19 pm »
Well the array was really only for testing purposes, but I'll give it a go.

13
Graphics / Inherited sf::Drawable crashing
« on: January 19, 2013, 05:57:36 pm »
Hi there,

I'm using SFML 2.0 and have created a SpriteSheet class which inherits sf::Drawable. It contains a pointer array to store sprites created dynamically and I'm having trouble getting the sprites to draw.

SpriteSheet Declaration:
class SpriteSheet : public sf::Drawable {
    public:
        SpriteSheet(sf::Texture* texture, const int tileSize);
        ~SpriteSheet();

        void draw(sf::RenderTarget& target, sf::RenderStates states) const;

    private:
        int theTileSize;
        int cols;
        int rows;

        sf::Texture *pTexture;
        sf::Sprite *pSprites[16][16];
};

This is how I'm populating the sprites pointer array within the SpriteSheet constructor.
    for (int i=0; i<rows; i++) {
        for (int j=0; j<cols; j++) {
            sf::IntRect rect(sf::Vector2i(x,y),sf::Vector2i(theTileSize, theTileSize));
            pSprites[i][j] = new sf::Sprite(*pTexture, rect);
            pSprites[i][j]->setPosition(x*tileSize,y*tileSize);
        }
    }


When I run my code with window.draw(SpriteSheet); I get segfault errors. This is my draw function. If I use the same syntax in main(), everything works fine.
void SpriteSheet::draw(sf::RenderTarget &target, sf::RenderStates states) const {
    target.draw(*pSprites[0][0]);
}

Any ideas? I've only recently picked C++ back up again and I'm probably missing something glaringly obvious.

Thanks.

Pages: [1]
anything