-3
編輯:我認爲這是限制在屬性創建GL上下文,但它不是,所以我重寫了這篇文章。SwapBuffer Nvidia崩潰
嘿傢伙,每當我打電話給SwapBuffers(hDC)
,我都會崩潰。如果我用WGL_CONTEXT_DEBUG_BIT_ARB
創建它,我會得到一個「信號量太多的帖子」。從Windows我打電話SwapBuffers
。這可能是什麼原因?
更新:如果我沒有繪製,只要清除並交換,就不會發生崩潰。
這裏有點用不相關的位碼的切出:
static PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be
{
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number
PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
PFD_DOUBLEBUFFER, // Must Support Double Buffering
PFD_TYPE_RGBA, // Request An RGBA Format
32, // Select Our Color Depth
0, 0, 0, 0, 0, 0, // Color Bits Ignored
0, // No Alpha Buffer
0, // Shift Bit Ignored
0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored
24, // 24Bit Z-Buffer (Depth Buffer)
0, // No Stencil Buffer
0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved
0, 0, 0 // Layer Masks Ignored
};
if (!(hDC = GetDC(windowHandle)))
return false;
unsigned int PixelFormat;
if (!(PixelFormat = ChoosePixelFormat(hDC, &pfd)))
return false;
if (!SetPixelFormat(hDC, PixelFormat, &pfd))
return false;
hRC = wglCreateContext(hDC);
if (!hRC) {
std::cout << "wglCreateContext Failed!\n";
return false;
}
if (wglMakeCurrent(hDC, hRC) == NULL) {
std::cout << "Make Context Current Second Failed!\n";
return false;
}
... // OGL Buffer Initialization
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
glBindVertexArray(vao);
glUseProgram(myprogram);
glDrawElements(GL_TRIANGLES, indexCount, GL_UNSIGNED_SHORT, (void *)indexStart);
SwapBuffers(GetDC(window_handle));
發佈[最小,完整且可驗證的示例](https://stackoverflow.com/help/mcve) – BDL
@BDL完成。這很難,因爲代碼量很大,我不確定可能導致錯誤的原因。如果這是相關的,我會得到一個GL_VALIDATE_STATUS爲假但沒有信息日誌。但GL_LINK_STATUS返回true。 –
您應該使用傳遞給'wglMakecurrent'的HDC調用'SwapBuffers'。 –