From patchwork Fri Oct 9 08:18:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 528280 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:4830:134:3::10]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 7F7151402B2 for ; Sat, 10 Oct 2015 02:55:04 +1100 (AEDT) Received: from lists.gnu.org ([208.118.235.17]:51942) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zka0b-0008Q2-Sc for incoming@patchwork.ozlabs.org; Fri, 09 Oct 2015 11:55:02 -0400 Received: from localhost ([::1]:39496 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zka0b-00044r-Kh for incoming@patchwork.ozlabs.org; Fri, 09 Oct 2015 11:55:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43947) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkSt2-00012e-P9 for qemu-devel@nongnu.org; Fri, 09 Oct 2015 04:18:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZkSsy-0003Jf-Oh for qemu-devel@nongnu.org; Fri, 09 Oct 2015 04:18:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36163) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkSsy-0003JF-Ik for qemu-devel@nongnu.org; Fri, 09 Oct 2015 04:18:40 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 2C5CA319AD1 for ; Fri, 9 Oct 2015 08:18:40 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-78.ams2.redhat.com [10.36.116.78]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t998IdOP018370; Fri, 9 Oct 2015 04:18:39 -0400 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 7A1C180951; Fri, 9 Oct 2015 10:18:37 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 9 Oct 2015 10:18:32 +0200 Message-Id: <1444378714-15190-10-git-send-email-kraxel@redhat.com> In-Reply-To: <1444378714-15190-1-git-send-email-kraxel@redhat.com> References: <1444378714-15190-1-git-send-email-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Gerd Hoffmann Subject: [Qemu-devel] [PULL 09/11] opengl: add egl-context.[ch] helpers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x Add helper functions to manage opengl contexts using egl. Signed-off-by: Gerd Hoffmann Reviewed-by: Marc-André Lureau --- include/ui/egl-context.h | 14 ++++++++++++++ ui/Makefile.objs | 1 + ui/egl-context.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 include/ui/egl-context.h create mode 100644 ui/egl-context.c diff --git a/include/ui/egl-context.h b/include/ui/egl-context.h new file mode 100644 index 0000000..f004ce1 --- /dev/null +++ b/include/ui/egl-context.h @@ -0,0 +1,14 @@ +#ifndef EGL_CONTEXT_H +#define EGL_CONTEXT_H + +#include "ui/console.h" +#include "ui/egl-helpers.h" + +QEMUGLContext qemu_egl_create_context(DisplayChangeListener *dcl, + QEMUGLParams *params); +void qemu_egl_destroy_context(DisplayChangeListener *dcl, QEMUGLContext ctx); +int qemu_egl_make_context_current(DisplayChangeListener *dcl, + QEMUGLContext ctx); +QEMUGLContext qemu_egl_get_current_context(DisplayChangeListener *dcl); + +#endif /* EGL_CONTEXT_H */ diff --git a/ui/Makefile.objs b/ui/Makefile.objs index 0034fbb..7a49026 100644 --- a/ui/Makefile.objs +++ b/ui/Makefile.objs @@ -31,6 +31,7 @@ ifeq ($(CONFIG_OPENGL),y) common-obj-y += shader.o common-obj-y += console-gl.o common-obj-y += egl-helpers.o +common-obj-y += egl-context.o common-obj-$(CONFIG_GTK) += gtk-egl.o endif diff --git a/ui/egl-context.c b/ui/egl-context.c new file mode 100644 index 0000000..40102e3 --- /dev/null +++ b/ui/egl-context.c @@ -0,0 +1,34 @@ +#include "qemu-common.h" +#include "ui/egl-context.h" + +QEMUGLContext qemu_egl_create_context(DisplayChangeListener *dcl, + QEMUGLParams *params) +{ + EGLContext ctx; + EGLint ctx_att[] = { + EGL_CONTEXT_CLIENT_VERSION, params->major_ver, + EGL_CONTEXT_MINOR_VERSION_KHR, params->minor_ver, + EGL_NONE + }; + + ctx = eglCreateContext(qemu_egl_display, qemu_egl_config, + eglGetCurrentContext(), ctx_att); + return ctx; +} + +void qemu_egl_destroy_context(DisplayChangeListener *dcl, QEMUGLContext ctx) +{ + eglDestroyContext(qemu_egl_display, ctx); +} + +int qemu_egl_make_context_current(DisplayChangeListener *dcl, + QEMUGLContext ctx) +{ + return eglMakeCurrent(qemu_egl_display, + EGL_NO_SURFACE, EGL_NO_SURFACE, ctx); +} + +QEMUGLContext qemu_egl_get_current_context(DisplayChangeListener *dcl) +{ + return eglGetCurrentContext(); +}