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

Author Topic: [solved]programm crashes at the end  (Read 5704 times)

0 Members and 1 Guest are viewing this topic.

helo

  • Newbie
  • *
  • Posts: 14
    • View Profile
[solved]programm crashes at the end
« on: March 09, 2010, 05:26:41 pm »
My Programm ,using sprites, crashes when I close it and about 70 sprites are used, one sprite less and it works fine, is there any maximum amoung of sprites within the library or is it my Code causing the crash?

phear-

  • Jr. Member
  • **
  • Posts: 64
    • MSN Messenger - LOApokalypse@hotmail.com
    • View Profile
    • http://gtproductions.org
[solved]programm crashes at the end
« Reply #1 on: March 09, 2010, 05:58:16 pm »
You have an ATI graphics card?
Eugene Alfonso
GTP | Twitter

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[solved]programm crashes at the end
« Reply #2 on: March 09, 2010, 06:25:00 pm »
Can you show your code?
Laurent Gomila - SFML developer

helo

  • Newbie
  • *
  • Posts: 14
    • View Profile
[solved]programm crashes at the end
« Reply #3 on: March 09, 2010, 09:38:49 pm »
@phear-:I have an ATI Graphics Card.
@Laurent:
If you have that much time to look after it in my source code it would be very nice. It is too much code to add it to this post, I think, therefore I uploaded it http://here

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[solved]programm crashes at the end
« Reply #4 on: March 09, 2010, 11:09:25 pm »
Quote
If you have that much time to look after it in my source code it would be very nice

I do have that much time, but honestly it would be much easier if you remove all the unrelated pieces of code and show us a minimal and complete example that reproduces this problem ;)
Laurent Gomila - SFML developer

helo

  • Newbie
  • *
  • Posts: 14
    • View Profile
[solved]programm crashes at the end
« Reply #5 on: March 10, 2010, 12:01:49 pm »
Ok I´ll try to^^

helo

  • Newbie
  • *
  • Posts: 14
    • View Profile
[solved]programm crashes at the end
« Reply #6 on: March 10, 2010, 12:14:36 pm »
Here(not anymore) it is reduced almost to the minimum, I think.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[solved]programm crashes at the end
« Reply #7 on: March 10, 2010, 12:18:42 pm »
"Object\SingleImageStatic.hpp" is missing.

And it's still not a minimal example, you can remove your classes (I don't think that all their getters and setters make a difference), extract what is really important and put it directly into one big main() ;)

You can also create your images with Create() rather than LoadFromFile(), so that I don't have to bother with image files to make it work.

Yeah I know, writing a minimal example is an art ;)
Laurent Gomila - SFML developer

phear-

  • Jr. Member
  • **
  • Posts: 64
    • MSN Messenger - LOApokalypse@hotmail.com
    • View Profile
    • http://gtproductions.org
[solved]programm crashes at the end
« Reply #8 on: March 10, 2010, 05:59:01 pm »
Quote from: "helo"
@phear-:I have an ATI Graphics Card.


Thats why you crash.
Eugene Alfonso
GTP | Twitter

dunce

  • Jr. Member
  • **
  • Posts: 77
    • View Profile
[solved]programm crashes at the end
« Reply #9 on: March 10, 2010, 06:07:29 pm »
I have two laptops with ATI cards both. I have never experienced any problems with maximum amount of sprites.

helo

  • Newbie
  • *
  • Posts: 14
    • View Profile
[solved]programm crashes at the end
« Reply #10 on: March 11, 2010, 05:06:38 pm »
@phear & dunce: hmm k  :?:
@Laurent: Ok I think, now I understood what you mean  :D

helo

  • Newbie
  • *
  • Posts: 14
    • View Profile
[solved]programm crashes at the end
« Reply #11 on: March 11, 2010, 09:03:51 pm »
Code: [Select]
#define SPRITE_AMOUNT 100000

#include <SFML/Graphics.hpp>

using namespace std;
using namespace sf;

int main()
{

    RenderWindow MyApp(sf::VideoMode(800, 600, 32), "SFML Graphics");

    Image MyImage = Image();

    Sprite MySprites[SPRITE_AMOUNT];

    MyImage.Create(10,10,Color(120,155,0));

    for(int i=0;i<SPRITE_AMOUNT;i++)
    {
        int j = i%100;
        MySprites[i] = Sprite();
        MySprites[i].SetImage(MyImage);
        MySprites[i].SetPosition(j*10,i);
    };

    while(MyApp.IsOpened())
    {
        MyApp.Clear();
        Event MyEvent;
        MyApp.GetEvent(MyEvent);

        if (MyEvent.Type == sf::Event::Closed)
        {
            MyApp.Close();
        }

        for(int i=0;i<SPRITE_AMOUNT;i++)
        {
            MyApp.Draw(MySprites[i]);
        };


        MyApp.Display();
    }



    return 0;
}


thats the maximum of reducing, I hope, but the mistake got lost on the way^^ Here I can use 20000 sprites and even more I think without breaking down  :wink:
The mistake have to be in my Code!

helo

  • Newbie
  • *
  • Posts: 14
    • View Profile
[solved]programm crashes at the end
« Reply #12 on: March 11, 2010, 09:17:53 pm »
I solved my Problem through replacing an array of pointers to objects with a sprite with an array of the objects directly.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[solved]programm crashes at the end
« Reply #13 on: March 11, 2010, 09:31:25 pm »
Great!

And yes, this is the kind of "minimal example" that I was talking about ;)
Laurent Gomila - SFML developer