diff --git a/src/ActorMultiTexture.cpp b/src/ActorMultiTexture.cpp index 3431ea1c80..7924255404 100644 --- a/src/ActorMultiTexture.cpp +++ b/src/ActorMultiTexture.cpp @@ -97,7 +97,6 @@ void ActorMultiTexture::DrawPrimitives() quadVerticies.top = -m_size.y/2.0f; quadVerticies.bottom = +m_size.y/2.0f; - DISPLAY->ClearAllTextures(); for( size_t i = 0; i < m_aTextureUnits.size(); ++i ) { TextureUnit tu = enum_add2(TextureUnit_1, i); @@ -130,7 +129,8 @@ void ActorMultiTexture::DrawPrimitives() for( size_t i = 0; i < m_aTextureUnits.size(); ++i ) DISPLAY->SetTexture( enum_add2(TextureUnit_1, i), 0 ); - DISPLAY->SetEffectMode( EffectMode_Normal ); + if ( m_EffectMode != EffectMode_Normal ) + DISPLAY->SetEffectMode(EffectMode_Normal); } bool ActorMultiTexture::EarlyAbortDraw() const diff --git a/src/ActorMultiVertex.cpp b/src/ActorMultiVertex.cpp index 36aa802916..f200bb43ff 100644 --- a/src/ActorMultiVertex.cpp +++ b/src/ActorMultiVertex.cpp @@ -218,7 +218,6 @@ void ActorMultiVertex::DrawPrimitives() { Actor::SetGlobalRenderStates(); // set Actor-specified render states - DISPLAY->ClearAllTextures(); DISPLAY->SetTexture( TextureUnit_1, _Texture->GetTexHandle() ); Actor::SetTextureRenderStates(); @@ -330,7 +329,8 @@ void ActorMultiVertex::DrawInternal( const AMV_TweenState *TS ) break; } - DISPLAY->SetEffectMode( EffectMode_Normal ); + if ( _EffectMode != EffectMode_Normal ) + DISPLAY->SetEffectMode(EffectMode_Normal); } bool ActorMultiVertex::EarlyAbortDraw() const diff --git a/src/BitmapText.cpp b/src/BitmapText.cpp index 0ef9c8b0b8..4ec16f6d0b 100644 --- a/src/BitmapText.cpp +++ b/src/BitmapText.cpp @@ -424,7 +424,6 @@ void BitmapText::DrawChars( bool bUseStrokeTexture ) bool haveTextures = false; int startingPoint = iStartGlyph; - DISPLAY->ClearAllTextures(); for ( int start = iStartGlyph; start < iEndGlyph; ) { int end = start; @@ -465,7 +464,6 @@ void BitmapText::DrawChars( bool bUseStrokeTexture ) DISPLAY->DrawQuads(&m_aVertices[startingPoint * 4], (end - startingPoint) * 4); // Setup for the next render pass - DISPLAY->ClearAllTextures(); startingPoint = end; haveTextures = false; } diff --git a/src/GraphDisplay.cpp b/src/GraphDisplay.cpp index c435a21278..1e7b69d75b 100644 --- a/src/GraphDisplay.cpp +++ b/src/GraphDisplay.cpp @@ -26,8 +26,6 @@ class GraphLine: public Actor { Actor::SetGlobalRenderStates(); // set Actor-specified render states - DISPLAY->ClearAllTextures(); - // Must call this after setting the texture or else texture // parameters have no effect. Actor::SetTextureRenderStates(); @@ -133,7 +131,6 @@ class GraphBody: public Actor { Actor::SetGlobalRenderStates(); // set Actor-specified render states - DISPLAY->ClearAllTextures(); DISPLAY->SetTexture( TextureUnit_1, m_pTexture->GetTexHandle() ); // Must call this after setting the texture or else texture diff --git a/src/GrooveRadar.cpp b/src/GrooveRadar.cpp index d0c53d50d3..cd76081ff3 100644 --- a/src/GrooveRadar.cpp +++ b/src/GrooveRadar.cpp @@ -146,7 +146,6 @@ void GrooveRadar::GrooveRadarValueMap::DrawPrimitives() // draw radar filling const float fRadius = GetUnzoomedWidth()/2.0f*1.1f; - DISPLAY->ClearAllTextures(); DISPLAY->SetTextureMode( TextureUnit_1, TextureMode_Modulate ); RageSpriteVertex v[12]; // needed to draw 5 fan primitives and 10 strip primitives diff --git a/src/Model.cpp b/src/Model.cpp index a1283c2b2c..145aeb61a9 100644 --- a/src/Model.cpp +++ b/src/Model.cpp @@ -418,7 +418,6 @@ void Model::DrawPrimitives() static const RageColor specular( 0.2f,0.2f,0.2f,1 ); static const float shininess = 1; DISPLAY->SetMaterial( emissive, ambient, diffuse, specular, shininess ); - DISPLAY->ClearAllTextures(); DISPLAY->SetSphereEnvironmentMapping( TextureUnit_1, false ); DrawMesh( i ); } @@ -445,7 +444,6 @@ void Model::DrawPrimitives() float shininess = 1; DISPLAY->SetMaterial( emissive, ambient, diffuse, specular, shininess ); - DISPLAY->ClearAllTextures(); if( pMesh->nMaterialIndex != -1 ) { @@ -453,10 +451,6 @@ void Model::DrawPrimitives() DISPLAY->SetTexture( TextureUnit_1, mat.diffuse.GetCurrentTexture() ? mat.diffuse.GetCurrentTexture()->GetTexHandle() : 0 ); Actor::SetTextureRenderStates(); // set Actor-specified render states } - else - { - // hey why is this otherwise empty else block here? -aj - } DrawMesh( i ); } diff --git a/src/NoteDisplay.cpp b/src/NoteDisplay.cpp index f8aa47c729..b2e924fddc 100644 --- a/src/NoteDisplay.cpp +++ b/src/NoteDisplay.cpp @@ -789,8 +789,6 @@ void NoteDisplay::DrawHoldPart(vector &vpSpr, } } - DISPLAY->ClearAllTextures(); - const float fTexCoordLeft = rect.left; const float fTexCoordRight = rect.right; const float fTexCoordCenter = (fTexCoordLeft+fTexCoordRight)/2; diff --git a/src/RageDisplay_D3D.cpp b/src/RageDisplay_D3D.cpp index 1a60cc5619..dd33688a4d 100644 --- a/src/RageDisplay_D3D.cpp +++ b/src/RageDisplay_D3D.cpp @@ -45,6 +45,7 @@ D3DCAPS9 g_DeviceCaps; D3DDISPLAYMODE g_DesktopMode; D3DPRESENT_PARAMETERS g_d3dpp; int g_ModelMatrixCnt=0; +DWORD g_lastFVF = 0; static bool g_bSphereMapping[NUM_TextureUnit] = { false, false }; // Need default color and depth buffer to restore them after using render targets @@ -565,6 +566,9 @@ RString RageDisplay_D3D::TryVideoMode( const VideoModeParams &_p, bool &bNewDevi // Present once the window is created so we don't display a white frame while initializing g_pd3dDevice->Present(0, 0, 0, 0); + // Ensure device is in a clean state when resolution changes occur + RecoverFromDeviceLoss(); + return RString(); // mode change successful } @@ -575,6 +579,12 @@ void RageDisplay_D3D::ResolutionChanged() RageDisplay::ResolutionChanged(); } +// Reset anything which doesn't survive device loss +void RageDisplay_D3D::RecoverFromDeviceLoss() +{ + g_lastFVF = 0; +} + int RageDisplay_D3D::GetMaxTextureSize() const { return g_DeviceCaps.MaxTextureWidth; @@ -587,6 +597,7 @@ bool RageDisplay_D3D::BeginFrame() switch( g_pd3dDevice->TestCooperativeLevel() ) { case D3DERR_DEVICELOST: + RecoverFromDeviceLoss(); return false; case D3DERR_DEVICENOTRESET: { @@ -715,70 +726,79 @@ const VideoModeParams* RageDisplay_D3D::GetActualVideoModeParams() const void RageDisplay_D3D::SendCurrentMatrices() { - RageMatrix m; - RageMatrixMultiply( &m, GetCentering(), GetProjectionTop() ); + static RageMatrix Centering; + static RageMatrix Projection; - if (g_bInvertY) + if ( Centering != *GetCentering() || Projection != *GetProjectionTop() ) { - RageMatrix flip; - RageMatrixScale(&flip, +1, -1, +1); - RageMatrixMultiply(&m, &flip, &m); - } + Centering = *GetCentering(); + Projection = *GetProjectionTop(); - // Convert to OpenGL-style "pixel-centered" coords - RageMatrix m2 = GetCenteringMatrix( -0.5f, -0.5f, 0, 0 ); - RageMatrix projection; - RageMatrixMultiply( &projection, &m2, &m ); - g_pd3dDevice->SetTransform( D3DTS_PROJECTION, (D3DMATRIX*)&projection ); + RageMatrix m; + RageMatrixMultiply( &m, GetCentering(), GetProjectionTop() ); - g_pd3dDevice->SetTransform( D3DTS_VIEW, (D3DMATRIX*)GetViewTop() ); - g_pd3dDevice->SetTransform( D3DTS_WORLD, (D3DMATRIX*)GetWorldTop() ); - - FOREACH_ENUM( TextureUnit, tu ) - { - // Optimization opportunity: Turn off texture transform if not using texture coords. - g_pd3dDevice->SetTextureStageState( tu, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 ); - - // If no texture is set for this texture unit, don't bother setting it up. - IDirect3DBaseTexture9* pTexture = NULL; - g_pd3dDevice->GetTexture( tu, &pTexture ); - if( pTexture == NULL ) - continue; - pTexture->Release(); - - if( g_bSphereMapping[tu] ) + if ( g_bInvertY ) { - static const RageMatrix tex = RageMatrix - ( - 0.5f, 0.0f, 0.0f, 0.0f, - 0.0f, -0.5f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, - 0.5f, -0.5f, 0.0f, 1.0f - ); - g_pd3dDevice->SetTransform( (D3DTRANSFORMSTATETYPE)(D3DTS_TEXTURE0+tu), (D3DMATRIX*)&tex ); - - // Tell D3D to use transformed reflection vectors as texture co-ordinate 0 - // and then transform this coordinate by the specified texture matrix. - g_pd3dDevice->SetTextureStageState( tu, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR ); + RageMatrix flip; + RageMatrixScale( &flip, +1, -1, +1 ); + RageMatrixMultiply( &m, &flip, &m ); } - else + + // Convert to OpenGL-style "pixel-centered" coords + RageMatrix m2 = GetCenteringMatrix( -0.5f, -0.5f, 0, 0 ); + RageMatrix projection; + RageMatrixMultiply( &projection, &m2, &m ); + g_pd3dDevice->SetTransform( D3DTS_PROJECTION, (D3DMATRIX*)&projection ); + + g_pd3dDevice->SetTransform( D3DTS_VIEW, (D3DMATRIX*)GetViewTop() ); + g_pd3dDevice->SetTransform( D3DTS_WORLD, (D3DMATRIX*)GetWorldTop() ); + + FOREACH_ENUM( TextureUnit, tu ) { - /* Direct3D is expecting a 3x3 matrix loaded into the 4x4 in order - * to transform the 2-component texture coordinates. We currently - * only use translate and scale, and ignore the z component entirely, - * so convert the texture matrix from 4x4 to 3x3 by dropping z. */ - - const RageMatrix &tex1 = *GetTextureTop(); - const RageMatrix tex2 = RageMatrix - ( - tex1.m[0][0], tex1.m[0][1], tex1.m[0][3], 0, - tex1.m[1][0], tex1.m[1][1], tex1.m[1][3], 0, - tex1.m[3][0], tex1.m[3][1], tex1.m[3][3], 0, - 0, 0, 0, 0 - ); - g_pd3dDevice->SetTransform( D3DTRANSFORMSTATETYPE(D3DTS_TEXTURE0+tu), (D3DMATRIX*)&tex2 ); - - g_pd3dDevice->SetTextureStageState( tu, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_PASSTHRU ); + // If no texture is set for this texture unit, don't bother setting it up. + IDirect3DBaseTexture9* pTexture = NULL; + g_pd3dDevice->GetTexture( tu, &pTexture ); + if (pTexture == NULL) + continue; + pTexture->Release(); + + // Optimization opportunity: Turn off texture transform if not using texture coords. + g_pd3dDevice->SetTextureStageState(tu, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2); + + if ( g_bSphereMapping[tu] ) + { + static const RageMatrix tex = RageMatrix + ( + 0.5f, 0.0f, 0.0f, 0.0f, + 0.0f, -0.5f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.5f, -0.5f, 0.0f, 1.0f + ); + g_pd3dDevice->SetTransform( (D3DTRANSFORMSTATETYPE)(D3DTS_TEXTURE0 + tu), (D3DMATRIX*)&tex ); + + // Tell D3D to use transformed reflection vectors as texture co-ordinate 0 + // and then transform this coordinate by the specified texture matrix. + g_pd3dDevice->SetTextureStageState( tu, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR ); + } + else + { + /* Direct3D is expecting a 3x3 matrix loaded into the 4x4 in order + * to transform the 2-component texture coordinates. We currently + * only use translate and scale, and ignore the z component entirely, + * so convert the texture matrix from 4x4 to 3x3 by dropping z. */ + + const RageMatrix &tex1 = *GetTextureTop(); + const RageMatrix tex2 = RageMatrix + ( + tex1.m[0][0], tex1.m[0][1], tex1.m[0][3], 0, + tex1.m[1][0], tex1.m[1][1], tex1.m[1][3], 0, + tex1.m[3][0], tex1.m[3][1], tex1.m[3][3], 0, + 0, 0, 0, 0 + ); + g_pd3dDevice->SetTransform( D3DTRANSFORMSTATETYPE(D3DTS_TEXTURE0 + tu), (D3DMATRIX*)&tex2 ); + + g_pd3dDevice->SetTextureStageState( tu, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_PASSTHRU ); + } } } } @@ -825,14 +845,19 @@ class RageCompiledGeometrySWD3D : public RageCompiledGeometry g_pd3dDevice->SetTransform( D3DTS_TEXTURE0, (D3DMATRIX*)&m ); } - g_pd3dDevice->SetFVF( D3DFVF_RageModelVertex ); + if ( g_lastFVF != D3DFVF_RageModelVertex ) + { + g_lastFVF = D3DFVF_RageModelVertex; + g_pd3dDevice->SetFVF( D3DFVF_RageModelVertex ); + } + g_pd3dDevice->DrawIndexedPrimitiveUP( D3DPT_TRIANGLELIST, // PrimitiveType meshInfo.iVertexStart, // MinIndex meshInfo.iVertexCount, // NumVertices meshInfo.iTriangleCount, // PrimitiveCount, &m_vTriangles[0]+meshInfo.iTriangleStart,// pIndexData, - D3DFMT_INDEX16, // IndexDataFormat, + D3DFMT_INDEX32, // IndexDataFormat, &m_vVertex[0], // pVertexStreamZeroData, sizeof(m_vVertex[0]) // VertexStreamZeroStride ); @@ -861,11 +886,11 @@ void RageDisplay_D3D::DrawQuadsInternal( const RageSpriteVertex v[], int iNumVer int iNumIndices = iNumTriangles*3; // make a temporary index buffer - static vector vIndices; - unsigned uOldSize = vIndices.size(); - unsigned uNewSize = max(uOldSize, static_cast(iNumIndices)); + static vector vIndices; + int iOldSize = vIndices.size(); + int uNewSize = max( iOldSize, iNumIndices ); vIndices.resize( uNewSize ); - for( uint16_t i=static_cast(uOldSize/6); i(iNumQuads); i++ ) + for(int i= iOldSize/6; iSetFVF( D3DFVF_RageSpriteVertex ); + if ( g_lastFVF != D3DFVF_RageSpriteVertex ) + { + g_lastFVF = D3DFVF_RageSpriteVertex; + g_pd3dDevice->SetFVF( D3DFVF_RageSpriteVertex ); + } + SendCurrentMatrices(); g_pd3dDevice->DrawIndexedPrimitiveUP( D3DPT_TRIANGLELIST, // PrimitiveType @@ -883,7 +913,7 @@ void RageDisplay_D3D::DrawQuadsInternal( const RageSpriteVertex v[], int iNumVer iNumVerts, // NumVertices iNumTriangles, // PrimitiveCount, &vIndices[0], // pIndexData, - D3DFMT_INDEX16, // IndexDataFormat, + D3DFMT_INDEX32, // IndexDataFormat, v, // pVertexStreamZeroData, sizeof(RageSpriteVertex) // VertexStreamZeroStride ); @@ -897,11 +927,11 @@ void RageDisplay_D3D::DrawQuadStripInternal( const RageSpriteVertex v[], int iNu int iNumIndices = iNumTriangles*3; // make a temporary index buffer - static vector vIndices; - unsigned uOldSize = vIndices.size(); - unsigned uNewSize = max(uOldSize,(unsigned)iNumIndices); - vIndices.resize( uNewSize ); - for( uint16_t i=(uint16_t)uOldSize/6; i<(uint16_t)iNumQuads; i++ ) + static vector vIndices; + int iOldSize = vIndices.size(); + int iNewSize = max( iOldSize,iNumIndices ); + vIndices.resize( iNewSize ); + for( int i=iOldSize/6; iSetFVF( D3DFVF_RageSpriteVertex ); + if ( g_lastFVF != D3DFVF_RageSpriteVertex ) + { + g_lastFVF = D3DFVF_RageSpriteVertex; + g_pd3dDevice->SetFVF( D3DFVF_RageSpriteVertex ); + } + SendCurrentMatrices(); g_pd3dDevice->DrawIndexedPrimitiveUP( D3DPT_TRIANGLELIST, // PrimitiveType @@ -919,7 +954,7 @@ void RageDisplay_D3D::DrawQuadStripInternal( const RageSpriteVertex v[], int iNu iNumVerts, // NumVertices iNumTriangles, // PrimitiveCount, &vIndices[0], // pIndexData, - D3DFMT_INDEX16, // IndexDataFormat, + D3DFMT_INDEX32, // IndexDataFormat, v, // pVertexStreamZeroData, sizeof(RageSpriteVertex) // VertexStreamZeroStride ); @@ -932,11 +967,11 @@ void RageDisplay_D3D::DrawSymmetricQuadStripInternal( const RageSpriteVertex v[] int iNumIndices = iNumTriangles*3; // make a temporary index buffer - static vector vIndices; - unsigned uOldSize = vIndices.size(); - unsigned uNewSize = max(uOldSize,(unsigned)iNumIndices); - vIndices.resize( uNewSize ); - for( uint16_t i=(uint16_t)uOldSize/12; i<(uint16_t)iNumPieces; i++ ) + static vector vIndices; + int iOldSize = vIndices.size(); + int iNewSize = max( iOldSize,iNumIndices ); + vIndices.resize( iNewSize ); + for(int i=iOldSize/12; iSetFVF( D3DFVF_RageSpriteVertex ); + if ( g_lastFVF != D3DFVF_RageSpriteVertex ) + { + g_lastFVF = D3DFVF_RageSpriteVertex; + g_pd3dDevice->SetFVF( D3DFVF_RageSpriteVertex ); + } + SendCurrentMatrices(); g_pd3dDevice->DrawIndexedPrimitiveUP( D3DPT_TRIANGLELIST, // PrimitiveType @@ -961,7 +1001,7 @@ void RageDisplay_D3D::DrawSymmetricQuadStripInternal( const RageSpriteVertex v[] iNumVerts, // NumVertices iNumTriangles, // PrimitiveCount, &vIndices[0], // pIndexData, - D3DFMT_INDEX16, // IndexDataFormat, + D3DFMT_INDEX32, // IndexDataFormat, v, // pVertexStreamZeroData, sizeof(RageSpriteVertex) // VertexStreamZeroStride ); @@ -969,7 +1009,12 @@ void RageDisplay_D3D::DrawSymmetricQuadStripInternal( const RageSpriteVertex v[] void RageDisplay_D3D::DrawFanInternal( const RageSpriteVertex v[], int iNumVerts ) { - g_pd3dDevice->SetFVF( D3DFVF_RageSpriteVertex ); + if ( g_lastFVF != D3DFVF_RageSpriteVertex ) + { + g_lastFVF = D3DFVF_RageSpriteVertex; + g_pd3dDevice->SetFVF( D3DFVF_RageSpriteVertex ); + } + SendCurrentMatrices(); g_pd3dDevice->DrawPrimitiveUP( D3DPT_TRIANGLEFAN, // PrimitiveType @@ -981,7 +1026,12 @@ void RageDisplay_D3D::DrawFanInternal( const RageSpriteVertex v[], int iNumVerts void RageDisplay_D3D::DrawStripInternal( const RageSpriteVertex v[], int iNumVerts ) { - g_pd3dDevice->SetFVF( D3DFVF_RageSpriteVertex ); + if ( g_lastFVF != D3DFVF_RageSpriteVertex ) + { + g_lastFVF = D3DFVF_RageSpriteVertex; + g_pd3dDevice->SetFVF( D3DFVF_RageSpriteVertex ); + } + SendCurrentMatrices(); g_pd3dDevice->DrawPrimitiveUP( D3DPT_TRIANGLESTRIP, // PrimitiveType @@ -993,7 +1043,12 @@ void RageDisplay_D3D::DrawStripInternal( const RageSpriteVertex v[], int iNumVer void RageDisplay_D3D::DrawTrianglesInternal( const RageSpriteVertex v[], int iNumVerts ) { - g_pd3dDevice->SetFVF( D3DFVF_RageSpriteVertex ); + if ( g_lastFVF != D3DFVF_RageSpriteVertex ) + { + g_lastFVF = D3DFVF_RageSpriteVertex; + g_pd3dDevice->SetFVF( D3DFVF_RageSpriteVertex ); + } + SendCurrentMatrices(); g_pd3dDevice->DrawPrimitiveUP( D3DPT_TRIANGLELIST, // PrimitiveType diff --git a/src/RageDisplay_D3D.h b/src/RageDisplay_D3D.h index 92933dc8a0..72f0c4fff5 100644 --- a/src/RageDisplay_D3D.h +++ b/src/RageDisplay_D3D.h @@ -86,8 +86,9 @@ class RageDisplay_D3D: public RageDisplay RString TryVideoMode( const VideoModeParams &p, bool &bNewDeviceOut ); RageSurface* CreateScreenshot(); - RageMatrix GetOrthoMatrix( float l, float r, float b, float t, float zn, float zf ); + RageMatrix GetOrthoMatrix( float l, float r, float b, float t, float zn, float zf ); + void RecoverFromDeviceLoss(); void SendCurrentMatrices(); }; diff --git a/src/RageDisplay_OGL.cpp b/src/RageDisplay_OGL.cpp index c757d8ce2e..fa7ea9b655 100644 --- a/src/RageDisplay_OGL.cpp +++ b/src/RageDisplay_OGL.cpp @@ -933,26 +933,35 @@ static void SetupVertices( const RageSpriteVertex v[], int iNumVerts ) void RageDisplay_Legacy::SendCurrentMatrices() { - RageMatrix projection; - RageMatrixMultiply( &projection, GetCentering(), GetProjectionTop() ); + static RageMatrix Centering; + static RageMatrix Projection; - if (g_bInvertY) + if ( Centering != *GetCentering() || Projection != *GetProjectionTop() ) { - RageMatrix flip; - RageMatrixScale( &flip, +1, -1, +1 ); - RageMatrixMultiply( &projection, &flip, &projection ); - } - glMatrixMode( GL_PROJECTION ); - glLoadMatrixf( (const float*)&projection ); + Centering = *GetCentering(); + Projection = *GetProjectionTop(); + + RageMatrix projection; + RageMatrixMultiply( &projection, GetCentering(), GetProjectionTop() ); - // OpenGL has just "modelView", whereas D3D has "world" and "view" - RageMatrix modelView; - RageMatrixMultiply( &modelView, GetViewTop(), GetWorldTop() ); - glMatrixMode( GL_MODELVIEW ); - glLoadMatrixf( (const float*)&modelView ); + if ( g_bInvertY ) + { + RageMatrix flip; + RageMatrixScale( &flip, +1, -1, +1 ); + RageMatrixMultiply( &projection, &flip, &projection ); + } + glMatrixMode( GL_PROJECTION ); + glLoadMatrixf( (const float*)&projection ); - glMatrixMode( GL_TEXTURE ); - glLoadMatrixf( (const float*)GetTextureTop() ); + // OpenGL has just "modelView", whereas D3D has "world" and "view" + RageMatrix modelView; + RageMatrixMultiply( &modelView, GetViewTop(), GetWorldTop() ); + glMatrixMode( GL_MODELVIEW ); + glLoadMatrixf( (const float*)&modelView ); + + glMatrixMode( GL_TEXTURE ); + glLoadMatrixf( (const float*)GetTextureTop() ); + } } class RageCompiledGeometrySWOGL : public RageCompiledGeometry @@ -995,8 +1004,6 @@ class RageCompiledGeometrySWOGL : public RageCompiledGeometry } void Draw( int iMeshIndex ) const { - TurnOffHardwareVBO(); - const MeshInfo& meshInfo = m_vMeshInfo[iMeshIndex]; glEnableClientState(GL_VERTEX_ARRAY); @@ -1038,7 +1045,7 @@ class RageCompiledGeometrySWOGL : public RageCompiledGeometry glDrawElements( GL_TRIANGLES, meshInfo.iTriangleCount*3, - GL_UNSIGNED_SHORT, + GL_INT, &m_vTriangles[0]+meshInfo.iTriangleStart ); } @@ -1382,7 +1389,7 @@ void RageCompiledGeometryHWOGL::Draw( int iMeshIndex ) const meshInfo.iVertexStart+meshInfo.iVertexCount-1, // maximum array index contained in indices meshInfo.iTriangleCount*3, // number of elements to be rendered - GL_UNSIGNED_SHORT, + GL_INT, BUFFER_OFFSET(meshInfo.iTriangleStart*sizeof(msTriangle)) ); DebugAssertNoGLError(); @@ -1408,7 +1415,6 @@ void RageDisplay_Legacy::DeleteCompiledGeometry( RageCompiledGeometry* p ) void RageDisplay_Legacy::DrawQuadsInternal( const RageSpriteVertex v[], int iNumVerts ) { - TurnOffHardwareVBO(); SendCurrentMatrices(); SetupVertices( v, iNumVerts ); @@ -1417,7 +1423,6 @@ void RageDisplay_Legacy::DrawQuadsInternal( const RageSpriteVertex v[], int iNum void RageDisplay_Legacy::DrawQuadStripInternal( const RageSpriteVertex v[], int iNumVerts ) { - TurnOffHardwareVBO(); SendCurrentMatrices(); SetupVertices( v, iNumVerts ); @@ -1431,11 +1436,11 @@ void RageDisplay_Legacy::DrawSymmetricQuadStripInternal( const RageSpriteVertex int iNumIndices = iNumTriangles*3; // make a temporary index buffer - static vector vIndices; - unsigned uOldSize = vIndices.size(); - unsigned uNewSize = max(uOldSize,(unsigned)iNumIndices); - vIndices.resize( uNewSize ); - for( uint16_t i=(uint16_t)uOldSize/12; i<(uint16_t)iNumPieces; i++ ) + static vector vIndices; + int iOldSize = vIndices.size(); + int iNewSize = max( iOldSize,iNumIndices ); + vIndices.resize( iNewSize ); + for( int i=iOldSize/12; iDraw( iMeshIndex ); @@ -1500,8 +1500,6 @@ void RageDisplay_Legacy::DrawCompiledGeometryInternal( const RageCompiledGeometr void RageDisplay_Legacy::DrawLineStripInternal( const RageSpriteVertex v[], int iNumVerts, float fLineWidth ) { - TurnOffHardwareVBO(); - if (!(*GetActualVideoModeParams()).bSmoothLines) { /* Fall back on the generic polygon-based line strip. */ diff --git a/src/ScreenGameplay.cpp b/src/ScreenGameplay.cpp index 4a64579b4d..53029b88e2 100644 --- a/src/ScreenGameplay.cpp +++ b/src/ScreenGameplay.cpp @@ -1817,6 +1817,12 @@ void ScreenGameplay::BeginBackingOutFromGameplay() m_pSoundMusic->StopPlaying(); m_GameplayAssist.StopPlaying(); // Stop any queued assist ticks. + if (GAMESTATE->IsPlaylistCourse()) { + SONGMAN->allplaylists[SONGMAN->playlistcourse].courseruns.emplace_back(playlistscorekeys); + GAMESTATE->isplaylistcourse = false; + SONGMAN->playlistcourse = ""; + } + this->ClearMessageQueue(); m_Cancel.StartTransitioning( SM_DoPrevScreen ); @@ -2258,6 +2264,7 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM ) if (GAMESTATE->IsPlaylistCourse()) { SONGMAN->allplaylists[SONGMAN->playlistcourse].courseruns.emplace_back(playlistscorekeys); GAMESTATE->isplaylistcourse = false; + SONGMAN->playlistcourse = ""; } TweenOffScreen(); diff --git a/src/Sprite.cpp b/src/Sprite.cpp index 70daa2b9f9..7be8697fce 100644 --- a/src/Sprite.cpp +++ b/src/Sprite.cpp @@ -527,7 +527,6 @@ void Sprite::DrawTexture( const TweenState *state ) } } - DISPLAY->ClearAllTextures(); DISPLAY->SetTexture( TextureUnit_1, m_pTexture? m_pTexture->GetTexHandle():0 ); // Must call this after setting the texture or else texture @@ -612,7 +611,9 @@ void Sprite::DrawTexture( const TweenState *state ) v[0].c = v[1].c = v[2].c = v[3].c = state->glow; DISPLAY->DrawQuad( v ); } - DISPLAY->SetEffectMode( EffectMode_Normal ); + + if ( m_EffectMode != EffectMode_Normal ) + DISPLAY->SetEffectMode( EffectMode_Normal ); } bool Sprite::EarlyAbortDraw() const