We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2668

Summary: Provide a way to get current HDC along with HWND
Product: SDL Reporter: Katie Stafford <katie>
Component: videoAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: enhancement    
Priority: P2 CC: icculus
Version: 2.0.3Keywords: triage-2.0.4
Hardware: All   
OS: Windows (All)   

Description Katie Stafford 2014-07-31 02:49:57 UTC
The Oculus Rift SDK requires you to pass in the HDC of the window along with the HWND so it can call SwapBuffers itself. This handle is present in the SDL_WindowData structure alongside the HWND, but is not available from SDL_GetWindowWMInfo.

I can copy the internal structures to my program and get this handle, but that is a major hack and I want to avoid that.
Comment 1 Sam Lantinga 2014-07-31 05:46:01 UTC
Can you just use GetDC()?
http://msdn.microsoft.com/en-us/library/windows/desktop/dd144871(v=vs.85).aspx
Comment 2 Katie Stafford 2014-07-31 12:24:55 UTC
The Rift SDK actually does call GetDC if you don't give it a device context, but for some reason it doesn't seem to work unless you give it the HDC that created the GL context. This may be a bug in the Oculus SDK, but it still wouldn't hurt to have the existing handle present in SDL_SysWMInfo.
Comment 3 Katie Stafford 2014-08-01 15:20:36 UTC
I just tried using GetDC on the window; that returns a different handle. The only thing that works is the actual handle that created the context.
Comment 4 Ryan C. Gordon 2015-02-19 06:32:13 UTC
Marking a large number of bugs with the "triage-2.0.4" keyword at once. Sorry
if you got a lot of email from this. This is to help me sort through some bugs
in regards to a 2.0.4 release. We may or may not fix this bug for 2.0.4,
though!
Comment 5 Ryan C. Gordon 2015-03-23 23:48:10 UTC
This is now available in https://hg.libsdl.org/SDL/rev/286c854c1d5b

--ryan.