diff --git a/stepmania/src/RageDisplay.cpp b/stepmania/src/RageDisplay.cpp index 4c43afd6c4..765c2a39ac 100644 --- a/stepmania/src/RageDisplay.cpp +++ b/stepmania/src/RageDisplay.cpp @@ -834,6 +834,27 @@ void RageDisplay::DrawLineStrip( const RageSpriteVertex v[], int iNumVerts, floa this->DrawLineStripInternal( v, iNumVerts, LineWidth ); } +/* + * Draw a strip of: + * + * 0..1..2 + * . /.\ . + * ./ . \. + * 3..4..5 + * . /.\ . + * ./ . \. + * 6..7..8 + */ + +void RageDisplay::DrawSymmetricQuadStrip( const RageSpriteVertex v[], int iNumVerts ) +{ + ASSERT( iNumVerts >= 3 ); + + this->DrawSymmetricQuadStripInternal( v, iNumVerts ); + + StatsAddVerts( iNumVerts ); +} + void RageDisplay::DrawCircle( const RageSpriteVertex &v, float radius ) { this->DrawCircleInternal( v, radius ); diff --git a/stepmania/src/RageDisplay.h b/stepmania/src/RageDisplay.h index 97d09acb33..9538705f27 100644 --- a/stepmania/src/RageDisplay.h +++ b/stepmania/src/RageDisplay.h @@ -269,6 +269,7 @@ public: void DrawTriangles( const RageSpriteVertex v[], int iNumVerts ); void DrawCompiledGeometry( const RageCompiledGeometry *p, int iMeshIndex, const vector &vMeshes ); void DrawLineStrip( const RageSpriteVertex v[], int iNumVerts, float LineWidth ); + void DrawSymmetricQuadStrip( const RageSpriteVertex v[], int iNumVerts ); void DrawCircle( const RageSpriteVertex &v, float radius ); void DrawQuad( const RageSpriteVertex v[] ) { DrawQuads(v,4); } /* alias. upper-left, upper-right, lower-left, lower-right */ @@ -296,6 +297,7 @@ protected: virtual void DrawTrianglesInternal( const RageSpriteVertex v[], int iNumVerts ) = 0; virtual void DrawCompiledGeometryInternal( const RageCompiledGeometry *p, int iMeshIndex ) = 0; 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 ); // return RString() if mode change was successful, an error message otherwise. diff --git a/stepmania/src/RageDisplay_D3D.cpp b/stepmania/src/RageDisplay_D3D.cpp index 2a1d52c01c..33a6c0abd1 100644 --- a/stepmania/src/RageDisplay_D3D.cpp +++ b/stepmania/src/RageDisplay_D3D.cpp @@ -989,6 +989,48 @@ void RageDisplay_D3D::DrawQuadStripInternal( const RageSpriteVertex v[], int iNu ); } +void RageDisplay_D3D::DrawSymmetricQuadStripInternal( const RageSpriteVertex v[], int iNumVerts ) +{ + int iNumPieces = (iNumVerts-3)/3; + int iNumTriangles = iNumPieces*4; + 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++ ) + { + // { 1, 3, 0 } { 1, 4, 3 } { 1, 5, 4 } { 1, 2, 5 } + vIndices[i*12+0] = i*3+1; + vIndices[i*12+1] = i*3+3; + vIndices[i*12+2] = i*3+0; + vIndices[i*12+3] = i*3+1; + vIndices[i*12+4] = i*3+4; + vIndices[i*12+5] = i*3+3; + vIndices[i*12+6] = i*3+1; + vIndices[i*12+7] = i*3+5; + vIndices[i*12+8] = i*3+4; + vIndices[i*12+9] = i*3+1; + vIndices[i*12+10] = i*3+2; + vIndices[i*12+11] = i*3+5; + } + + g_pd3dDevice->SetVertexShader( D3DFVF_RageSpriteVertex ); + SendCurrentMatrices(); + g_pd3dDevice->DrawIndexedPrimitiveUP( + D3DPT_TRIANGLELIST, // PrimitiveType + 0, // MinIndex + iNumVerts, // NumVertices + iNumTriangles, // PrimitiveCount, + &vIndices[0], // pIndexData, + D3DFMT_INDEX16, // IndexDataFormat, + v, // pVertexStreamZeroData, + sizeof(RageSpriteVertex) // VertexStreamZeroStride + ); +} + void RageDisplay_D3D::DrawFanInternal( const RageSpriteVertex v[], int iNumVerts ) { g_pd3dDevice->SetVertexShader( D3DFVF_RageSpriteVertex ); diff --git a/stepmania/src/RageDisplay_D3D.h b/stepmania/src/RageDisplay_D3D.h index 52e8fcac89..ef29d564ad 100644 --- a/stepmania/src/RageDisplay_D3D.h +++ b/stepmania/src/RageDisplay_D3D.h @@ -77,6 +77,7 @@ protected: void DrawFanInternal( const RageSpriteVertex v[], int iNumVerts ); void DrawStripInternal( const RageSpriteVertex v[], int iNumVerts ); void DrawTrianglesInternal( const RageSpriteVertex v[], int iNumVerts ); + void DrawSymmetricQuadStripInternal( const RageSpriteVertex v[], int iNumVerts ); void DrawCompiledGeometryInternal( const RageCompiledGeometry *p, int iMeshIndex ); RString TryVideoMode( const VideoModeParams &p, bool &bNewDeviceOut ); diff --git a/stepmania/src/RageDisplay_Null.h b/stepmania/src/RageDisplay_Null.h index 4d6cdbf513..cbad9bb9cf 100644 --- a/stepmania/src/RageDisplay_Null.h +++ b/stepmania/src/RageDisplay_Null.h @@ -76,6 +76,7 @@ protected: void DrawTrianglesInternal( const RageSpriteVertex v[], int iNumVerts ) { } void DrawCompiledGeometryInternal( const RageCompiledGeometry *p, int iMeshIndex ) { } void DrawLineStripInternal( const RageSpriteVertex v[], int iNumVerts, float LineWidth ) { } + void DrawSymmetricQuadStripInternal( const RageSpriteVertex v[], int iNumVerts ) { } VideoModeParams m_Params; RString TryVideoMode( const VideoModeParams &p, bool &bNewDeviceOut ) { m_Params = p; return RString(); } diff --git a/stepmania/src/RageDisplay_OGL.cpp b/stepmania/src/RageDisplay_OGL.cpp index 72e9f8e0d9..305dea8178 100644 --- a/stepmania/src/RageDisplay_OGL.cpp +++ b/stepmania/src/RageDisplay_OGL.cpp @@ -1209,6 +1209,45 @@ void RageDisplay_OGL::DrawQuadStripInternal( const RageSpriteVertex v[], int iNu glDrawArrays( GL_QUAD_STRIP, 0, iNumVerts ); } +void RageDisplay_OGL::DrawSymmetricQuadStripInternal( const RageSpriteVertex v[], int iNumVerts ) +{ + int iNumPieces = (iNumVerts-3)/3; + int iNumTriangles = iNumPieces*4; + 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++ ) + { + // { 1, 3, 0 } { 1, 4, 3 } { 1, 5, 4 } { 1, 2, 5 } + vIndices[i*12+0] = i*3+1; + vIndices[i*12+1] = i*3+3; + vIndices[i*12+2] = i*3+0; + vIndices[i*12+3] = i*3+1; + vIndices[i*12+4] = i*3+4; + vIndices[i*12+5] = i*3+3; + vIndices[i*12+6] = i*3+1; + vIndices[i*12+7] = i*3+5; + vIndices[i*12+8] = i*3+4; + vIndices[i*12+9] = i*3+1; + vIndices[i*12+10] = i*3+2; + vIndices[i*12+11] = i*3+5; + } + + TurnOffHardwareVBO(); + SendCurrentMatrices(); + + SetupVertices( v, iNumVerts ); + glDrawElements( + GL_TRIANGLES, + iNumIndices, + GL_UNSIGNED_SHORT, + &vIndices[0] ); +} + void RageDisplay_OGL::DrawFanInternal( const RageSpriteVertex v[], int iNumVerts ) { TurnOffHardwareVBO(); diff --git a/stepmania/src/RageDisplay_OGL.h b/stepmania/src/RageDisplay_OGL.h index 89bab59999..16282c7f4e 100644 --- a/stepmania/src/RageDisplay_OGL.h +++ b/stepmania/src/RageDisplay_OGL.h @@ -95,6 +95,7 @@ protected: void DrawTrianglesInternal( const RageSpriteVertex v[], int iNumVerts ); void DrawCompiledGeometryInternal( const RageCompiledGeometry *p, int iMeshIndex ); void DrawLineStripInternal( const RageSpriteVertex v[], int iNumVerts, float LineWidth ); + void DrawSymmetricQuadStripInternal( const RageSpriteVertex v[], int iNumVerts ); RString TryVideoMode( const VideoModeParams &p, bool &bNewDeviceOut ); RageSurface* CreateScreenshot();