SFML community forums

Help => General => Topic started by: idontmakesense on September 13, 2013, 02:42:30 pm

Title: Changing from dev c++ to visual studio 2012
Post by: idontmakesense on September 13, 2013, 02:42:30 pm
I first got sfml up and running perfectly in visual studio 2012(got the green circle and everything).

Then I copy-pasted the code, since it was a small project containing only a main file.
Next I pasted a few sprites which I'm using in the code in the debug folder of my project in visual studio.

The project compiles and builds fine. When I run it, I get an unhandled exception with msvcr110.dll in braces.

Help will be really appreciated. 
Title: Re: Changing from dev c++ to visual studio 2012
Post by: eXpl0it3r on September 13, 2013, 02:50:18 pm
Run it through the debugger and find out where things go wrong with a call trace back.
Title: Re: Changing from dev c++ to visual studio 2012
Post by: idontmakesense on September 13, 2013, 03:08:07 pm
Problem occurs when the image is being loaded in the texture variable. Where exactly do i need to save the '.png' files? Or do i have the give the full path name? Right now there are in the debug folder along with the sfml dlls and project application/run file
Title: Re: Changing from dev c++ to visual studio 2012
Post by: eXpl0it3r on September 13, 2013, 03:20:27 pm
You put it in the working directory, which can be changed in the project settings. By default Visual Studio sets it next to the project file.
Also failing to load an image should not crash the application, instead it should simply output a message on the console.

Do you have a minimal but complete example code?
Title: Re: Changing from dev c++ to visual studio 2012
Post by: idontmakesense on September 13, 2013, 03:41:35 pm
Im sorry I didn't get you...

This is the part of the code till it runs.

Quote
#include<SFML/Graphics.hpp>
#include<iostream>
#include<cmath>

#define PI 3.14159265

using namespace std;

int main()
{
   const int xRes= 1300;
   const int yRes= 700;
   
   sf::RenderWindow window(sf::VideoMode(xRes, yRes), "Window");
   
   float carLength= 35, carBreadth= 15, bulletLength= 20, bulletBreadth= 10;
   
   float xCar= 100, yCar= 100;
   sf::Texture car_texture, bullet_texture;
   if(!car_texture.loadFromFile("black_car.png"))
      cout<<"Could not load image file"<<endl;

Then it breaks saying...

Quote
First-chance exception at 0x748EDCF8 (msvcr110.dll) in sfml_prac.exe: 0xC0000005: Access violation reading location 0x00511000.
Unhandled exception at 0x748EDCF8 (msvcr110.dll) in sfml_prac.exe: 0xC0000005: Access violation reading location 0x00511000.