//opengl scene, params: input texture (not the output filter->texture) static void gst_gl_filter_glass_callback (gpointer stuff) { static gint64 start_time = 0; gfloat rotation; GstGLFilter *filter = GST_GL_FILTER (stuff); GstGLFilterGlass *glass_filter = GST_GL_FILTER_GLASS (stuff); GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable; gint width = GST_VIDEO_INFO_WIDTH (&filter->out_info); gint height = GST_VIDEO_INFO_HEIGHT (&filter->out_info); guint texture = glass_filter->in_tex; if (start_time == 0) start_time = get_time (); else { gint64 time_left = (glass_filter->timestamp / 1000) - (get_time () - start_time); time_left -= 1000000 / 25; if (time_left > 2000) { GST_LOG ("escape"); return; } } gst_gl_shader_use (glass_filter->passthrough_shader); gst_gl_filter_glass_draw_background_gradient (glass_filter); //Rotation if (start_time != 0) { gint64 time_passed = get_time () - start_time; rotation = sin (time_passed / 1200000.0) * 45.0f; } else { rotation = 0.0f; } gl->Enable (GL_BLEND); gl->BlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gst_gl_shader_use (glass_filter->shader); //Reflection gst_gl_filter_glass_draw_video_plane (filter, width, height, texture, 0.0f, 2.0f, 0.3f, 0.0f, TRUE, rotation); //Main video gst_gl_filter_glass_draw_video_plane (filter, width, height, texture, 0.0f, 0.0f, 1.0f, 1.0f, FALSE, rotation); gst_gl_context_clear_shader (GST_GL_BASE_FILTER (filter)->context); gl->Disable (GL_BLEND); }
//opengl scene, params: input texture (not the output filter->texture) static void gst_gl_filter_glass_callback (gint width, gint height, guint texture, gpointer stuff) { static gint64 start_time = 0; GstGLFilter *filter = GST_GL_FILTER (stuff); GstGLFilterGlass *glass_filter = GST_GL_FILTER_GLASS (stuff); if (start_time == 0) start_time = get_time (); else { gint64 time_left = (glass_filter->timestamp / 1000) - (get_time () - start_time); time_left -= 1000000 / 25; if (time_left > 2000) { GST_LOG ("escape"); return; } } glTranslatef (0.0f, 2.0f, -3.0f); gst_gl_filter_glass_draw_background_gradient (); //Rotation if (start_time != 0) { gint64 time_passed = get_time () - start_time; glRotated (sin (time_passed / 1200000.0) * 45.0, 0.0, 1.0, 0.0); } glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //Reflection gst_gl_filter_glass_draw_video_plane (filter, width, height, texture, 0.0f, 0.0f, 0.3f, 0.0f, TRUE); //Main video gst_gl_filter_glass_draw_video_plane (filter, width, height, texture, 0.0f, -2.0f, 1.0f, 1.0f, FALSE); glDisable (GL_TEXTURE_RECTANGLE_ARB); glDisable (GL_BLEND); }