From f60d88a54ca3fe3820c4d8c8b4b883ad21b28b74 Mon Sep 17 00:00:00 2001 From: mudlord Date: Wed, 14 Nov 2007 06:47:15 +0000 Subject: [PATCH] OpenGL update phase 2. Added GL_POLYGON support to renderer for the sake of complete customizability of render modes. --- src/win32/MainWnd.cpp | 2 ++ src/win32/MainWnd.h | 2 ++ src/win32/MainWndOptions.cpp | 14 ++++++++++++++ src/win32/OpenGL.cpp | 25 ++++++++++++++++++++++--- src/win32/VBA.cpp | 2 +- src/win32/VBA.rc | 3 ++- src/win32/resource.h | 6 ++++-- 7 files changed, 47 insertions(+), 7 deletions(-) diff --git a/src/win32/MainWnd.cpp b/src/win32/MainWnd.cpp index cc66fa94..27bc1051 100644 --- a/src/win32/MainWnd.cpp +++ b/src/win32/MainWnd.cpp @@ -180,6 +180,8 @@ BEGIN_MESSAGE_MAP(MainWnd, CWnd) ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDEROPTIONS_GLTRIANGLE, OnUpdateOptionsVideoRenderoptionsGltriangle) ON_COMMAND(ID_OPTIONS_VIDEO_RENDEROPTIONS_GLQUADS, OnOptionsVideoRenderoptionsGlquads) ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDEROPTIONS_GLQUADS, OnUpdateOptionsVideoRenderoptionsGlquads) + ON_COMMAND(ID_OPTIONS_VIDEO_RENDEROPTIONS_GLPOLYGONS, OnOptionsVideoRenderoptionsGlpolygons) + ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDEROPTIONS_GLPOLYGONS, OnUpdateOptionsVideoRenderoptionsGlpolygons) ON_COMMAND(ID_OPTIONS_VIDEO_RENDEROPTIONS_SELECTSKIN, OnOptionsVideoRenderoptionsSelectskin) ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_RENDEROPTIONS_SELECTSKIN, OnUpdateOptionsVideoRenderoptionsSelectskin) ON_COMMAND(ID_OPTIONS_VIDEO_RENDEROPTIONS_SKIN, OnOptionsVideoRenderoptionsSkin) diff --git a/src/win32/MainWnd.h b/src/win32/MainWnd.h index 9d5d2b96..9931357c 100644 --- a/src/win32/MainWnd.h +++ b/src/win32/MainWnd.h @@ -209,6 +209,8 @@ class MainWnd : public CWnd afx_msg void OnUpdateOptionsVideoRenderoptionsGltriangle(CCmdUI* pCmdUI); afx_msg void OnOptionsVideoRenderoptionsGlquads(); afx_msg void OnUpdateOptionsVideoRenderoptionsGlquads(CCmdUI* pCmdUI); + afx_msg void OnOptionsVideoRenderoptionsGlpolygons(); + afx_msg void OnUpdateOptionsVideoRenderoptionsGlpolygons(CCmdUI* pCmdUI); afx_msg void OnOptionsVideoRenderoptionsSelectskin(); afx_msg void OnUpdateOptionsVideoRenderoptionsSelectskin(CCmdUI* pCmdUI); afx_msg void OnOptionsVideoRenderoptionsSkin(); diff --git a/src/win32/MainWndOptions.cpp b/src/win32/MainWndOptions.cpp index 0ad6073e..44f7e731 100644 --- a/src/win32/MainWndOptions.cpp +++ b/src/win32/MainWndOptions.cpp @@ -614,6 +614,20 @@ void MainWnd::OnUpdateOptionsVideoRenderoptionsGlquads(CCmdUI* pCmdUI) pCmdUI->SetCheck(theApp.glType == 1); } +void MainWnd::OnOptionsVideoRenderoptionsGlpolygons() +{ + theApp.glType = 2; + if( theApp.display ) { + theApp.display->setOption( _T("glType"), theApp.glType ); + } +} + + +void MainWnd::OnUpdateOptionsVideoRenderoptionsGlpolygons(CCmdUI* pCmdUI) +{ + pCmdUI->SetCheck(theApp.glType == 2); +} + void MainWnd::OnOptionsVideoRenderoptionsSelectskin() { #ifndef NOSKINS diff --git a/src/win32/OpenGL.cpp b/src/win32/OpenGL.cpp index 33d8a65d..ed61c5ca 100644 --- a/src/win32/OpenGL.cpp +++ b/src/win32/OpenGL.cpp @@ -418,8 +418,6 @@ void OpenGLDisplay::render() GL_UNSIGNED_BYTE, data ); - - if( theApp.glType == 0 ) { glBegin( GL_TRIANGLE_STRIP ); @@ -436,7 +434,9 @@ void OpenGLDisplay::render() glVertex3i( theApp.surfaceSizeX, theApp.surfaceSizeY, 0 ); glEnd(); - } else { + } + if(theApp.glType == 1) + { glBegin( GL_QUADS ); glTexCoord2f( 0.0f, 0.0f ); @@ -454,6 +454,25 @@ void OpenGLDisplay::render() glEnd(); } + if(theApp.glType == 2) + { + glBegin( GL_POLYGON ); + + glTexCoord2f( 0.0f, 0.0f ); + glVertex3i( 0, 0, 0 ); + + glTexCoord2f( (float)(width) / size, 0.0f ); + glVertex3i( theApp.surfaceSizeX, 0, 0 ); + + glTexCoord2f( (float)(width) / size, (float)(height) / size ); + glVertex3i( theApp.surfaceSizeX, theApp.surfaceSizeY, 0 ); + + glTexCoord2f( 0.0f, (float)(height) / size ); + glVertex3i( 0, theApp.surfaceSizeY, 0 ); + + glEnd(); + } + if( theApp.showSpeed ) { // && ( theApp.videoOption > VIDEO_4X ) ) { char buffer[30]; diff --git a/src/win32/VBA.cpp b/src/win32/VBA.cpp index 372fdb35..66bfbf7e 100644 --- a/src/win32/VBA.cpp +++ b/src/win32/VBA.cpp @@ -1416,7 +1416,7 @@ void VBA::loadSettings() glFilter = 1; glType = regQueryDwordValue("glType", 0); - if(glType < 0 || glType > 1) + if(glType < 0 || glType > 2) glType = 0; filterType = regQueryDwordValue("filter", 0); diff --git a/src/win32/VBA.rc b/src/win32/VBA.rc index 712ff5c5..d1d52be1 100644 --- a/src/win32/VBA.rc +++ b/src/win32/VBA.rc @@ -1555,6 +1555,7 @@ BEGIN MENUITEM " Filter: Bilinear", ID_OPTIONS_VIDEO_RENDEROPTIONS_GLBILINEAR MENUITEM " Vertex: Triangle", ID_OPTIONS_VIDEO_RENDEROPTIONS_GLTRIANGLE MENUITEM " Vertex: Quads", ID_OPTIONS_VIDEO_RENDEROPTIONS_GLQUADS + MENUITEM " Vertex: Polygons", ID_OPTIONS_VIDEO_RENDEROPTIONS_GLPOLYGONS MENUITEM SEPARATOR MENUITEM "&VSync", ID_OPTIONS_VIDEO_VSYNC MENUITEM "Triple Buffering", ID_OPTIONS_VIDEO_TRIPLEBUFFERING @@ -1645,7 +1646,7 @@ BEGIN BEGIN MENUITEM "&Simple 4x", ID_OPTIONS_FILTER_SIMPLE4X MENUITEM SEPARATOR - MENUITEM "&HQ4x", ID_OPTIONS_FILTER_HQ4X, GRAYED + MENUITEM "&HQ4x", ID_OPTIONS_FILTER_HQ4X END END POPUP "&Interframe Blending" diff --git a/src/win32/resource.h b/src/win32/resource.h index bf71faa3..c272cf1c 100644 --- a/src/win32/resource.h +++ b/src/win32/resource.h @@ -796,14 +796,16 @@ #define ID_OPTIONS_EMULATOR_REMOVEINTROSGBA 40331 #define ID_Menu 40332 #define ID_OPTIONS_VIDEO_RENDEROPTIONS_GLANISOTROPIC 40333 -#define ID_OPTIONS_LINK_ENABLE 40335 +#define ID_OPTIONS_LINK_ENABLE 40335 +#define ID_RENDERAPI_VERTEX 40336 +#define ID_OPTIONS_VIDEO_RENDEROPTIONS_GLPOLYGONS 40337 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 159 -#define _APS_NEXT_COMMAND_VALUE 40336 +#define _APS_NEXT_COMMAND_VALUE 40338 #define _APS_NEXT_CONTROL_VALUE 1269 #define _APS_NEXT_SYMED_VALUE 103 #endif