This is the code i am trying to run everything works fine
but when I try to run it i get an error saying "Unhandled exception at 0x75a6f7cc in board render tes.exe: 0xC0000005: Access violation reading location 0x65742064.".
previously i was able to run the projects of sfml
no such error occurred.
now also i use the old projects and just write the code in them and works perfectly fine but if i make any new project i get this error.
please help me to solve this error
As far as creating at creation of window, i'm not 100% sure.
but there is ONE problem with your code.
You have these lines:
sf::IntRect myRect(x,y,32,32);
mySprite.setTextureRect(myRect);
myWindow.clear();
myWindow.draw(mySprite);
myWindow.display();
inside the second while loop, when it should be under
so it'll be this:
#include <SFML\Graphics.hpp>
#include <SFML\System.hpp>
#include <SFML\Window.hpp>
#include <iostream>
using namespace std;
int main()
{
int x=0,y=0;
sf::VideoMode myMode(640,480,32);
sf::RenderWindow myWindow(myMode,"board test");
sf::Texture myTexture;
if(!myTexture.loadFromFile("C:\\Users\\Voldy\\Documents\\Blue Tile.png"))
{
cout << " Could not load image" << endl ;
return 0;
}
sf::Sprite mySprite(myTexture);
sf::Event event;
while (myWindow.isOpen())
{
while (myWindow.pollEvent(event))
{
if(event.type == sf::Event::Closed || event.key.code == sf::Keyboard::Escape)
{
myWindow.close();
}
}
sf::IntRect myRect(x,y,32,32);
mySprite.setTextureRect(myRect);
myWindow.clear();
myWindow.draw(mySprite);
myWindow.display();
}
}
As FRex said, make sure your linker and includes are correct.
Maybe rebuild SFML lib, and remove all old SFML (if any)