Fix for size of VBO index type when drawing multires in sculpt mode.
authorNicholas Bishop <nicholasbishop@gmail.com>
Fri, 16 Mar 2012 23:21:40 +0000 (23:21 +0000)
committerNicholas Bishop <nicholasbishop@gmail.com>
Fri, 16 Mar 2012 23:21:40 +0000 (23:21 +0000)
The VBO index type can be either ushort or uint depending on the grid
size. The comparison was checking how many quads are in the array, but
this was incorrect; the size of the index elements should depend on
the maximum value they reference, i.e. the maximum coord/normal
element.

source/blender/gpu/intern/gpu_buffers.c

index aeb2b13d15e83ec42de3b871f6c632745616cc2f..57118e92d938215807ddb320f68545873c15c488 100644 (file)
@@ -1572,7 +1572,7 @@ static GLuint gpu_get_grid_buffer(int gridsize, GLenum *index_type, unsigned *to
 
                glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, buffer);
 
-               if(*totquad < USHRT_MAX) {
+               if(gridsize * gridsize < USHRT_MAX) {
                        *index_type = GL_UNSIGNED_SHORT;
                        FILL_QUAD_BUFFER(unsigned short, *totquad, buffer);
                }
@@ -1617,7 +1617,7 @@ GPU_Buffers *GPU_build_grid_buffers(int *grid_indices, int totgrid,
 
                        glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, buffers->index_buf);
 
-                       if(totquad < USHRT_MAX) {
+                       if(totgrid * gridsize * gridsize < USHRT_MAX) {
                                buffers->index_type = GL_UNSIGNED_SHORT;
                                FILL_QUAD_BUFFER(unsigned short, totquad, buffers->index_buf);
                        }