Commit 20d2f925 authored by hybrid's avatar hybrid

Use advanced pixelformat chooser for more occasions.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3667 dfc29bdd-3216-0410-991c-e03cc46cb475
parent f0d8ef93
...@@ -78,7 +78,6 @@ bool COpenGLDriver::changeRenderContext(const SExposedVideoData& videoData, CIrr ...@@ -78,7 +78,6 @@ bool COpenGLDriver::changeRenderContext(const SExposedVideoData& videoData, CIrr
return true; return true;
} }
//! 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)
{ {
...@@ -235,7 +234,7 @@ bool COpenGLDriver::initDriver(irr::SIrrlichtCreationParameters params, CIrrDevi ...@@ -235,7 +234,7 @@ bool COpenGLDriver::initDriver(irr::SIrrlichtCreationParameters params, CIrrDevi
return false; return false;
} }
io::path wglExtensions; core::stringc wglExtensions;
#ifdef WGL_ARB_extensions_string #ifdef WGL_ARB_extensions_string
PFNWGLGETEXTENSIONSSTRINGARBPROC irrGetExtensionsString = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB"); PFNWGLGETEXTENSIONSSTRINGARBPROC irrGetExtensionsString = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB");
if (irrGetExtensionsString) if (irrGetExtensionsString)
...@@ -248,13 +247,15 @@ bool COpenGLDriver::initDriver(irr::SIrrlichtCreationParameters params, CIrrDevi ...@@ -248,13 +247,15 @@ bool COpenGLDriver::initDriver(irr::SIrrlichtCreationParameters params, CIrrDevi
const bool pixel_format_supported = (wglExtensions.find("WGL_ARB_pixel_format") != -1); const bool pixel_format_supported = (wglExtensions.find("WGL_ARB_pixel_format") != -1);
const bool multi_sample_supported = ((wglExtensions.find("WGL_ARB_multisample") != -1) || const bool multi_sample_supported = ((wglExtensions.find("WGL_ARB_multisample") != -1) ||
(wglExtensions.find("WGL_EXT_multisample") != -1) || (wglExtensions.find("WGL_3DFX_multisample") != -1) ); (wglExtensions.find("WGL_EXT_multisample") != -1) || (wglExtensions.find("WGL_3DFX_multisample") != -1) );
const bool framebuffer_srgb_supported = ((wglExtensions.find("WGL_ARB_framebuffer_sRGB") != -1) ||
(wglExtensions.find("WGL_EXT_framebuffer_sRGB") != -1) );
#ifdef _DEBUG #ifdef _DEBUG
os::Printer::log("WGL_extensions", wglExtensions); os::Printer::log("WGL_extensions", wglExtensions);
#endif #endif
#ifdef WGL_ARB_pixel_format #ifdef WGL_ARB_pixel_format
PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormat_ARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB"); PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormat_ARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
if (pixel_format_supported && multi_sample_supported && wglChoosePixelFormat_ARB) if (pixel_format_supported && wglChoosePixelFormat_ARB)
{ {
// This value determines the number of samples used for antialiasing // This value determines the number of samples used for antialiasing
// My experience is that 8 does not show a big // My experience is that 8 does not show a big
...@@ -276,41 +277,48 @@ bool COpenGLDriver::initDriver(irr::SIrrlichtCreationParameters params, CIrrDevi ...@@ -276,41 +277,48 @@ bool COpenGLDriver::initDriver(irr::SIrrlichtCreationParameters params, CIrrDevi
WGL_STENCIL_BITS_ARB,(params.Stencilbuffer) ? 1 : 0, WGL_STENCIL_BITS_ARB,(params.Stencilbuffer) ? 1 : 0,
WGL_DOUBLE_BUFFER_ARB,(params.Doublebuffer) ? GL_TRUE : GL_FALSE, WGL_DOUBLE_BUFFER_ARB,(params.Doublebuffer) ? GL_TRUE : GL_FALSE,
WGL_STEREO_ARB,(params.Stereobuffer) ? GL_TRUE : GL_FALSE, WGL_STEREO_ARB,(params.Stereobuffer) ? GL_TRUE : GL_FALSE,
WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
#ifdef WGL_ARB_multisample #ifdef WGL_ARB_multisample
WGL_SAMPLE_BUFFERS_ARB, 1,
WGL_SAMPLES_ARB,AntiAlias, // 20,21 WGL_SAMPLES_ARB,AntiAlias, // 20,21
WGL_SAMPLE_BUFFERS_ARB, 1,
#elif defined(WGL_EXT_multisample) #elif defined(WGL_EXT_multisample)
WGL_SAMPLE_BUFFERS_EXT, 1,
WGL_SAMPLES_EXT,AntiAlias, // 20,21 WGL_SAMPLES_EXT,AntiAlias, // 20,21
WGL_SAMPLE_BUFFERS_EXT, 1,
#elif defined(WGL_3DFX_multisample) #elif defined(WGL_3DFX_multisample)
WGL_SAMPLE_BUFFERS_3DFX, 1,
WGL_SAMPLES_3DFX,AntiAlias, // 20,21 WGL_SAMPLES_3DFX,AntiAlias, // 20,21
WGL_SAMPLE_BUFFERS_3DFX, 1,
#endif #endif
WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
// other possible values:
// WGL_ARB_pixel_format_float: WGL_TYPE_RGBA_FLOAT_ARB
// WGL_EXT_pixel_format_packed_float: WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT
#if 0 #if 0
#ifdef WGL_EXT_framebuffer_sRGB #ifdef WGL_ARB_framebuffer_sRGB
WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT, GL_FALSE, WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB, GL_TRUE,
#elif defined(WGL_EXT_framebuffer_sRGB)
WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT, GL_TRUE,
#endif #endif
#endif #endif
0,0 0,0
}; };
if (!multi_sample_supported)
{
iAttributes[20]=0;
iAttributes[21]=0;
iAttributes[22]=0;
iAttributes[23]=0;
}
s32 rv=0; s32 rv=0;
// Try to get an acceptable pixel format // Try to get an acceptable pixel format
while(rv==0 && iAttributes[21]>1) do
{ {
s32 pixelFormat=0; int pixelFormat=0;
u32 numFormats=0; UINT numFormats=0;
const s32 valid = wglChoosePixelFormat_ARB(HDc,iAttributes,fAttributes,1,&pixelFormat,&numFormats); const BOOL valid = wglChoosePixelFormat_ARB(HDc,iAttributes,fAttributes,1,&pixelFormat,&numFormats);
if (valid && numFormats>0) if (valid && numFormats>0)
rv = pixelFormat; rv = pixelFormat;
else else
iAttributes[21] -= 1; iAttributes[21] -= 1;
} }
while(rv==0 && iAttributes[21]>1);
if (rv) if (rv)
{ {
PixelFormat=rv; PixelFormat=rv;
...@@ -336,7 +344,7 @@ bool COpenGLDriver::initDriver(irr::SIrrlichtCreationParameters params, CIrrDevi ...@@ -336,7 +344,7 @@ bool COpenGLDriver::initDriver(irr::SIrrlichtCreationParameters params, CIrrDevi
} }
// search for pixel format the simple way // search for pixel format the simple way
if (AntiAlias < 2) if (PixelFormat==0 || (!SetPixelFormat(HDc, PixelFormat, &pfd)))
{ {
for (u32 i=0; i<5; ++i) for (u32 i=0; i<5; ++i)
{ {
......
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