diff --git a/src/Config.cpp b/src/Config.cpp
index 2a989350..949c1bfa 100644
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -37,6 +37,8 @@ char DSiBIOS7Path[1024];
char DSiFirmwarePath[1024];
char DSiNANDPath[1024];
+int RandomizeMAC;
+
#ifdef JIT_ENABLED
int JIT_Enable = false;
int JIT_MaxBlockSize = 32;
diff --git a/src/GPU.h b/src/GPU.h
index 039e0651..c7d25ec2 100644
--- a/src/GPU.h
+++ b/src/GPU.h
@@ -79,6 +79,7 @@ typedef struct
bool Soft_Threaded;
int GL_ScaleFactor;
+ bool GL_BetterPolygons;
} RenderSettings;
diff --git a/src/GPU3D_OpenGL.cpp b/src/GPU3D_OpenGL.cpp
index ba77a0c0..658b2613 100644
--- a/src/GPU3D_OpenGL.cpp
+++ b/src/GPU3D_OpenGL.cpp
@@ -113,7 +113,7 @@ GLuint TexMemID;
GLuint TexPalMemID;
int ScaleFactor;
-bool Antialias;
+bool BetterPolygons;
int ScreenW, ScreenH;
GLuint FramebufferTex[8];
@@ -405,6 +405,7 @@ void SetRenderSettings(GPU::RenderSettings& settings)
int scale = settings.GL_ScaleFactor;
ScaleFactor = scale;
+ BetterPolygons = settings.GL_BetterPolygons;
ScreenW = 256 * scale;
ScreenH = 192 * scale;
@@ -635,7 +636,7 @@ void BuildPolygons(RendererPolygon* polygons, int npolys)
{
rp->PrimType = GL_TRIANGLES;
- if (false)
+ if (!BetterPolygons)
{
// regular triangle-splitting
@@ -835,6 +836,10 @@ void RenderSceneChunk(int y, int h)
GLboolean fogenable = (RenderDispCnt & (1<<7)) ? GL_TRUE : GL_FALSE;
+ // TODO: proper 'equal' depth test!
+ // (has margin of +-0x200 in Z-buffer mode, +-0xFF in W-buffer mode)
+ // for now we're using GL_LEQUAL to make it work to some extent
+
// pass 1: opaque pixels
UseRenderShader(flags);
@@ -853,8 +858,10 @@ void RenderSceneChunk(int y, int h)
if (rp->PolyData->IsShadowMask) { i++; continue; }
- // zorp
- glDepthFunc(GL_LESS);
+ if (rp->PolyData->Attr & (1<<14))
+ glDepthFunc(GL_LEQUAL);
+ else
+ glDepthFunc(GL_LESS);
u32 polyattr = rp->PolyData->Attr;
u32 polyid = (polyattr >> 24) & 0x3F;
@@ -939,8 +946,10 @@ void RenderSceneChunk(int y, int h)
{
UseRenderShader(flags | RenderFlag_Trans);
- // zorp
- glDepthFunc(GL_LESS);
+ if (rp->PolyData->Attr & (1<<14))
+ glDepthFunc(GL_LEQUAL);
+ else
+ glDepthFunc(GL_LESS);
u32 polyattr = rp->PolyData->Attr;
u32 polyid = (polyattr >> 24) & 0x3F;
@@ -1030,8 +1039,10 @@ void RenderSceneChunk(int y, int h)
if (!(polyattr & (1<<15))) transfog = fogenable;
else transfog = GL_FALSE;
- // zorp
- glDepthFunc(GL_LESS);
+ if (rp->PolyData->Attr & (1<<14))
+ glDepthFunc(GL_LEQUAL);
+ else
+ glDepthFunc(GL_LESS);
if (rp->PolyData->IsShadow)
{
diff --git a/src/frontend/qt_sdl/PlatformConfig.cpp b/src/frontend/qt_sdl/PlatformConfig.cpp
index 76c5f4be..0628eaa1 100644
--- a/src/frontend/qt_sdl/PlatformConfig.cpp
+++ b/src/frontend/qt_sdl/PlatformConfig.cpp
@@ -51,7 +51,7 @@ int _3DRenderer;
int Threaded3D;
int GL_ScaleFactor;
-int GL_Antialias;
+int GL_BetterPolygons;
int LimitFPS;
int AudioSync;
@@ -143,7 +143,7 @@ ConfigEntry PlatformConfigFile[] =
{"Threaded3D", 0, &Threaded3D, 1, NULL, 0},
{"GL_ScaleFactor", 0, &GL_ScaleFactor, 1, NULL, 0},
- {"GL_Antialias", 0, &GL_Antialias, 0, NULL, 0},
+ {"GL_BetterPolygons", 0, &GL_BetterPolygons, 0, NULL, 0},
{"LimitFPS", 0, &LimitFPS, 0, NULL, 0},
{"AudioSync", 0, &AudioSync, 1, NULL, 0},
diff --git a/src/frontend/qt_sdl/PlatformConfig.h b/src/frontend/qt_sdl/PlatformConfig.h
index bc9bba41..9deee7f3 100644
--- a/src/frontend/qt_sdl/PlatformConfig.h
+++ b/src/frontend/qt_sdl/PlatformConfig.h
@@ -64,7 +64,7 @@ extern int _3DRenderer;
extern int Threaded3D;
extern int GL_ScaleFactor;
-extern int GL_Antialias;
+extern int GL_BetterPolygons;
extern int LimitFPS;
extern int AudioSync;
diff --git a/src/frontend/qt_sdl/VideoSettingsDialog.cpp b/src/frontend/qt_sdl/VideoSettingsDialog.cpp
index ba433c33..ac1ed7ad 100644
--- a/src/frontend/qt_sdl/VideoSettingsDialog.cpp
+++ b/src/frontend/qt_sdl/VideoSettingsDialog.cpp
@@ -167,3 +167,10 @@ void VideoSettingsDialog::on_cbxGLResolution_currentIndexChanged(int idx)
emit updateVideoSettings(false);
}
+
+void VideoSettingsDialog::on_cbBetterPolygons_stateChanged(int state)
+{
+ Config::GL_BetterPolygons = (state != 0);
+
+ emit updateVideoSettings(false);
+}
diff --git a/src/frontend/qt_sdl/VideoSettingsDialog.h b/src/frontend/qt_sdl/VideoSettingsDialog.h
index 2311d4d2..f18793c7 100644
--- a/src/frontend/qt_sdl/VideoSettingsDialog.h
+++ b/src/frontend/qt_sdl/VideoSettingsDialog.h
@@ -64,6 +64,7 @@ private slots:
void on_sbVSyncInterval_valueChanged(int val);
void on_cbxGLResolution_currentIndexChanged(int idx);
+ void on_cbBetterPolygons_stateChanged(int state);
void on_cbSoftwareThreaded_stateChanged(int state);
diff --git a/src/frontend/qt_sdl/VideoSettingsDialog.ui b/src/frontend/qt_sdl/VideoSettingsDialog.ui
index 6cdd5d82..69853047 100644
--- a/src/frontend/qt_sdl/VideoSettingsDialog.ui
+++ b/src/frontend/qt_sdl/VideoSettingsDialog.ui
@@ -7,7 +7,7 @@
0
0
482
- 237
+ 244
@@ -43,6 +43,16 @@
+ -
+
+
+ <html><head/><body><p>Enabling this may help reduce distortion on quads and more complex polygons, but may also reduce performance.</p></body></html>
+
+
+ Improved polygon splitting
+
+
+
diff --git a/src/frontend/qt_sdl/main.cpp b/src/frontend/qt_sdl/main.cpp
index 02283993..1e7e4a69 100644
--- a/src/frontend/qt_sdl/main.cpp
+++ b/src/frontend/qt_sdl/main.cpp
@@ -405,8 +405,11 @@ void EmuThread::run()
videoRenderer = hasOGL ? Config::_3DRenderer : 0;
videoSettingsDirty = false;
+
videoSettings.Soft_Threaded = Config::Threaded3D != 0;
videoSettings.GL_ScaleFactor = Config::GL_ScaleFactor;
+ videoSettings.GL_BetterPolygons = Config::GL_BetterPolygons;
+
GPU::SetRenderSettings(videoRenderer, videoSettings);
}