本文整理汇总了C++中GstGLFuncs::DrawArrays方法的典型用法代码示例。如果您正苦于以下问题:C++ GstGLFuncs::DrawArrays方法的具体用法?C++ GstGLFuncs::DrawArrays怎么用?C++ GstGLFuncs::DrawArrays使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GstGLFuncs
的用法示例。
在下文中一共展示了GstGLFuncs::DrawArrays方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
//opengl scene, params: input texture (not the output filter->texture)
static void
gst_gl_deinterlace_callback (gint width, gint height, guint texture,
gpointer stuff)
{
GstGLDeinterlace *deinterlace_filter = GST_GL_DEINTERLACE (stuff);
GstGLFilter *filter = GST_GL_FILTER (stuff);
GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable;
guint temp;
GLfloat verts[] = { -1.0, -1.0,
1.0, -1.0,
1.0, 1.0,
-1.0, 1.0
};
GLfloat texcoords0[] = { 0.0f, 0.0f,
1.0f, 0.0f,
1.0f, 1.0f,
0.0f, 1.0f
};
GLfloat texcoords1[] = { 0.0f, 0.0f,
1.0f, 0.0f,
1.0f, 1.0f,
0.0f, 1.0f
};
gl->MatrixMode (GL_PROJECTION);
gl->LoadIdentity ();
gst_gl_shader_use (deinterlace_filter->shader);
if (G_UNLIKELY (deinterlace_filter->prev_tex == 0)) {
gst_gl_context_gen_texture (GST_GL_BASE_FILTER (filter)->context,
&deinterlace_filter->prev_tex,
GST_VIDEO_INFO_FORMAT (&filter->out_info),
GST_VIDEO_INFO_WIDTH (&filter->out_info),
GST_VIDEO_INFO_HEIGHT (&filter->out_info));
} else {
gl->ActiveTexture (GL_TEXTURE1);
gst_gl_shader_set_uniform_1i (deinterlace_filter->shader, "tex_prev", 1);
gl->BindTexture (GL_TEXTURE_2D, deinterlace_filter->prev_tex);
}
gl->ActiveTexture (GL_TEXTURE0);
gst_gl_shader_set_uniform_1i (deinterlace_filter->shader, "tex", 0);
gst_gl_shader_set_uniform_1f (deinterlace_filter->shader, "max_comb",
5.0f / 255.0f);
gst_gl_shader_set_uniform_1f (deinterlace_filter->shader, "motion_threshold",
25.0f / 255.0f);
gst_gl_shader_set_uniform_1f (deinterlace_filter->shader, "motion_sense",
30.0f / 255.0f);
gst_gl_shader_set_uniform_1f (deinterlace_filter->shader, "width",
GST_VIDEO_INFO_WIDTH (&filter->out_info));
gst_gl_shader_set_uniform_1f (deinterlace_filter->shader, "height",
GST_VIDEO_INFO_HEIGHT (&filter->out_info));
gl->ClientActiveTexture (GL_TEXTURE0);
gl->EnableClientState (GL_TEXTURE_COORD_ARRAY);
gl->EnableClientState (GL_VERTEX_ARRAY);
gl->VertexPointer (2, GL_FLOAT, 0, &verts);
gl->TexCoordPointer (2, GL_FLOAT, 0, &texcoords0);
gl->ClientActiveTexture (GL_TEXTURE1);
gl->EnableClientState (GL_TEXTURE_COORD_ARRAY);
gl->TexCoordPointer (2, GL_FLOAT, 0, &texcoords1);
gl->DrawArrays (GL_TRIANGLE_FAN, 0, 4);
gl->DisableClientState (GL_VERTEX_ARRAY);
gl->DisableClientState (GL_TEXTURE_COORD_ARRAY);
gl->ClientActiveTexture (GL_TEXTURE0);
gl->DisableClientState (GL_TEXTURE_COORD_ARRAY);
if (texture == filter->in_tex_id) {
temp = filter->in_tex_id;
filter->in_tex_id = deinterlace_filter->prev_tex;
deinterlace_filter->prev_tex = temp;
} else {
deinterlace_filter->prev_tex = texture;
}
}
示例2: sizeof
/**
* gst_gl_filter_draw_texture:
* @filter: a #GstGLFilter
* @texture: the texture to draw
* @width: width of @texture
* @height: height of texture
*
* Draws @texture into the OpenGL scene at the specified @width and @height.
*/
void
gst_gl_filter_draw_texture (GstGLFilter * filter, GLuint texture,
guint width, guint height)
{
GstGLContext *context = filter->context;
GstGLFuncs *gl = context->gl_vtable;
GST_DEBUG ("drawing texture:%u dimensions:%ux%u", texture, width, height);
#if GST_GL_HAVE_OPENGL
if (gst_gl_context_get_gl_api (context) & GST_GL_API_OPENGL) {
GLfloat verts[] = { -1.0f, -1.0f,
1.0f, -1.0f,
1.0f, 1.0f,
-1.0f, 1.0f
};
GLfloat texcoords[] = { 0.0f, 0.0f,
1.0f, 0.0f,
1.0f, 1.0f,
0.0f, 1.0f
};
gl->ActiveTexture (GL_TEXTURE0);
gl->Enable (GL_TEXTURE_2D);
gl->BindTexture (GL_TEXTURE_2D, texture);
gl->ClientActiveTexture (GL_TEXTURE0);
gl->EnableClientState (GL_VERTEX_ARRAY);
gl->EnableClientState (GL_TEXTURE_COORD_ARRAY);
gl->VertexPointer (2, GL_FLOAT, 0, &verts);
gl->TexCoordPointer (2, GL_FLOAT, 0, &texcoords);
gl->DrawArrays (GL_TRIANGLE_FAN, 0, 4);
gl->DisableClientState (GL_VERTEX_ARRAY);
gl->DisableClientState (GL_TEXTURE_COORD_ARRAY);
}
#endif
#if GST_GL_HAVE_GLES2
if (gst_gl_context_get_gl_api (context) & GST_GL_API_GLES2) {
const GLfloat vVertices[] = {
-1.0f, -1.0f, 0.0f,
0.0f, 0.0f,
1.0, -1.0f, 0.0f,
1.0f, 0.0f,
1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f
};
GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
/* glClear (GL_COLOR_BUFFER_BIT); */
/* Load the vertex position */
gl->VertexAttribPointer (filter->draw_attr_position_loc, 3, GL_FLOAT,
GL_FALSE, 5 * sizeof (GLfloat), vVertices);
/* Load the texture coordinate */
gl->VertexAttribPointer (filter->draw_attr_texture_loc, 2, GL_FLOAT,
GL_FALSE, 5 * sizeof (GLfloat), &vVertices[3]);
gl->EnableVertexAttribArray (filter->draw_attr_position_loc);
gl->EnableVertexAttribArray (filter->draw_attr_texture_loc);
gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
}
#endif
}