hw: ccid-card-emulated: cleanup resource when realize in error path
[qemu/ar7.git] / ui / egl-context.c
blob78e6c7ab7cf7fafdb5bd7eb3c86b89a6fb7465ea
1 #include "qemu/osdep.h"
2 #include "qemu-common.h"
3 #include "ui/egl-context.h"
5 QEMUGLContext qemu_egl_create_context(DisplayChangeListener *dcl,
6 QEMUGLParams *params)
8 EGLContext ctx;
9 EGLint ctx_att_core[] = {
10 EGL_CONTEXT_OPENGL_PROFILE_MASK, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
11 EGL_CONTEXT_CLIENT_VERSION, params->major_ver,
12 EGL_CONTEXT_MINOR_VERSION_KHR, params->minor_ver,
13 EGL_NONE
15 EGLint ctx_att_gles[] = {
16 EGL_CONTEXT_CLIENT_VERSION, params->major_ver,
17 EGL_CONTEXT_MINOR_VERSION_KHR, params->minor_ver,
18 EGL_NONE
20 bool gles = (qemu_egl_mode == DISPLAYGL_MODE_ES);
22 ctx = eglCreateContext(qemu_egl_display, qemu_egl_config,
23 eglGetCurrentContext(),
24 gles ? ctx_att_gles : ctx_att_core);
25 return ctx;
28 void qemu_egl_destroy_context(DisplayChangeListener *dcl, QEMUGLContext ctx)
30 eglDestroyContext(qemu_egl_display, ctx);
33 int qemu_egl_make_context_current(DisplayChangeListener *dcl,
34 QEMUGLContext ctx)
36 return eglMakeCurrent(qemu_egl_display,
37 EGL_NO_SURFACE, EGL_NO_SURFACE, ctx);
40 QEMUGLContext qemu_egl_get_current_context(DisplayChangeListener *dcl)
42 return eglGetCurrentContext();