Hiya. I am having some problems trying to load my texture file. I dont fully understand textures at all i dont feel that the tutorial is as descriptive as i would want it to be as far as what a texture is and what it is used for. The way i am interpreting it is that its an image with a bunch of (for example characters) things on it and a sprite is an individual thing(character). Im so confused =/ Anyway i am using codeblocks and c++. My image is within the same file as my exe and everything else, i added the image file to my codeblocks project but that didnt seem to do anything. Im not sure what else i could do. Can anyone tell me what a texture is and how to use it? And also what might be wrong with my code? The reason it says its not working is because it is unable to open file.
Code:
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <iostream>
using namespace std;
int main(){
sf::RenderWindow window(sf::VideoMode(800, 600), "Insomnia");
window.setPosition(sf::Vector2i(0, 0));
sf::Vector2u size = window.getSize();
unsigned int windowLength = size.x;
unsigned int windowWidth = size.y;
while(window.isOpen()){
sf::Texture texture;
if(!texture.loadFromFile("TextureImage")){
return 1;
}
sf::Event event;
while(window.pollEvent(event)){
if(event.type == sf::Event::Closed)
window.close();
}
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)){
window.close();
}
window.clear(sf::Color::Black);
window.display();
}
return 0;
}