wglCreateContext() works fine.
The way you've got everything set up with the static variables Windows_Main.h is... interesting, to say the least.
Hm. I'm not sure why it's happening the way it does, but when you try to access hrc from main.cpp, it doesn't like to see it.
However, I put the line: 'hrc = wglGetCurrentContext()' above the check you're doing in main.cpp, and it gets the same context that was created in your wndproc. This shouldn't have to happen.
I'm cant explain exactly what happens, but when the WM_CREATE message gets sent, the rendering context gets created just fine, and every time I hit a breakpoint in the wndproc, it sits unchanged. Though back in main, by time CreateWindowEx() returns, hrc seems to be NULL. (Further, the same thing seems to happen with 'hdc'.)
The structure of everything with these static variables in the header is very odd.
I fixed it, and here's what I did:
Removed the keyword 'static' from all
the variable declarations.
Moved the WndProc() from the header, to Windows_Main.cpp.
Moved HDC hdc, HGLRC hrc, and the two windows classes to the global space in main.cpp.
Moved int height, width into the WndProc function.
In the WndProc, at the top:
extern HDC hdc;
extern HGLRC hrc;
I'm pretty sure those are the only changes I made. Let me know if that works for you.
Also, if you handle "WM_CLOSE", you're expected to call DestroyWindow(). (http://msdn.microsoft.com/en-us/library/ms632617(VS.85).aspx
I'm saying hwnd might be different when you call GetDC(hwnd); because hwnd = CreateWindowEx has not yet returned. I'm not sure how it works =/
Nah. They're not gonna switch up the HWND on you, even if it's all during the creation of the window. Once you get the WM_CREATE message, that handle to the window is valid, and will remain valid.