Is there an example of successfully integrating SFML within a native window in Windows that does not fire off OpenGL warnings?
What I'm talking about here is not a complicated request: just a single native window from which SFML can create a render window.
Since the upgrade from SFML 2 to SFML 3, I've found this to be impossible.
For example, this code:
#include <SFML/Graphics.hpp>
#include <Windows.h>
#include <iostream>
LRESULT CALLBACK WindowProcedure(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
int main()
{
HINSTANCE hInstance{ GetModuleHandle(NULL) };
// main window
const wchar_t mainClassName[] = L"Main Window Class";
WNDCLASS wc = { };
wc.lpfnWndProc = WindowProcedure;
wc.hInstance = hInstance;
wc.lpszClassName = mainClassName;
RegisterClass(&wc);
HWND hWnd = CreateWindowEx(
0, mainClassName, L"SFML in native window test", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, // position
1000, 1000, // size
NULL, NULL, hInstance, NULL
);
if (!hWnd)
return EXIT_FAILURE;
ShowWindow(hWnd, SW_SHOWNORMAL);
sf::RenderWindow sfmlWindow(hWnd);
sfmlWindow.clear(sf::Color(255u, 160u, 64u)); // fill the SFML window with a solid colour
sfmlWindow.display();
MSG msg{};
while (GetMessage(&msg, NULL, 0, 0) > 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
LRESULT CALLBACK WindowProcedure(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
}
}
as well as this official example:
https://github.com/SFML/SFML/blob/master/examples/win32/Win32.cppcause this error since SFML 3:

(that failed call is from here:
https://github.com/SFML/SFML/blob/master/src/SFML/Graphics/RenderWindow.cpp#L113)
The error is always thrown on window.create() and is thrown repeatedly and locks the progress of the program. Only in debug mode, however. In release mode, it's fine and the graphics module works as expected.