From 182232344fc6551995cd3d2b9691c8823305b89f Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Fri, 11 Nov 2005 21:16:48 +0000 Subject: [PATCH] GetVideoModeParams -> GetActualVideoModeParams add GetApiDescription --- stepmania/src/GameLoop.cpp | 2 +- stepmania/src/GameSoundManager.cpp | 2 +- stepmania/src/RageDisplay.cpp | 4 +-- stepmania/src/RageDisplay.h | 6 +++-- stepmania/src/RageDisplay_D3D.h | 3 ++- stepmania/src/RageDisplay_Null.h | 3 ++- stepmania/src/RageDisplay_OGL.cpp | 27 ++++++++++--------- stepmania/src/RageDisplay_OGL.h | 3 ++- stepmania/src/StepMania.cpp | 17 ++++++------ .../src/arch/LowLevelWindow/LowLevelWindow.h | 2 +- .../LowLevelWindow/LowLevelWindow_SDL.cpp | 4 +-- .../arch/LowLevelWindow/LowLevelWindow_SDL.h | 2 +- .../LowLevelWindow/LowLevelWindow_Win32.cpp | 2 +- .../LowLevelWindow/LowLevelWindow_Win32.h | 2 +- .../arch/LowLevelWindow/LowLevelWindow_X11.h | 2 +- 15 files changed, 45 insertions(+), 36 deletions(-) diff --git a/stepmania/src/GameLoop.cpp b/stepmania/src/GameLoop.cpp index d7a34dbe47..89b661f63c 100644 --- a/stepmania/src/GameLoop.cpp +++ b/stepmania/src/GameLoop.cpp @@ -44,7 +44,7 @@ static void CheckGameLoopTimerSkips( float fDeltaTime ) /* If vsync is on, and we have a solid framerate (vsync == refresh and we've sustained this * for at least one second), we expect the amount of time for the last frame to be 1/FPS. */ - if( iThisFPS != DISPLAY->GetVideoModeParams().rate || iThisFPS != iLastFPS ) + if( iThisFPS != DISPLAY->GetActualVideoModeParams().rate || iThisFPS != iLastFPS ) { iLastFPS = iThisFPS; return; diff --git a/stepmania/src/GameSoundManager.cpp b/stepmania/src/GameSoundManager.cpp index 8d2c33309e..e2333cb335 100644 --- a/stepmania/src/GameSoundManager.cpp +++ b/stepmania/src/GameSoundManager.cpp @@ -433,7 +433,7 @@ float GameSoundManager::GetFrameTimingAdjustment( float fDeltaTime ) static int iLastFPS = 0; int iThisFPS = DISPLAY->GetFPS(); - if( iThisFPS != DISPLAY->GetVideoModeParams().rate || iThisFPS != iLastFPS ) + if( iThisFPS != DISPLAY->GetActualVideoModeParams().rate || iThisFPS != iLastFPS ) { iLastFPS = iThisFPS; return 0; diff --git a/stepmania/src/RageDisplay.cpp b/stepmania/src/RageDisplay.cpp index ac44ca12ab..e0ebc7cdc6 100644 --- a/stepmania/src/RageDisplay.cpp +++ b/stepmania/src/RageDisplay.cpp @@ -629,8 +629,8 @@ bool RageDisplay::SaveScreenshot( CString sPath, GraphicsFileFormat format ) if( format != SAVE_LOSSLESS ) { /* Maintain the DAR. */ - int iWidth = lrintf( 640 / GetVideoModeParams().fDisplayAspectRatio ); - LOG->Trace( "%ix%i -> %ix%i (%.3f)", surface->w, surface->h, 640, iWidth, GetVideoModeParams().fDisplayAspectRatio ); + int iWidth = lrintf( 640 / GetActualVideoModeParams().fDisplayAspectRatio ); + LOG->Trace( "%ix%i -> %ix%i (%.3f)", surface->w, surface->h, 640, iWidth, GetActualVideoModeParams().fDisplayAspectRatio ); RageSurfaceUtils::Zoom( surface, 640, iWidth ); } diff --git a/stepmania/src/RageDisplay.h b/stepmania/src/RageDisplay.h index 3fdec9ef6a..c0b5c2d4c1 100644 --- a/stepmania/src/RageDisplay.h +++ b/stepmania/src/RageDisplay.h @@ -133,6 +133,8 @@ public: /* This is needed or the overridden classes' dtors will not be called. */ virtual ~RageDisplay() { } + virtual CString GetApiDescription() = 0; + // Don't override this. Override TryVideoMode() instead. // This will set the video mode to be as close as possible to params. // Return true if device was re-created and we need to reload textures. @@ -143,8 +145,8 @@ public: virtual bool BeginFrame() = 0; virtual void EndFrame(); - virtual VideoModeParams GetVideoModeParams() const = 0; - bool IsWindowed() const { return this->GetVideoModeParams().windowed; } + virtual VideoModeParams GetActualVideoModeParams() const = 0; + bool IsWindowed() const { return this->GetActualVideoModeParams().windowed; } virtual void SetBlendMode( BlendMode mode ) = 0; diff --git a/stepmania/src/RageDisplay_D3D.h b/stepmania/src/RageDisplay_D3D.h index e8d6e88a96..ac67e220c7 100644 --- a/stepmania/src/RageDisplay_D3D.h +++ b/stepmania/src/RageDisplay_D3D.h @@ -10,12 +10,13 @@ public: ~RageDisplay_D3D(); CString Init( VideoModeParams p ); + virtual CString GetApiDescription() { return "D3D"; } void ResolutionChanged(); const PixelFormatDesc *GetPixelFormatDesc(PixelFormat pf) const; bool BeginFrame(); void EndFrame(); - VideoModeParams GetVideoModeParams() const; + VideoModeParams GetActualVideoModeParams() const; void SetBlendMode( BlendMode mode ); bool SupportsTextureFormat( PixelFormat pixfmt, bool realtime=false ); bool SupportsThreadedRendering(); diff --git a/stepmania/src/RageDisplay_Null.h b/stepmania/src/RageDisplay_Null.h index a133c1f4d3..57bd239ef9 100644 --- a/stepmania/src/RageDisplay_Null.h +++ b/stepmania/src/RageDisplay_Null.h @@ -8,12 +8,13 @@ class RageDisplay_Null: public RageDisplay public: RageDisplay_Null( VideoModeParams p ); + virtual CString GetApiDescription() { return "Null"; } void ResolutionChanged() { } const PixelFormatDesc *GetPixelFormatDesc(PixelFormat pf) const; bool BeginFrame() { return true; } void EndFrame(); - VideoModeParams GetVideoModeParams() const { return m_Params; } + VideoModeParams GetActualVideoModeParams() const { return m_Params; } void SetBlendMode( BlendMode mode ) { } bool SupportsTextureFormat( PixelFormat pixfmt, bool realtime=false ) { return true; } bool SupportsPerVertexMatrixScale() { return false; } diff --git a/stepmania/src/RageDisplay_OGL.cpp b/stepmania/src/RageDisplay_OGL.cpp index 1522c9d903..38b163b6ed 100644 --- a/stepmania/src/RageDisplay_OGL.cpp +++ b/stepmania/src/RageDisplay_OGL.cpp @@ -706,10 +706,10 @@ void RageDisplay_OGL::SetViewport(int shift_left, int shift_down) { /* left and down are on a 0..SCREEN_WIDTH, 0..SCREEN_HEIGHT scale. * Scale them to the actual viewport range. */ - shift_left = int( shift_left * float(wind->GetVideoModeParams().width) / SCREEN_WIDTH ); - shift_down = int( shift_down * float(wind->GetVideoModeParams().height) / SCREEN_HEIGHT ); + shift_left = int( shift_left * float(wind->GetActualVideoModeParams().width) / SCREEN_WIDTH ); + shift_down = int( shift_down * float(wind->GetActualVideoModeParams().height) / SCREEN_HEIGHT ); - glViewport(shift_left, -shift_down, wind->GetVideoModeParams().width, wind->GetVideoModeParams().height); + glViewport(shift_left, -shift_down, wind->GetActualVideoModeParams().width, wind->GetActualVideoModeParams().height); } int RageDisplay_OGL::GetMaxTextureSize() const @@ -777,8 +777,8 @@ void RageDisplay_OGL::EndFrame() RageSurface* RageDisplay_OGL::CreateScreenshot() { - int width = wind->GetVideoModeParams().width; - int height = wind->GetVideoModeParams().height; + int width = wind->GetActualVideoModeParams().width; + int height = wind->GetActualVideoModeParams().height; const PixelFormatDesc &desc = PIXEL_FORMAT_DESC[PixelFormat_RGBA8]; RageSurface *image = CreateSurface( width, height, desc.bpp, @@ -789,7 +789,7 @@ RageSurface* RageDisplay_OGL::CreateScreenshot() glReadBuffer( GL_FRONT ); AssertNoGLError(); - glReadPixels(0, 0, wind->GetVideoModeParams().width, wind->GetVideoModeParams().height, GL_RGBA, + glReadPixels(0, 0, wind->GetActualVideoModeParams().width, wind->GetActualVideoModeParams().height, GL_RGBA, GL_UNSIGNED_BYTE, image->pixels); AssertNoGLError(); @@ -798,7 +798,10 @@ RageSurface* RageDisplay_OGL::CreateScreenshot() return image; } -VideoModeParams RageDisplay_OGL::GetVideoModeParams() const { return wind->GetVideoModeParams(); } +VideoModeParams RageDisplay_OGL::GetActualVideoModeParams() const +{ + return wind->GetActualVideoModeParams(); +} static void SetupVertices( const RageSpriteVertex v[], int iNumVerts ) { @@ -1334,7 +1337,7 @@ void RageDisplay_OGL::DrawLineStripInternal( const RageSpriteVertex v[], int iNu { TurnOffHardwareVBO(); - if( !GetVideoModeParams().bSmoothLines ) + if( !GetActualVideoModeParams().bSmoothLines ) { /* Fall back on the generic polygon-based line strip. */ RageDisplay::DrawLineStripInternal(v, iNumVerts, LineWidth ); @@ -1351,8 +1354,8 @@ void RageDisplay_OGL::DrawLineStripInternal( const RageSpriteVertex v[], int iNu /* Our line width is wrt the regular internal SCREEN_WIDTHxSCREEN_HEIGHT screen, * but these width functions actually want raster sizes (that is, actual pixels). * Scale the line width and point size by the average ratio of the scale. */ - float WidthVal = float(wind->GetVideoModeParams().width) / SCREEN_WIDTH; - float HeightVal = float(wind->GetVideoModeParams().height) / SCREEN_HEIGHT; + float WidthVal = float(wind->GetActualVideoModeParams().width) / SCREEN_WIDTH; + float HeightVal = float(wind->GetActualVideoModeParams().height) / SCREEN_HEIGHT; LineWidth *= (WidthVal + HeightVal) / 2; /* Clamp the width to the hardware max for both lines and points (whichever @@ -1787,7 +1790,7 @@ unsigned RageDisplay_OGL::CreateTexture( GLint minFilter; if( bGenerateMipMaps ) { - if( wind->GetVideoModeParams().bTrilinearFiltering ) + if( wind->GetActualVideoModeParams().bTrilinearFiltering ) minFilter = GL_LINEAR_MIPMAP_LINEAR; else minFilter = GL_LINEAR_MIPMAP_NEAREST; @@ -1798,7 +1801,7 @@ unsigned RageDisplay_OGL::CreateTexture( } glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minFilter); - if( wind->GetVideoModeParams().bAnisotropicFiltering && + if( wind->GetActualVideoModeParams().bAnisotropicFiltering && GLExt.HasExtension("GL_EXT_texture_filter_anisotropic") ) { GLfloat largest_supported_anisotropy; diff --git a/stepmania/src/RageDisplay_OGL.h b/stepmania/src/RageDisplay_OGL.h index 8b6be8507f..14f7d80c26 100644 --- a/stepmania/src/RageDisplay_OGL.h +++ b/stepmania/src/RageDisplay_OGL.h @@ -10,13 +10,14 @@ public: virtual ~RageDisplay_OGL(); CString Init( VideoModeParams p, bool bAllowUnacceleratedRenderer ); + virtual CString GetApiDescription() { return "OpenGL"; } bool IsSoftwareRenderer(); void ResolutionChanged(); const PixelFormatDesc *GetPixelFormatDesc(PixelFormat pf) const; bool BeginFrame(); void EndFrame(); - VideoModeParams GetVideoModeParams() const; + VideoModeParams GetActualVideoModeParams() const; void SetBlendMode( BlendMode mode ); bool SupportsTextureFormat( PixelFormat pixfmt, bool realtime=false ); bool SupportsPerVertexMatrixScale(); diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index 3714659621..3dd7e3b9da 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -112,14 +112,15 @@ void GetPreferredVideoModeParams( VideoModeParams ¶msOut ) static void StoreActualGraphicOptions( bool initial ) { // find out what we actually have - PREFSMAN->m_bWindowed.Set( DISPLAY->GetVideoModeParams().windowed ); - PREFSMAN->m_iDisplayWidth.Set( DISPLAY->GetVideoModeParams().width ); - PREFSMAN->m_iDisplayHeight.Set( DISPLAY->GetVideoModeParams().height ); - PREFSMAN->m_iDisplayColorDepth.Set( DISPLAY->GetVideoModeParams().bpp ); - PREFSMAN->m_iRefreshRate.Set( DISPLAY->GetVideoModeParams().rate ); - PREFSMAN->m_bVsync.Set( DISPLAY->GetVideoModeParams().vsync ); + PREFSMAN->m_bWindowed .Set( DISPLAY->GetActualVideoModeParams().windowed ); + PREFSMAN->m_iDisplayWidth .Set( DISPLAY->GetActualVideoModeParams().width ); + PREFSMAN->m_iDisplayHeight .Set( DISPLAY->GetActualVideoModeParams().height ); + PREFSMAN->m_iDisplayColorDepth .Set( DISPLAY->GetActualVideoModeParams().bpp ); + PREFSMAN->m_iRefreshRate .Set( DISPLAY->GetActualVideoModeParams().rate ); + PREFSMAN->m_bVsync .Set( DISPLAY->GetActualVideoModeParams().vsync ); - CString log = ssprintf("%s %dx%d %d color %d texture %dHz %s %s", + CString log = ssprintf("%s %s %dx%d %d color %d texture %dHz %s %s", + DISPLAY->GetApiDescription().c_str(), PREFSMAN->m_bWindowed ? "Windowed" : "Fullscreen", (int)PREFSMAN->m_iDisplayWidth, (int)PREFSMAN->m_iDisplayHeight, @@ -133,7 +134,7 @@ static void StoreActualGraphicOptions( bool initial ) else SCREENMAN->SystemMessage( log ); - Dialog::SetWindowed( DISPLAY->GetVideoModeParams().windowed ); + Dialog::SetWindowed( DISPLAY->GetActualVideoModeParams().windowed ); } RageDisplay *CreateDisplay(); diff --git a/stepmania/src/arch/LowLevelWindow/LowLevelWindow.h b/stepmania/src/arch/LowLevelWindow/LowLevelWindow.h index c9f71fcdfa..c9628896ec 100644 --- a/stepmania/src/arch/LowLevelWindow/LowLevelWindow.h +++ b/stepmania/src/arch/LowLevelWindow/LowLevelWindow.h @@ -20,7 +20,7 @@ public: virtual void SwapBuffers() = 0; virtual void Update() { } - virtual VideoModeParams GetVideoModeParams() const = 0; + virtual VideoModeParams GetActualVideoModeParams() const = 0; }; #endif diff --git a/stepmania/src/arch/LowLevelWindow/LowLevelWindow_SDL.cpp b/stepmania/src/arch/LowLevelWindow/LowLevelWindow_SDL.cpp index aa1fce54ef..13cf582829 100644 --- a/stepmania/src/arch/LowLevelWindow/LowLevelWindow_SDL.cpp +++ b/stepmania/src/arch/LowLevelWindow/LowLevelWindow_SDL.cpp @@ -217,7 +217,7 @@ void LowLevelWindow_SDL::Update() break; if( event.active.gain && // app regaining focus - !DISPLAY->GetVideoModeParams().windowed ) // full screen + !DISPLAY->GetActualVideoModeParams().windowed ) // full screen { // need to reacquire an OGL context /* This hasn't been done in a long time, since HandleSDLEvents was @@ -225,7 +225,7 @@ void LowLevelWindow_SDL::Update() * it resulted in input not being regained and textures being erased, * so I left it disabled; but this might be needed on some cards (with * the above fixed) ... */ - // DISPLAY->SetVideoMode( DISPLAY->GetVideoModeParams() ); + // DISPLAY->SetVideoMode( DISPLAY->GetActualVideoModeParams() ); } { diff --git a/stepmania/src/arch/LowLevelWindow/LowLevelWindow_SDL.h b/stepmania/src/arch/LowLevelWindow/LowLevelWindow_SDL.h index f342162616..a8bfdd375a 100644 --- a/stepmania/src/arch/LowLevelWindow/LowLevelWindow_SDL.h +++ b/stepmania/src/arch/LowLevelWindow/LowLevelWindow_SDL.h @@ -13,7 +13,7 @@ public: void SwapBuffers(); void Update(); - VideoModeParams GetVideoModeParams() const { return CurrentParams; } + VideoModeParams GetActualVideoModeParams() const { return CurrentParams; } private: VideoModeParams CurrentParams; diff --git a/stepmania/src/arch/LowLevelWindow/LowLevelWindow_Win32.cpp b/stepmania/src/arch/LowLevelWindow/LowLevelWindow_Win32.cpp index 60049c72ad..50a3303437 100644 --- a/stepmania/src/arch/LowLevelWindow/LowLevelWindow_Win32.cpp +++ b/stepmania/src/arch/LowLevelWindow/LowLevelWindow_Win32.cpp @@ -221,7 +221,7 @@ void LowLevelWindow_Win32::Update() GraphicsWindow::Update(); } -VideoModeParams LowLevelWindow_Win32::GetVideoModeParams() const +VideoModeParams LowLevelWindow_Win32::GetActualVideoModeParams() const { VideoModeParams p; GraphicsWindow::GetParams( p ); diff --git a/stepmania/src/arch/LowLevelWindow/LowLevelWindow_Win32.h b/stepmania/src/arch/LowLevelWindow/LowLevelWindow_Win32.h index e3e280bcb5..0a25443087 100644 --- a/stepmania/src/arch/LowLevelWindow/LowLevelWindow_Win32.h +++ b/stepmania/src/arch/LowLevelWindow/LowLevelWindow_Win32.h @@ -13,7 +13,7 @@ public: void SwapBuffers(); void Update(); - VideoModeParams GetVideoModeParams() const; + VideoModeParams GetActualVideoModeParams() const; }; #ifdef ARCH_LOW_LEVEL_WINDOW diff --git a/stepmania/src/arch/LowLevelWindow/LowLevelWindow_X11.h b/stepmania/src/arch/LowLevelWindow/LowLevelWindow_X11.h index 6488cca8a3..74c9ff551c 100644 --- a/stepmania/src/arch/LowLevelWindow/LowLevelWindow_X11.h +++ b/stepmania/src/arch/LowLevelWindow/LowLevelWindow_X11.h @@ -15,7 +15,7 @@ public: CString TryVideoMode(VideoModeParams p, bool &bNewDeviceOut); void SwapBuffers(); - VideoModeParams GetVideoModeParams() const { return CurrentParams; } + VideoModeParams GetActualVideoModeParams() const { return CurrentParams; } private: bool m_bWindowIsOpen;