-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'。 –