本文整理汇总了C++中GstGLFuncs::ClearColor方法的典型用法代码示例。如果您正苦于以下问题:C++ GstGLFuncs::ClearColor方法的具体用法?C++ GstGLFuncs::ClearColor怎么用?C++ GstGLFuncs::ClearColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GstGLFuncs
的用法示例。
在下文中一共展示了GstGLFuncs::ClearColor方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
static void
_init_scene (Gst3DScene * scene)
{
GstGLContext *context = scene->context;
GstGLFuncs *gl = context->gl_vtable;
GError *error = NULL;
Gst3DMesh *sphere_mesh;
Gst3DNode *sphere_node;
Gst3DShader *sphere_shader =
gst_3d_shader_new_vert_frag (context, "mvp_uv.vert",
"texture_uv.frag", &error);
if (sphere_shader == NULL) {
GST_WARNING ("Failed to create VR compositor shaders. Error: %s", error->message);
g_clear_error (&error);
return; /* FIXME: Add boolean return result */
}
sphere_mesh = gst_3d_mesh_new_sphere (context, 800.0, 100, 100);
sphere_node = gst_3d_node_new_from_mesh_shader (context, sphere_mesh, sphere_shader);
gst_3d_scene_append_node (scene, sphere_node);
gl->ClearColor (0.f, 0.f, 0.f, 0.f);
gl->ActiveTexture (GL_TEXTURE0);
gst_3d_shader_bind (sphere_shader);
gst_gl_shader_set_uniform_1i (sphere_shader->shader, "texture", 0);
}
示例2:
static void
clear_tex (gpointer data)
{
GstGLContext *context = data;
GstGLFuncs *gl = context->gl_vtable;
static gfloat r = 0.0, g = 0.0, b = 0.0;
gl->ClearColor (r, g, b, 1.0);
gl->Clear (GL_COLOR_BUFFER_BIT);
r = r > 1.0 ? 0.0 : r + 0.03;
g = g > 1.0 ? 0.0 : g + 0.01;
b = b > 1.0 ? 0.0 : b + 0.015;
}
示例3:
static gboolean
gst_gl_filtershader_hcallback (GstGLFilter * filter, GstGLMemory * in_tex,
gpointer stuff)
{
GstGLFilterShader *filtershader = GST_GL_FILTERSHADER (filter);
GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable;
GstGLShader *shader;
if (!(shader = _maybe_recompile_shader (filtershader)))
return FALSE;
gl->ClearColor (0.0, 0.0, 0.0, 1.0);
gl->Clear (GL_COLOR_BUFFER_BIT);
gst_gl_shader_use (shader);
/* FIXME: propertise these */
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
gst_gl_shader_set_uniform_1f (shader, "width",
GST_VIDEO_INFO_WIDTH (&filter->out_info));
gst_gl_shader_set_uniform_1f (shader, "height",
GST_VIDEO_INFO_HEIGHT (&filter->out_info));
gst_gl_shader_set_uniform_1f (shader, "time", filtershader->time);
/* FIXME: propertise these */
filter->draw_attr_position_loc =
gst_gl_shader_get_attribute_location (shader, "a_position");
filter->draw_attr_texture_loc =
gst_gl_shader_get_attribute_location (shader, "a_texcoord");
gl->ActiveTexture (GL_TEXTURE0);
gl->BindTexture (GL_TEXTURE_2D, gst_gl_memory_get_texture_id (in_tex));
gst_gl_filter_draw_fullscreen_quad (filter);
gst_object_unref (shader);
return TRUE;
}
示例4:
static void
gst_gl_filtershader_hcallback (gint width, gint height, guint texture,
gpointer stuff)
{
GstGLFilter *filter = GST_GL_FILTER (stuff);
GstGLFilterShader *filtershader = GST_GL_FILTERSHADER (filter);
GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable;
GstGLShader *shader;
if (!(shader = _maybe_recompile_shader (filtershader)))
return;
gl->ClearColor (0.0, 0.0, 0.0, 1.0);
gl->Clear (GL_COLOR_BUFFER_BIT);
gst_gl_shader_use (shader);
/* FIXME: propertise these */
gst_gl_shader_set_uniform_1i (shader, "tex", 0);
gst_gl_shader_set_uniform_1f (shader, "width", width);
gst_gl_shader_set_uniform_1f (shader, "height", height);
gst_gl_shader_set_uniform_1f (shader, "time", filtershader->time);
/* FIXME: propertise these */
filter->draw_attr_position_loc =
gst_gl_shader_get_attribute_location (shader, "a_position");
filter->draw_attr_texture_loc =
gst_gl_shader_get_attribute_location (shader, "a_texcoord");
gl->ActiveTexture (GL_TEXTURE0);
gl->BindTexture (GL_TEXTURE_2D, texture);
gst_gl_filter_draw_texture (filter, texture, width, height);
gst_object_unref (shader);
}
示例5: while
/* opengl scene, params: input texture (not the output mixer->texture) */
static gboolean
gst_gl_mosaic_callback (gpointer stuff)
{
GstGLMosaic *mosaic = GST_GL_MOSAIC (stuff);
GstGLMixer *mixer = GST_GL_MIXER (mosaic);
GstGLFuncs *gl = GST_GL_BASE_MIXER (mixer)->context->gl_vtable;
GList *walk;
static GLfloat xrot = 0;
static GLfloat yrot = 0;
static GLfloat zrot = 0;
GLint attr_position_loc = 0;
GLint attr_texture_loc = 0;
const GLfloat matrix[] = {
0.5f, 0.0f, 0.0f, 0.0f,
0.0f, 0.5f, 0.0f, 0.0f,
0.0f, 0.0f, 0.5f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
};
const GLushort indices[] = {
0, 1, 2,
0, 2, 3
};
guint count = 0;
gst_gl_context_clear_shader (GST_GL_BASE_MIXER (mixer)->context);
gl->BindTexture (GL_TEXTURE_2D, 0);
gl->Enable (GL_DEPTH_TEST);
gl->ClearColor (0.0, 0.0, 0.0, 0.0);
gl->Clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gst_gl_shader_use (mosaic->shader);
attr_position_loc =
gst_gl_shader_get_attribute_location (mosaic->shader, "a_position");
attr_texture_loc =
gst_gl_shader_get_attribute_location (mosaic->shader, "a_texCoord");
GST_OBJECT_LOCK (mosaic);
walk = GST_ELEMENT (mosaic)->sinkpads;
while (walk) {
GstGLMixerPad *pad = walk->data;
/* *INDENT-OFF* */
gfloat v_vertices[] = {
/* front face */
1.0f, 1.0f,-1.0f, 1.0f, 0.0f,
1.0f,-1.0f,-1.0f, 1.0f, 1.0f,
-1.0f,-1.0f,-1.0f, 0.0f, 1.0f,
-1.0f, 1.0f,-1.0f, 0.0f, 0.0f,
/* right face */
1.0f, 1.0f, 1.0f, 1.0f, 0.0f,
1.0f,-1.0f, 1.0f, 0.0f, 0.0f,
1.0f,-1.0f,-1.0f, 0.0f, 1.0f,
1.0f, 1.0f,-1.0f, 1.0f, 1.0f,
/* left face */
-1.0f, 1.0f, 1.0f, 1.0f, 0.0f,
-1.0f, 1.0f,-1.0f, 1.0f, 1.0f,
-1.0f,-1.0f,-1.0f, 0.0f, 1.0f,
-1.0f,-1.0f, 1.0f, 0.0f, 0.0f,
/* top face */
1.0f,-1.0f, 1.0f, 1.0f, 0.0f,
-1.0f,-1.0f, 1.0f, 0.0f, 0.0f,
-1.0f,-1.0f,-1.0f, 0.0f, 1.0f,
1.0f,-1.0f,-1.0f, 1.0f, 1.0f,
/* bottom face */
1.0f, 1.0f, 1.0f, 1.0f, 0.0f,
1.0f, 1.0f,-1.0f, 1.0f, 1.0f,
-1.0f, 1.0f,-1.0f, 0.0f, 1.0f,
-1.0f, 1.0f, 1.0f, 0.0f, 0.0f,
/* back face */
1.0f, 1.0f, 1.0f, 1.0f, 0.0f,
-1.0f, 1.0f, 1.0f, 0.0f, 0.0f,
-1.0f,-1.0f, 1.0f, 0.0f, 1.0f,
1.0f,-1.0f, 1.0f, 1.0f, 1.0f
};
/* *INDENT-ON* */
guint in_tex;
guint width, height;
in_tex = pad->current_texture;
width = GST_VIDEO_INFO_WIDTH (&GST_VIDEO_AGGREGATOR_PAD (pad)->info);
height = GST_VIDEO_INFO_HEIGHT (&GST_VIDEO_AGGREGATOR_PAD (pad)->info);
if (!in_tex || width <= 0 || height <= 0) {
GST_DEBUG ("skipping texture:%u pad:%p width:%u height %u",
in_tex, pad, width, height);
count++;
walk = g_list_next (walk);
continue;
}
GST_TRACE ("processing texture:%u dimensions:%ux%u", in_tex, width, height);
gl->VertexAttribPointer (attr_position_loc, 3, GL_FLOAT,
//.........这里部分代码省略.........
示例6: sizeof
static void
_callback_gles2 (gint width, gint height, guint texture, gpointer stuff)
{
GstGLFilter *filter = GST_GL_FILTER (stuff);
GstGLFilterCube *cube_filter = GST_GL_FILTER_CUBE (filter);
GstGLFuncs *gl = filter->context->gl_vtable;
static GLfloat xrot = 0;
static GLfloat yrot = 0;
static GLfloat zrot = 0;
/* *INDENT-OFF* */
const GLfloat v_vertices[] = {
/*| Vertex | TexCoord |*/
/* front face */
1.0, 1.0, -1.0, 1.0, 0.0,
1.0, -1.0, -1.0, 1.0, 1.0,
-1.0, -1.0, -1.0, 0.0, 1.0,
-1.0, 1.0, -1.0, 0.0, 0.0,
/* back face */
1.0, 1.0, 1.0, 1.0, 0.0,
-1.0, 1.0, 1.0, 0.0, 0.0,
-1.0, -1.0, 1.0, 0.0, 1.0,
1.0, -1.0, 1.0, 1.0, 1.0,
/* right face */
1.0, 1.0, 1.0, 1.0, 0.0,
1.0, -1.0, 1.0, 0.0, 0.0,
1.0, -1.0, -1.0, 0.0, 1.0,
1.0, 1.0, -1.0, 1.0, 1.0,
/* left face */
-1.0, 1.0, 1.0, 1.0, 0.0,
-1.0, 1.0, -1.0, 1.0, 1.0,
-1.0, -1.0, -1.0, 0.0, 1.0,
-1.0, -1.0, 1.0, 0.0, 0.0,
/* top face */
1.0, -1.0, 1.0, 1.0, 0.0,
-1.0, -1.0, 1.0, 0.0, 0.0,
-1.0, -1.0, -1.0, 0.0, 1.0,
1.0, -1.0, -1.0, 1.0, 1.0,
/* bottom face */
1.0, 1.0, 1.0, 1.0, 0.0,
1.0, 1.0, -1.0, 1.0, 1.0,
-1.0, 1.0, -1.0, 0.0, 1.0,
-1.0, 1.0, 1.0, 0.0, 0.0
};
/* *INDENT-ON* */
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
};
GLint attr_position_loc = 0;
GLint attr_texture_loc = 0;
const GLfloat matrix[] = {
0.5f, 0.0f, 0.0f, 0.0f,
0.0f, 0.5f, 0.0f, 0.0f,
0.0f, 0.0f, 0.5f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
};
gl->Enable (GL_DEPTH_TEST);
gl->ClearColor (cube_filter->red, cube_filter->green, cube_filter->blue, 0.0);
gl->Clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gst_gl_shader_use (cube_filter->shader);
attr_position_loc =
gst_gl_shader_get_attribute_location (cube_filter->shader, "a_position");
attr_texture_loc =
gst_gl_shader_get_attribute_location (cube_filter->shader, "a_texCoord");
/* Load the vertex position */
gl->VertexAttribPointer (attr_position_loc, 3, GL_FLOAT,
GL_FALSE, 5 * sizeof (GLfloat), v_vertices);
/* Load the texture coordinate */
gl->VertexAttribPointer (attr_texture_loc, 2, GL_FLOAT,
GL_FALSE, 5 * sizeof (GLfloat), &v_vertices[3]);
gl->EnableVertexAttribArray (attr_position_loc);
gl->EnableVertexAttribArray (attr_texture_loc);
gl->ActiveTexture (GL_TEXTURE0);
gl->BindTexture (GL_TEXTURE_2D, texture);
gst_gl_shader_set_uniform_1i (cube_filter->shader, "s_texture", 0);
gst_gl_shader_set_uniform_1f (cube_filter->shader, "xrot_degree", xrot);
gst_gl_shader_set_uniform_1f (cube_filter->shader, "yrot_degree", yrot);
//.........这里部分代码省略.........
示例7: gluLookAt
static void
_callback_opengl (gint width, gint height, guint texture, gpointer stuff)
{
GstGLFilterCube *cube_filter = GST_GL_FILTER_CUBE (stuff);
GstGLFilter *filter = GST_GL_FILTER (stuff);
GstGLFuncs *gl = filter->context->gl_vtable;
static GLfloat xrot = 0;
static GLfloat yrot = 0;
static GLfloat zrot = 0;
/* *INDENT-OFF* */
const GLfloat v_vertices[] = {
/*| Vertex | TexCoord |*/
/* front face */
1.0, 1.0, -1.0, 0.0, 0.0,
1.0, -1.0, -1.0, 1.0, 0.0,
-1.0, -1.0, -1.0, 1.0, 1.0,
-1.0, 1.0, -1.0, 0.0, 1.0,
/* back face */
-1.0, 1.0, 1.0, 0.0, 0.0,
-1.0, -1.0, 1.0, 1.0, 0.0,
1.0, -1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 0.0, 1.0,
/* right face */
-1.0, 1.0, -1.0, 0.0, 0.0,
-1.0, -1.0, -1.0, 1.0, 0.0,
-1.0, -1.0, 1.0, 1.0, 1.0,
-1.0, 1.0, 1.0, 0.0, 1.0,
/* left face */
1.0, 1.0, 1.0, 0.0, 0.0,
1.0, -1.0, 1.0, 1.0, 0.0,
1.0, -1.0, -1.0, 1.0, 1.0,
1.0, 1.0, -1.0, 0.0, 1.0,
/* top face */
1.0, 1.0, 1.0, 0.0, 0.0,
1.0, 1.0, -1.0, 1.0, 0.0,
-1.0, 1.0, -1.0, 1.0, 1.0,
-1.0, 1.0, 1.0, 0.0, 1.0,
/* bottom face */
1.0, -1.0, 1.0, 0.0, 0.0,
1.0, -1.0, -1.0, 1.0, 0.0,
-1.0, -1.0, -1.0, 1.0, 1.0,
-1.0, -1.0, 1.0, 0.0, 1.0,
};
/* *INDENT-ON* */
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
};
gl->Enable (GL_DEPTH_TEST);
gl->Enable (GL_TEXTURE_2D);
gl->BindTexture (GL_TEXTURE_2D, texture);
gl->ClearColor (cube_filter->red, cube_filter->green, cube_filter->blue, 0.0);
gl->Clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gl->MatrixMode (GL_PROJECTION);
gluLookAt (0.0, 0.0, -6.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
gl->MatrixMode (GL_MODELVIEW);
gl->LoadIdentity ();
// gl->Translatef (0.0f, 0.0f, -5.0f);
gl->Rotatef (xrot, 1.0f, 0.0f, 0.0f);
gl->Rotatef (yrot, 0.0f, 1.0f, 0.0f);
gl->Rotatef (zrot, 0.0f, 0.0f, 1.0f);
gl->ClientActiveTexture (GL_TEXTURE0);
gl->EnableClientState (GL_TEXTURE_COORD_ARRAY);
gl->EnableClientState (GL_VERTEX_ARRAY);
gl->VertexPointer (3, GL_FLOAT, 5 * sizeof (float), v_vertices);
gl->TexCoordPointer (2, GL_FLOAT, 5 * sizeof (float), &v_vertices[3]);
gl->DrawElements (GL_TRIANGLES, 36, GL_UNSIGNED_SHORT, indices);
gl->DisableClientState (GL_TEXTURE_COORD_ARRAY);
gl->DisableClientState (GL_VERTEX_ARRAY);
gl->Disable (GL_DEPTH_TEST);
xrot += 0.3f;
yrot += 0.2f;
zrot += 0.4f;
}
示例8: if
static gboolean
_2d_texture_renderer_draw (GstAmc2DTextureRenderer * renderer)
{
GstGLFuncs *gl;
guint out_width, out_height;
GLint viewport_dim[4];
/* *INDENT-OFF* */
const GLfloat vertices[] = {
1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
-1.0f, -1.0f, 0.0f, 0.0f, 0.0f,
-1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
1.0f, 1.0f, 0.0f, 1.0f, 1.0f
};
/* *INDENT-ON* */
GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
GLenum multipleRT[] = {
GL_COLOR_ATTACHMENT0,
GL_COLOR_ATTACHMENT1,
GL_COLOR_ATTACHMENT2
};
gl = renderer->context->gl_vtable;
out_width = GST_VIDEO_INFO_WIDTH (&renderer->info);
out_height = GST_VIDEO_INFO_HEIGHT (&renderer->info);
gl->BindFramebuffer (GL_FRAMEBUFFER, renderer->fbo);
/* attach the texture to the FBO to rendererer to */
gl->BindTexture (GL_TEXTURE_2D, renderer->tex_id);
gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, renderer->tex_id, 0);
if (gl->DrawBuffers)
gl->DrawBuffers (1, multipleRT);
else if (gl->DrawBuffer)
gl->DrawBuffer (GL_COLOR_ATTACHMENT0);
gl->GetIntegerv (GL_VIEWPORT, viewport_dim);
gl->Viewport (0, 0, out_width, out_height);
gl->ClearColor (0.0, 0.0, 0.0, 0.0);
gl->Clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gst_gl_shader_use (renderer->shader);
gst_gl_shader_set_uniform_matrix_4fv (renderer->shader, "u_transformation", 1,
FALSE, renderer->transformation_matrix);
gl->VertexAttribPointer (renderer->shader_attr_position_loc, 4,
GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), vertices);
gl->VertexAttribPointer (renderer->shader_attr_texture_loc, 2,
GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), &vertices[3]);
gl->EnableVertexAttribArray (renderer->shader_attr_position_loc);
gl->EnableVertexAttribArray (renderer->shader_attr_texture_loc);
gl->ActiveTexture (GL_TEXTURE0);
gl->BindTexture (GL_TEXTURE_EXTERNAL_OES, renderer->oes_tex_id);
gl->TexParameteri (GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S,
GL_CLAMP_TO_EDGE);
gl->TexParameteri (GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T,
GL_CLAMP_TO_EDGE);
gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
gl->DisableVertexAttribArray (renderer->shader_attr_position_loc);
gl->DisableVertexAttribArray (renderer->shader_attr_texture_loc);
if (gl->DrawBuffer)
gl->DrawBuffer (GL_NONE);
/* we are done with the shader */
gst_gl_context_clear_shader (renderer->context);
gl->Viewport (viewport_dim[0], viewport_dim[1], viewport_dim[2],
viewport_dim[3]);
gst_gl_context_check_framebuffer_status (renderer->context);
gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
return TRUE;
}
示例9: sizeof
static void
gst_gl_transformation_callback (gpointer stuff)
{
GstGLFilter *filter = GST_GL_FILTER (stuff);
GstGLTransformation *transformation = GST_GL_TRANSFORMATION (filter);
GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable;
GLfloat temp_matrix[16];
gst_gl_context_clear_shader (GST_GL_BASE_FILTER (filter)->context);
gl->BindTexture (GL_TEXTURE_2D, 0);
gl->ClearColor (0.f, 0.f, 0.f, 1.f);
gl->Clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gst_gl_shader_use (transformation->shader);
gl->ActiveTexture (GL_TEXTURE0);
gl->BindTexture (GL_TEXTURE_2D, transformation->in_tex);
gst_gl_shader_set_uniform_1i (transformation->shader, "texture", 0);
graphene_matrix_to_float (&transformation->mvp_matrix, temp_matrix);
gst_gl_shader_set_uniform_matrix_4fv (transformation->shader, "mvp",
1, GL_FALSE, temp_matrix);
if (!transformation->vertex_buffer) {
transformation->attr_position =
gst_gl_shader_get_attribute_location (transformation->shader,
"position");
transformation->attr_texture =
gst_gl_shader_get_attribute_location (transformation->shader, "uv");
if (gl->GenVertexArrays) {
gl->GenVertexArrays (1, &transformation->vao);
gl->BindVertexArray (transformation->vao);
}
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;
}
if (gl->GenVertexArrays)
gl->BindVertexArray (transformation->vao);
if (transformation->caps_change) {
_upload_vertices (transformation);
_bind_buffer (transformation);
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);
}
gl->DrawElements (GL_TRIANGLE_STRIP, 5, GL_UNSIGNED_SHORT, indices);
if (gl->GenVertexArrays)
gl->BindVertexArray (0);
else
_unbind_buffer (transformation);
gst_gl_context_clear_shader (GST_GL_BASE_FILTER (filter)->context);
transformation->caps_change = FALSE;
}
示例10: if
static gboolean
_do_convert_draw (GstGLContext * context, GstGLColorConvert * convert)
{
GstGLFuncs *gl;
struct ConvertInfo *c_info = &convert->priv->convert_info;
guint out_width, out_height;
gint i;
GLint viewport_dim[4];
const GLfloat vVertices[] = { 1.0f, -1.0f, 0.0f,
1.0f, 0.0f,
-1.0f, -1.0f, 0.0f,
0.0f, 0.0f,
-1.0f, 1.0f, 0.0f,
0.0f, 1.0f,
1.0f, 1.0f, 0.0f,
1.0f, 1.0f
};
GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
GLenum multipleRT[] = {
GL_COLOR_ATTACHMENT0,
GL_COLOR_ATTACHMENT1,
GL_COLOR_ATTACHMENT2
};
gl = context->gl_vtable;
out_width = GST_VIDEO_INFO_WIDTH (&convert->out_info);
out_height = GST_VIDEO_INFO_HEIGHT (&convert->out_info);
gl->BindFramebuffer (GL_FRAMEBUFFER, convert->fbo);
/* attach the texture to the FBO to renderer to */
for (i = 0; i < c_info->out_n_textures; i++) {
/* needed? */
gl->BindTexture (GL_TEXTURE_2D, convert->priv->out_tex[i]->tex_id);
gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i,
GL_TEXTURE_2D, convert->priv->out_tex[i]->tex_id, 0);
}
if (gl->DrawBuffers)
gl->DrawBuffers (c_info->out_n_textures, multipleRT);
else if (gl->DrawBuffer)
gl->DrawBuffer (GL_COLOR_ATTACHMENT0);
gl->GetIntegerv (GL_VIEWPORT, viewport_dim);
gl->Viewport (0, 0, out_width, out_height);
gl->ClearColor (0.0, 0.0, 0.0, 0.0);
gl->Clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gst_gl_shader_use (convert->shader);
gl->VertexAttribPointer (convert->shader_attr_position_loc, 3,
GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), vVertices);
gl->VertexAttribPointer (convert->shader_attr_texture_loc, 2,
GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), &vVertices[3]);
gl->EnableVertexAttribArray (convert->shader_attr_position_loc);
gl->EnableVertexAttribArray (convert->shader_attr_texture_loc);
for (i = c_info->in_n_textures - 1; i >= 0; i--) {
gchar *scale_name = g_strdup_printf ("tex_scale%u", i);
gl->ActiveTexture (GL_TEXTURE0 + i);
gl->BindTexture (GL_TEXTURE_2D, convert->priv->in_tex[i]->tex_id);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
gst_gl_shader_set_uniform_2fv (convert->shader, scale_name, 1,
convert->priv->in_tex[i]->tex_scaling);
g_free (scale_name);
}
gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
gl->DisableVertexAttribArray (convert->shader_attr_position_loc);
gl->DisableVertexAttribArray (convert->shader_attr_texture_loc);
if (gl->DrawBuffer)
gl->DrawBuffer (GL_NONE);
/* we are done with the shader */
gst_gl_context_clear_shader (context);
gl->Viewport (viewport_dim[0], viewport_dim[1], viewport_dim[2],
viewport_dim[3]);
gst_gl_context_check_framebuffer_status (context);
gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
//.........这里部分代码省略.........
示例11:
static void
gst_gl_transformation_callback (gpointer stuff)
{
GstGLFilter *filter = GST_GL_FILTER (stuff);
GstGLTransformation *transformation = GST_GL_TRANSFORMATION (filter);
GstGLFuncs *gl = filter->context->gl_vtable;
/* *INDENT-OFF* */
const GLfloat positions[] = {
-transformation->aspect, 1.0, 0.0, 1.0,
transformation->aspect, 1.0, 0.0, 1.0,
transformation->aspect, -1.0, 0.0, 1.0,
-transformation->aspect, -1.0, 0.0, 1.0,
};
const GLfloat texture_coordinates[] = {
0.0, 1.0,
1.0, 1.0,
1.0, 0.0,
0.0, 0.0,
};
/* *INDENT-ON* */
GLushort indices[] = { 0, 1, 2, 3, 0 };
GLfloat temp_matrix[16];
GLint attr_position_loc = 0;
GLint attr_texture_loc = 0;
gst_gl_context_clear_shader (filter->context);
gl->BindTexture (GL_TEXTURE_2D, 0);
gl->ClearColor (0.f, 0.f, 0.f, 0.f);
gl->Clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gst_gl_shader_use (transformation->shader);
attr_position_loc =
gst_gl_shader_get_attribute_location (transformation->shader, "position");
attr_texture_loc =
gst_gl_shader_get_attribute_location (transformation->shader, "uv");
/* Load the vertex position */
gl->VertexAttribPointer (attr_position_loc, 4, GL_FLOAT,
GL_FALSE, 0, positions);
/* Load the texture coordinate */
gl->VertexAttribPointer (attr_texture_loc, 2, GL_FLOAT,
GL_FALSE, 0, texture_coordinates);
gl->EnableVertexAttribArray (attr_position_loc);
gl->EnableVertexAttribArray (attr_texture_loc);
gl->ActiveTexture (GL_TEXTURE0);
gl->BindTexture (GL_TEXTURE_2D, transformation->in_tex);
gst_gl_shader_set_uniform_1i (transformation->shader, "texture", 0);
graphene_matrix_to_float (&transformation->mvp_matrix, temp_matrix);
gst_gl_shader_set_uniform_matrix_4fv (transformation->shader, "mvp",
1, GL_FALSE, temp_matrix);
gl->DrawElements (GL_TRIANGLE_STRIP, 5, GL_UNSIGNED_SHORT, indices);
gl->DisableVertexAttribArray (attr_position_loc);
gl->DisableVertexAttribArray (attr_texture_loc);
gst_gl_context_clear_shader (filter->context);
}
示例12: sizeof
static gboolean
_callback (gpointer stuff)
{
GstGLFilter *filter = GST_GL_FILTER (stuff);
GstGLFilterCube *cube_filter = GST_GL_FILTER_CUBE (filter);
GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable;
static GLfloat xrot = 0;
static GLfloat yrot = 0;
static GLfloat zrot = 0;
const GLfloat matrix[] = {
0.5f, 0.0f, 0.0f, 0.0f,
0.0f, 0.5f, 0.0f, 0.0f,
0.0f, 0.0f, 0.5f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
};
gl->Enable (GL_DEPTH_TEST);
gl->ClearColor (cube_filter->red, cube_filter->green, cube_filter->blue, 0.0);
gl->Clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gst_gl_shader_use (cube_filter->shader);
gl->ActiveTexture (GL_TEXTURE0);
gl->BindTexture (GL_TEXTURE_2D, cube_filter->in_tex->tex_id);
gst_gl_shader_set_uniform_1i (cube_filter->shader, "s_texture", 0);
gst_gl_shader_set_uniform_1f (cube_filter->shader, "xrot_degree", xrot);
gst_gl_shader_set_uniform_1f (cube_filter->shader, "yrot_degree", yrot);
gst_gl_shader_set_uniform_1f (cube_filter->shader, "zrot_degree", zrot);
gst_gl_shader_set_uniform_matrix_4fv (cube_filter->shader, "u_matrix", 1,
GL_FALSE, matrix);
if (!cube_filter->vertex_buffer) {
if (gl->GenVertexArrays) {
gl->GenVertexArrays (1, &cube_filter->vao);
gl->BindVertexArray (cube_filter->vao);
}
gl->GenBuffers (1, &cube_filter->vertex_buffer);
gl->BindBuffer (GL_ARRAY_BUFFER, cube_filter->vertex_buffer);
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->BindVertexArray (0);
}
gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0);
gl->BindBuffer (GL_ARRAY_BUFFER, 0);
}
if (gl->GenVertexArrays)
gl->BindVertexArray (cube_filter->vao);
_bind_buffer (cube_filter);
gl->DrawElements (GL_TRIANGLES, 36, GL_UNSIGNED_SHORT, 0);
if (gl->GenVertexArrays)
gl->BindVertexArray (0);
_unbind_buffer (cube_filter);
gl->Disable (GL_DEPTH_TEST);
xrot += 0.3f;
yrot += 0.2f;
zrot += 0.4f;
return TRUE;
}