I'm using Visual Studio 2017. When debugging it points me to line 11
texture.getTexture().copyToImage().saveToFile("C:/test.bmp");
with an error
Exception thrown at 0x54B06B9E (sfml-graphics-2.dll) in Project2.exe: 0xC0000005: Access violation reading location 0xCCE6C37F.
I want to save the texture to a .bmp file.
#include<iostream>
#include<SFML/Graphics.hpp>
int main()
{
using namespace sf;
RenderTexture texture;
texture.create(800, 600);
texture.display();
texture.clear(Color::Black);
texture.getTexture().copyToImage().saveToFile("C:/test.bmp");
return 0;
}
As far as we've detected it's the .saveToFile("C:/test.bmp")
fragment that's causing the issue, the code works fine without it
I got SFML packages manually, I include them from a set folder each time I'm making a new project and link the libraries, also added manually through external lib folder
After some work I managed to fix the debug libraries and release libraries, now the code throws an exception
Run-Time Check Failure #2 - Stack around the variable 'texture' was corrupted.
A screenshot with the whole output and code:
Another thing is, when I continue without handling the exception it throws at me this:
Unhandled exception at 0x00D26859 in Project2.exe: Stack cookie instrumentation code detected a stack-based buffer overrun.
I found an answer, the issue was that I wasn't using .dlls compiled for VS 2017, I was using those compiled for 2015 instead, switched them and it works like a charm