if hardware doesn't support per-vertex tex matrix scale, apply the scaling of the first vertex to the whole mesh
This commit is contained in:
@@ -784,10 +784,11 @@ void RageCompiledGeometry::Set( const vector<msMesh> &vMeshes, bool bNeedsNormal
|
|||||||
{
|
{
|
||||||
m_bNeedsNormals = bNeedsNormals;
|
m_bNeedsNormals = bNeedsNormals;
|
||||||
|
|
||||||
m_bNeedsTextureMatrixScale = false;
|
|
||||||
size_t totalVerts = 0;
|
size_t totalVerts = 0;
|
||||||
size_t totalTriangles = 0;
|
size_t totalTriangles = 0;
|
||||||
|
|
||||||
|
m_bAnyNeedsTextureMatrixScale = false;
|
||||||
|
|
||||||
m_vMeshInfo.resize( vMeshes.size() );
|
m_vMeshInfo.resize( vMeshes.size() );
|
||||||
for( unsigned i=0; i<vMeshes.size(); i++ )
|
for( unsigned i=0; i<vMeshes.size(); i++ )
|
||||||
{
|
{
|
||||||
@@ -796,6 +797,7 @@ void RageCompiledGeometry::Set( const vector<msMesh> &vMeshes, bool bNeedsNormal
|
|||||||
const vector<msTriangle> &Triangles = mesh.Triangles;
|
const vector<msTriangle> &Triangles = mesh.Triangles;
|
||||||
|
|
||||||
MeshInfo& meshInfo = m_vMeshInfo[i];
|
MeshInfo& meshInfo = m_vMeshInfo[i];
|
||||||
|
meshInfo.m_bNeedsTextureMatrixScale = false;
|
||||||
|
|
||||||
meshInfo.iVertexStart = totalVerts;
|
meshInfo.iVertexStart = totalVerts;
|
||||||
meshInfo.iVertexCount = Vertices.size();
|
meshInfo.iVertexCount = Vertices.size();
|
||||||
@@ -806,8 +808,13 @@ void RageCompiledGeometry::Set( const vector<msMesh> &vMeshes, bool bNeedsNormal
|
|||||||
totalTriangles += Triangles.size();
|
totalTriangles += Triangles.size();
|
||||||
|
|
||||||
for( unsigned j = 0; j < Vertices.size(); ++j )
|
for( unsigned j = 0; j < Vertices.size(); ++j )
|
||||||
|
{
|
||||||
if( Vertices[j].TextureMatrixScale.x != 1.0f || Vertices[j].TextureMatrixScale.y != 1.0f )
|
if( Vertices[j].TextureMatrixScale.x != 1.0f || Vertices[j].TextureMatrixScale.y != 1.0f )
|
||||||
m_bNeedsTextureMatrixScale = true;
|
{
|
||||||
|
meshInfo.m_bNeedsTextureMatrixScale = true;
|
||||||
|
m_bAnyNeedsTextureMatrixScale = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this->Allocate( vMeshes );
|
this->Allocate( vMeshes );
|
||||||
|
|||||||
@@ -33,10 +33,11 @@ protected:
|
|||||||
int iVertexCount;
|
int iVertexCount;
|
||||||
int iTriangleStart;
|
int iTriangleStart;
|
||||||
int iTriangleCount;
|
int iTriangleCount;
|
||||||
|
bool m_bNeedsTextureMatrixScale;
|
||||||
};
|
};
|
||||||
vector<MeshInfo> m_vMeshInfo;
|
vector<MeshInfo> m_vMeshInfo;
|
||||||
bool m_bNeedsNormals;
|
bool m_bNeedsNormals;
|
||||||
bool m_bNeedsTextureMatrixScale;
|
bool m_bAnyNeedsTextureMatrixScale;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum PixelFormat
|
enum PixelFormat
|
||||||
|
|||||||
@@ -1059,7 +1059,7 @@ void RageCompiledGeometryHWOGL::UploadData()
|
|||||||
// AssertNoGLError();
|
// AssertNoGLError();
|
||||||
|
|
||||||
|
|
||||||
if( m_bNeedsTextureMatrixScale )
|
if( m_bAnyNeedsTextureMatrixScale )
|
||||||
{
|
{
|
||||||
GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureMatrixScale );
|
GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureMatrixScale );
|
||||||
GLExt.glBufferDataARB(
|
GLExt.glBufferDataARB(
|
||||||
@@ -1171,19 +1171,28 @@ void RageCompiledGeometryHWOGL::Draw( int iMeshIndex ) const
|
|||||||
glDisableClientState(GL_NORMAL_ARRAY);
|
glDisableClientState(GL_NORMAL_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_bNeedsTextureMatrixScale && g_bTextureMatrixShader != 0 )
|
if( meshInfo.m_bNeedsTextureMatrixScale )
|
||||||
{
|
{
|
||||||
/* If we're using texture matrix scales, set up that buffer, too, and enable the
|
if( false ) //g_bTextureMatrixShader != 0 )
|
||||||
* vertex shader. This shader doesn't support all OpenGL state, so only enable it
|
{
|
||||||
* if we're using it. */
|
/* If we're using texture matrix scales, set up that buffer, too, and enable the
|
||||||
GLExt.glEnableVertexAttribArrayARB( ATTRIB_TEXTURE_MATRIX_SCALE );
|
* vertex shader. This shader doesn't support all OpenGL state, so only enable it
|
||||||
AssertNoGLError();
|
* if we're using it. */
|
||||||
GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureMatrixScale );
|
GLExt.glEnableVertexAttribArrayARB( ATTRIB_TEXTURE_MATRIX_SCALE );
|
||||||
AssertNoGLError();
|
AssertNoGLError();
|
||||||
GLExt.glVertexAttribPointerARB( ATTRIB_TEXTURE_MATRIX_SCALE, 2, GL_FLOAT, false, 0, NULL );
|
GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureMatrixScale );
|
||||||
AssertNoGLError();
|
AssertNoGLError();
|
||||||
|
GLExt.glVertexAttribPointerARB( ATTRIB_TEXTURE_MATRIX_SCALE, 2, GL_FLOAT, false, 0, NULL );
|
||||||
|
AssertNoGLError();
|
||||||
|
|
||||||
GLExt.glUseProgramObjectARB( g_bTextureMatrixShader );
|
GLExt.glUseProgramObjectARB( g_bTextureMatrixShader );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Approximate by applying the texture scale of the first vertex to the whole mesh.
|
||||||
|
glMatrixMode( GL_TEXTURE );
|
||||||
|
glScalef( 0, 0, 0 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GLExt.glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, m_nTriangles );
|
GLExt.glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, m_nTriangles );
|
||||||
@@ -1202,7 +1211,7 @@ void RageCompiledGeometryHWOGL::Draw( int iMeshIndex ) const
|
|||||||
BUFFER_OFFSET(meshInfo.iTriangleStart*sizeof(msTriangle)) );
|
BUFFER_OFFSET(meshInfo.iTriangleStart*sizeof(msTriangle)) );
|
||||||
AssertNoGLError();
|
AssertNoGLError();
|
||||||
|
|
||||||
if( m_bNeedsTextureMatrixScale && g_bTextureMatrixShader != 0 )
|
if( meshInfo.m_bNeedsTextureMatrixScale && g_bTextureMatrixShader != 0 )
|
||||||
{
|
{
|
||||||
GLExt.glDisableVertexAttribArrayARB( ATTRIB_TEXTURE_MATRIX_SCALE );
|
GLExt.glDisableVertexAttribArrayARB( ATTRIB_TEXTURE_MATRIX_SCALE );
|
||||||
GLExt.glUseProgramObjectARB( 0 );
|
GLExt.glUseProgramObjectARB( 0 );
|
||||||
|
|||||||
Reference in New Issue
Block a user