Code: Select all
Index: include/SIrrCreationParameters.h
===================================================================
--- include/SIrrCreationParameters.h (Revision 2027)
+++ include/SIrrCreationParameters.h (Arbeitskopie)
@@ -25,7 +25,7 @@
Fullscreen(false),
Stencilbuffer(false),
Vsync(false),
- AntiAlias(false),
+ AntiAlias(0),
WithAlphaChannel(false),
IgnoreInput(false),
HighPrecisionFPU(false),
@@ -100,8 +100,8 @@
be a good idea to make it possible to switch this option off
again by the user.
This is curently not supported in OpenGL under Windows.
- Default value: false */
- bool AntiAlias;
+ Default value: 0 */
+ u8 AntiAlias;
//! Whether the main framebuffer uses an alpha channel.
/** In some situations it might be desireable to get a color
Index: source/Irrlicht/CD3D8Driver.cpp
===================================================================
--- source/Irrlicht/CD3D8Driver.cpp (Revision 2027)
+++ source/Irrlicht/CD3D8Driver.cpp (Arbeitskopie)
@@ -144,7 +144,7 @@
//! initialises the Direct3D API
bool CD3D8Driver::initDriver(const core::dimension2d<s32>& screenSize,
HWND hwnd, u32 bits, bool fullScreen, bool pureSoftware,
- bool highPrecisionFPU, bool vsync, bool antiAlias)
+ bool highPrecisionFPU, bool vsync, u8 antiAlias)
{
HRESULT hr;
D3DLibrary = LoadLibrary( "d3d8.dll" );
@@ -225,20 +225,48 @@
#endif
// enable anti alias if possible and whished
- if (antiAlias)
+ if (antiAlias > 0)
{
+ if(antiAlias > 16)
+ {
+ antiAlias = 16;
+ }
+
if (!FAILED(pID3D->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT,
devtype , present.BackBufferFormat, !fullScreen,
- D3DMULTISAMPLE_2_SAMPLES)))
+ (D3DMULTISAMPLE_TYPE)antiAlias)))
{
// enable multi sampling
present.SwapEffect = D3DSWAPEFFECT_DISCARD;
- present.MultiSampleType = D3DMULTISAMPLE_2_SAMPLES;
+ present.MultiSampleType = (D3DMULTISAMPLE_TYPE)antiAlias;
}
else
{
- os::Printer::log("Anti aliasing disabled because hardware/driver lacks necessary caps.", ELL_WARNING);
- antiAlias = false;
+ bool success = false;
+ --antiAlias;
+
+ while(!success && antiAlias > 0)
+ {
+ if(!FAILED(pID3D->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT,
+ devtype , present.BackBufferFormat, !fullScreen,
+ (D3DMULTISAMPLE_TYPE)antiAlias)))
+ {
+ present.MultiSampleType = (D3DMULTISAMPLE_TYPE)antiAlias;
+ present.SwapEffect = D3DSWAPEFFECT_DISCARD;
+
+ success = true;
+ }
+ else
+ {
+ --antiAlias;
+ }
+ }
+
+ if(!success)
+ {
+ os::Printer::log("Anti aliasing disabled because hardware/driver lacks necessary caps.", ELL_WARNING);
+ antiAlias = false;
+ }
}
}
Index: source/Irrlicht/CD3D8Driver.h
===================================================================
--- source/Irrlicht/CD3D8Driver.h (Revision 2027)
+++ source/Irrlicht/CD3D8Driver.h (Arbeitskopie)
@@ -103,7 +103,7 @@
//! initialises the Direct3D API
bool initDriver(const core::dimension2d<s32>& screenSize, HWND hwnd,
u32 bits, bool fullScreen, bool pureSoftware,
- bool highPrecisionFPU, bool vsync, bool antiAlias);
+ bool highPrecisionFPU, bool vsync, u8 antiAlias);
//! \return Returns the name of the video driver. Example: In case of the DIRECT3D8
//! driver, it would return "Direct3D8.1".
Index: source/Irrlicht/CD3D9Driver.cpp
===================================================================
--- source/Irrlicht/CD3D9Driver.cpp (Revision 2027)
+++ source/Irrlicht/CD3D9Driver.cpp (Arbeitskopie)
@@ -152,7 +152,7 @@
//! initialises the Direct3D API
bool CD3D9Driver::initDriver(const core::dimension2d<s32>& screenSize,
HWND hwnd, u32 bits, bool fullScreen, bool pureSoftware,
- bool highPrecisionFPU, bool vsync, bool antiAlias)
+ bool highPrecisionFPU, bool vsync, u8 antiAlias)
{
HRESULT hr;
Fullscreen = fullScreen;
@@ -271,44 +271,53 @@
#endif
// enable anti alias if possible and desired
- if (antiAlias)
+ if (antiAlias > 0)
{
+ if(antiAlias > 16)
+ {
+ antiAlias = 16;
+ }
+
DWORD qualityLevels = 0;
if (SUCCEEDED(pID3D->CheckDeviceMultiSampleType(adapter,
devtype, present.BackBufferFormat, !fullScreen,
- D3DMULTISAMPLE_4_SAMPLES, &qualityLevels)))
+ (D3DMULTISAMPLE_TYPE)antiAlias, &qualityLevels)))
{
// enable multi sampling
- present.MultiSampleType = D3DMULTISAMPLE_4_SAMPLES;
+ present.MultiSampleType = (D3DMULTISAMPLE_TYPE)antiAlias;
present.MultiSampleQuality = qualityLevels-1;
present.SwapEffect = D3DSWAPEFFECT_DISCARD;
}
else
- if (SUCCEEDED(pID3D->CheckDeviceMultiSampleType(adapter,
- devtype, present.BackBufferFormat, !fullScreen,
- D3DMULTISAMPLE_2_SAMPLES, &qualityLevels)))
{
- // enable multi sampling
- present.MultiSampleType = D3DMULTISAMPLE_2_SAMPLES;
- present.MultiSampleQuality = qualityLevels-1;
- present.SwapEffect = D3DSWAPEFFECT_DISCARD;
- }
- else
- if (SUCCEEDED(pID3D->CheckDeviceMultiSampleType(adapter,
+ bool success = false;
+ --antiAlias;
+
+ while(!success && antiAlias > 0)
+ {
+ if(SUCCEEDED(pID3D->CheckDeviceMultiSampleType(adapter,
devtype, present.BackBufferFormat, !fullScreen,
- D3DMULTISAMPLE_NONMASKABLE, &qualityLevels)))
- {
- // enable non maskable multi sampling
- present.MultiSampleType = D3DMULTISAMPLE_NONMASKABLE;
- present.MultiSampleQuality = qualityLevels-1;
- present.SwapEffect = D3DSWAPEFFECT_DISCARD;
+ (D3DMULTISAMPLE_TYPE)antiAlias, &qualityLevels)))
+ {
+ present.MultiSampleType = (D3DMULTISAMPLE_TYPE)antiAlias;
+ present.MultiSampleQuality = qualityLevels-1;
+ present.SwapEffect = D3DSWAPEFFECT_DISCARD;
+
+ success = true;
+ }
+ else
+ {
+ --antiAlias;
+ }
+ }
+
+ if(!success)
+ {
+ os::Printer::log("Anti aliasing disabled because hardware/driver lacks necessary caps.", ELL_WARNING);
+ antiAlias = 0;
+ }
}
- else
- {
- os::Printer::log("Anti aliasing disabled because hardware/driver lacks necessary caps.", ELL_WARNING);
- antiAlias = false;
- }
}
// check stencil buffer compatibility
Index: source/Irrlicht/CD3D9Driver.h
===================================================================
--- source/Irrlicht/CD3D9Driver.h (Revision 2027)
+++ source/Irrlicht/CD3D9Driver.h (Arbeitskopie)
@@ -136,7 +136,7 @@
//! initialises the Direct3D API
bool initDriver(const core::dimension2d<s32>& screenSize, HWND hwnd,
u32 bits, bool fullScreen, bool pureSoftware,
- bool highPrecisionFPU, bool vsync, bool antiAlias);
+ bool highPrecisionFPU, bool vsync, u8 antiAlias);
//! \return Returns the name of the video driver. Example: In case of the DIRECT3D8
//! driver, it would return "Direct3D8.1".
Index: source/Irrlicht/COpenGLDriver.cpp
===================================================================
--- source/Irrlicht/COpenGLDriver.cpp (Revision 2027)
+++ source/Irrlicht/COpenGLDriver.cpp (Arbeitskopie)
@@ -71,7 +71,7 @@
GLuint PixelFormat;
- if (AntiAlias)
+ if (AntiAlias > 0)
{
// Create a window to test antialiasing support
const c8* ClassName = "GLCIrrDeviceWin32";
@@ -189,7 +189,13 @@
// valid numbers are 2, 4, 8. My experience is that 8 does not
// show a big improvement over 4, but 4 shows a big improvement over
// 2.
- const s32 numSamples = 4;
+
+ if(AntiAlias > 16)
+ {
+ AntiAlias = 16;
+ }
+
+ const s32 numSamples = AntiAlias;
f32 fAttributes[] =
{
0.0, 0.0
@@ -242,7 +248,7 @@
}
// search for pixel format the simple way
- if (!AntiAlias)
+ if (AntiAlias < 2)
{
for (u32 i=0; i<5; ++i)
{
@@ -505,7 +511,7 @@
glDepthFunc(GL_LEQUAL);
glFrontFace( GL_CW );
- if (AntiAlias)
+ if (AntiAlias >= 2)
{
if (MultiSamplingExtension)
glEnable(GL_MULTISAMPLE_ARB);
Index: source/Irrlicht/COpenGLDriver.h
===================================================================
--- source/Irrlicht/COpenGLDriver.h (Revision 2027)
+++ source/Irrlicht/COpenGLDriver.h (Arbeitskopie)
@@ -385,7 +385,7 @@
//! bool to make all renderstates reset if set to true.
bool ResetRenderStates;
bool Transformation3DChanged;
- bool AntiAlias;
+ u8 AntiAlias;
SMaterial Material, LastMaterial;
COpenGLTexture* RenderTargetTexture;
Since I'm a total noob in OpenGL I don't know if this is totally right. I'm struggling with this line
I'm not sure if this just enables anti aliasing at all or just to a specific level but there is a difference between 0 samples and 8