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

Author Topic: Weird problem with images  (Read 3766 times)

0 Members and 1 Guest are viewing this topic.

TricksterGuy

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Weird problem with images
« 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

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Weird problem with images
« Reply #1 on: April 12, 2009, 09:58:37 am »
Does http://www.sfml-dev.org/forum/viewtopic.php?t=969&highlight=white+sprite help you ?
(Haven't enough time to read your code.)
SFML / OS X developer

K-Bal

  • Full Member
  • ***
  • Posts: 104
    • View Profile
    • pencilcase.bandcamp.com
    • Email
Weird problem with images
« Reply #2 on: April 12, 2009, 01:15:08 pm »
Are you sure that you are running the executable in the right folder?
Listen to my band: pencilcase.bandcamp.com

TricksterGuy

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Weird problem with images
« Reply #3 on: April 12, 2009, 07:45:04 pm »
@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

  • Full Member
  • ***
  • Posts: 104
    • View Profile
    • pencilcase.bandcamp.com
    • Email
Weird problem with images
« Reply #4 on: April 13, 2009, 03:05:18 am »
Quote from: "TricksterGuy"

@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 ;)
Listen to my band: pencilcase.bandcamp.com

TricksterGuy

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Weird problem with images
« Reply #5 on: April 17, 2009, 08:42:14 pm »
Quote from: "K-Bal"
Quote from: "TricksterGuy"

@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 :/

Code: [Select]

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

Code: [Select]

#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 :/

 

anything