diff --git a/src/BitmapText.cpp b/src/BitmapText.cpp index c0977f8c96..49457f7b6f 100644 --- a/src/BitmapText.cpp +++ b/src/BitmapText.cpp @@ -487,7 +487,8 @@ void BitmapText::DrawChars( bool bUseStrokeTexture ) if ( haveTextures && end < m_vpFontPageTextures.size() && m_vpFontPageTextures[start]->m_pTextureMain != m_vpFontPageTextures[end]->m_pTextureMain ) renderNow = true; - if ( (haveTextures && (renderNow || end >= iEndGlyph)) || texUnit == 8 || texUnit > DISPLAY->GetNumTextureUnits() || !PREFSMAN->m_bAllowMultitexture ) + // Render if we can't store any more textures without running into software or hardware limitations + if ( haveTextures && (((renderNow || end >= iEndGlyph) || texUnit == 8) || (texUnit == DISPLAY->GetNumTextureUnits() || !PREFSMAN->m_bAllowMultitexture )) ) { DISPLAY->DrawQuads(&m_aVertices[startingPoint * 4], (end - startingPoint) * 4); diff --git a/src/RageDisplay.cpp b/src/RageDisplay.cpp index a070b02faa..e7f08aea0e 100644 --- a/src/RageDisplay.cpp +++ b/src/RageDisplay.cpp @@ -283,6 +283,12 @@ void RageDisplay::SetDefaultRenderStates() LoadMenuPerspective( 0, 640, 480, 320, 240 ); // 0 FOV = ortho } +bool RageDisplay::IsD3DInternal() +{ + return false; +} + + // Matrix stuff class MatrixStack @@ -1043,6 +1049,11 @@ void RageDisplay::SetPresentTime(std::chrono::nanoseconds presentTime) g_LastFramePresentTime = presentTime; } +bool RageDisplay::IsD3D() +{ + return DISPLAY->IsD3DInternal(); +} + RageCompiledGeometry::~RageCompiledGeometry() { m_bNeedsNormals = false; diff --git a/src/RageDisplay.h b/src/RageDisplay.h index 1c687db267..39f69f5a58 100644 --- a/src/RageDisplay.h +++ b/src/RageDisplay.h @@ -200,6 +200,7 @@ class RageDisplay // Call this when the resolution has been changed externally: virtual void ResolutionChanged(); + bool IsD3D(); virtual bool BeginFrame(); virtual void EndFrame(); @@ -337,6 +338,8 @@ class RageDisplay virtual void DrawLineStripInternal( const RageSpriteVertex v[], int iNumVerts, float LineWidth ); virtual void DrawSymmetricQuadStripInternal( const RageSpriteVertex v[], int iNumVerts ) = 0; virtual void DrawCircleInternal( const RageSpriteVertex &v, float radius ); + + virtual bool IsD3DInternal(); // return RString() if mode change was successful, an error message otherwise. // bNewDeviceOut is set true if a new device was created and textures diff --git a/src/RageDisplay_D3D.cpp b/src/RageDisplay_D3D.cpp index c7dc8e3604..16cec5de2a 100644 --- a/src/RageDisplay_D3D.cpp +++ b/src/RageDisplay_D3D.cpp @@ -1169,20 +1169,20 @@ void RageDisplay_D3D::SetBlendMode( BlendMode mode ) g_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ZERO ); g_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE ); // Alpha: iSourceAlpha = GL_ZERO; iDestAlpha = GL_SRC_ALPHA; - /* - g_pd3dDevice->SetRenderState( D3DRS_SRCALPHA, D3DBLEND_ZERO ); - g_pd3dDevice->SetRenderState( D3DRS_DESTALPHA, D3DBLEND_SRCALPHA ); - */ + + g_pd3dDevice->SetRenderState(D3DRS_SRCBLENDALPHA, D3DBLEND_ZERO ); + g_pd3dDevice->SetRenderState(D3DRS_DESTBLENDALPHA, D3DBLEND_SRCALPHA ); + break; case BLEND_ALPHA_KNOCK_OUT: // RGB: iSourceRGB = GL_ZERO; iDestRGB = GL_ONE; g_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ZERO ); g_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE ); // Alpha: iSourceAlpha = GL_ZERO; iDestAlpha = GL_ONE_MINUS_SRC_ALPHA; - /* + g_pd3dDevice->SetRenderState( D3DRS_SRCBLENDALPHA, D3DBLEND_ZERO ); g_pd3dDevice->SetRenderState( D3DRS_DESTBLENDALPHA, D3DBLEND_INVSRCALPHA ); - */ + break; case BLEND_ALPHA_MULTIPLY: g_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA ); @@ -1654,6 +1654,7 @@ void RageDisplay_D3D::SetRenderTarget(unsigned uTexHandle, bool bPreserveTexture // Need to blend the render targets together, not sure why OpenGL doesn't need this -xwidghet g_pd3dDevice->SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, true); + /* If bPreserveTexture is false, clear the render target. Only clear the depth * buffer if the target has one; otherwise we're clearing the real depth buffer. */ @@ -1668,7 +1669,7 @@ void RageDisplay_D3D::SetRenderTarget(unsigned uTexHandle, bool bPreserveTexture }*/ if (FAILED(g_pd3dDevice->Clear(0, NULL, iBit, - D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0x00000000))) + D3DCOLOR_ARGB(0, 0, 0, 0), 1.0f, 0x00000000))) LOG->Warn("Failed to clear render target"); } } @@ -1683,6 +1684,11 @@ void RageDisplay_D3D::SetCelShaded( int stage ) // todo: implement me! } +bool RageDisplay_D3D::IsD3DInternal() +{ + return true; +} + /* * Copyright (c) 2001-2004 Chris Danford, Glenn Maynard * All rights reserved. diff --git a/src/RageDisplay_D3D.h b/src/RageDisplay_D3D.h index 30381975fe..92933dc8a0 100644 --- a/src/RageDisplay_D3D.h +++ b/src/RageDisplay_D3D.h @@ -70,6 +70,8 @@ class RageDisplay_D3D: public RageDisplay void SetSphereEnvironmentMapping( TextureUnit tu, bool b ); void SetCelShaded( int stage ); + bool IsD3DInternal(); + RageCompiledGeometry* CreateCompiledGeometry(); void DeleteCompiledGeometry( RageCompiledGeometry* p ); diff --git a/src/RageDisplay_Null.cpp b/src/RageDisplay_Null.cpp index 16d8fd7607..b83e27ea97 100644 --- a/src/RageDisplay_Null.cpp +++ b/src/RageDisplay_Null.cpp @@ -122,6 +122,11 @@ void RageDisplay_Null::EndFrame() { ProcessStatsOnFlip(); } + +bool RageDisplay_Null::IsD3DInternal() +{ + return false; +} class RageCompiledGeometryNull : public RageCompiledGeometry diff --git a/src/RageDisplay_Null.h b/src/RageDisplay_Null.h index 2f3d027999..fed40b759e 100644 --- a/src/RageDisplay_Null.h +++ b/src/RageDisplay_Null.h @@ -63,6 +63,8 @@ class RageDisplay_Null: public RageDisplay void SetSphereEnvironmentMapping( TextureUnit /* tu */, bool /* b */ ) { } void SetCelShaded( int /* stage */ ) { } + bool IsD3DInternal(); + RageCompiledGeometry* CreateCompiledGeometry(); void DeleteCompiledGeometry( RageCompiledGeometry* ); diff --git a/src/RageDisplay_OGL.cpp b/src/RageDisplay_OGL.cpp index d088c115df..baaee8e7a1 100644 --- a/src/RageDisplay_OGL.cpp +++ b/src/RageDisplay_OGL.cpp @@ -2746,6 +2746,11 @@ void RageDisplay_Legacy::SetCelShaded( int stage ) } } +bool RageDisplay_Legacy::IsD3DInternal() +{ + return false; +} + /* * Copyright (c) 2001-2011 Chris Danford, Glenn Maynard, Colby Klein * All rights reserved. diff --git a/src/RageDisplay_OGL.h b/src/RageDisplay_OGL.h index 2b55392668..8457742f8a 100644 --- a/src/RageDisplay_OGL.h +++ b/src/RageDisplay_OGL.h @@ -100,6 +100,8 @@ class RageDisplay_Legacy: public RageDisplay void SetSphereEnvironmentMapping( TextureUnit tu, bool b ); void SetCelShaded( int stage ); + bool IsD3DInternal(); + RageCompiledGeometry* CreateCompiledGeometry(); void DeleteCompiledGeometry( RageCompiledGeometry* p );