Commit 7909a00d authored by hybrid's avatar hybrid

Update render context switch code, should work under windows now.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3018 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 0a380037
...@@ -49,31 +49,6 @@ COpenGLDriver::COpenGLDriver(const irr::SIrrlichtCreationParameters& params, ...@@ -49,31 +49,6 @@ COpenGLDriver::COpenGLDriver(const irr::SIrrlichtCreationParameters& params,
//! inits the open gl driver //! inits the open gl driver
bool COpenGLDriver::initDriver(irr::SIrrlichtCreationParameters params, CIrrDeviceWin32* device) bool COpenGLDriver::initDriver(irr::SIrrlichtCreationParameters params, CIrrDeviceWin32* device)
{ {
// Set up pixel format descriptor with desired parameters
PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number
PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
(params.Doublebuffer?PFD_DOUBLEBUFFER:0) | // Must Support Double Buffering
(params.Stereobuffer?PFD_STEREO:0), // Must Support Stereo Buffer
PFD_TYPE_RGBA, // Request An RGBA Format
params.Bits, // Select Our Color Depth
0, 0, 0, 0, 0, 0, // Color Bits Ignored
0, // No Alpha Buffer
0, // Shift Bit Ignored
0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored
params.ZBufferBits, // Z-Buffer (Depth Buffer)
params.Stencilbuffer ? 1 : 0, // Stencil Buffer Depth
0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved
0, 0, 0 // Layer Masks Ignored
};
GLuint PixelFormat;
// Create a window to test antialiasing support // Create a window to test antialiasing support
const fschar_t* ClassName = __TEXT("GLCIrrDeviceWin32"); const fschar_t* ClassName = __TEXT("GLCIrrDeviceWin32");
HINSTANCE lhInstance = GetModuleHandle(0); HINSTANCE lhInstance = GetModuleHandle(0);
...@@ -93,8 +68,8 @@ bool COpenGLDriver::initDriver(irr::SIrrlichtCreationParameters params, CIrrDevi ...@@ -93,8 +68,8 @@ bool COpenGLDriver::initDriver(irr::SIrrlichtCreationParameters params, CIrrDevi
wcex.lpszClassName = ClassName; wcex.lpszClassName = ClassName;
wcex.hIconSm = 0; wcex.hIconSm = 0;
wcex.hIcon = 0; wcex.hIcon = 0;
RegisterClassEx(&wcex); RegisterClassEx(&wcex);
RECT clientSize; RECT clientSize;
clientSize.top = 0; clientSize.top = 0;
clientSize.left = 0; clientSize.left = 0;
...@@ -102,7 +77,6 @@ bool COpenGLDriver::initDriver(irr::SIrrlichtCreationParameters params, CIrrDevi ...@@ -102,7 +77,6 @@ bool COpenGLDriver::initDriver(irr::SIrrlichtCreationParameters params, CIrrDevi
clientSize.bottom = params.WindowSize.Height; clientSize.bottom = params.WindowSize.Height;
DWORD style = WS_POPUP; DWORD style = WS_POPUP;
if (!params.Fullscreen) if (!params.Fullscreen)
style = WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; style = WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
...@@ -114,8 +88,8 @@ bool COpenGLDriver::initDriver(irr::SIrrlichtCreationParameters params, CIrrDevi ...@@ -114,8 +88,8 @@ bool COpenGLDriver::initDriver(irr::SIrrlichtCreationParameters params, CIrrDevi
const s32 windowLeft = (GetSystemMetrics(SM_CXSCREEN) - realWidth) / 2; const s32 windowLeft = (GetSystemMetrics(SM_CXSCREEN) - realWidth) / 2;
const s32 windowTop = (GetSystemMetrics(SM_CYSCREEN) - realHeight) / 2; const s32 windowTop = (GetSystemMetrics(SM_CYSCREEN) - realHeight) / 2;
HWND temporary_wnd=CreateWindow(ClassName, __TEXT(""), style, windowLeft, windowTop, HWND temporary_wnd=CreateWindow(ClassName, __TEXT(""), style, windowLeft,
realWidth, realHeight, NULL, NULL, lhInstance, NULL); windowTop, realWidth, realHeight, NULL, NULL, lhInstance, NULL);
if (!temporary_wnd) if (!temporary_wnd)
{ {
...@@ -125,6 +99,31 @@ bool COpenGLDriver::initDriver(irr::SIrrlichtCreationParameters params, CIrrDevi ...@@ -125,6 +99,31 @@ bool COpenGLDriver::initDriver(irr::SIrrlichtCreationParameters params, CIrrDevi
HDc = GetDC(temporary_wnd); HDc = GetDC(temporary_wnd);
// Set up pixel format descriptor with desired parameters
PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number
PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
(params.Doublebuffer?PFD_DOUBLEBUFFER:0) | // Must Support Double Buffering
(params.Stereobuffer?PFD_STEREO:0), // Must Support Stereo Buffer
PFD_TYPE_RGBA, // Request An RGBA Format
params.Bits, // Select Our Color Depth
0, 0, 0, 0, 0, 0, // Color Bits Ignored
0, // No Alpha Buffer
0, // Shift Bit Ignored
0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored
params.ZBufferBits, // Z-Buffer (Depth Buffer)
params.Stencilbuffer ? 1 : 0, // Stencil Buffer Depth
0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved
0, 0, 0 // Layer Masks Ignored
};
GLuint PixelFormat;
for (u32 i=0; i<5; ++i) for (u32 i=0; i<5; ++i)
{ {
if (i == 1) if (i == 1)
...@@ -751,16 +750,18 @@ bool COpenGLDriver::beginScene(bool backBuffer, bool zBuffer, SColor color, ...@@ -751,16 +750,18 @@ bool COpenGLDriver::beginScene(bool backBuffer, bool zBuffer, SColor color,
CNullDriver::beginScene(backBuffer, zBuffer, color, videoData, sourceRect); CNullDriver::beginScene(backBuffer, zBuffer, color, videoData, sourceRect);
#if 0 #if 0
// This should be fixed to allow using OpenGL with the videoData parameter // This should be fixed to allow using all OpenGL drivers with the videoData parameter
if (videoData.OpenGLWin32.HWnd) if (videoData.OpenGLWin32.HWnd && videoData.OpenGLWin32.HDc && videoData.OpenGLWin32.HRc)
{ {
HDc = (HDC)videoData.OpenGLWin32.HDc; HDc = (HDC)videoData.OpenGLWin32.HDc;
wglMakeCurrent(HDc, (HGLRC)videoData.OpenGLWin32.HRc); if (!wglMakeCurrent(HDc, (HGLRC)videoData.OpenGLWin32.HRc))
os::Printer::log("Render Context switch failed.");
} }
else if (HDc != ExposedData.OpenGLWin32.HDc) else if (HDc != ExposedData.OpenGLWin32.HDc)
{ {
HDc = (HDC)ExposedData.OpenGLWin32.HDc; HDc = (HDC)ExposedData.OpenGLWin32.HDc;
wglMakeCurrent(HDc, (HGLRC)ExposedData.OpenGLWin32.HRc); if (!wglMakeCurrent(HDc, (HGLRC)ExposedData.OpenGLWin32.HRc))
os::Printer::log("Render Context switch failed.");
} }
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment