Revision: 59540
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59540
Author:   jwilkins
Date:     2013-08-26 22:03:38 +0000 (Mon, 26 Aug 2013)
Log Message:
-----------
converting gpu_buffers to use extension_wrapper

Modified Paths:
--------------
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_buffers.c
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_common.c
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_common.h
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_immediate_gl.c

Modified: branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_buffers.c
===================================================================
--- branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_buffers.c       
2013-08-26 21:39:06 UTC (rev 59539)
+++ branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_buffers.c       
2013-08-26 22:03:38 UTC (rev 59540)
@@ -303,8 +303,7 @@
                 * buffer, so increase pool size */
                if (pool->maxsize == pool->totbuf) {
                        pool->maxsize += MAX_FREE_GPU_BUFFERS;
-                       pool->buffers = MEM_reallocN(pool->buffers,
-                                                    sizeof(GPUBuffer *) * 
pool->maxsize);
+                       pool->buffers = 
(GPUBuffer**)MEM_reallocN(pool->buffers, sizeof(GPUBuffer *) * pool->maxsize);
                }
        }
 
@@ -918,17 +917,16 @@
        if (!gpu_buffer_setup_common(dm, GPU_BUFFER_VERTEX))
                return;
 
-#if defined(WITH_GL_PROFILE_COMPAT)
-       glEnableClientState(GL_VERTEX_ARRAY);
+       gpu_enable_vertex_array();
+
        if (useVBOs) {
                gpu_glBindBuffer(GL_ARRAY_BUFFER, dm->drawObject->points->id);
-               glVertexPointer(3, GL_FLOAT, 0, 0);
+               gpu_vertex_pointer(3, GL_FLOAT, 0, 0);
        }
        else {
-               glVertexPointer(3, GL_FLOAT, 0, 
dm->drawObject->points->pointer);
+               gpu_vertex_pointer(3, GL_FLOAT, 0, 
dm->drawObject->points->pointer);
        }
-#endif
-       
+
        GLStates |= GPU_BUFFER_VERTEX_STATE;
 }
 
@@ -937,16 +935,15 @@
        if (!gpu_buffer_setup_common(dm, GPU_BUFFER_NORMAL))
                return;
 
-#if defined(WITH_GL_PROFILE_COMPAT)
-       glEnableClientState(GL_NORMAL_ARRAY);
+       gpu_enable_normal_array();
+
        if (useVBOs) {
                gpu_glBindBuffer(GL_ARRAY_BUFFER, dm->drawObject->normals->id);
-               glNormalPointer(GL_FLOAT, 0, 0);
+               gpu_normal_pointer(GL_FLOAT, 0, GL_FALSE, 0);
        }
        else {
-               glNormalPointer(GL_FLOAT, 0, dm->drawObject->normals->pointer);
+               gpu_normal_pointer(GL_FLOAT, 0, GL_FALSE, 
dm->drawObject->normals->pointer);
        }
-#endif
 
        GLStates |= GPU_BUFFER_NORMAL_STATE;
 }
@@ -956,16 +953,15 @@
        if (!gpu_buffer_setup_common(dm, GPU_BUFFER_UV))
                return;
 
-#if defined(WITH_GL_PROFILE_COMPAT)
-       glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+       gpu_enable_texcoord_array();
+
        if (useVBOs) {
                gpu_glBindBuffer(GL_ARRAY_BUFFER, dm->drawObject->uv->id);
-               glTexCoordPointer(2, GL_FLOAT, 0, 0);
+               gpu_texcoord_pointer(2, GL_FLOAT, 0, 0);
        }
        else {
-               glTexCoordPointer(2, GL_FLOAT, 0, dm->drawObject->uv->pointer);
+               gpu_texcoord_pointer(2, GL_FLOAT, 0, 
dm->drawObject->uv->pointer);
        }
-#endif
 
        GLStates |= GPU_BUFFER_TEXCOORD_STATE;
 }
@@ -995,16 +991,15 @@
        if (!gpu_buffer_setup_common(dm, GPU_BUFFER_COLOR))
                return;
 
-#if defined(WITH_GL_PROFILE_COMPAT)
-       glEnableClientState(GL_COLOR_ARRAY);
+       gpu_enable_color_array();
+
        if (useVBOs) {
                gpu_glBindBuffer(GL_ARRAY_BUFFER, dm->drawObject->colors->id);
-               glColorPointer(3, GL_UNSIGNED_BYTE, 0, 0);
+               gpu_color_pointer(3, GL_UNSIGNED_BYTE, 0, 0);
        }
        else {
-               glColorPointer(3, GL_UNSIGNED_BYTE, 0, 
dm->drawObject->colors->pointer);
+               gpu_color_pointer(3, GL_UNSIGNED_BYTE, 0, 
dm->drawObject->colors->pointer);
        }
-#endif
 
        GLStates |= GPU_BUFFER_COLOR_STATE;
 }
@@ -1017,16 +1012,15 @@
        if (!gpu_buffer_setup_common(dm, GPU_BUFFER_VERTEX))
                return;
 
