Prefer to let OpenGL assign attribute locations, as in
http://developer.download.nvidia.com/opengl/glsl/glsl_release_notes.pdf "Vertex Attribute Aliasing"
This commit is contained in:
@@ -284,10 +284,7 @@ GLhandleARB CompileShader( GLenum ShaderType, RString sBuffer )
|
|||||||
return VertexShader;
|
return VertexShader;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum
|
int g_iAttribTextureMatrixScale;
|
||||||
{
|
|
||||||
ATTRIB_TEXTURE_MATRIX_SCALE = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
/* XXX: How should we include these? Doing them like this is ugly. Linking them in
|
/* XXX: How should we include these? Doing them like this is ugly. Linking them in
|
||||||
* from another file as a text symbol would be ideal, but that's completely different
|
* from another file as a text symbol would be ideal, but that's completely different
|
||||||
@@ -323,9 +320,6 @@ void InitScalingScript()
|
|||||||
GLExt.glAttachObjectARB( g_bTextureMatrixShader, VertexShader );
|
GLExt.glAttachObjectARB( g_bTextureMatrixShader, VertexShader );
|
||||||
GLExt.glDeleteObjectARB( VertexShader );
|
GLExt.glDeleteObjectARB( VertexShader );
|
||||||
|
|
||||||
// Bind attributes.
|
|
||||||
GLExt.glBindAttribLocationARB( g_bTextureMatrixShader, ATTRIB_TEXTURE_MATRIX_SCALE, "TextureMatrixScale" );
|
|
||||||
|
|
||||||
// Link the program.
|
// Link the program.
|
||||||
GLExt.glLinkProgramARB( g_bTextureMatrixShader );
|
GLExt.glLinkProgramARB( g_bTextureMatrixShader );
|
||||||
GLint bLinkStatus = false;
|
GLint bLinkStatus = false;
|
||||||
@@ -338,7 +332,17 @@ void InitScalingScript()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLExt.glVertexAttrib2fARB( ATTRIB_TEXTURE_MATRIX_SCALE, 1, 1 );
|
// Bind attributes.
|
||||||
|
g_iAttribTextureMatrixScale = GLExt.glGetAttribLocationARB( g_bTextureMatrixShader, "TextureMatrixScale" );
|
||||||
|
if( g_iAttribTextureMatrixScale == -1 )
|
||||||
|
{
|
||||||
|
LOG->Trace( "Scaling shader link failed: couldn't bind attribute \"TextureMatrixScale\"" );
|
||||||
|
GLExt.glDeleteObjectARB( g_bTextureMatrixShader );
|
||||||
|
g_bTextureMatrixShader = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GLExt.glVertexAttrib2fARB( g_iAttribTextureMatrixScale, 1, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
const GLcharARB *g_ColorBurnFragmentShader = " \
|
const GLcharARB *g_ColorBurnFragmentShader = " \
|
||||||
@@ -1220,11 +1224,11 @@ void RageCompiledGeometryHWOGL::Draw( int iMeshIndex ) const
|
|||||||
/* If we're using texture matrix scales, set up that buffer, too, and enable the
|
/* If we're using texture matrix scales, set up that buffer, too, and enable the
|
||||||
* vertex shader. This shader doesn't support all OpenGL state, so only enable it
|
* vertex shader. This shader doesn't support all OpenGL state, so only enable it
|
||||||
* if we're using it. */
|
* if we're using it. */
|
||||||
GLExt.glEnableVertexAttribArrayARB( ATTRIB_TEXTURE_MATRIX_SCALE );
|
GLExt.glEnableVertexAttribArrayARB( g_iAttribTextureMatrixScale );
|
||||||
AssertNoGLError();
|
AssertNoGLError();
|
||||||
GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureMatrixScale );
|
GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureMatrixScale );
|
||||||
AssertNoGLError();
|
AssertNoGLError();
|
||||||
GLExt.glVertexAttribPointerARB( ATTRIB_TEXTURE_MATRIX_SCALE, 2, GL_FLOAT, false, 0, NULL );
|
GLExt.glVertexAttribPointerARB( g_iAttribTextureMatrixScale, 2, GL_FLOAT, false, 0, NULL );
|
||||||
AssertNoGLError();
|
AssertNoGLError();
|
||||||
|
|
||||||
GLExt.glUseProgramObjectARB( g_bTextureMatrixShader );
|
GLExt.glUseProgramObjectARB( g_bTextureMatrixShader );
|
||||||
@@ -1275,7 +1279,7 @@ void RageCompiledGeometryHWOGL::Draw( int iMeshIndex ) const
|
|||||||
|
|
||||||
if( meshInfo.m_bNeedsTextureMatrixScale && g_bTextureMatrixShader != 0 )
|
if( meshInfo.m_bNeedsTextureMatrixScale && g_bTextureMatrixShader != 0 )
|
||||||
{
|
{
|
||||||
GLExt.glDisableVertexAttribArrayARB( ATTRIB_TEXTURE_MATRIX_SCALE );
|
GLExt.glDisableVertexAttribArrayARB( g_iAttribTextureMatrixScale );
|
||||||
GLExt.glUseProgramObjectARB( 0 );
|
GLExt.glUseProgramObjectARB( 0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user