add RageDisplay::DrawSymmetricQuadStrip

This commit is contained in:
Glenn Maynard
2007-01-15 08:08:57 +00:00
parent ce407f819f
commit 74aaecc2b9
7 changed files with 107 additions and 0 deletions
+21
View File
@@ -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 );
+2
View File
@@ -269,6 +269,7 @@ public:
void DrawTriangles( const RageSpriteVertex v[], int iNumVerts );
void DrawCompiledGeometry( const RageCompiledGeometry *p, int iMeshIndex, const vector<msMesh> &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.
+42
View File
@@ -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<uint16_t> 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 );
+1
View File
@@ -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 );
+1
View File
@@ -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(); }
+39
View File
@@ -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<uint16_t> 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();
+1
View File
@@ -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();