Пример #1
0
GLboolean _vbo_CreateContext( struct gl_context *ctx )
{
    struct vbo_context *vbo = CALLOC_STRUCT(vbo_context);

    ctx->vbo_context = vbo;

    /* Initialize the arrayelt helper
     */
    if (!ctx->aelt_context &&
            !_ae_create_context( ctx )) {
        return GL_FALSE;
    }

    init_legacy_currval( ctx );
    init_generic_currval( ctx );
    init_mat_currval( ctx );

    /* Build mappings from VERT_ATTRIB -> VBO_ATTRIB depending on type
     * of vertex program active.
     */
    {
        GLuint i;

        /* identity mapping */
        for (i = 0; i < Elements(vbo->map_vp_none); i++)
            vbo->map_vp_none[i] = i;
        /* map material attribs to generic slots */
        for (i = 0; i < NR_MAT_ATTRIBS; i++)
            vbo->map_vp_none[VERT_ATTRIB_GENERIC(i)]
                = VBO_ATTRIB_MAT_FRONT_AMBIENT + i;

        for (i = 0; i < Elements(vbo->map_vp_arb); i++)
            vbo->map_vp_arb[i] = i;
    }


    /* Hook our functions into exec and compile dispatch tables.  These
     * will pretty much be permanently installed, which means that the
     * vtxfmt mechanism can be removed now.
     */
    vbo_exec_init( ctx );
    if (ctx->API == API_OPENGL_COMPAT)
        vbo_save_init( ctx );

    _math_init_eval();

    return GL_TRUE;
}
Пример #2
0
GLboolean
_vbo_CreateContext(struct gl_context *ctx)
{
   struct vbo_context *vbo = CALLOC_STRUCT(vbo_context);

   ctx->vbo_context = vbo;

   /* Initialize the arrayelt helper
    */
   if (!ctx->aelt_context &&
       !_ae_create_context(ctx)) {
      return GL_FALSE;
   }

   vbo->binding.Offset = 0;
   vbo->binding.Stride = 0;
   vbo->binding.InstanceDivisor = 0;
   _mesa_reference_buffer_object(ctx, &vbo->binding.BufferObj,
                                 ctx->Shared->NullBufferObj);
   init_legacy_currval(ctx);
   init_generic_currval(ctx);
   init_mat_currval(ctx);
   _vbo_init_inputs(&vbo->draw_arrays);
   vbo_set_indirect_draw_func(ctx, vbo_draw_indirect_prims);

   /* make sure all VBO_ATTRIB_ values can fit in an unsigned byte */
   STATIC_ASSERT(VBO_ATTRIB_MAX <= 255);

   /* Hook our functions into exec and compile dispatch tables.  These
    * will pretty much be permanently installed, which means that the
    * vtxfmt mechanism can be removed now.
    */
   vbo_exec_init(ctx);
   if (ctx->API == API_OPENGL_COMPAT)
      vbo_save_init(ctx);

   vbo->VAO = _mesa_new_vao(ctx, ~((GLuint)0));
   /* The exec VAO assumes to have all arributes bound to binding 0 */
   for (unsigned i = 0; i < VERT_ATTRIB_MAX; ++i)
      _mesa_vertex_attrib_binding(ctx, vbo->VAO, i, 0, false);

   _math_init_eval();

   return GL_TRUE;
}
Пример #3
0
GLboolean _vbo_CreateContext( GLcontext *ctx )
{
   struct vbo_context *vbo = CALLOC_STRUCT(vbo_context);

   ctx->swtnl_im = (void *)vbo;

   /* Initialize the arrayelt helper
    */
   if (!ctx->aelt_context &&
       !_ae_create_context( ctx )) {
      return GL_FALSE;
   }

   /* TODO: remove these pointers.
    */
   vbo->legacy_currval = &vbo->currval[VBO_ATTRIB_POS];
   vbo->generic_currval = &vbo->currval[VBO_ATTRIB_GENERIC0];
   vbo->mat_currval = &vbo->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT];

   init_legacy_currval( ctx );
   init_generic_currval( ctx );
   init_mat_currval( ctx );

   /* Build mappings from VERT_ATTRIB -> VBO_ATTRIB depending on type
    * of vertex program active.
    */
   {
      GLuint i;

      /* When no vertex program, pull in the material attributes in
       * the 16..32 generic range.
       */
      for (i = 0; i < 16; i++) 
	 vbo->map_vp_none[i] = i;
      for (i = 0; i < 12; i++) 
	 vbo->map_vp_none[16+i] = VBO_ATTRIB_MAT_FRONT_AMBIENT + i;
      for (i = 0; i < 4; i++)
	 vbo->map_vp_none[28+i] = i;	
      
      for (i = 0; i < Elements(vbo->map_vp_arb); i++)
	 vbo->map_vp_arb[i] = i;
   }


   /* By default: 
    */
#if 0 /* dead - see vbo_set_draw_func() */
   vbo->draw_prims = _tnl_draw_prims;
#endif

   /* Hook our functions into exec and compile dispatch tables.  These
    * will pretty much be permanently installed, which means that the
    * vtxfmt mechanism can be removed now.
    */
   vbo_exec_init( ctx );
#if FEATURE_dlist
   vbo_save_init( ctx );
#endif

   _math_init_eval();

   return GL_TRUE;
}