The code works well but does not appear
image you know why?
#ifndef HILO_H_INCLUDED
#define HILO_H_INCLUDED
#include <SFML/System.hpp>
#include <iostream>
#include <SFML/Graphics.hpp>
using namespace sf;
class Hilo: public sf::Thread
{
public :
Hilo(sf::RenderWindow *app, sf::Image iCual);
virtual void Run();
private:
RenderWindow *App;
sf::Sprite Sprite;
};
#include <iostream>
#include "Hilo.h"
using namespace sf;
Hilo::Hilo( sf::RenderWindow *app, sf::Image iCual ){
App = app;
}
void Hilo::Run(){
sf::Image Image;
Image.LoadFromFile("datas/pong/fo2.jpg");
// Create the sprite
sf::Sprite Sprite(Image);
Sprite.SetPosition(200.f, 100.f);
while (App->IsOpened())
{
std::cout << "I'm the thread number 2" << std::endl;
App->Clear();
App->Draw(Sprite);
App->Display();
}
}
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/System.hpp>
#include <iostream>
#include <SFML/Graphics.hpp>
using namespace sf;
//Mutex GlobalMutex; // This mutex will be used to synchronize our threads
#include "Hilo.h"
int main()
{
// Create the main rendering window
RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics");
sf::Image Image;
if (!Image.LoadFromFile("datas/pong/fo2.jpg"))
return EXIT_FAILURE;
Hilo *w_Hilo= new Hilo(&App,Image);
w_Hilo->Launch();
// Start game loop
while (App.IsOpened())
{
// Process events
sf::Event Event;
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
App.Close();
}
return EXIT_SUCCESS;
}