mirror of
https://github.com/love2d/love.git
synced 2026-08-15 15:51:12 +02:00
Replace glMapBufferARB() with temp memory + glBufferSubDataARB().
Instead of letting OpenGL manage the memory mapping, allocate a temporary block of memory upon VBO:map(). Upon VBO::unmap() the block is copied to graphics memory using glBufferSubDataARB() and then released. Hopefully this will fix some weird error with Windows XP + old drivers, where VBOs can be created, but the mapped memory cannot be allocated resulting in the sprite batch drawing nothing at all. According to the interwebs this could actually faster than using OpenGL mapped memory, because there is no unnecessary syncing involved.
This commit is contained in:
@@ -72,7 +72,7 @@ namespace opengl
|
||||
delete [] buf;
|
||||
}
|
||||
|
||||
void *VertexArray::map(GLenum/* access*/)
|
||||
void *VertexArray::map()
|
||||
{
|
||||
return buf;
|
||||
}
|
||||
@@ -122,20 +122,21 @@ namespace opengl
|
||||
unload(false);
|
||||
}
|
||||
|
||||
void *VBO::map(GLenum access)
|
||||
void *VBO::map()
|
||||
{
|
||||
// Don't map twice.
|
||||
// mapping twice could result in memory leaks
|
||||
if (mapped)
|
||||
return mapped;
|
||||
throw love::Exception("VBO is already mapped!");
|
||||
|
||||
mapped = glMapBufferARB(getTarget(), access);
|
||||
mapped = malloc(getSize());
|
||||
|
||||
return mapped;
|
||||
}
|
||||
|
||||
void VBO::unmap()
|
||||
{
|
||||
glUnmapBufferARB(getTarget());
|
||||
glBufferSubDataARB(getTarget(), 0, getSize(), (void*)mapped);
|
||||
free(mapped);
|
||||
mapped = 0;
|
||||
}
|
||||
|
||||
@@ -209,7 +210,7 @@ namespace opengl
|
||||
GLint size;
|
||||
glGetBufferParameterivARB(getTarget(), GL_BUFFER_SIZE, &size);
|
||||
|
||||
const char *src = static_cast<char *>(map(GL_READ_ONLY));
|
||||
const char *src = static_cast<char *>(map());
|
||||
|
||||
if (src)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user