예제 #1
0
파일: st_draw.c 프로젝트: Echelon9/mesa
void
st_init_draw(struct st_context *st)
{
   struct gl_context *ctx = st->ctx;

   vbo_set_draw_func(ctx, st_draw_vbo);
   vbo_set_indirect_draw_func(ctx, st_indirect_draw_vbo);
}
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 );
   vbo_set_indirect_draw_func(ctx, vbo_draw_indirect_prims);

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

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

      for (i = 0; i < ARRAY_SIZE(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;
}
예제 #3
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;
}