so what im trying to do is take a screenshot from the entire screen(not only from sfml window) and saving it to memory to then save to a file (i am trying to just save to memory but to debug i am saving) and it gives me the error at the title (i am only using 1 file for a while)
#include "functions.h"
#include <SFML/Graphics.hpp>
#include <SFML/Network.hpp>
#include <Windows.h>
#undef IS_USING_TEXT
void* screenCapturePart() {
HDC hdcSource = GetDC(NULL);
HDC hdcMemory = CreateCompatibleDC(hdcSource);
int capX = GetDeviceCaps(hdcSource, HORZRES);
int capY = GetDeviceCaps(hdcSource, VERTRES);
HBITMAP hBitmap = CreateCompatibleBitmap(hdcSource, 1920, 1080);
HBITMAP hBitmapOld = (HBITMAP)SelectObject(hdcMemory, hBitmap);
BitBlt(hdcMemory, 0, 0, 1920, 1080, hdcSource, 0, 0, SRCCOPY);
hBitmap = (HBITMAP)SelectObject(hdcMemory, hBitmapOld);
return hBitmap;
}
int WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nShowCmd)
{
#ifdef IS_USING_TEXT
static auto defFont = new sf::Font;
defFont->loadFromFile("Roboto-Regular.ttf");
#endif // IS_USING_TEXT
sf::RenderWindow window(sf::VideoMode(800u, 800u), "SFML", sf::Style::Close);
window.setVerticalSyncEnabled(true);
sf::Event evnt;
sf::Image screenshot;
screenshot.loadFromMemory(screenCapturePart(), (size_t)1920 * 1080 * sizeof(sf::Color));
if (screenshot.saveToFile("z.bmp"))
window.close();
while (window.isOpen())
{
ProcessEvents(window, evnt);
window.clear();
window.display();
}
#ifdef IS_USING_TEXT
delete defFont;
#endif // IS_USING_TEXT
return 0;
}