Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- LRESULT GLWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- switch(uMsg)
- {
- case WM_CREATE:
- {
- if(!m_hdc)
- {
- m_hdc = GetDC(hWnd);
- }
- SetupPixelFormat();
- if(!m_hglrc)
- {
- int attribs[] = {
- WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
- WGL_CONTEXT_MINOR_VERSION_ARB, 0,
- 0};
- HGLRC tmpContext;
- if(!(tmpContext = wglCreateContext(m_hdc)))
- {
- MessageBox(NULL, L"Can't create temp context", NULL, MB_OK);
- }
- if(!wglMakeCurrent(m_hdc, tmpContext))
- {
- MessageBox(NULL, L"Can't make temp context current", NULL, MB_OK);
- }
- wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");
- if(!wglCreateContextAttribsARB)
- { // If wgl_create_context doesn't exist.
- m_hglrc = tmpContext;
- tmpContext = NULL;
- }
- else
- { // If wgl_create_context exists.
- m_hglrc = wglCreateContextAttribsARB(m_hdc, 0, attribs);
- if(!m_hglrc)
- { // If trying a higher OpenGL version fails. (Maybe try to query for a lower OpenGL version this way? Is there a point?)
- m_hglrc = tmpContext;
- tmpContext = NULL;
- }
- // Everything is looking good, use it and delete the old context.
- wglDeleteContext(tmpContext);
- tmpContext = NULL;
- wglMakeCurrent(m_hdc, m_hglrc);
- }
- }
- m_isRunning = true;
- }
- break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement