I'm having problems with releasing the device context.
/**
* Destructor
*/
COpenGLDriver::~COpenGLDriver()
{
if( hRC ){
if( !wglMakeCurrent(0,0) )
util::Message::print("COpenGLDriver::~COpenGLDriver: Release of DC and RC failed.");
if( !wglDeleteContext(hRC) )
util::Message::print("COpenGLDriver::~COpenGLDriver: Release of rendering context failed.");
hRC = NULL;
}
if( ReleaseDC(Window, hDC) != 1 ){
util::Message::print("COpenGLDriver::~COpenGLDriver: Could not release openGL dc.");
}
// Dodgy - I'm using the 'else if' as an &&
// This will only execute if hRC == NULL and the ReleaseDC call succeeds.
else if( hRC == NULL )
util::Message::print("COpenGLDriver::~COpenGLDriver: OpenGL was uninitialized properly.");
hDC = NULL;
}
Whenever I close my program, I always get
"COpenGLDriver::~COpenGLDriver: Could not release openGL dc." printed out, and I can't figure out why.
This is straight from MSDN Library, from VS 6.0:
Quote:
int ReleaseDC(
HWND hWnd, // handle to window
HDC hDC // handle to device context
);
The return value specifies whether the device context is released. If the device context is released, the return value is 1.
So, is there something that jumps out at people?
Also (this is of secondary importance), in some of my constructors, I actually call 'return' during it, say, if something has gone wrong and the rest of the constructor should not be executed. Is this bad programming practice, or just plain bad?
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper