Fix OpenGL texture coordinate pointer not being updated when the array enabled state changes but the RenderTarget's cache state doesn't.
This commit is contained in:
parent
b3d6e4811d
commit
516678fe1f
@ -259,16 +259,6 @@ void RenderTarget::draw(const Vertex* vertices, std::size_t vertexCount,
|
||||
if (states.shader)
|
||||
applyShader(states.shader);
|
||||
|
||||
// If we pre-transform the vertices, we must use our internal vertex cache
|
||||
if (useVertexCache)
|
||||
{
|
||||
// ... and if we already used it previously, we don't need to set the pointers again
|
||||
if (!m_cache.useVertexCache)
|
||||
vertices = m_cache.vertexCache;
|
||||
else
|
||||
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)
|
||||
@ -277,18 +267,30 @@ void RenderTarget::draw(const Vertex* vertices, std::size_t vertexCount,
|
||||
glCheck(glEnableClientState(GL_TEXTURE_COORD_ARRAY));
|
||||
else
|
||||
glCheck(glDisableClientState(GL_TEXTURE_COORD_ARRAY));
|
||||
m_cache.texCoordsArrayEnabled = enableTexCoordsArray;
|
||||
}
|
||||
|
||||
// Setup the pointers to the vertices' components
|
||||
if (vertices)
|
||||
// If we switch between non-cache and cache mode or enable texture
|
||||
// coordinates we need to set up the pointers to the vertices' components
|
||||
if (!useVertexCache || !m_cache.useVertexCache)
|
||||
{
|
||||
const char* data = reinterpret_cast<const char*>(vertices);
|
||||
|
||||
// If we pre-transform the vertices, we must use our internal vertex cache
|
||||
if (useVertexCache)
|
||||
data = reinterpret_cast<const char*>(m_cache.vertexCache);
|
||||
|
||||
glCheck(glVertexPointer(2, GL_FLOAT, sizeof(Vertex), data + 0));
|
||||
glCheck(glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Vertex), data + 8));
|
||||
if (enableTexCoordsArray)
|
||||
glCheck(glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), data + 12));
|
||||
}
|
||||
else if (enableTexCoordsArray && !m_cache.texCoordsArrayEnabled)
|
||||
{
|
||||
// If we enter this block, we are already using our internal vertex cache
|
||||
const char* data = reinterpret_cast<const char*>(m_cache.vertexCache);
|
||||
|
||||
glCheck(glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), data + 12));
|
||||
}
|
||||
|
||||
// Find the OpenGL primitive type
|
||||
static const GLenum modes[] = {GL_POINTS, GL_LINES, GL_LINE_STRIP, GL_TRIANGLES,
|
||||
@ -309,6 +311,7 @@ void RenderTarget::draw(const Vertex* vertices, std::size_t vertexCount,
|
||||
|
||||
// Update the cache
|
||||
m_cache.useVertexCache = useVertexCache;
|
||||
m_cache.texCoordsArrayEnabled = enableTexCoordsArray;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user