关键代码段
DWORD WINAPI GLThread(LPVOID lpParams) { PIXELFORMATDESCRIPTOR pfd = {0}; HDC hDC = GetDC(hwndTest); HGLRC hRC = 0; /* Set absolute minimum format attributes; i.e. select default mode */ pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); pfd.nVersion = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; pfd.iPixelType = PFD_TYPE_RGBA; SetPixelFormat(hDC, ChoosePixelFormat(hDC, &pfd), &pfd); hRC = wglCreateContext(hDC); wglMakeCurrent(hDC, hRC); float color[3][3]={1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f}; int nSwitch = 0; while (!done) { nSwitch++; if (nSwitch>2) nSwitch = 0; glClearColor(color[nSwitch][0], color[nSwitch][1], color[nSwitch][2], 0.0f); glClear(GL_COLOR_BUFFER_BIT); SwapBuffers(hDC); Sleep(500); } return 0; }