SFML community forums
Help => Graphics => Topic started by: TricksterGuy on April 12, 2009, 09:16:16 am
-
Maybe I'm doing something wrong here (or I am going crazy) but my images are not displaying
but the problem is my "sprites" appear as white blocks on the screen the colors are there that is calling image.GetPixel(X, Y) doesn't even return a color thats close to white
So here are all of my source files stripped down to show the problem in action - http://www.wg2140.com/users/trickster/TestImage.zip
Thanks for your time
-
Does http://www.sfml-dev.org/forum/viewtopic.php?t=969&highlight=white+sprite help you ?
(Haven't enough time to read your code.)
-
Are you sure that you are running the executable in the right folder?
-
@Hiura - I'll have another look at that topic.
@K-Bal - Yep I am sure actually I can get one of the images to display if you uncomment a line that loads the image again in Game.cpp but its kinda a dumb workaround for it :/
-
@K-Bal - Yep I am sure actually I can get one of the images to display if you uncomment a line that loads the image again in Game.cpp but its kinda a dumb workaround for it :/
Maybe you assign the sprite a image which is only temporarily available like a local variable in a function? My fortune telling was better some years ago ;)
-
@K-Bal - Yep I am sure actually I can get one of the images to display if you uncomment a line that loads the image again in Game.cpp but its kinda a dumb workaround for it :/
Maybe you assign the sprite a image which is only temporarily available like a local variable in a function? My fortune telling was better some years ago ;)
That couldn't be it. I made it a member variable of my class :/
class DrawingThing : public sf::Drawable
{
public:
DrawingThing();
~DrawingThing();
void Render(sf::RenderTarget& target) const;
private:
sf::Sprite sprite;
sf::Image* image;
};
In the constructor I load the image and set a sprite to that image and then in the render method I display that sprite
but I also have a game class (which has the class above as a member variable) and I load the same image there that I am trying to load in the Board class and it works and it doesn't make any sense to me on why that happens :| I never create a sprite to hold the image in the Game class I just have an image and load it and the one in the other class displays mysteriously...
Update
Here is my latest code
#include "DrawingThing.hpp"
using namespace sf;
Image hey;
DrawingThing::DrawingThing() : Drawable()
{
if (!hey.LoadFromFile("hey.png"))
printf("HEY IT DIDN'T LOAD");
sprite.SetImage(hey);
}
DrawingThing::~DrawingThing()
{
}
void DrawingThing::Render(RenderTarget& target) const
{
target.Draw(sprite);
}
It still gives the same effect :/