So, im pretty new to C++ and SFML and i ran into an error with this code:
#include "stdafx.h"
#include <SFML/Graphics.hpp>
int main()
{
// create the window
sf::RenderWindow window(sf::VideoMode(800, 600), "2D Sprites");
sf::Texture texture;
sf::Sprite sprite;
sprite.setTexture(texture);
sprite.setPosition(sf::Vector2f(50, 50));
texture.loadFromFile("TAA1TAA.png");
texture.setSmooth(true);
// run the program as long as the window is open
while (window.isOpen())
{
// check all the window's events that were triggered since the last iteration of the loop
sf::Event event;
while (window.pollEvent(event))
{
// "close requested" event: we close the window
if (event.type == sf::Event::Closed)
window.close();
}
// clear the window with black color
window.clear(sf::Color::Black);
// draw everything here...
window.draw(sprite);
// end the current frame
window.display();
}
return 0;
}
and the error (or exception):
First-chance exception at 0x6E9ADCF8 (msvcr110.dll) in Test2.exe: 0xC0000005: Access violation reading location 0x00277000.
As im new to SFML and C++, im not really sure how this error came, but it seems to come from the Graphics module for sure. Opening Windows gives me no such errors.