Exemplo n.º 1
0
static bool gl_cg_set_coords(void *handle_data, void *shader_data, const struct video_coords *coords)
{
   cg_shader_data_t *cg = (cg_shader_data_t*)shader_data;

   if (!cg || !coords)
      goto fallback;

   if (cg->prg[cg->active_idx].vertex)
      gl_cg_set_coord_array(cg->prg[cg->active_idx].vertex, cg, coords->vertex, 2);

   if (cg->prg[cg->active_idx].tex)
      gl_cg_set_coord_array(cg->prg[cg->active_idx].tex, cg, coords->tex_coord, 2);

   if (cg->prg[cg->active_idx].lut_tex)
      gl_cg_set_coord_array(cg->prg[cg->active_idx].lut_tex, cg, coords->lut_tex_coord, 2);

   if (cg->prg[cg->active_idx].color)
      gl_cg_set_coord_array(cg->prg[cg->active_idx].color, cg, coords->color, 4);

   return true;

fallback:
   gl_ff_vertex(coords);
   return false;
}
Exemplo n.º 2
0
static bool gl_glsl_set_coords(void *handle_data, void *shader_data, const struct video_coords *coords)
{
   /* Avoid hitting malloc on every single regular quad draw. */
   GLfloat short_buffer[4 * (2 + 2 + 4 + 2)];
   GLfloat *buffer;
   struct glsl_attrib attribs[4];
   size_t attribs_size = 0, size = 0;
   struct glsl_attrib *attr = NULL;
   const struct shader_uniforms *uni = NULL;
   glsl_shader_data_t *glsl = (glsl_shader_data_t*)shader_data;

   if (!glsl || !glsl->shader->modern || !coords)
      goto fallback;

   buffer = short_buffer;
   if (coords->vertices > 4)
      buffer = (GLfloat*)calloc(coords->vertices * 
            (2 + 2 + 4 + 2), sizeof(*buffer));

   if (!buffer)
      goto fallback;

   attr = attribs;
   uni  = &glsl->uniforms[glsl->active_idx];

   if (uni->tex_coord >= 0)
      gl_glsl_set_coord_array(attr, uni->tex_coord, coords->tex_coord, coords, size, 2);

   if (uni->vertex_coord >= 0)
      gl_glsl_set_coord_array(attr, uni->vertex_coord, coords->vertex, coords, size, 2);

   if (uni->color >= 0)
      gl_glsl_set_coord_array(attr, uni->color, coords->color, coords, size, 4);

   if (uni->lut_tex_coord >= 0)
      gl_glsl_set_coord_array(attr, uni->lut_tex_coord, coords->lut_tex_coord, coords, size, 2);

   if (size)
      gl_glsl_set_attribs(glsl,
            glsl->vbo[glsl->active_idx].vbo_primary,
            &glsl->vbo[glsl->active_idx].buffer_primary,
            &glsl->vbo[glsl->active_idx].size_primary,
            buffer, size,
            attribs, attribs_size);

   if (buffer != short_buffer)
      free(buffer);

   return true;

fallback:
   if (coords)
      gl_ff_vertex(coords);
   return false;
}
Exemplo n.º 3
0
static bool shader_null_set_coords(void *handle_data, void *shader_data, const void *data)
{
#ifdef HAVE_OPENGL
#ifndef NO_GL_FF_VERTEX
   if (string_is_equal(video_driver_get_ident(), "gl"))
   {
      const struct gfx_coords *coords = (const struct gfx_coords*)data;
      gl_ff_vertex(coords);
   }
#endif
#endif
   return false;
}
Exemplo n.º 4
0
static bool shader_null_set_coords(const void *data)
{
#ifdef HAVE_OPENGL
#ifndef NO_GL_FF_VERTEX
   gl_t *gl = (gl_t*)video_driver_get_ptr(NULL);
   if (gl)
   {
      const struct gfx_coords *coords = (const struct gfx_coords*)data;
      gl_ff_vertex(coords);
   }
#endif
#endif
   return false;
}
Exemplo n.º 5
0
static bool gl_cg_set_coords(void *handle_data, void *shader_data, const void *data)
{
   const struct gfx_coords *coords = (const struct gfx_coords*)data;
   cg_shader_data_t *cg_data = (cg_shader_data_t*)shader_data;

   if (!cg_data || !coords)
      goto fallback;

   SET_COORD(cg_data, vertex, vertex, 2);
   SET_COORD(cg_data, tex, tex_coord, 2);
   SET_COORD(cg_data, lut_tex, lut_tex_coord, 2);
   SET_COORD(cg_data, color, color, 4);

   return true;
fallback:
   gl_ff_vertex(coords);
   return false;
}
Exemplo n.º 6
0
static bool gl_cg_set_coords(const void *data)
{
   const struct gfx_coords *coords = (const struct gfx_coords*)data;
   driver_t *driver = driver_get_ptr();
   cg_shader_data_t *cg = (cg_shader_data_t*)driver->video_shader_data;

   if (!cg || !coords)
      goto fallback;

   SET_COORD(cg, vertex, vertex, 2);
   SET_COORD(cg, tex, tex_coord, 2);
   SET_COORD(cg, lut_tex, lut_tex_coord, 2);
   SET_COORD(cg, color, color, 4);

   return true;
fallback:
   gl_ff_vertex(coords);
   return false;
}
Exemplo n.º 7
0
static bool gl_cg_set_coords(const void *data)
{
   const struct gl_coords *coords = (const struct gl_coords*)data;
   cg_shader_data_t *cg = (cg_shader_data_t*)driver.video_shader_data;

   if (!cg || !coords)
      goto fallback;

   SET_COORD(cg, vertex, vertex, 2);
   SET_COORD(cg, tex, tex_coord, 2);
   SET_COORD(cg, lut_tex, lut_tex_coord, 2);
   SET_COORD(cg, color, color, 4);

   return true;
fallback:
#ifndef NO_GL_FF_VERTEX
   gl_ff_vertex(coords);
#endif
   return false;
}
Exemplo n.º 8
0
static bool gl_glsl_set_coords_fallback(void *handle_data, void *shader_data,
      const struct video_coords *coords)
{
   gl_ff_vertex(coords);
   return true;
}
Exemplo n.º 9
0
static bool gl_glsl_set_coords(const void *data)
{
    /* Avoid hitting malloc on every single regular quad draw. */
    GLfloat short_buffer[4 * (2 + 2 + 4 + 2)];
    GLfloat *buffer;
    struct glsl_attrib attribs[4];
    size_t attribs_size = 0, size = 0;
    struct glsl_attrib *attr = NULL;
    const struct shader_uniforms *uni = NULL;
    const struct gfx_coords *coords = (const struct gfx_coords*)data;
    driver_t *driver = driver_get_ptr();
    glsl_shader_data_t *glsl = (glsl_shader_data_t*)driver->video_shader_data;

    if (!glsl || !glsl->shader->modern || !coords)
    {
        gl_ff_vertex(coords);
        return false;
    }

    buffer = short_buffer;
    if (coords->vertices > 4)
        buffer = (GLfloat*)calloc(coords->vertices *
                                  (2 + 2 + 4 + 2), sizeof(*buffer));

    if (!buffer)
    {
        gl_ff_vertex(coords);
        return false;
    }

    attr = attribs;
    uni  = &glsl->gl_uniforms[glsl->glsl_active_index];

    if (uni->tex_coord >= 0)
    {
        attr->loc    = uni->tex_coord;
        attr->size   = 2;
        attr->offset = size * sizeof(GLfloat);
        attribs_size++;
        attr++;

        memcpy(buffer + size, coords->tex_coord,
               2 * coords->vertices * sizeof(GLfloat));
        size += 2 * coords->vertices;
    }

    if (uni->vertex_coord >= 0)
    {
        attr->loc    = uni->vertex_coord;
        attr->size   = 2;
        attr->offset = size * sizeof(GLfloat);
        attribs_size++;
        attr++;

        memcpy(buffer + size, coords->vertex,
               2 * coords->vertices * sizeof(GLfloat));
        size += 2 * coords->vertices;
    }

    if (uni->color >= 0)
    {
        attr->loc    = uni->color;
        attr->size   = 4;
        attr->offset = size * sizeof(GLfloat);
        attribs_size++;
        attr++;

        memcpy(buffer + size, coords->color,
               4 * coords->vertices * sizeof(GLfloat));
        size += 4 * coords->vertices;
    }

    if (uni->lut_tex_coord >= 0)
    {
        attr->loc    = uni->lut_tex_coord;
        attr->size   = 2;
        attr->offset = size * sizeof(GLfloat);
        attribs_size++;
        attr++;

        memcpy(buffer + size, coords->lut_tex_coord,
               2 * coords->vertices * sizeof(GLfloat));
        size += 2 * coords->vertices;
    }

    if (size)
    {
        gl_glsl_set_attribs(glsl,
                            glsl->glsl_vbo[glsl->glsl_active_index].vbo_primary,
                            &glsl->glsl_vbo[glsl->glsl_active_index].buffer_primary,
                            &glsl->glsl_vbo[glsl->glsl_active_index].size_primary,
                            buffer, size,
                            attribs, attribs_size);
    }

    if (buffer != short_buffer)
        free(buffer);

    return true;
}