From Rajce Nickolov, improvements to PixelBufferWin32 and GraphicsWindowWin32

This commit is contained in:
Robert Osfield
2007-06-27 10:37:30 +00:00
parent c0a8c9dd53
commit 97ff495a9c
2 changed files with 72 additions and 36 deletions

View File

@@ -1535,13 +1535,41 @@ bool GraphicsWindowWin32::realizeImplementation()
{
init();
if (!_initialized) return false;
}
{
if (_traits.valid() && _traits->sharedContext)
{
GraphicsWindowWin32* sharedContextWin32 = dynamic_cast<GraphicsWindowWin32*>(_traits->sharedContext);
if (sharedContextWin32)
{
if (!makeCurrent()) return false;
struct RestoreContext
{
RestoreContext()
{
_hdc = wglGetCurrentDC();
_hglrc = wglGetCurrentContext();
}
~RestoreContext()
{
if (_hdc)
{
wglMakeCurrent(_hdc,_hglrc);
}
}
protected:
HDC _hdc;
HGLRC _hglrc;
} restoreContext;
_realized = true;
bool result = makeCurrent();
_realized = false;
if (!result)
{
return false;
}
if (!wglShareLists(sharedContextWin32->getWGLContext(), getWGLContext()))
{
reportErrorForScreen("GraphicsWindowWin32::realizeImplementation() - Unable to share OpenGL context", _traits->screenNum, ::GetLastError());