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

Author Topic: Weird setImage problem  (Read 1920 times)

0 Members and 1 Guest are viewing this topic.

niko

  • Newbie
  • *
  • Posts: 1
    • View Profile
Weird setImage problem
« on: July 03, 2009, 01:32:44 am »
Hello there,

I have been learning C++ and was recommended SFML to start using graphics with. Things have been fine so far untill I ran into this problem.

Before I carry on, I understand that there are already Managers for images and Tile engines made, I will most likely end up using them. However I thought it would be good exercise in C++ to create my own for now before using anyone else's code.

Here is a snipper of the part of the code causing me grief:
http://codepad.org/1wOfDXnO

Hopefully you can see that I am trying to use a reference to the image loaded in the manager and pass it to the Tile class, and then set the sprites image according to the pointer.

I have tried two ways of doing this:
Firstly with line 18 as it is in the link and secondly by changing line 18 to:
Code: [Select]

sf::image test  = *img;
sprite.setImage(test)


The first way leads into a segmentation fault and the stack ends with:
Code: [Select]

Program received signal SIGSEGV, Segmentation fault.
In std::_Rb_tree<sf::ResourcePtr<sf::Image>*, sf::ResourcePtr<sf::Image>*, std::_Identity<sf::ResourcePtr<sf::Image>*>, std::less<sf::ResourcePtr<sf::Image>*>, std::allocator<sf::ResourcePtr<sf::Image>*> >::insert_unique () (D:\Documents\C++\TD\sfml-graphics.dll)


And the second way ends in:
Code: [Select]

Failed to create image, its internal size is too high (2292668x1)

This results in a white line on the top of the screen.

I have no idea why either of these are happening, It could be either my implementation or something else I am doing wrong.

Hopefully someone would be able to help =D

PS. I did search the forums but count find anything similar :<

Hope to hear from someone soon!

niko