cube_filter->vertex_buffer = 0;
}
+ if (cube_filter->vbo_indices) {
+ gl->DeleteBuffers (1, &cube_filter->vbo_indices);
+ cube_filter->vbo_indices = 0;
+ }
+
if (cube_filter->shader) {
gst_gl_context_del_shader (GST_GL_BASE_FILTER (filter)->context,
cube_filter->shader);
-1.0, 1.0, -1.0, 0.0, 1.0,
-1.0, 1.0, 1.0, 0.0, 0.0
};
+
+static const GLushort indices[] = {
+ 0, 1, 2,
+ 0, 2, 3,
+ 4, 5, 6,
+ 4, 6, 7,
+ 8, 9, 10,
+ 8, 10, 11,
+ 12, 13, 14,
+ 12, 14, 15,
+ 16, 17, 18,
+ 16, 18, 19,
+ 20, 21, 22,
+ 20, 22, 23
+};
/* *INDENT-ON* */
static void
{
const GstGLFuncs *gl = GST_GL_BASE_FILTER (cube_filter)->context->gl_vtable;
+ gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, cube_filter->vbo_indices);
gl->BindBuffer (GL_ARRAY_BUFFER, cube_filter->vertex_buffer);
cube_filter->attr_position =
{
const GstGLFuncs *gl = GST_GL_BASE_FILTER (cube_filter)->context->gl_vtable;
+ gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0);
gl->BindBuffer (GL_ARRAY_BUFFER, 0);
gl->DisableVertexAttribArray (cube_filter->attr_position);
static GLfloat yrot = 0;
static GLfloat zrot = 0;
- GLushort indices[] = {
- 0, 1, 2,
- 0, 2, 3,
- 4, 5, 6,
- 4, 6, 7,
- 8, 9, 10,
- 8, 10, 11,
- 12, 13, 14,
- 12, 14, 15,
- 16, 17, 18,
- 16, 18, 19,
- 20, 21, 22,
- 20, 22, 23
- };
-
const GLfloat matrix[] = {
0.5f, 0.0f, 0.0f, 0.0f,
0.0f, 0.5f, 0.0f, 0.0f,
gl->BufferData (GL_ARRAY_BUFFER, 6 * 4 * 5 * sizeof (GLfloat), vertices,
GL_STATIC_DRAW);
+ gl->GenBuffers (1, &cube_filter->vbo_indices);
+ gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, cube_filter->vbo_indices);
+ gl->BufferData (GL_ELEMENT_ARRAY_BUFFER, sizeof (indices), indices,
+ GL_STATIC_DRAW);
+
if (gl->GenVertexArrays) {
_bind_buffer (cube_filter);
- gl->BindBuffer (GL_ARRAY_BUFFER, 0);
+ gl->BindVertexArray (0);
}
+
+ gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0);
+ gl->BindBuffer (GL_ARRAY_BUFFER, 0);
}
if (gl->GenVertexArrays)
else
_bind_buffer (cube_filter);
- gl->DrawElements (GL_TRIANGLES, 36, GL_UNSIGNED_SHORT, indices);
+ gl->DrawElements (GL_TRIANGLES, 36, GL_UNSIGNED_SHORT, 0);
if (gl->GenVertexArrays)
gl->BindVertexArray (0);
guint in_tex;
GLuint vao;
+ GLuint vbo_indices;
GLuint vertex_buffer;
GLint attr_position;
GLint attr_texture;
-1.0f, -1.0f, 0.0f, 0.0f, 1.0f,
1.0f, -1.0f, 0.0f, 1.0f, 1.0f
};
+
+static const GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
/* *INDENT-ON* */
static void
{
const GstGLFuncs *gl = gl_sink->context->gl_vtable;
+ gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, gl_sink->vbo_indices);
gl->BindBuffer (GL_ARRAY_BUFFER, gl_sink->vertex_buffer);
- gl->BufferData (GL_ARRAY_BUFFER, 4 * 5 * sizeof (GLfloat), vertices,
- GL_STATIC_DRAW);
/* Load the vertex position */
gl->VertexAttribPointer (gl_sink->attr_position, 3, GL_FLOAT, GL_FALSE,
{
const GstGLFuncs *gl = gl_sink->context->gl_vtable;
+ gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0);
gl->BindBuffer (GL_ARRAY_BUFFER, 0);
gl->DisableVertexAttribArray (gl_sink->attr_position);
gl->BindVertexArray (gl_sink->vao);
}
- gl->GenBuffers (1, &gl_sink->vertex_buffer);
- _bind_buffer (gl_sink);
+ if (!gl_sink->vertex_buffer) {
+ gl->GenBuffers (1, &gl_sink->vertex_buffer);
+ gl->BindBuffer (GL_ARRAY_BUFFER, gl_sink->vertex_buffer);
+ gl->BufferData (GL_ARRAY_BUFFER, 4 * 5 * sizeof (GLfloat), vertices,
+ GL_STATIC_DRAW);
+ }
+
+ if (!gl_sink->vbo_indices) {
+ gl->GenBuffers (1, &gl_sink->vbo_indices);
+ gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, gl_sink->vbo_indices);
+ gl->BufferData (GL_ELEMENT_ARRAY_BUFFER, sizeof (indices), indices,
+ GL_STATIC_DRAW);
+ }
if (gl->GenVertexArrays) {
+ _bind_buffer (gl_sink);
gl->BindVertexArray (0);
- gl->BindBuffer (GL_ARRAY_BUFFER, 0);
- } else {
- _unbind_buffer (gl_sink);
}
+
+ gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0);
+ gl->BindBuffer (GL_ARRAY_BUFFER, 0);
}
static void
gl->DeleteVertexArrays (1, &gl_sink->vao);
gl_sink->vao = 0;
}
+
+ if (gl_sink->vbo_indices) {
+ gl->DeleteVertexArrays (1, &gl_sink->vbo_indices);
+ gl_sink->vbo_indices = 0;
+ }
}
static void
if (!do_redisplay) {
gfloat alpha = gl_sink->ignore_alpha ? 1.0f : 0.0f;
- GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
gl->ClearColor (0.0, 0.0, 0.0, alpha);
gl->Clear (GL_COLOR_BUFFER_BIT);
gl->BindTexture (GL_TEXTURE_2D, gl_sink->redisplay_texture);
gst_gl_shader_set_uniform_1i (gl_sink->redisplay_shader, "tex", 0);
- gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
+ gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
gst_gl_context_clear_shader (gl_sink->context);
GstGLShader *redisplay_shader;
GLuint vao;
+ GLuint vbo_indices;
GLuint vertex_buffer;
GLint attr_position;
GLint attr_texture;
overlay->vbo = 0;
}
+ if (overlay->vbo_indices) {
+ gl->DeleteBuffers (1, &overlay->vbo_indices);
+ overlay->vbo_indices = 0;
+ }
+
if (overlay->overlay_vao) {
gl->DeleteVertexArrays (1, &overlay->overlay_vao);
overlay->overlay_vao = 0;
{
const GstGLFuncs *gl = GST_GL_BASE_FILTER (overlay)->context->gl_vtable;
+ gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0);
gl->BindBuffer (GL_ARRAY_BUFFER, 0);
gl->DisableVertexAttribArray (overlay->attr_position);
{
const GstGLFuncs *gl = GST_GL_BASE_FILTER (overlay)->context->gl_vtable;
+ gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, overlay->vbo_indices);
gl->BindBuffer (GL_ARRAY_BUFFER, vbo);
gl->EnableVertexAttribArray (overlay->attr_position);
1.0f, 1.0f, 0.0f, 1.0f, 1.0f,
-1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
};
+
+static const GLushort indices[] = { 0, 1, 2, 0, 2, 3, };
/* *INDENT-ON* */
static void
gboolean memory_mapped = FALSE;
const GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable;
- GLushort indices[] = {
- 0, 1, 2,
- 0, 2, 3,
- };
-
#if GST_GL_HAVE_OPENGL
if (gst_gl_context_get_gl_api (GST_GL_BASE_FILTER (filter)->context) &
GST_GL_API_OPENGL) {
gl->BufferData (GL_ARRAY_BUFFER, 4 * 5 * sizeof (GLfloat), v_vertices,
GL_STATIC_DRAW);
- if (gl->GenVertexArrays)
+ gl->GenBuffers (1, &overlay->vbo_indices);
+ gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, overlay->vbo_indices);
+ gl->BufferData (GL_ELEMENT_ARRAY_BUFFER, sizeof (indices), indices,
+ GL_STATIC_DRAW);
+
+ if (gl->GenVertexArrays) {
_bind_buffer (overlay, overlay->vbo);
+ gl->BindVertexArray (0);
+ }
+
+ gl->BindBuffer (GL_ARRAY_BUFFER, 0);
+ gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0);
}
if (gl->GenVertexArrays)
else
_bind_buffer (overlay, overlay->vbo);
- gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
+ gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
if (!overlay->image_memory)
goto out;
gl->GenBuffers (1, &overlay->overlay_vbo);
gl->BindBuffer (GL_ARRAY_BUFFER, overlay->overlay_vbo);
+ gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, overlay->vbo_indices);
overlay->geometry_change = TRUE;
}
+ if (gl->GenVertexArrays) {
+ gl->BindVertexArray (overlay->overlay_vao);
+ }
+
if (overlay->geometry_change) {
gint render_width, render_height;
gfloat x, y, image_width, image_height;
GL_STATIC_DRAW);
}
- if (gl->GenVertexArrays) {
- if (overlay->geometry_change)
- _bind_buffer (overlay, overlay->overlay_vbo);
- gl->BindVertexArray (overlay->overlay_vao);
- gl->BindBuffer (GL_ARRAY_BUFFER, 0);
- } else {
+ if (!gl->GenVertexArrays || overlay->geometry_change) {
_bind_buffer (overlay, overlay->overlay_vbo);
}
gl->BindTexture (GL_TEXTURE_2D, image_tex);
gst_gl_shader_set_uniform_1f (overlay->shader, "alpha", overlay->alpha);
- gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
+ gl->Enable (GL_BLEND);
+ gl->BlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ gl->BlendEquation (GL_FUNC_ADD);
+
+ gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
+
+ gl->Disable (GL_BLEND);
out:
if (gl->GenVertexArrays) {
GLuint overlay_vao;
GLuint vbo;
GLuint overlay_vbo;
+ GLuint vbo_indices;
GLuint attr_position;
GLuint attr_texture;
};
transformation->vertex_buffer = 0;
}
+ if (transformation->vbo_indices) {
+ gl->DeleteBuffers (1, &transformation->vbo_indices);
+ transformation->vbo_indices = 0;
+ }
+
if (transformation->shader) {
gst_object_unref (transformation->shader);
transformation->shader = NULL;
return TRUE;
}
+static const GLushort indices[] = { 0, 1, 2, 3, 0 };
static void
_upload_vertices (GstGLTransformation * transformation)
const GstGLFuncs *gl =
GST_GL_BASE_FILTER (transformation)->context->gl_vtable;
+ gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, transformation->vbo_indices);
gl->BindBuffer (GL_ARRAY_BUFFER, transformation->vertex_buffer);
/* Load the vertex position */
const GstGLFuncs *gl =
GST_GL_BASE_FILTER (transformation)->context->gl_vtable;
+ gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0);
gl->BindBuffer (GL_ARRAY_BUFFER, 0);
gl->DisableVertexAttribArray (transformation->attr_position);
GstGLTransformation *transformation = GST_GL_TRANSFORMATION (filter);
GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable;
- GLushort indices[] = { 0, 1, 2, 3, 0 };
-
GLfloat temp_matrix[16];
gst_gl_context_clear_shader (GST_GL_BASE_FILTER (filter)->context);
}
gl->GenBuffers (1, &transformation->vertex_buffer);
+
+ gl->GenBuffers (1, &transformation->vbo_indices);
+ gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, transformation->vbo_indices);
+ gl->BufferData (GL_ELEMENT_ARRAY_BUFFER, sizeof (indices), indices,
+ GL_STATIC_DRAW);
+
transformation->caps_change = TRUE;
}
_upload_vertices (transformation);
_bind_buffer (transformation);
- if (gl->GenVertexArrays)
+ if (gl->GenVertexArrays) {
+ gl->BindVertexArray (0);
+ gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0);
gl->BindBuffer (GL_ARRAY_BUFFER, 0);
+ }
} else if (!gl->GenVertexArrays) {
_bind_buffer (transformation);
}
GstGLShader *shader;
GLuint vao;
+ GLuint vbo_indices;
GLuint vertex_buffer;
GLint attr_position;
GLint attr_texture;
video_mixer->vao = 0;
}
+ if (video_mixer->vbo_indices) {
+ gl->DeleteBuffers (1, &video_mixer->vbo_indices);
+ video_mixer->vbo_indices = 0;
+ }
+
gst_aggregator_iterate_sinkpads (GST_AGGREGATOR (video_mixer), _reset_pad_gl,
NULL);
}
return TRUE;
}
+static const GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
+
+static void
+_init_vbo_indices (GstGLVideoMixer * mixer)
+{
+ const GstGLFuncs *gl = GST_GL_BASE_MIXER (mixer)->context->gl_vtable;
+
+ if (!mixer->vbo_indices) {
+ gl->GenBuffers (1, &mixer->vbo_indices);
+ gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, mixer->vbo_indices);
+ gl->BufferData (GL_ELEMENT_ARRAY_BUFFER, sizeof (indices), indices,
+ GL_STATIC_DRAW);
+ }
+}
+
static gboolean
_draw_checker_background (GstGLVideoMixer * video_mixer)
{
const GstGLFuncs *gl = GST_GL_BASE_MIXER (mixer)->context->gl_vtable;
gint attr_position_loc = 0;
- const GLushort indices[] = {
- 0, 1, 2,
- 0, 2, 3
- };
/* *INDENT-OFF* */
gfloat v_vertices[] = {
-1.0,-1.0,-1.0f,
attr_position_loc =
gst_gl_shader_get_attribute_location (video_mixer->checker, "a_position");
+ _init_vbo_indices (video_mixer);
+
if (!video_mixer->checker_vbo) {
gl->GenBuffers (1, &video_mixer->checker_vbo);
gl->BindBuffer (GL_ARRAY_BUFFER, video_mixer->checker_vbo);
gl->BufferData (GL_ARRAY_BUFFER, 4 * 3 * sizeof (GLfloat), v_vertices,
GL_STATIC_DRAW);
} else {
+ gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, video_mixer->vbo_indices);
gl->BindBuffer (GL_ARRAY_BUFFER, video_mixer->checker_vbo);
}
gl->EnableVertexAttribArray (attr_position_loc);
- gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
+ gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
gl->DisableVertexAttribArray (attr_position_loc);
+ gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0);
gl->BindBuffer (GL_ARRAY_BUFFER, 0);
return TRUE;
GLint attr_texture_loc = 0;
guint out_width, out_height;
- const GLushort indices[] = {
- 0, 1, 2,
- 0, 2, 3
- };
-
guint count = 0;
out_width = GST_VIDEO_INFO_WIDTH (&vagg->info);
in_tex = frame->texture;
+ _init_vbo_indices (video_mixer);
+
if (pad->geometry_change || !pad->vertex_buffer) {
gint pad_width, pad_height;
gfloat w, h;
} else {
gl->BindBuffer (GL_ARRAY_BUFFER, pad->vertex_buffer);
}
+ gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, video_mixer->vbo_indices);
gl->BlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
gl->BlendEquation (GL_FUNC_ADD);
gl->VertexAttribPointer (attr_texture_loc, 2, GL_FLOAT,
GL_FALSE, 5 * sizeof (GLfloat), (void *) (3 * sizeof (GLfloat)));
- gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
+ gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
++count;
}
if (gl->GenVertexArrays)
gl->BindVertexArray (0);
+ gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0);
gl->BindBuffer (GL_ARRAY_BUFFER, 0);
gl->BindTexture (GL_TEXTURE_2D, 0);
GPtrArray *input_frames;
GLuint vao;
+ GLuint vbo_indices;
GLuint checker_vbo;
};
{
const GstGLFuncs *gl = convert->context->gl_vtable;
+ gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, convert->priv->vbo_indices);
gl->BindBuffer (GL_ARRAY_BUFFER, convert->priv->vertex_buffer);
/* Load the vertex position */
{
const GstGLFuncs *gl = convert->context->gl_vtable;
+ gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0);
gl->BindBuffer (GL_ARRAY_BUFFER, 0);
gl->DisableVertexAttribArray (convert->priv->attr_position);
gl->BufferData (GL_ARRAY_BUFFER, 4 * 5 * sizeof (GLfloat), vertices,
GL_STATIC_DRAW);
+ gl->GenBuffers (1, &convert->priv->vbo_indices);
+ gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, convert->priv->vbo_indices);
+ gl->BufferData (GL_ELEMENT_ARRAY_BUFFER, sizeof (indices), indices,
+ GL_STATIC_DRAW);
+
if (gl->GenVertexArrays) {
_bind_buffer (convert);
gl->BindVertexArray (0);
}
gl->BindBuffer (GL_ARRAY_BUFFER, 0);
+ gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0);
}
- if (!convert->priv->vbo_indices) {
- gl->GenBuffers (1, &convert->priv->vbo_indices);
- gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, convert->priv->vbo_indices);
- gl->BufferData (GL_ELEMENT_ARRAY_BUFFER, sizeof (indices), indices,
- GL_STATIC_DRAW);
- gl->BindBuffer (GL_ARRAY_BUFFER, 0);
- }
-
-
gl->BindTexture (GL_TEXTURE_2D, 0);
convert->initted = TRUE;
g_free (scale_name);
}
- gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, convert->priv->vbo_indices);
gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
if (gl->BindVertexArray)
if (gl->DrawBuffer)
gl->DrawBuffer (GL_NONE);
- gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0);
-
/* we are done with the shader */
gst_gl_context_clear_shader (context);
filter->vertex_buffer = 0;
}
+ if (filter->vbo_indices) {
+ gl->DeleteBuffers (1, &filter->vbo_indices);
+ filter->vbo_indices = 0;
+ }
+
if (filter->fbo != 0) {
gst_gl_context_del_fbo (context, filter->fbo, filter->depthbuffer);
}
1.0f, 1.0f, 0.0f, 1.0f, 1.0f,
-1.0f, 1.0f, 0.0f, 0.0f, 1.0f
};
+
+static const GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
/* *INDENT-ON* */
static void
GstGLContext *context = GST_GL_BASE_FILTER (filter)->context;
const GstGLFuncs *gl = context->gl_vtable;
+ gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, filter->vbo_indices);
gl->BindBuffer (GL_ARRAY_BUFFER, filter->vertex_buffer);
_get_attributes (filter);
GstGLContext *context = GST_GL_BASE_FILTER (filter)->context;
const GstGLFuncs *gl = context->gl_vtable;
+ gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0);
gl->BindBuffer (GL_ARRAY_BUFFER, 0);
gl->DisableVertexAttribArray (filter->draw_attr_position_loc);
#endif
if (gst_gl_context_get_gl_api (context) & (GST_GL_API_GLES2 |
GST_GL_API_OPENGL3)) {
- GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
-
if (!filter->vertex_buffer) {
if (gl->GenVertexArrays) {
gl->GenVertexArrays (1, &filter->vao);
gl->BufferData (GL_ARRAY_BUFFER, 4 * 5 * sizeof (GLfloat), vertices,
GL_STATIC_DRAW);
+ gl->GenBuffers (1, &filter->vbo_indices);
+ gl->BindBuffer (GL_ARRAY_BUFFER, filter->vbo_indices);
+ gl->BufferData (GL_ARRAY_BUFFER, sizeof (indices), indices,
+ GL_STATIC_DRAW);
+
if (gl->GenVertexArrays) {
_bind_buffer (filter);
- gl->BindBuffer (GL_ARRAY_BUFFER, 0);
+ gl->BindVertexArray (0);
}
+
+ gl->BindBuffer (GL_ARRAY_BUFFER, 0);
+ gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0);
}
if (gl->GenVertexArrays)
else
_bind_buffer (filter);
- gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
+ gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
if (gl->GenVertexArrays)
gl->BindVertexArray (0);
GstGLShader *default_shader;
GLuint vao;
+ GLuint vbo_indices;
GLuint vertex_buffer;
GLint draw_attr_position_loc;
GLint draw_attr_texture_loc;