Example #1
0
static void
_fill_context_info (GstGLContext * context, struct context_info *info)
{
  info->handle = gst_gl_context_get_current_gl_context (info->platform);
  info->api =
      gst_gl_context_get_current_gl_api (info->platform, &info->major,
      &info->minor);
}
Example #2
0
static GUBGraphicContext *gub_create_graphic_context_egl(GstPipeline *pipeline, float crop_left, float crop_top, float crop_right, float crop_bottom)
{
    static const GLfloat vVertices[] = {
        -1.f, -1.f,   0.f, 0.f,
        -1.f,  1.f,   0.f, 1.f,
         1.f, -1.f,   1.f, 0.f,
         1.f,  1.f,   1.f, 1.f
    };
    guintptr raw_context;
    GstStructure *s;
    GstGLDisplay *display;
    GstGLContext *gl_context;
    GUBGraphicContextEGL *gcontext;

    raw_context = gst_gl_context_get_current_gl_context(GST_GL_PLATFORM_EGL);
    if (!raw_context) {
        gub_log("Could not retrieve current EGL context");
        return NULL;
    }

    display = (GstGLDisplay *)gst_gl_display_egl_new();
    gl_context = gst_gl_context_new_wrapped(display, raw_context, GST_GL_PLATFORM_EGL, GST_GL_API_GLES2);
    gub_log("Current GL context is %p (GSTGL Platform %s GSTGL API %s)", raw_context,
        gst_gl_platform_to_string(gst_gl_context_get_gl_platform(gl_context)),
        gst_gl_api_to_string(gst_gl_context_get_gl_api(gl_context)));
    gub_log("VENDOR: %s", glGetString(GL_VENDOR));
    gub_log("RENDERER: %s", glGetString(GL_RENDERER));
    gub_log("VERSION: %s", glGetString(GL_VERSION));
    gub_log("GLSL VERSION: %s", glGetString(GL_SHADING_LANGUAGE_VERSION));

    gcontext = (GUBGraphicContextEGL *)malloc(sizeof(GUBGraphicContextEGL));
    gcontext->gl = gl_context;
    gcontext->display = display;
    gcontext->crop_left = crop_left;
    gcontext->crop_top = crop_top;
    gcontext->crop_right = crop_right;
    gcontext->crop_bottom = crop_bottom;

    glGenFramebuffers(1, &gcontext->fbo);

    if (gl_context->gl_vtable->GenVertexArrays)
        gl_context->gl_vtable->GenVertexArrays(1, &gcontext->vao);
    if (gcontext->gl->gl_vtable->BindVertexArray)
        gcontext->gl->gl_vtable->BindVertexArray(gcontext->vao);

    glGenBuffers(1, &gcontext->vbo);
    glBindBuffer(GL_ARRAY_BUFFER, gcontext->vbo);
    glBufferData(GL_ARRAY_BUFFER, 16 * sizeof(GLfloat), vVertices, GL_STATIC_DRAW);
    glBindBuffer(GL_ARRAY_BUFFER, 0);

    gcontext->po = gub_create_program();

    gcontext->samplerLoc = glGetUniformLocation(gcontext->po, "sTexture");

    return gcontext;
}
Example #3
0
static GUBGraphicContext *gub_create_graphic_context_opengl(GstPipeline *pipeline, float crop_left, float crop_top, float crop_right, float crop_bottom)
{
    GUBGraphicContextOpenGL *gcontext = NULL;
    guintptr raw_context = gst_gl_context_get_current_gl_context(GUB_GL_PLATFORM);
    if (raw_context) {
        GstGLDisplay *display = gst_gl_display_new();
        GstGLContext *gl_context = gst_gl_context_new_wrapped(display, raw_context, GUB_GL_PLATFORM, GST_GL_API_OPENGL);

        gcontext = (GUBGraphicContextOpenGL *)malloc(sizeof(GUBGraphicContextOpenGL));
        gcontext->display = display;
    }
    else {
        gub_log("Could not retrieve current GL context");
    }

    return gcontext;
}