/* Helper function for 'CHOOSE' macro.  Do what's necessary when an
 * entrypoint is called for the first time.
 */
static void do_choose( GLuint attr, GLuint sz, 
		       void (*attr_func)( const GLfloat *),
		       void (*choose1)( const GLfloat *),
		       void (*choose2)( const GLfloat *),
		       void (*choose3)( const GLfloat *),
		       void (*choose4)( const GLfloat *),
		       const GLfloat *v )
{ 
   GET_CURRENT_CONTEXT( ctx ); 
   TNLcontext *tnl = TNL_CONTEXT(ctx); 
   static GLfloat id[4] = { 0, 0, 0, 1 };
   int i;

   if (tnl->save.attrsz[attr] < sz) {
      /* New size is larger.  Need to flush existing vertices and get
       * an enlarged vertex format.
       */
      _save_upgrade_vertex( ctx, attr, sz );
   }
   else {
      /* New size is equal or smaller - just need to fill in some
       * zeros.
       */
      for (i = sz ; i <= tnl->save.attrsz[attr] ; i++)
	 tnl->save.attrptr[attr][i-1] = id[i-1];
   }

   /* Reset any active pointers for this attribute 
    */
   tnl->save.tabfv[attr][0] = choose1;
   tnl->save.tabfv[attr][1] = choose2;
   tnl->save.tabfv[attr][2] = choose3;
   tnl->save.tabfv[attr][3] = choose4;

   /* Update the secondary dispatch table with the new function
    */
   tnl->save.tabfv[attr][sz-1] = attr_func;

   (*attr_func)(v);
}
static void save_fixup_vertex( GLcontext *ctx, GLuint attr, GLuint sz )
{
   struct vbo_save_context *save = &vbo_context(ctx)->save; 

   if (sz > save->attrsz[attr]) {
      /* New size is larger.  Need to flush existing vertices and get
       * an enlarged vertex format.
       */
      _save_upgrade_vertex( ctx, attr, sz );
   }
   else if (sz < save->active_sz[attr]) {
      static GLfloat id[4] = { 0, 0, 0, 1 };
      GLuint i;

      /* New size is equal or smaller - just need to fill in some
       * zeros.
       */
      for (i = sz ; i <= save->attrsz[attr] ; i++)
	 save->attrptr[attr][i-1] = id[i-1];
   }

   save->active_sz[attr] = sz;
}
Exemple #3
0
static void
save_fixup_vertex(struct gl_context *ctx, GLuint attr, GLuint sz)
{
   struct vbo_save_context *save = &vbo_context(ctx)->save;

   if (sz > save->attrsz[attr]) {
      /* New size is larger.  Need to flush existing vertices and get
       * an enlarged vertex format.
       */
      _save_upgrade_vertex(ctx, attr, sz);
   }
   else if (sz < save->active_sz[attr]) {
      GLuint i;
      const GLfloat *id = vbo_get_default_vals_as_float(save->attrtype[attr]);

      /* New size is equal or smaller - just need to fill in some
       * zeros.
       */
      for (i = sz; i <= save->attrsz[attr]; i++)
         save->attrptr[attr][i - 1] = id[i - 1];
   }

   save->active_sz[attr] = sz;
}