HI !
I am new to SFML .
I wanted to make a window and show a picture inside it .
I create the window correctly and the picture is loaded correctly , BUT I still can't display the sprite .
What I did is I created a RenderWindow and I tried to loadFromFile a sprite , BUT I saw an error indicating its not possible , so I loadeFromFileED a texture and setTextureED the sprite .
BUT I still can't observe the picture .
This is my code :
#include <SFML/graphics.hpp>
#include <iostream>
using std :: cout ;
int main ()
{
sf::RenderWindow winMain (sf::VideoMode(800,600),"Test") ;
sf::Texture winTexture ;
if (!winTexture.loadFromFile("Untitled.jpg"))
{
cout << "ERROR opening Untitled.jpg" ;
}
sf::Sprite winSprite ;
winSprite.setTexture(winTexture) ;
winMain.display() ;
while (winMain.isOpen())
{
sf::Event winEvent ;
while (winMain.pollEvent(winEvent))
{
winMain.draw(winSprite) ;
winTexture.update (winMain) ;
switch (winEvent.type)
{
case sf::Event::Closed :
winMain.close() ;
break ;
}
}
}
}
Thnaks !