Commit: 71656ac222a7381e460cb799edc4284a8a254057
Author: Mike Erwin
Date:   Thu Oct 13 00:31:23 2016 -0400
Branches: blender2.8
https://developer.blender.org/rB71656ac222a7381e460cb799edc4284a8a254057

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.

===================================================================

M       source/blender/gpu/gawain/immediate.c
M       source/blender/gpu/gawain/immediate.h

===================================================================

diff --git a/source/blender/gpu/gawain/immediate.c 
b/source/blender/gpu/gawain/immediate.c
index 9565c89..8acb9e1 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 bca7542..956ea6b 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);

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to