I have now decided to move the code in our framework around so that we have a number of threads.
Firstly, I have the main message dispatching loop that just uses thePeek/Translate/Wait/DispatchMessage() functions. This starts by calling the main routine to get our 3D drivers and then to set one up, then loops until the end of the program and then calls the exit code to delete the driver.
Secondly, there is a WndProc that puts events into a queue - this queue is locked with a mutex. If the app becomes inactive it sets a flag - under mutual exclusion.
Thirdly, I have moved the rendering code to another thread to free up the main app thread. This removes a message from the queue and calls the driver to do whatever needs to be done. If the app is inactive, this thread will wait on a semaphore until the WndProc thread gets an activate message.
The problem is this, when using the OpenGL driver the first time I go into the Flip() function, it crashes at SwapBuffers(m_hDC). I get the following message “Unhandled exception in <myapp> (NVOGLNT.DLL): 0xC0000005: Access violation.”
My driver is the latest from the NVidia site: 5.12.01.0631.
Has anybody else had a problem like this? (Or the same?)
Also, is there any way to check - like a monitor or something - how many threads are accessing something at any one time? This shouldn’t be happening as I’m putting all messages recieved into a queu to be taken out by another thread as I don’t want the WndProc thread to become locked ever.
Luke A. Guest.