嘿伙计们,每当我打电话给SwapBuffers(hDC)
时,我都会崩溃。如果我使用WGL_CONTEXT_DEBUG_BIT_ARB
创建它,我会得到一个
我打电话给信号量过多的帖子。
SwapBuffers
时,从Windows获取。可能是什么原因造成的?
更新:如果我不画画,只要清除并交换就不会发生崩溃。
这里有一些代码与不相关的位被删除:
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));
答案 0 :(得分:0)
我找到了答案。 SwapBuffer(hDC)命令只是发生错误的地方,但与它没有任何关系。我相信我的错误是由于与我的索引有关的东西,好像我只画了模型中的第一个网格,一切都按预期工作。 Nvidia因此错误而崩溃,英特尔继续并忽略了它。
尽管如此,感谢Chris Becke使用GetDC(hwnd)指出未来的内存泄漏。