OpenGL: invalidate buffers the modern way

There are older ways to give OpenGL hints about buffer invalidation, but
glInvalidateBufferData does exactly what we want. Use this function when
OpenGL 4.3 is available (Windows and proprietary Linux drivers).

Part of Gawain immediate mode.
This commit is contained in:
2016-08-09 17:17:34 -04:00
parent f3d65ad23c
commit e4e1b0c7d3

View File

@@ -318,8 +318,10 @@ void immBegin(GLenum primitive, unsigned vertex_ct)
#if APPLE_LEGACY
glBufferData(GL_ARRAY_BUFFER, IMM_BUFFER_SIZE, NULL, GL_DYNAMIC_DRAW);
#else
glMapBufferRange(GL_ARRAY_BUFFER, 0, IMM_BUFFER_SIZE, GL_MAP_INVALIDATE_BUFFER_BIT);
// glInvalidateBufferData(imm.vbo_id); // VERSION >= 4.3 || ARB_invalidate_subdata
if (GLEW_VERSION_4_3 || GLEW_ARB_invalidate_subdata)
glInvalidateBufferData(imm.vbo_id);
else
glMapBufferRange(GL_ARRAY_BUFFER, 0, IMM_BUFFER_SIZE, GL_MAP_INVALIDATE_BUFFER_BIT);
#endif
imm.buffer_offset = 0;