-#if defined(WITH_GL_PROFILE_COMPAT)
-       glEnableClientState(GL_VERTEX_ARRAY);
+       gpu_enable_vertex_array();
+
        if (useVBOs) {
                gpu_glBindBuffer(GL_ARRAY_BUFFER, dm->drawObject->points->id);
-               glVertexPointer(3, GL_FLOAT, 0, 0);
+               gpu_vertex_pointer(3, GL_FLOAT, 0, 0);
        }
        else {
-               glVertexPointer(3, GL_FLOAT, 0, 
dm->drawObject->points->pointer);
+               gpu_vertex_pointer(3, GL_FLOAT, 0, 
dm->drawObject->points->pointer);
        }
-#endif
 
        GLStates |= GPU_BUFFER_VERTEX_STATE;
 
@@ -1041,16 +1035,15 @@
        if (!gpu_buffer_setup_common(dm, GPU_BUFFER_UVEDGE))
                return;
 
-#if defined(WITH_GL_PROFILE_COMPAT)
-       glEnableClientState(GL_VERTEX_ARRAY);
+       gpu_enable_vertex_array();
+
        if (useVBOs) {
                gpu_glBindBuffer(GL_ARRAY_BUFFER, dm->drawObject->uvedges->id);
-               glVertexPointer(2, GL_FLOAT, 0, 0);
+               gpu_vertex_pointer(2, GL_FLOAT, 0, 0);
        }
        else {
-               glVertexPointer(2, GL_FLOAT, 0, 
dm->drawObject->uvedges->pointer);
+               gpu_vertex_pointer(2, GL_FLOAT, 0, 
dm->drawObject->uvedges->pointer);
        }
-#endif
 
        GLStates |= GPU_BUFFER_VERTEX_STATE;
 }
@@ -1125,60 +1118,61 @@
 }
 
 
+
 void GPU_buffer_unbind(void)
 {
        int i;
 
-#if defined(WITH_GL_PROFILE_COMPAT)
        if (GLStates & GPU_BUFFER_VERTEX_STATE)
-               glDisableClientState(GL_VERTEX_ARRAY);
+               gpu_disable_vertex_array();
+
        if (GLStates & GPU_BUFFER_NORMAL_STATE)
-               glDisableClientState(GL_NORMAL_ARRAY);
+               gpu_disable_normal_array();
+
        if (GLStates & GPU_BUFFER_TEXCOORD_STATE)
-               glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+               gpu_disable_texcoord_array();
+
        if (GLStates & GPU_BUFFER_COLOR_STATE)
-               glDisableClientState(GL_COLOR_ARRAY);
-       if (GLStates & GPU_BUFFER_ELEMENT_STATE) {
-               if (useVBOs) {
-                       gpu_glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
-               }
-       }
-#endif
+               gpu_disable_color_array();
 
-       GLStates &= ~(GPU_BUFFER_VERTEX_STATE | GPU_BUFFER_NORMAL_STATE |
-                     GPU_BUFFER_TEXCOORD_STATE | GPU_BUFFER_COLOR_STATE |
-                     GPU_BUFFER_ELEMENT_STATE);
+       if (useVBOs && (GLStates & GPU_BUFFER_ELEMENT_STATE))
+               gpu_glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
 
+       if (useVBOs)
+               gpu_glBindBuffer(GL_ARRAY_BUFFER, 0);
+
        for (i = 0; i < MAX_GPU_ATTRIB_DATA; i++) {
-               if (attribData[i].index != -1) {
+               if (attribData[i].index != -1)
                        gpu_glDisableVertexAttribArray(attribData[i].index);
-               }
                else
                        break;
        }
 
-       if (useVBOs)
-               gpu_glBindBuffer(GL_ARRAY_BUFFER, 0);
+       GLStates &= ~(GPU_BUFFER_VERTEX_STATE | GPU_BUFFER_NORMAL_STATE |
+                     GPU_BUFFER_TEXCOORD_STATE | GPU_BUFFER_COLOR_STATE |
+                     GPU_BUFFER_ELEMENT_STATE);
 }
 
+
+
 void GPU_color_switch(int mode)
 {
        if (mode) {
-#if defined(WITH_GL_PROFILE_COMPAT)
                if (!(GLStates & GPU_BUFFER_COLOR_STATE))
-                       glEnableClientState(GL_COLOR_ARRAY);
-#endif
+                       gpu_enable_color_array();
+
                GLStates |= GPU_BUFFER_COLOR_STATE;
        }
        else {
-#if defined(WITH_GL_PROFILE_COMPAT)
                if (GLStates & GPU_BUFFER_COLOR_STATE)
-                       glDisableClientState(GL_COLOR_ARRAY);
-#endif
+                       gpu_disable_color_array();
+
                GLStates &= ~GPU_BUFFER_COLOR_STATE;
        }
 }
 
+
+
 /* return 1 if drawing should be done using old immediate-mode
  * code, 0 otherwise */
 int GPU_buffer_legacy(DerivedMesh *dm)
