1
Graphics / [SOLVED] window.draw(sprite) White Screen
« on: March 03, 2018, 10:22:41 am »
Hello,
After searching the whole internet, I'm desperately asking for help.
While executing the code below, I'm getting a white screen instead of the texture!
What might be the cause?
I'm not destructing Texture anywhere, file is loaded into the texture...
Thank you anyway!
After searching the whole internet, I'm desperately asking for help.
While executing the code below, I'm getting a white screen instead of the texture!
What might be the cause?
I'm not destructing Texture anywhere, file is loaded into the texture...
Thank you anyway!

#include "stdafx.h"
#include <SFML/Graphics.hpp>
#include <iostream>
using namespace sf;
int main()
{
VideoMode vm(1280, 720);
RenderWindow window(vm, "TIMBER_VS17", Style::Default);
Texture backgroundTexture;
//DEBUG LOADING TEXTURE FROM FILE//
if (!backgroundTexture.loadFromFile("graphics/background.jpg"))
{
std::cout << "LOG:\tCANNOT OPEN THE FILE\n";
}
else if (backgroundTexture.loadFromFile("graphics/background.jpg"))
{
std::cout << "LOG:\tFILE LOADED SUCCESSFULLY\n";
}
Sprite spriteBackground;
spriteBackground.setTexture(backgroundTexture);
spriteBackground.setPosition(0, 0);
while (window.isOpen())
{
if (Keyboard::isKeyPressed(Keyboard::Escape))
{
window.close();
}
}
window.clear();
window.draw(spriteBackground);
window.display();
return 0;
}
#include <SFML/Graphics.hpp>
#include <iostream>
using namespace sf;
int main()
{
VideoMode vm(1280, 720);
RenderWindow window(vm, "TIMBER_VS17", Style::Default);
Texture backgroundTexture;
//DEBUG LOADING TEXTURE FROM FILE//
if (!backgroundTexture.loadFromFile("graphics/background.jpg"))
{
std::cout << "LOG:\tCANNOT OPEN THE FILE\n";
}
else if (backgroundTexture.loadFromFile("graphics/background.jpg"))
{
std::cout << "LOG:\tFILE LOADED SUCCESSFULLY\n";
}
Sprite spriteBackground;
spriteBackground.setTexture(backgroundTexture);
spriteBackground.setPosition(0, 0);
while (window.isOpen())
{
if (Keyboard::isKeyPressed(Keyboard::Escape))
{
window.close();
}
}
window.clear();
window.draw(spriteBackground);
window.display();
return 0;
}