std::ifstream fichier(chemin.c_str());
std::string ligne;
if(fichier.fail())
{
std::cerr << "fichier de config non trouv�\n" << std::endl;
exit(1);
}
fichier >> nb_fenetre;
std::cout << nb_fenetre << std::endl;
std::cout << chemin << std::endl;
liste_images = new sf::Texture[nb_fenetre];
std::getline(fichier, ligne);
while(i != nb_fenetre)
{
std::getline(fichier, ligne);
std::cout << ligne << std::endl;
if (!liste_images[i].loadFromFile(ligne.c_str()))
std::cerr << ligne << " not found" << std::endl;
//exit(1);
}
i++;
std::cout << ligne << "-" << std::endl;
std::cout << i << "/" << nb_fenetre << std::endl;
}
fond.setTexture(liste_images[2], true);
do_wait: drmWaitVBlank returned -1, IRQs don't seem to be working correctly.
Try adjusting the vblank_mode configuration parameter.
3
Config/intro.txt
icone1.png
". Reason : Unable to open fileg
not found
-cone1.png
1/3
icone2.png
". Reason : Unable to open fileg
not found
-cone2.png
2/3
icone3.png
icone3.png-
3/3
void NFenetre_intro::getImage(Nwindow &wind)//Nwindow hérite de sf::RenderWindow
{
wind.draw(fond);
}
pour l'affichage, j'ai une fenetre totalement noir.3/3
neckara@NeckDebian:~/test$ ./exe
do_wait: drmWaitVBlank returned -1, IRQs don't seem to be working correctly.
Try adjusting the vblank_mode configuration parameter.
3
Config/intro.txt
icone1.png
". Reason : Unable to open fileg
not found
-cone1.png
1/3
icone2.png
". Reason : Unable to open fileg
not found
-cone2.png
2/3
~/Documents/Donnees/Gestion-fenetre/icone3.png
". Reason : Unable to open filets/Donnees/Gestion-fenetre/icone3.png
not founds/Donnees/Gestion-fenetre/icone3.png
-/Documents/Donnees/Gestion-fenetre/icone3.png
3/3
std::cout << ligne << "-" << std::endl;
le "-" remplace le premier caractère de ligne dans l'affichage et ce uniquement lorsque le chargement de l'image ne marche pas.!liste_images[i].loadFromFile(ligne.c_str())
par!liste_images[i].loadFromFile("icone3.png")
ligne += "/";
std::cout << ligne << std::endl;
et il m'affiche/cone.png
void draw (const Drawable &drawable, const RenderStates &states=RenderStates::Default)
class Hevent
{
private:
bool Running;
sf::RenderWindow wind;
public:
void event();
void afficher();
Hevent();
~Hevent();
};
.cppvoid lance_afficher(void *data)
{
Hevent *hevent = static_cast<Hevent*>(data);
hevent->afficher();
}
Hevent::Hevent()
{
sf::Thread Thread(&lance_afficher, this);
Thread.launch();
event();
Thread.wait();
}
Hevent::~Hevent()
{
}
void Hevent::event()
{
Running = true;
while (Running)
{
sf::Event Event;
while (wind.waitEvent(Event))
{
//traitement de l'évènement
}
}
}
void Hevent::afficher()
{
wind.setFramerateLimit(IMGPROSEC);
while(Running)
{
//tous les wind.draw
wind.display();
}
}
Sous Débian avec une carte graphique intel, je suis obligé d'activer le RenderWindow dans le thread quand je met une image dans un Texture sinon la texture est modifiée lors du draw(ma_texture) de la boucle d'affichage.Je veux bien un code complet minimal de ça, histoire de pouvoir creuser un peu.
Sinon, pour l'activation du renderWindow pour les draw, clear, display c'est juste pour les renderWindow? Je n'ai pas besoin de l'activé si je dessine sur un renderTexture?Tu ne dois rien faire, ça fait tout seul ce que ça doit faire quand ça doit le faire :P
class Hevent
{
private:
bool Running;
sf::RenderWindow wind;
public:
void event();
void afficher();
Hevent();
~Hevent();
Fenetre * mafenetre;
};
.cppvoid lance_afficher(void *data)
{
Hevent *hevent = static_cast<Hevent*>(data);
hevent->afficher();
}
Hevent::Hevent() : mafenetre(NULL), wind(500,500)
{
wind.setActive(false);
sf::Thread Thread(&lance_afficher, this);
Thread.launch();
Fenetre toto;//chargement de sf::Texture et autre
mafenetre = &toto;
event();
Thread.wait();
}
Hevent::~Hevent()
{
}
void Hevent::event()
{
Running = true;
while (Running)
{
sf::Event Event;
while (wind.waitEvent(Event))
{
//traitement de l'évènement
}
}
}
void Hevent::afficher()
{
wind.setFramerateLimit(IMGPROSEC);
while(Running)
{
if(mafenetre != NULL)
wind.draw(mafenetre->getSprite());
//tous les wind.draw
wind.display();
}
}
class Fenetre
{
sf::Texture text;
public :
Fenetre()
{
text.loadFromFile("toto.png");
}
const sf::Sprite & getSprite(){ sf::Sprite toto(text); return toto; };
}
I tried to look for the problem a little bit further. Maybe you already know these things, but I'll post them in case you didn't.Je n'ai pas tout à fait tout compris, mais j'ai retenu qu'il faut charger l'image dans le sf::Texture quand le renderWindow est activé
The problem lies with the glBindTexture call in texture.Create.
This is only one part of the problem, something in window.Create makes this problem.
So I split up the Create function in two parts: one was executed before and one after the texture was loaded.
Window.Create contains this line: "myContext = priv::GlContext::New(settings, myImpl, mode.BitsPerPixel);".
If this line is executed after the texture has been created then it will not be drawn correctly.
Here the problem lies with the "context->Initialize();" function.
And the line were the problem lies is "SetActive(true);"
So window.myContext has to be active before the texture gets created.
This would mean that the problem lies with currentContext.
Je ne sais pas si utiliser une sf::Image change vraiment quelque chose.Oui on s'en fiche, c'était juste pour rendre le code indépendant de ressources externes. Comme ça n'importe qui peut le copier-coller et le tester directement.
Mais il me semble avoir le même problème que sur le lien que vous m'aviez donné : https://github.com/SFML/SFML/issues/160Oui c'est fort possible, quoique là on aurait une nouvelle variante.
Je n'ai pas tout à fait tout compris, mais j'ai retenu qu'il faut charger l'image dans le sf::Texture quand le renderWindow est activéOui, et c'est là qu'est le bug : normalement SFML fait en sorte qu'il n'y ait pas besoin de faire ça.
sf::Context context;