Skip glTexCoordPointer() call if not needed
This commit is contained in:
parent
858c9ce924
commit
973ac8ddcd
@ -414,6 +414,7 @@ private:
|
|||||||
bool viewChanged; ///< Has the current view changed since last draw?
|
bool viewChanged; ///< Has the current view changed since last draw?
|
||||||
BlendMode lastBlendMode; ///< Cached blending mode
|
BlendMode lastBlendMode; ///< Cached blending mode
|
||||||
Uint64 lastTextureId; ///< Cached texture
|
Uint64 lastTextureId; ///< Cached texture
|
||||||
|
bool texCoordsArrayEnabled; ///< Is GL_TEXTURE_COORD_ARRAY client state enabled?
|
||||||
bool useVertexCache; ///< Did we previously use the vertex cache?
|
bool useVertexCache; ///< Did we previously use the vertex cache?
|
||||||
Vertex vertexCache[VertexCacheSize]; ///< Pre-transformed vertices cache
|
Vertex vertexCache[VertexCacheSize]; ///< Pre-transformed vertices cache
|
||||||
};
|
};
|
||||||
|
@ -269,12 +269,24 @@ void RenderTarget::draw(const Vertex* vertices, std::size_t vertexCount,
|
|||||||
vertices = NULL;
|
vertices = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if texture coordinates array is needed, and update client state accordingly
|
||||||
|
bool enableTexCoordsArray = (states.texture || states.shader);
|
||||||
|
if (enableTexCoordsArray != m_cache.texCoordsArrayEnabled)
|
||||||
|
{
|
||||||
|
if (enableTexCoordsArray)
|
||||||
|
glCheck(glEnableClientState(GL_TEXTURE_COORD_ARRAY));
|
||||||
|
else
|
||||||
|
glCheck(glDisableClientState(GL_TEXTURE_COORD_ARRAY));
|
||||||
|
m_cache.texCoordsArrayEnabled = enableTexCoordsArray;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup the pointers to the vertices' components
|
// Setup the pointers to the vertices' components
|
||||||
if (vertices)
|
if (vertices)
|
||||||
{
|
{
|
||||||
const char* data = reinterpret_cast<const char*>(vertices);
|
const char* data = reinterpret_cast<const char*>(vertices);
|
||||||
glCheck(glVertexPointer(2, GL_FLOAT, sizeof(Vertex), data + 0));
|
glCheck(glVertexPointer(2, GL_FLOAT, sizeof(Vertex), data + 0));
|
||||||
glCheck(glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Vertex), data + 8));
|
glCheck(glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Vertex), data + 8));
|
||||||
|
if (enableTexCoordsArray)
|
||||||
glCheck(glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), data + 12));
|
glCheck(glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), data + 12));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,6 +402,8 @@ void RenderTarget::resetGLStates()
|
|||||||
if (shaderAvailable)
|
if (shaderAvailable)
|
||||||
applyShader(NULL);
|
applyShader(NULL);
|
||||||
|
|
||||||
|
m_cache.texCoordsArrayEnabled = true;
|
||||||
|
|
||||||
m_cache.useVertexCache = false;
|
m_cache.useVertexCache = false;
|
||||||
|
|
||||||
// Set the default view
|
// Set the default view
|
||||||
|
Loading…
Reference in New Issue
Block a user