Ah oui c'était pourtant évident !
Bon j'ai mis maintenant l'IDE me met:
erreur : undefined reference to `vtable for Stream'
erreur : undefined reference to `Stream::seek(long long)'
Un problème d'héritage je crois. J'ai pourtant bien remis les méthodes virtuelles pures de la classe parente non? :S
main.cpp
#include <SFML/Graphics.hpp>
#include "stream.h"
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 800), "SFML works!");
sf::Texture image;
Stream stream(":/img/uuu.jpg");
if (!image.loadFromStream(stream))
return EXIT_FAILURE;
sf::Sprite sprite;
sprite.setTexture(image);
sprite.setPosition(0,0);
sprite.setScale(0.5,0.5);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(sprite);
window.display();
}
return 0;
}
stream.cpp
#include "stream.h"
Stream::Stream(const char name[])
{
QFile file(name);
seek(file.pos());
}
stream.h
#ifndef STREAM_H
#define STREAM_H
#include <SFML/System.hpp>
#include <QTemporaryFile>
#include <QFile>
class Stream : public sf::InputStream
{
public:
Stream(const char name[]);
sf::Int64 read(void* data, sf::Int64 size);
sf::Int64 seek(sf::Int64 position);
sf::Int64 tell();
sf::Int64 getSize();
};
#endif // STREAM_H