Strange GL frame buffer corruption
I am working on a new app using GL 4.2 core profile from scratch.
This is my init code:
Code :
HDC hDC = ::GetDC(hWnd);
PIXELFORMATDESCRIPTOR pfd;
::ZeroMemory(&pfd, sizeof(pfd));
pfd.nSize = sizeof(pfd);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL
| PFD_GENERIC_ACCELERATED | PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 32;
pfd.cAlphaBits = 8;
pfd.cDepthBits = 24;
pfd.cStencilBits = 8;
int format = ::ChoosePixelFormat(hDC, &pfd);
::SetPixelFormat (hDC, format, &pfd);
HGLRC hTempRC = ::wglCreateContext(hDC);
::wglMakeCurrent(hDC, hTempRC);
wgl_LoadFunctions(hDC);
int attribs[] =
{
WGL_CONTEXT_MAJOR_VERSION_ARB, 4,
WGL_CONTEXT_MINOR_VERSION_ARB, 2,
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
0
};
HGLRC hRC = ::wglCreateContextAttribsARB(hDC, nullptr, attribs);
::wglMakeCurrent(nullptr, nullptr);
wglDeleteContext(hTempRC);
::wglMakeCurrent(hDC, hRC);
ogl_LoadFunctions();
I then clear the framebuffer to red:
Code :
::glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
::glClearDepthf(1.0f);
::glClearStencil(0);
::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
SwapBuffers(hDC);
This is the result:
http://i.imgur.com/0Nk9D.png
What am I doing wrong?
I am on Windows 7 SP1 64-bit, with AMD Catalyst 12.11 drivers.