From 848ad6e2bea69be3aa421f8c28e594236b88bf9a Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Thu, 20 Feb 2003 21:22:18 +0000 Subject: [PATCH] clean up detection and handling of drivers with problematic AA lines only draw topmost screen if topmost screen isn't transparent (speeds up options menus in editor) optimized beat bar drawing in NoteField --- stepmania/src/Actor.cpp | 6 ++--- stepmania/src/GrooveRadar.cpp | 8 +++++- stepmania/src/NoteField.cpp | 27 ++++++++++++++----- stepmania/src/NoteField.h | 1 - stepmania/src/RageDisplay.cpp | 15 ++++++----- stepmania/src/RageDisplay.h | 4 +-- stepmania/src/RageDisplayInternal.h | 3 +++ stepmania/src/Screen.cpp | 1 + stepmania/src/Screen.h | 6 ++++- stepmania/src/ScreenManager.cpp | 11 +++++--- stepmania/src/ScreenMiniMenu.cpp | 2 ++ stepmania/src/ScreenPrompt.cpp | 2 ++ stepmania/src/ScreenTextEntry.cpp | 2 ++ .../InputHandler/InputHandler_Win32_Pump.cpp | 3 ++- stepmania/stepmania.nsi | 2 +- 15 files changed, 65 insertions(+), 28 deletions(-) diff --git a/stepmania/src/Actor.cpp b/stepmania/src/Actor.cpp index 06c430cf93..c3a72e1c2c 100644 --- a/stepmania/src/Actor.cpp +++ b/stepmania/src/Actor.cpp @@ -144,11 +144,11 @@ void Actor::BeginDraw() // set the world matrix and calculate actor properties DISPLAY->Scale( m_temp.scale.x, m_temp.scale.y, m_temp.scale.z ); - if( m_temp.rotation.x != 0 ) +// if( m_temp.rotation.x != 0 ) DISPLAY->RotateX( m_temp.rotation.x ); - if( m_temp.rotation.y != 0 ) +// if( m_temp.rotation.y != 0 ) DISPLAY->RotateY( m_temp.rotation.y ); - if( m_temp.rotation.z != 0 ) +// if( m_temp.rotation.z != 0 ) DISPLAY->RotateZ( m_temp.rotation.z ); } diff --git a/stepmania/src/GrooveRadar.cpp b/stepmania/src/GrooveRadar.cpp index b6909a1c64..3d0d8927fa 100644 --- a/stepmania/src/GrooveRadar.cpp +++ b/stepmania/src/GrooveRadar.cpp @@ -191,7 +191,13 @@ void GrooveRadar::GrooveRadarValueMap::DrawPrimitives() v[i].c = PlayerToColor( (PlayerNumber)p ); } - DISPLAY->DrawLoop( v, NUM_RADAR_CATEGORIES, RADAR_EDGE_WIDTH ); + switch( PREFSMAN->m_iPolygonRadar ) + { + case 0: DISPLAY->DrawLoop_LinesAndPoints( v, NUM_RADAR_CATEGORIES, RADAR_EDGE_WIDTH ); break; + case 1: DISPLAY->DrawLoop_Polys( v, NUM_RADAR_CATEGORIES, RADAR_EDGE_WIDTH ); break; + default: + case -1: DISPLAY->DrawLoop( v, NUM_RADAR_CATEGORIES, RADAR_EDGE_WIDTH ); break; + } } } diff --git a/stepmania/src/NoteField.cpp b/stepmania/src/NoteField.cpp index d287b9617d..51330350e5 100644 --- a/stepmania/src/NoteField.cpp +++ b/stepmania/src/NoteField.cpp @@ -23,6 +23,7 @@ #include "RageLog.h" #include #include "ThemeManager.h" +#include "RageDisplay.h" const float HOLD_NOTE_BITS_PER_BEAT = 6; @@ -31,8 +32,6 @@ const float ROWS_BETWEEN_HOLD_BITS = 1 / HOLD_NOTE_BITS_PER_ROW; NoteField::NoteField() { - m_rectMeasureBar.TurnShadowOff(); - m_textMeasureNumber.LoadFromFont( THEME->GetPathTo("Fonts","normal") ); m_textMeasureNumber.SetZoom( 1.0f ); @@ -96,6 +95,10 @@ void NoteField::DrawBeatBar( const float fBeat ) const float fYPos = ArrowGetYPos( m_PlayerNumber, fYOffset ); + RageVertex v[4]; // upper-left, upper-right, lower-right, lower-left + memset( v, 0, sizeof(v) ); + + int iSegWidth; int iSpaceWidth; float fBrightness; @@ -109,14 +112,24 @@ void NoteField::DrawBeatBar( const float fBeat ) } CLAMP( fBrightness, 0, 1 ); + DISPLAY->SetTexture( NULL ); + DISPLAY->SetTextureModeModulate(); + DISPLAY->SetBlendModeNormal(); + float fWidth = GetWidth(); for( float f=-fWidth/2; f<+fWidth/2; ) { - m_rectMeasureBar.StretchTo( RectF(f,0,f+iSegWidth,0) ); - m_rectMeasureBar.SetY( fYPos ); - m_rectMeasureBar.SetZoomY( bIsMeasure ? 6.f : 3.f ); - m_rectMeasureBar.SetDiffuse( RageColor(1,1,1,0.5f*fBrightness) ); - m_rectMeasureBar.Draw(); + v[0].c = v[1].c = v[2].c = v[3].c = RageColor(1,1,1,0.5f*fBrightness); + + float fLeft = f; + float fRight = f+iSegWidth; + float fHeight = bIsMeasure ? 6.f : 3.f; + v[0].p = RageVector3( fLeft, fYPos-fHeight/2, 0 ); // upper-left + v[1].p = RageVector3( fRight, fYPos-fHeight/2, 0 ); // upper-right + v[2].p = RageVector3( fRight, fYPos+fHeight/2, 0 ); // lower-right + v[3].p = RageVector3( fLeft, fYPos+fHeight/2, 0 ); // lower-left + + DISPLAY->DrawQuad( v ); f += iSegWidth + iSpaceWidth; } diff --git a/stepmania/src/NoteField.h b/stepmania/src/NoteField.h index 5ecb5e54c9..f99d3431ef 100644 --- a/stepmania/src/NoteField.h +++ b/stepmania/src/NoteField.h @@ -60,7 +60,6 @@ protected: NoteDisplay m_NoteDisplay[MAX_NOTE_TRACKS]; // used in MODE_EDIT - Quad m_rectMeasureBar; BitmapText m_textMeasureNumber; Quad m_rectMarkerBar; Quad m_rectAreaHighlight; diff --git a/stepmania/src/RageDisplay.cpp b/stepmania/src/RageDisplay.cpp index f9b20023cd..b032c37861 100644 --- a/stepmania/src/RageDisplay.cpp +++ b/stepmania/src/RageDisplay.cpp @@ -23,8 +23,6 @@ #include "RageTypes.h" #include "GameConstantsAndTypes.h" #include "StepMania.h" -/* XXX: remove this once we add oglspecs_t::DisableAALines */ -#include "PrefsManager.h" #include @@ -102,13 +100,17 @@ RageDisplay::RageDisplay( bool windowed, int width, int height, int bpp, int rat glGetFloatv(GL_POINT_SIZE_RANGE, m_oglspecs->point_range); glGetFloatv(GL_POINT_SIZE_GRANULARITY, &m_oglspecs->point_granularity); LOG->Info("Point size range: %f-%f +%f", m_oglspecs->point_range[0], m_oglspecs->point_range[1], m_oglspecs->point_granularity); + + m_oglspecs->bAALinesCauseProblems = strncmp((const char*)glGetString(GL_RENDERER),"3Dfx/Voodoo3 (tm)/2 TMUs/16 MB SDRAM/ICD (Nov 2 2000)",sizeof("3Dfx/Voodoo3"))==0; + if( m_oglspecs->bAALinesCauseProblems ) + LOG->Info("Anti-aliased lines are known to cause problems with this driver."); } bool RageDisplay::IsSoftwareRenderer() { return - ( stricmp((const char*)glGetString(GL_VENDOR),"Microsoft Corporation")==0 ) && - ( stricmp((const char*)glGetString(GL_RENDERER),"GDI Generic")==0 ); + ( strcmp((const char*)glGetString(GL_VENDOR),"Microsoft Corporation")==0 ) && + ( strcmp((const char*)glGetString(GL_RENDERER),"GDI Generic")==0 ); } void RageDisplay::SetupOpenGL() @@ -469,7 +471,7 @@ bool RageDisplay::IsWindowed() const { return true; // FIXME } -void RageDisplay::DrawQuad( const RageVertex v[4] ) // upper-left, upper-right, lower-left, lower-right +void RageDisplay::DrawQuad( const RageVertex v[4] ) // upper-left, upper-right, lower-right, lower-left { DrawQuads( v, 4 ); } @@ -618,8 +620,7 @@ void RageDisplay::DrawLoop_LinesAndPoints( const RageVertex v[], int iNumVerts, void RageDisplay::DrawLoop( const RageVertex v[], int iNumVerts, float LineWidth ) { - /* XXX: -1, 0, 1 */ - if(PREFSMAN->m_iPolygonRadar == 1) + if( m_oglspecs->bAALinesCauseProblems ) DrawLoop_Polys(v, iNumVerts, LineWidth); else DrawLoop_LinesAndPoints(v, iNumVerts, LineWidth); diff --git a/stepmania/src/RageDisplay.h b/stepmania/src/RageDisplay.h index df3dd0e088..4749963237 100644 --- a/stepmania/src/RageDisplay.h +++ b/stepmania/src/RageDisplay.h @@ -71,6 +71,8 @@ public: void DrawFan( const RageVertex v[], int iNumVerts ); void DrawStrip( const RageVertex v[], int iNumVerts ); void DrawLoop( const RageVertex v[], int iNumVerts, float LineWidth ); + void DrawLoop_LinesAndPoints( const RageVertex v[], int iNumVerts, float LineWidth ); + void DrawLoop_Polys( const RageVertex v[], int iNumVerts, float LineWidth ); void FlushQueue(); int GetMaxTextureSize() const; @@ -102,8 +104,6 @@ protected: void RageDisplay::DumpOpenGLDebugInfo(); void DrawPolyLine(const RageVertex &p1, const RageVertex &p2, float LineWidth ); - void DrawLoop_LinesAndPoints( const RageVertex v[], int iNumVerts, float LineWidth ); - void DrawLoop_Polys( const RageVertex v[], int iNumVerts, float LineWidth ); }; diff --git a/stepmania/src/RageDisplayInternal.h b/stepmania/src/RageDisplayInternal.h index 2edb6a7b8b..07405269b6 100644 --- a/stepmania/src/RageDisplayInternal.h +++ b/stepmania/src/RageDisplayInternal.h @@ -44,6 +44,9 @@ struct oglspecs_t { bool EXT_texture_env_combine, WGL_EXT_swap_control, EXT_paletted_texture; + + /* Is AA known to cause problems in this driver? (Voodoo3) */ + bool bAALinesCauseProblems; }; /* Extension functions we use. Put these in a namespace instead of in oglspecs_t, diff --git a/stepmania/src/Screen.cpp b/stepmania/src/Screen.cpp index 3ed2a47b55..3b43e66860 100644 --- a/stepmania/src/Screen.cpp +++ b/stepmania/src/Screen.cpp @@ -20,6 +20,7 @@ Screen::Screen() { + m_bIsTransparent = false; } Screen::~Screen() diff --git a/stepmania/src/Screen.h b/stepmania/src/Screen.h index 91cfaf93ec..360c78bb8d 100644 --- a/stepmania/src/Screen.h +++ b/stepmania/src/Screen.h @@ -39,8 +39,10 @@ public: void SendScreenMessage( const ScreenMessage SM, const float fDelay ); void ClearMessageQueue(); void ClearMessageQueue( const ScreenMessage SM ); // clear of a specific SM -protected: + bool IsTransparent() { return m_bIsTransparent; } + +protected: // structure for holding messages sent to a Screen struct QueuedScreenMessage { ScreenMessage SM; @@ -48,6 +50,8 @@ protected: }; vector m_QueuedMessages; + bool m_bIsTransparent; // screens below us need to be drawn first + public: // let subclass override if they want diff --git a/stepmania/src/ScreenManager.cpp b/stepmania/src/ScreenManager.cpp index 83ea995910..fe2a08b14a 100644 --- a/stepmania/src/ScreenManager.cpp +++ b/stepmania/src/ScreenManager.cpp @@ -113,7 +113,7 @@ void ScreenManager::Update( float fDeltaTime ) void ScreenManager::Restore() { - // Draw all CurrentScreens (back to front) + // Restore all CurrentScreens (back to front) for( unsigned i=0; iRestore(); } @@ -126,9 +126,12 @@ void ScreenManager::Invalidate() void ScreenManager::Draw() { - // Draw all CurrentScreens (back to front) - for( unsigned i=0; iDraw(); + if( !m_ScreenStack.empty() && !m_ScreenStack.back()->IsTransparent() ) // top screen isn't transparent + m_ScreenStack.back()->Draw(); + else + for( unsigned i=0; iDraw(); + if( m_textSystemMessage.GetDiffuse().a != 0 ) m_textSystemMessage.Draw(); diff --git a/stepmania/src/ScreenMiniMenu.cpp b/stepmania/src/ScreenMiniMenu.cpp index 86efb63b07..554d713597 100644 --- a/stepmania/src/ScreenMiniMenu.cpp +++ b/stepmania/src/ScreenMiniMenu.cpp @@ -40,6 +40,8 @@ int ScreenMiniMenu::s_iLastAnswers[MAX_MINI_MENU_LINES]; ScreenMiniMenu::ScreenMiniMenu( MiniMenuDefinition* pDef, ScreenMessage SM_SendOnOK, ScreenMessage SM_SendOnCancel ) { + m_bIsTransparent = true; // draw screens below us + m_SMSendOnOK = SM_SendOnOK; m_SMSendOnCancel = SM_SendOnCancel; m_Def = *pDef; diff --git a/stepmania/src/ScreenPrompt.cpp b/stepmania/src/ScreenPrompt.cpp index 805f7b472a..4121f9ec71 100644 --- a/stepmania/src/ScreenPrompt.cpp +++ b/stepmania/src/ScreenPrompt.cpp @@ -28,6 +28,8 @@ const float PROMPT_Y = CENTER_Y + 120; ScreenPrompt::ScreenPrompt( ScreenMessage SM_SendWhenDone, CString sText, bool bYesNoPrompt, bool bDefaultAnswer, void(*OnYes)(), void(*OnNo)() ) { + m_bIsTransparent = true; // draw screens below us + m_SMSendWhenDone = SM_SendWhenDone; m_bYesNoPrompt = bYesNoPrompt; m_bAnswer = bDefaultAnswer; diff --git a/stepmania/src/ScreenTextEntry.cpp b/stepmania/src/ScreenTextEntry.cpp index aaaa5edaeb..d7dad8059d 100644 --- a/stepmania/src/ScreenTextEntry.cpp +++ b/stepmania/src/ScreenTextEntry.cpp @@ -37,6 +37,8 @@ const float ANSWER_HEIGHT = 30; */ ScreenTextEntry::ScreenTextEntry( ScreenMessage SM_SendWhenDone, CString sQuestion, CString sInitialAnswer, void(*OnOK)(CString sAnswer), void(*OnCancel)() ) { + m_bIsTransparent = true; // draw screens below us + m_SMSendWhenDone = SM_SendWhenDone; m_pOnOK = OnOK; m_pOnCancel = OnCancel; diff --git a/stepmania/src/arch/InputHandler/InputHandler_Win32_Pump.cpp b/stepmania/src/arch/InputHandler/InputHandler_Win32_Pump.cpp index 03574e7a54..a149c0990c 100644 --- a/stepmania/src/arch/InputHandler/InputHandler_Win32_Pump.cpp +++ b/stepmania/src/arch/InputHandler/InputHandler_Win32_Pump.cpp @@ -172,7 +172,8 @@ int InputHandler_Win32_Pump::dev_t::GetPadEvent() return -1; if(ret == 0) { - LOG->Warn(werr_ssprintf(GetLastError(), "Error reading Pump pad")); + // this prints too much info in Win98 +// LOG->Warn(werr_ssprintf(GetLastError(), "Error reading Pump pad")); return -1; } diff --git a/stepmania/stepmania.nsi b/stepmania/stepmania.nsi index a9c4785178..b694844e1b 100644 --- a/stepmania/stepmania.nsi +++ b/stepmania/stepmania.nsi @@ -19,7 +19,7 @@ !define PRODUCT_NAME_VER "${PRODUCT_NAME} ${VERSION}" Name "${PRODUCT_NAME}" -OutFile "StepMania-CVS-20030219.exe" +OutFile "StepMania-CVS-20030220.exe" ;OutFile "StepMania301.exe" ; Some default compiler settings (uncomment and change at will):