Fix #31593: Every time I switch between edit and object mode, it crashes
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 5 Jun 2012 08:41:53 +0000 (08:41 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 5 Jun 2012 08:41:53 +0000 (08:41 +0000)
Crash was caused by incorrect restoring OpenGL context due to some
weird bit operations used to indicate whether stuff like color arrays
is initialized resulting in some unpredictable results on different
platforms and drivers.

source/blender/gpu/intern/gpu_buffers.c

index 4c6ead3d3f44ecb08be338c6a6a4eaed657a8ab8..75ed7d7eb197f558db360529b11c685c4537bd68 100644 (file)
@@ -1151,7 +1151,7 @@ void GPU_buffer_unbind(void)
                        glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
                }
        }
-       GLStates &= !(GPU_BUFFER_VERTEX_STATE | GPU_BUFFER_NORMAL_STATE |
+       GLStates &= ~(GPU_BUFFER_VERTEX_STATE | GPU_BUFFER_NORMAL_STATE |
                      GPU_BUFFER_TEXCOORD_STATE | GPU_BUFFER_COLOR_STATE |
                      GPU_BUFFER_ELEMENT_STATE);
 
@@ -1191,7 +1191,7 @@ void GPU_color_switch(int mode)
        else {
                if (GLStates & GPU_BUFFER_COLOR_STATE)
                        glDisableClientState(GL_COLOR_ARRAY);
-               GLStates &= (!GPU_BUFFER_COLOR_STATE);
+               GLStates &= ~GPU_BUFFER_COLOR_STATE;
        }
 }