PDA

View Full Version : Acess violation at every opengl function call at “OpenAdapter10_2” after SwapBuffers



6opoDuJIo
06-19-2016, 06:19 AM
this is how my context made :
(WNDCLASSE and RegisterClassE should end with "X", but forum is intolerate to winapi names (that contain "S E X") and block's them)

bool InitializeContext(HWND& hwnd, HDC& dc, HGLRC& wglcontext)
{
LPCWSTR myclass = L"local_wnd_context_";

WNDCLASSE wndclass =
{
sizeof(WNDCLASSE),
CS_OWNDC,
WndProc,
0, 0,
GetModuleHandle(0),
LoadIcon(0,IDI_APPLICATION),
LoadCursor(0,IDC_ARROW),
HBRUSH(COLOR_WINDOW + 1),
0,
myclass,
LoadIcon(0,IDI_APPLICATION)
};

if (RegisterClassE(&wndclass))
{
hwnd = CreateWindowEx
(
0,
myclass,
L"title",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
0,
0,
GetModuleHandle(0),
0
);

if (hwnd)
{
ShowWindow(hwnd, SW_SHOWDEFAULT);

PIXELFORMATDESCRIPTOR pfd =
{
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW , //Flags
PFD_TYPE_RGBA, //The kind of framebuffer. RGBA or palette.
32, //Colordepth of the framebuffer.
0, 0, 0, 0, 0, 0,
0,
0,
0,
0, 0, 0, 0,
24, //Number of bits for the depthbuffer
8, //Number of bits for the stencilbuffer
0, //Number of Aux buffers in the framebuffer.
PFD_MAIN_PLANE,
0,
0, 0, 0
};

dc = GetDC(hwnd);
int pixelFormat = ChoosePixelFormat(dc, &pfd);

if (SetPixelFormat(dc, pixelFormat, &pfd))
{
wglcontext = wglCreateContext(dc);
std::cout << wglMakeCurrent(dc, wglcontext) << "\n";
return true;
}
}
}

return false;
}


And, sometimes, context created like this may cause exceptions for any function (for example, glGetGraphicsResetStatus, other SwapBuffers or wglGetCurrentDC) called after SwapBuffers, at location with following call stack (gDebugger GL):


OpenAdapter10_2 - igd10iumd64.dll
OpenAdapter10_2 - igd10iumd64.dll
OpenAdapter10_2 - igd10iumd64.dll
OpenAdapter10_2 - igd10iumd64.dll
DrvPresentBuffers - nvoglv64.DLL
DrvPresentBuffers - nvoglv64.DLL
DrvPresentBuffers - nvoglv64.DLL
DrvPresentBuffers - nvoglv64.DLL
DrvPresentBuffers - nvoglv64.DLL
BaseThreadInitThunk - KERNEL32.DLL

So, the main question is "what's the reason and how to fix it"?
I tried also to make context via wglCreateContextAttribsARB, but result is the same.