move some code out of the header

This commit is contained in:
Glenn Maynard
2005-01-31 22:58:12 +00:00
parent aa48ebd081
commit 57f5c487bc
2 changed files with 56 additions and 35 deletions
+52
View File
@@ -473,6 +473,23 @@ void RageDisplay::LoadMenuPerspective( float fovDegrees, float fVanishPointX, fl
-fVanishPointX+SCREEN_CENTER_X, -fVanishPointY+SCREEN_CENTER_Y, 0,
0.0f, 1.0f, 0.0f) );
}
const float fDAR = GetVideoModeParams().fDisplayAspectRatio;
const float fOutputDAR = GetVideoModeParams().fOutputDisplayAspectRatio;
if( fOutputDAR != -1 && fabsf(fDAR-fOutputDAR) > 0.001f )
{
if( fOutputDAR > fDAR )
{
/* Letterboxed horizontally (showing widescreen on a regular monitor). */
float fYAdjust = fDAR / fOutputDAR;
g_ProjectionStack.Scale( 1, fYAdjust, 1 );
} else {
/* Letterboxed vertically (showing 4:3 on a widescreen monitor). */
float fXAdjust = fOutputDAR / fDAR;
g_ProjectionStack.Scale( fXAdjust, 1, 1 );
}
}
}
@@ -719,6 +736,41 @@ void RageDisplay::DrawCircle( const RageSpriteVertex &v, float radius )
this->DrawCircleInternal( v, radius );
}
RageCompiledGeometry::~RageCompiledGeometry()
{
m_bNeedsNormals = false;
}
void RageCompiledGeometry::Set( const vector<msMesh> &vMeshes, bool bNeedsNormals )
{
m_bNeedsNormals = bNeedsNormals;
size_t totalVerts = 0;
size_t totalTriangles = 0;
m_vMeshInfo.resize( vMeshes.size() );
for( unsigned i=0; i<vMeshes.size(); i++ )
{
const msMesh& mesh = vMeshes[i];
const vector<RageModelVertex> &Vertices = mesh.Vertices;
const vector<msTriangle> &Triangles = mesh.Triangles;
MeshInfo& meshInfo = m_vMeshInfo[i];
meshInfo.iVertexStart = totalVerts;
meshInfo.iVertexCount = Vertices.size();
meshInfo.iTriangleStart = totalTriangles;
meshInfo.iTriangleCount = Triangles.size();
totalVerts += Vertices.size();
totalTriangles += Triangles.size();
}
this->Allocate( vMeshes );
Change( vMeshes );
}
/*
* Copyright (c) 2001-2004 Chris Danford, Glenn Maynard
* All rights reserved.
+4 -35
View File
@@ -17,48 +17,17 @@ const int MAX_TEXTURE_UNITS = 2;
class RageCompiledGeometry
{
public:
virtual ~RageCompiledGeometry()
{
m_bNeedsNormals = false;
}
virtual ~RageCompiledGeometry();
void Set( const vector<msMesh> &vMeshes, bool bNeedsNormals )
{
m_bNeedsNormals = bNeedsNormals;
size_t totalVerts = 0;
size_t totalTriangles = 0;
m_vMeshInfo.resize( vMeshes.size() );
for( unsigned i=0; i<vMeshes.size(); i++ )
{
const msMesh& mesh = vMeshes[i];
const vector<RageModelVertex> &Vertices = mesh.Vertices;
const vector<msTriangle> &Triangles = mesh.Triangles;
MeshInfo& meshInfo = m_vMeshInfo[i];
meshInfo.iVertexStart = totalVerts;
meshInfo.iVertexCount = Vertices.size();
meshInfo.iTriangleStart = totalTriangles;
meshInfo.iTriangleCount = Triangles.size();
totalVerts += Vertices.size();
totalTriangles += Triangles.size();
}
this->Allocate( vMeshes );
Change( vMeshes );
}
void Set( const vector<msMesh> &vMeshes, bool bNeedsNormals );
virtual void Allocate( const vector<msMesh> &vMeshes ) = 0; // allocate space
virtual void Change( const vector<msMesh> &vMeshes ) = 0; // new data must be the same size as was passed to Set()
virtual void Draw( int iMeshIndex ) const = 0;
protected:
size_t GetTotalVertices() { if( m_vMeshInfo.empty() ) return 0; return m_vMeshInfo.back().iVertexStart + m_vMeshInfo.back().iVertexCount; }
size_t GetTotalTriangles() { if( m_vMeshInfo.empty() ) return 0; return m_vMeshInfo.back().iTriangleStart + m_vMeshInfo.back().iTriangleCount; }
size_t GetTotalVertices() const { if( m_vMeshInfo.empty() ) return 0; return m_vMeshInfo.back().iVertexStart + m_vMeshInfo.back().iVertexCount; }
size_t GetTotalTriangles() const { if( m_vMeshInfo.empty() ) return 0; return m_vMeshInfo.back().iTriangleStart + m_vMeshInfo.back().iTriangleCount; }
struct MeshInfo
{