ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

void vbo_rebase_prims ( GLcontext *  ctx,
const struct gl_client_array arrays[],
const struct _mesa_prim prim,
GLuint  nr_prims,
const struct _mesa_index_buffer ib,
GLuint  min_index,
GLuint  max_index,
vbo_draw_func  draw 
)

Definition at line 107 of file vbo_rebase.c.

Referenced by _tnl_draw_prims().

{
   struct gl_client_array tmp_arrays[VERT_ATTRIB_MAX];
   const struct gl_client_array *tmp_array_pointers[VERT_ATTRIB_MAX];

   struct _mesa_index_buffer tmp_ib;
   struct _mesa_prim *tmp_prims = NULL;
   void *tmp_indices = NULL;
   GLuint i;

   assert(min_index != 0);

   if (0)
      _mesa_printf("%s %d..%d\n", __FUNCTION__, min_index, max_index);

   if (ib) {
      /* Unfortunately need to adjust each index individually.
       */
      GLboolean map_ib = ib->obj->Name && !ib->obj->Pointer;
      void *ptr;

      if (map_ib) 
     ctx->Driver.MapBuffer(ctx, 
                   GL_ELEMENT_ARRAY_BUFFER,
                   GL_READ_ONLY_ARB,
                   ib->obj);


      ptr = ADD_POINTERS(ib->obj->Pointer, ib->ptr);

      /* Some users might prefer it if we translated elements to
       * GLuints here.  Others wouldn't...
       */
      switch (ib->type) {
      case GL_UNSIGNED_INT: 
     tmp_indices = rebase_GLuint( ptr, ib->count, min_index );
     break;
      case GL_UNSIGNED_SHORT: 
     tmp_indices = rebase_GLushort( ptr, ib->count, min_index );
     break;
      case GL_UNSIGNED_BYTE: 
     tmp_indices = rebase_GLubyte( ptr, ib->count, min_index );
     break;
      }      

      if (map_ib) 
     ctx->Driver.UnmapBuffer(ctx, 
                 GL_ELEMENT_ARRAY_BUFFER,
                 ib->obj);

      tmp_ib.obj = ctx->Array.NullBufferObj;
      tmp_ib.ptr = tmp_indices;
      tmp_ib.count = ib->count;
      tmp_ib.type = ib->type;

      ib = &tmp_ib;
   }
   else {
      /* Otherwise the primitives need adjustment.
       */
      tmp_prims = (struct _mesa_prim *)_mesa_malloc(sizeof(*prim) * nr_prims);

      for (i = 0; i < nr_prims; i++) {
     /* If this fails, it could indicate an application error:
      */
     assert(prim[i].start >= min_index);

     tmp_prims[i] = prim[i];
     tmp_prims[i].start -= min_index;
      }

      prim = tmp_prims;
   }

   /* Just need to adjust the pointer values on each incoming array.
    * This works for VBO and non-vbo rendering and shouldn't pesimize
    * VBO-based upload schemes.  However this may still not be a fast
    * path for hardware tnl for VBO based rendering as most machines
    * will be happier if you just specify a starting vertex value in
    * each primitive.
    *
    * For drivers with hardware tnl, you only want to do this if you
    * are forced to, eg non-VBO indexed rendering with start != 0.
    */
   for (i = 0; i < VERT_ATTRIB_MAX; i++) {
      tmp_arrays[i] = *arrays[i];
      tmp_arrays[i].Ptr += min_index * tmp_arrays[i].StrideB;
      tmp_array_pointers[i] = &tmp_arrays[i];
   }
   
   /* Re-issue the draw call.
    */
   draw( ctx, 
     tmp_array_pointers, 
     prim, 
     nr_prims, 
     ib, 
     0, 
     max_index - min_index );
   
   if (tmp_indices)
      _mesa_free(tmp_indices);
   
   if (tmp_prims)
      _mesa_free(tmp_prims);
}

Generated on Sun May 27 2012 05:00:05 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.