From 72bfacbdfeedbbb961104f08ed5d44506c44bb06 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Mon, 7 Nov 2005 03:59:05 +0000 Subject: [PATCH] add multitexture debug toggle --- stepmania/src/Model.cpp | 50 ++++++------ stepmania/src/PrefsManager.cpp | 1 + stepmania/src/PrefsManager.h | 1 + stepmania/src/ScreenDebugOverlay.cpp | 111 +++++++++++++++------------ 4 files changed, 92 insertions(+), 71 deletions(-) diff --git a/stepmania/src/Model.cpp b/stepmania/src/Model.cpp index 4368da43ac..b78c2b8f29 100644 --- a/stepmania/src/Model.cpp +++ b/stepmania/src/Model.cpp @@ -12,11 +12,12 @@ #include "ModelManager.h" #include "Foreach.h" #include "LuaBinding.h" +#include "PrefsManager.h" REGISTER_ACTOR_CLASS( Model ) -const float FRAMES_PER_SECOND = 30; -const CString DEFAULT_ANIMATION_NAME = "default"; +static const float FRAMES_PER_SECOND = 30; +static const CString DEFAULT_ANIMATION_NAME = "default"; Model::Model() { @@ -363,28 +364,8 @@ void Model::DrawPrimitives() /* There's some common code that could be folded out here, but it seems * clearer to keep it separate. */ - if( DISPLAY->GetNumTextureUnits() < 2 ) - { - // render the diffuse texture - DISPLAY->SetTexture( TextureUnit_1, mat.diffuse.GetCurrentTexture() ); - Actor::SetTextureRenderStates(); // set Actor-specified render states - DISPLAY->SetSphereEnvironmentMapping( mat.diffuse.m_bSphereMapped ); - DrawMesh( i ); - - // render the additive texture - if( mat.alpha.GetCurrentTexture() ) - { - DISPLAY->SetTexture( TextureUnit_1, mat.alpha.GetCurrentTexture() ); - Actor::SetTextureRenderStates(); // set Actor-specified render states - - DISPLAY->SetSphereEnvironmentMapping( mat.alpha.m_bSphereMapped ); - // UGLY: This overrides the Actor's BlendMode - DISPLAY->SetBlendMode( BLEND_ADD ); - DISPLAY->SetTextureFiltering( true ); - DrawMesh( i ); - } - } - else + bool bUseMultitexture = PREFSMAN->m_bAllowMultitexture && DISPLAY->GetNumTextureUnits() >= 2; + if( bUseMultitexture ) { // render the diffuse texture with texture unit 1 DISPLAY->SetTexture( TextureUnit_1, mat.diffuse.GetCurrentTexture() ); @@ -416,6 +397,27 @@ void Model::DrawPrimitives() DISPLAY->SetTexture( TextureUnit_1, NULL ); DISPLAY->SetSphereEnvironmentMapping( 0 ); } + else + { + // render the diffuse texture + DISPLAY->SetTexture( TextureUnit_1, mat.diffuse.GetCurrentTexture() ); + Actor::SetTextureRenderStates(); // set Actor-specified render states + DISPLAY->SetSphereEnvironmentMapping( mat.diffuse.m_bSphereMapped ); + DrawMesh( i ); + + // render the additive texture + if( mat.alpha.GetCurrentTexture() ) + { + DISPLAY->SetTexture( TextureUnit_1, mat.alpha.GetCurrentTexture() ); + Actor::SetTextureRenderStates(); // set Actor-specified render states + + DISPLAY->SetSphereEnvironmentMapping( mat.alpha.m_bSphereMapped ); + // UGLY: This overrides the Actor's BlendMode + DISPLAY->SetBlendMode( BLEND_ADD ); + DISPLAY->SetTextureFiltering( true ); + DrawMesh( i ); + } + } if( vTexTranslate.x != 0 || vTexTranslate.y != 0 ) DISPLAY->TexturePopMatrix(); diff --git a/stepmania/src/PrefsManager.cpp b/stepmania/src/PrefsManager.cpp index 12684b5eae..1ee6480ab8 100644 --- a/stepmania/src/PrefsManager.cpp +++ b/stepmania/src/PrefsManager.cpp @@ -220,6 +220,7 @@ PrefsManager::PrefsManager() : m_iMaxTextureResolution ( "MaxTextureResolution", 2048 ), m_iRefreshRate ( "RefreshRate", REFRESH_DEFAULT ), m_fDisplayAspectRatio ( "DisplayAspectRatio", 4/3.0f ), + m_bAllowMultitexture ( "AllowMultitexture", true ), m_bShowStats ( "ShowStats", TRUE_IF_DEBUG), m_bShowBanners ( "ShowBanners", true ), diff --git a/stepmania/src/PrefsManager.h b/stepmania/src/PrefsManager.h index e073369983..f3a69d4d80 100644 --- a/stepmania/src/PrefsManager.h +++ b/stepmania/src/PrefsManager.h @@ -30,6 +30,7 @@ public: Preference m_iMaxTextureResolution; Preference m_iRefreshRate; Preference m_fDisplayAspectRatio; + Preference m_bAllowMultitexture; Preference m_bShowStats; Preference m_bShowBanners; diff --git a/stepmania/src/ScreenDebugOverlay.cpp b/stepmania/src/ScreenDebugOverlay.cpp index 5ab68a2594..dc98760cee 100644 --- a/stepmania/src/ScreenDebugOverlay.cpp +++ b/stepmania/src/ScreenDebugOverlay.cpp @@ -121,29 +121,31 @@ void ScreenDebugOverlay::Init() g_Mappings.holdForDebug1 = DeviceInput(DEVICE_KEYBOARD, KEY_F3); g_Mappings.holdForDebug2.MakeInvalid(); - g_Mappings.gameplayButton[0] = DeviceInput(DEVICE_KEYBOARD, KEY_F8); - g_Mappings.gameplayButton[1] = DeviceInput(DEVICE_KEYBOARD, KEY_F7); - g_Mappings.gameplayButton[2] = DeviceInput(DEVICE_KEYBOARD, KEY_F6); - g_Mappings.debugButton[3] = DeviceInput(DEVICE_KEYBOARD, KEY_C1); - g_Mappings.debugButton[4] = DeviceInput(DEVICE_KEYBOARD, KEY_C2); - g_Mappings.debugButton[5] = DeviceInput(DEVICE_KEYBOARD, KEY_C3); - g_Mappings.debugButton[6] = DeviceInput(DEVICE_KEYBOARD, KEY_C4); - g_Mappings.debugButton[7] = DeviceInput(DEVICE_KEYBOARD, KEY_C5); - g_Mappings.debugButton[8] = DeviceInput(DEVICE_KEYBOARD, KEY_C6); - g_Mappings.debugButton[9] = DeviceInput(DEVICE_KEYBOARD, KEY_C7); - g_Mappings.debugButton[10] = DeviceInput(DEVICE_KEYBOARD, KEY_C8); - g_Mappings.debugButton[11] = DeviceInput(DEVICE_KEYBOARD, KEY_C9); - g_Mappings.debugButton[12] = DeviceInput(DEVICE_KEYBOARD, KEY_C0); - g_Mappings.debugButton[13] = DeviceInput(DEVICE_KEYBOARD, KEY_Cq); - g_Mappings.debugButton[14] = DeviceInput(DEVICE_KEYBOARD, KEY_Cw); - g_Mappings.debugButton[15] = DeviceInput(DEVICE_KEYBOARD, KEY_Ce); - g_Mappings.debugButton[16] = DeviceInput(DEVICE_KEYBOARD, KEY_Cr); - g_Mappings.debugButton[17] = DeviceInput(DEVICE_KEYBOARD, KEY_Ct); - g_Mappings.debugButton[18] = DeviceInput(DEVICE_KEYBOARD, KEY_Cy); - g_Mappings.debugButton[19] = DeviceInput(DEVICE_KEYBOARD, KEY_Cu); - g_Mappings.debugButton[20] = DeviceInput(DEVICE_KEYBOARD, KEY_Ci); - g_Mappings.debugButton[21] = DeviceInput(DEVICE_KEYBOARD, KEY_UP); - g_Mappings.debugButton[22] = DeviceInput(DEVICE_KEYBOARD, KEY_DOWN); + int i=0; + g_Mappings.gameplayButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_F8); + g_Mappings.gameplayButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_F7); + g_Mappings.gameplayButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_F6); + g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C1); + g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C2); + g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C3); + g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C4); + g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C5); + g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C6); + g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C7); + g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C8); + g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C9); + g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C0); + g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cq); + g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cw); + g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Ce); + g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cr); + g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Ct); + g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cy); + g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cu); + g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Ci); + g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Co); + g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_UP); + g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_DOWN); } @@ -341,6 +343,8 @@ void ChangeVolume( float fDelta ) // // DebugLines // +#define DECLARE_ONE( x ) static x g_##x + class DebugLineAutoplay : public IDebugLine { virtual CString GetDescription() { return "AutoPlay"; } @@ -367,7 +371,7 @@ class DebugLineAutoplay : public IDebugLine IDebugLine::Do( sMessageOut ); } }; -static DebugLineAutoplay g_DebugLineAutoplay; +DECLARE_ONE( DebugLineAutoplay ); class DebugLineAssistTick : public IDebugLine { @@ -383,7 +387,7 @@ class DebugLineAssistTick : public IDebugLine IDebugLine::Do( sMessageOut ); } }; -static DebugLineAssistTick g_DebugLineAssistTick; +DECLARE_ONE( DebugLineAssistTick ); class DebugLineAutosync : public IDebugLine { @@ -408,7 +412,7 @@ class DebugLineAutosync : public IDebugLine IDebugLine::Do( sMessageOut ); } }; -static DebugLineAutosync g_DebugLineAutosync; +DECLARE_ONE( DebugLineAutosync ); class DebugLineCoinMode : public IDebugLine { @@ -424,7 +428,7 @@ class DebugLineCoinMode : public IDebugLine IDebugLine::Do( sMessageOut ); } }; -static DebugLineCoinMode g_DebugLineCoinMode; +DECLARE_ONE( DebugLineCoinMode ); class DebugLineSlow : public IDebugLine { @@ -438,7 +442,7 @@ class DebugLineSlow : public IDebugLine IDebugLine::Do( sMessageOut ); } }; -static DebugLineSlow g_DebugLineSlow; +DECLARE_ONE( DebugLineSlow ); class DebugLineHalt : public IDebugLine { @@ -453,7 +457,7 @@ class DebugLineHalt : public IDebugLine IDebugLine::Do( sMessageOut ); } }; -static DebugLineHalt g_DebugLineHalt; +DECLARE_ONE( DebugLineHalt ); class DebugLineLightsDebug : public IDebugLine { @@ -466,7 +470,7 @@ class DebugLineLightsDebug : public IDebugLine IDebugLine::Do( sMessageOut ); } }; -static DebugLineLightsDebug g_DebugLineLightsDebug; +DECLARE_ONE( DebugLineLightsDebug ); class DebugLineMonkeyInput : public IDebugLine { @@ -479,7 +483,7 @@ class DebugLineMonkeyInput : public IDebugLine IDebugLine::Do( sMessageOut ); } }; -static DebugLineMonkeyInput g_DebugLineMonkeyInput; +DECLARE_ONE( DebugLineMonkeyInput ); class DebugLineStats : public IDebugLine { @@ -492,7 +496,7 @@ class DebugLineStats : public IDebugLine IDebugLine::Do( sMessageOut ); } }; -static DebugLineStats g_DebugLineStats; +DECLARE_ONE( DebugLineStats ); class DebugLineVsync : public IDebugLine { @@ -506,7 +510,20 @@ class DebugLineVsync : public IDebugLine IDebugLine::Do( sMessageOut ); } }; -static DebugLineVsync g_DebugLineVsync; +DECLARE_ONE( DebugLineVsync ); + +class DebugLineAllowMultitexture : public IDebugLine +{ + virtual CString GetDescription() { return "Multitexture"; } + virtual CString GetValue() { return IsEnabled() ? "on":"off"; } + virtual bool IsEnabled() { return PREFSMAN->m_bAllowMultitexture.Get(); } + virtual void Do( CString &sMessageOut ) + { + PREFSMAN->m_bAllowMultitexture.Set( !PREFSMAN->m_bAllowMultitexture ); + IDebugLine::Do( sMessageOut ); + } +}; +DECLARE_ONE( DebugLineAllowMultitexture ); class DebugLineScreenTestMode : public IDebugLine { @@ -519,7 +536,7 @@ class DebugLineScreenTestMode : public IDebugLine IDebugLine::Do( sMessageOut ); } }; -static DebugLineScreenTestMode g_DebugLineScreenTestMode; +DECLARE_ONE( DebugLineScreenTestMode ); class DebugLineClearMachineStats : public IDebugLine { @@ -534,7 +551,7 @@ class DebugLineClearMachineStats : public IDebugLine IDebugLine::Do( sMessageOut ); } }; -static DebugLineClearMachineStats g_DebugClearMachineStats; +DECLARE_ONE( DebugLineClearMachineStats ); class DebugLineFillMachineStats : public IDebugLine { @@ -549,7 +566,7 @@ class DebugLineFillMachineStats : public IDebugLine IDebugLine::Do( sMessageOut ); } }; -static DebugLineFillMachineStats g_DebugLineFillMachineStats; +DECLARE_ONE( DebugLineFillMachineStats ); class DebugLineSendNotesEnded : public IDebugLine { @@ -562,7 +579,7 @@ class DebugLineSendNotesEnded : public IDebugLine IDebugLine::Do( sMessageOut ); } }; -static DebugLineSendNotesEnded g_DebugLineSendNotesEnded; +DECLARE_ONE( DebugLineSendNotesEnded ); class DebugLineReloadCurrentScreen : public IDebugLine { @@ -578,7 +595,7 @@ class DebugLineReloadCurrentScreen : public IDebugLine sMessageOut = ""; } }; -static DebugLineReloadCurrentScreen g_DebugLineReloadCurrentScreen; +DECLARE_ONE( DebugLineReloadCurrentScreen ); class DebugLineReloadTheme : public IDebugLine { @@ -596,7 +613,7 @@ class DebugLineReloadTheme : public IDebugLine IDebugLine::Do( sMessageOut ); } }; -static DebugLineReloadTheme g_DebugLineReloadTheme; +DECLARE_ONE( DebugLineReloadTheme ); class DebugLineWriteProfiles : public IDebugLine { @@ -624,7 +641,7 @@ class DebugLineWriteProfiles : public IDebugLine IDebugLine::Do( sMessageOut ); } }; -static DebugLineWriteProfiles g_DebugLineWriteProfiles; +DECLARE_ONE( DebugLineWriteProfiles ); class DebugLineWritePreferences : public IDebugLine { @@ -637,7 +654,7 @@ class DebugLineWritePreferences : public IDebugLine IDebugLine::Do( sMessageOut ); } }; -static DebugLineStats g_DebugLineWritePreferences; +DECLARE_ONE( DebugLineWritePreferences ); class DebugLineMenuTimer : public IDebugLine { @@ -650,7 +667,7 @@ class DebugLineMenuTimer : public IDebugLine IDebugLine::Do( sMessageOut ); } }; -static DebugLineMenuTimer g_DebugLineMenuTimer; +DECLARE_ONE( DebugLineMenuTimer ); class DebugLineFlushLog : public IDebugLine { @@ -663,7 +680,7 @@ class DebugLineFlushLog : public IDebugLine IDebugLine::Do( sMessageOut ); } }; -static DebugLineFlushLog g_DebugLineFlushLog; +DECLARE_ONE( DebugLineFlushLog ); class DebugLinePullBackCamera : public IDebugLine { @@ -679,7 +696,7 @@ class DebugLinePullBackCamera : public IDebugLine IDebugLine::Do( sMessageOut ); } }; -static DebugLinePullBackCamera g_DebugLinePullBackCamera; +DECLARE_ONE( DebugLinePullBackCamera ); class DebugLineVolumeUp : public IDebugLine { @@ -692,7 +709,7 @@ class DebugLineVolumeUp : public IDebugLine IDebugLine::Do( sMessageOut ); } }; -static DebugLineVolumeUp g_DebugLineVolumeUp; +DECLARE_ONE( DebugLineVolumeUp ); class DebugLineVolumeDown : public IDebugLine { @@ -705,7 +722,7 @@ class DebugLineVolumeDown : public IDebugLine IDebugLine::Do( sMessageOut ); } }; -static DebugLineVolumeDown g_DebugLineVolumeDown; +DECLARE_ONE( DebugLineVolumeDown ); class DebugLineUptime : public IDebugLine { @@ -714,7 +731,7 @@ class DebugLineUptime : public IDebugLine virtual bool IsEnabled() { return false; } virtual void Do( CString &sMessageOut ) {} }; -static DebugLineUptime g_DebugLineUptime; +DECLARE_ONE( DebugLineUptime ); /*