76
Graphics / Error loading Image with SFML [Solved]
« on: November 20, 2008, 09:18:37 pm »
This was solved over here.
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.
const sf::Input& Input = App.GetInput();
bool LeftKeyDown = Input.IsKeyDown(sf::Key::Left);
The way you're doing it rather means you're extending SFML's graphics classes.That's exactly what I'm trying to do. I want a Sprite, but with extra features like easy animation capabilities.
class Animatable : public virtual sf::Drawable
{
...
void AddMove(Move*); //Adds an animation move to our queue.
virtual void Update(float elapsedTime); //Call once per frame to update logic and do animation.
...
};
class Move
{
public:
virtual void Apply(sf::Drawable& obj, float elapsedTime) = 0;
virtual void Alive() const = 0; //should return false when the move is over.
};
class Man : public Animatable
{
...
private:
sf::Sprite head, body, arms, etc;
};
class ASprite : public sf::Sprite, public Animatable //Bam, diamond problem!
{};
as the "drawable" side of a class is generally just an implementation detail, not a part of its public interface.But it is a public interface for Sprite, String, and Shape.
ASprite test; //ASprite inherits from sf::Sprite and includes move functionality.
test.LoadFromFile("sprite.tga")
...
test.AddMove(new Move::LinearA(0, 0, 100, 100, 1.0f));
test.AddMove(new Move::RotateA(0, 90, 1.0f));
That would make test animate from 0, 0 to 100, 100 over the next 1 second while rotating from 0 degrees to 90 degrees. My specific problem is that my ASprite class must know that it's Drawable inorder for the moves to operate on it. Therefor, if it inherits from sf::Sprite, I run into the diamond problem. Virtual inheritance cleanly fixes this. (an alternative is to use dynamic_cast - that has the disadvantage of run time errors)Why should two windows have the nasty hidden implicit coupling of sharing a context? It's the same reason globals are bad.Do you think that MDI is always bad then?
If your program is completely sandboxed, then yes. In that case logic says that you can free anything you allocate, no matter how convoluted your design becomes.Quote from: "Laurent"
And you haven't experienced every single situation to say that 100% of leaks can be removed.
Experience doesn't enter into it, just logic. Anything you create, you can destroy.
actually I shouldn't even take in account the 3D API when designing my library, it's just an implementation detail.Right on, Laurent! Seriously, don't ever sacrifice your ideals.
probably because nobody uses the Code::Blocks debuggerActually I don't use it either. (Although I do think it's a great IDE, as far as they go.) I just though that was the easiest/only way to compile SFML with MinGW. Your make files seem to be hard coded for Linux/Unix.