@@ -1327,10 +1321,9 @@
 {
        // SSS not needed?
        //gpuDisableColorMaterial();
-#if defined(WITH_GL_PROFILE_COMPAT)
+
        if (vbo_state == VBO_ENABLED)
-               glDisableClientState(GL_COLOR_ARRAY);
-#endif
+               gpu_disable_color_array();
 }
 
 static float gpu_color_from_mask(float mask)
@@ -1388,6 +1381,7 @@
                                          float diffuse_color[4])
 {
        float color = gpu_color_from_mask_quad(key, a, b, c, d);
+       // XXX jwilkins: this probably needs a VertexAttrib as well
        gpuColor3f(diffuse_color[0] * color, diffuse_color[1] * color, 
diffuse_color[2] * color);
 }
 

Modified: branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_common.c
===================================================================
--- branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_common.c        
2013-08-26 21:39:06 UTC (rev 59539)
+++ branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_common.c        
2013-08-26 22:03:38 UTC (rev 59540)
@@ -412,33 +412,3 @@
 }
 
 
-
-void gpu_enable_vertex_attrib_array (GLuint index)
-{
-       if (current_common != NULL)
-               gpu_glEnableVertexAttribArray(index);
-}
-
-
-
-void gpu_disable_vertex_attrib_array(GLuint index)
-{
-       if (current_common != NULL)
-               gpu_glDisableVertexAttribArray(index);
-}
-
-
-
-void gpu_vertex_attrib_pointer(
-       GLuint        index,
-       GLint         size,
-       GLenum        type,
-       GLboolean     normalize,
-       GLsizei       stride,
-       const GLvoid* pointer)
-{
-       if (current_common != NULL)
-               gpu_glVertexAttribPointer(index, size, type, normalize, stride, 
pointer);
-}
-
-

Modified: branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_common.h
===================================================================
--- branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_common.h        
2013-08-26 21:39:06 UTC (rev 59539)
+++ branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_common.h        
2013-08-26 22:03:38 UTC (rev 59540)
@@ -137,19 +137,8 @@
 void  gpu_set_common_active_texture(GLint texture);
 GLint gpu_get_common_active_texture(void);
 
-void gpu_enable_vertex_attrib_array (GLuint index);
-void gpu_disable_vertex_attrib_array(GLuint index);
 
-void gpu_vertex_attrib_pointer(
-       GLuint        index,
-       GLint         size,
-       GLenum        type,
-       GLboolean     normalize,
-       GLsizei       stride,
-       const GLvoid* pointer);
 
-
-
 #ifdef __cplusplus
 }
 #endif

Modified: 
branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_immediate_gl.c
===================================================================
--- branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_immediate_gl.c  
2013-08-26 21:39:06 UTC (rev 59539)
+++ branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_immediate_gl.c  
2013-08-26 22:03:38 UTC (rev 59540)
@@ -212,7 +212,7 @@
        /* float vertex attribute */
        for (i = 0; i < format->attribCount_f; i++) {
                if (format->attribSize_f[i] > 0) {
-                       gpu_vertex_attrib_pointer(
+                       gpu_glVertexAttribPointer(
                                format->attribIndexMap_f[i],
                                format->attribSize_f[i],
                                GL_FLOAT,
@@ -223,7 +223,7 @@
 
                        offset += (size_t)(format->attribSize_f[i]) * 
sizeof(GLfloat);
 
-                       
gpu_enable_vertex_attrib_array(format->attribIndexMap_f[i]);
+                       
gpu_glEnableVertexAttribArray(format->attribIndexMap_f[i]);
 GPU_CHECK_NO_ERROR();
                }
        }
@@ -231,7 +231,7 @@
        /* byte vertex attribute */
        for (i = 0; i < format->attribCount_ub; i++) {
                if (format->attribSize_ub[i] > 0) {
-                       gpu_vertex_attrib_pointer(
+                       gpu_glVertexAttribPointer(
                                format->attribIndexMap_ub[i],
                                format->attribSize_ub[i],
                                GL_UNSIGNED_BYTE,
@@ -242,7 +242,7 @@
 
                        offset += 4 * sizeof(GLubyte);
 
-                       
gpu_enable_vertex_attrib_array(format->attribIndexMap_ub[i]);
+                       
gpu_glEnableVertexAttribArray(format->attribIndexMap_ub[i]);
 GPU_CHECK_NO_ERROR();
                }
        }
@@ -283,12 +283,12 @@
        /* float vertex attribute */
        for (i = 0; i < GPU_IMMEDIATE->format.attribCount_f; i++)
 //             if (GPU_IMMEDIATE->format.attribSize_f[i] > 0)
-                       
gpu_disable_vertex_attrib_array(GPU_IMMEDIATE->format.attribIndexMap_f[i]);
+                       
gpu_glDisableVertexAttribArray(GPU_IMMEDIATE->format.attribIndexMap_f[i]);
 
        /* byte vertex attribute */
        for (i = 0; i < GPU_IMMEDIATE->format.attribCount_ub; i++)
 //             if (GPU_IMMEDIATE->format.attribSize_ub[i] > 0)

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to