I have an OpenGL program that works on all but one of my computers. This is a desktop with Vista 64 and Radeon HD4850. The problem seems to be in my call to SwapBuffers (hdc).
It compiles fine and then gives me an exception:
Unhandled exception at 0x00000000 in Program.exe: 0xC0000005: Access violation.
Using VC ++ to break before calling SwapBuffers shows the value of hdc:
0xfe011734 {unused = ???} CXX0030: Error: expression could not be evaluated
Does anyone know what could happen? Is there anything about SwapBuffers that changes from one PC to another? I got it to work on XP32, XP64 and (other) Vista64.
while (!quit) { if (PeekMessage(&msg, NULL, NULL, NULL, PM_REMOVE)) { if (msg.message == WM_QUIT) quit = true; TranslateMessage(&msg); DispatchMessage(&msg); } renderFrame();
Problem System Drivers (HD4850) updated. I ran and wrote the program on another Vista64 system with Radeon HD4870, also with modern drivers. As far as I know, the drivers for these two cards are almost identical, as in the HD48xx series. For this reason, it seems strange that the GPU is causing the problem.
Anyway, am I mistaken or is it a memory problem? (Access Violation)
In addition, if I delete the SwapBuffers (hdc) call, the program seems to work fine, although it doesnβt work, of course, because framebuffers never change places. But it is at least stable.
Call Stack (-> - ptr stack):
ATKOGL32.dll!6aef27bc() opengl32.dll!665edb2d() opengl32.dll!665f80d1() gdi32.dll!75e14104() -> MyProg.exe!WinMain(HINSTANCE__ * hinstance=0x009a0000, HINSTANCE__ * hprevinstance=0x00000000, char * lpcmdline=0x003b4a51, int nshowcmd=1) Line 259 + 0xe bytes MyProg.exe!__tmainCRTStartup() Line 578 + 0x35 bytes MyProg.exe!WinMainCRTStartup() Line 400 kernel32.dll!7641e3f3() ntdll.dll!777dcfed() ntdll.dll!777dd1ff()
Here is the assembly (-> the following instruction must be executed):
SwapBuffers(hdc); 009B1B5C mov esi,esp 009B1B5E mov eax,dword ptr [hdc (9BF874h)] 009B1B63 push eax 009B1B64 call dword ptr [ __imp__SwapBuffers@4 (0E1040Ch)] -> 009B1B6A cmp esi,esp 009B1B6C call @ILT+780(__RTC_CheckEsp) (9B1311h)