diff options
author | Mike Erwin <significant.bit@gmail.com> | 2016-10-13 07:31:23 +0300 |
---|---|---|
committer | Mike Erwin <significant.bit@gmail.com> | 2016-10-13 07:38:29 +0300 |
commit | 71656ac222a7381e460cb799edc4284a8a254057 (patch) | |
tree | 0be6d1a55165fc0595b427fbcb27918e365b0f1e /source | |
parent | d5b75256e08582e30910bfe6ada61f893b78ce8b (diff) |
Gawain: fix immediate mode for multiple GL contexts
New functions activate & deactivate immediate mode. Call these when switching context and the internal VAO will be handled properly. VAOs are one of the few things *not* shared between OpenGL contexts.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/gpu/gawain/immediate.c | 27 | ||||
-rw-r--r-- | source/blender/gpu/gawain/immediate.h | 2 |
2 files changed, 24 insertions, 5 deletions
diff --git a/source/blender/gpu/gawain/immediate.c b/source/blender/gpu/gawain/immediate.c index 9565c896c47..8acb9e190cf 100644 --- a/source/blender/gpu/gawain/immediate.c +++ b/source/blender/gpu/gawain/immediate.c @@ -57,8 +57,6 @@ void immInit() memset(&imm, 0, sizeof(Immediate)); - glGenVertexArrays(1, &imm.vao_id); - glBindVertexArray(imm.vao_id); glGenBuffers(1, &imm.vbo_id); glBindBuffer(GL_ARRAY_BUFFER, imm.vbo_id); glBufferData(GL_ARRAY_BUFFER, IMM_BUFFER_SIZE, NULL, GL_DYNAMIC_DRAW); @@ -72,19 +70,38 @@ void immInit() imm.strict_vertex_ct = true; glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindVertexArray(0); initialized = true; + + immActivate(); } -void immDestroy() +void immActivate() { #if TRUST_NO_ONE assert(initialized); assert(imm.primitive == PRIM_NONE); // make sure we're not between a Begin/End pair + assert(imm.vao_id == 0); +#endif + + glGenVertexArrays(1, &imm.vao_id); + } + +void immDeactivate() + { +#if TRUST_NO_ONE + assert(initialized); + assert(imm.primitive == PRIM_NONE); // make sure we're not between a Begin/End pair + assert(imm.vao_id != 0); #endif - VertexFormat_clear(&imm.vertex_format); glDeleteVertexArrays(1, &imm.vao_id); + imm.vao_id = 0; + imm.prev_enabled_attrib_bits = 0; + } + +void immDestroy() + { + immDeactivate(); glDeleteBuffers(1, &imm.vbo_id); initialized = false; } diff --git a/source/blender/gpu/gawain/immediate.h b/source/blender/gpu/gawain/immediate.h index bca7542f653..956ea6bd562 100644 --- a/source/blender/gpu/gawain/immediate.h +++ b/source/blender/gpu/gawain/immediate.h @@ -90,4 +90,6 @@ void immUniformColor4ubv(const unsigned char rgba[4]); // these are called by the system -- not part of drawing API void immInit(void); +void immActivate(void); +void immDeactivate(void); void immDestroy(void); |