1
Window / Get window device context (hDC) and GL reource context (hGLRC)
« on: July 17, 2023, 07:13:56 pm »
I was trying to get this so I can pass them to openxr which needs to know about these handles.
I saw 2 ways of doing this and expected both ways to give me the same address but they don't so I'm a bit confused by this and I'm not sure what I'm missing here.
1st way is to just use wglGetCurrentDC() and wglGetCurrentContext(). I figured this would be fine since all of this is done on the main thread during initialization anyway but I wanted to be sure that I was grabbing the context of the window generated by SFML.
So I started to see if I could do it this way (2nd way)
Is there a way to get both the hDC and hGLRC from SFML, even it's like what I'm trying to do in the code part?
I saw 2 ways of doing this and expected both ways to give me the same address but they don't so I'm a bit confused by this and I'm not sure what I'm missing here.
1st way is to just use wglGetCurrentDC() and wglGetCurrentContext(). I figured this would be fine since all of this is done on the main thread during initialization anyway but I wanted to be sure that I was grabbing the context of the window generated by SFML.
So I started to see if I could do it this way (2nd way)
sf::RenderWindow window(...);
auto win_handle = window.getSystemHandle();
auto win_context = GetDC(win_handle ); // the hDC address I get back from doing this does not match the address I get back from wglGetDeviceContext
// Im not really sure how to get to the hGLRC since it is private.
auto win_handle = window.getSystemHandle();
auto win_context = GetDC(win_handle ); // the hDC address I get back from doing this does not match the address I get back from wglGetDeviceContext
// Im not really sure how to get to the hGLRC since it is private.
Is there a way to get both the hDC and hGLRC from SFML, even it's like what I'm trying to do in the code part?