]>
Commit | Line | Data |
---|---|---|
e16f4c87 | 1 | #include "qemu/osdep.h" |
1d48c9fd | 2 | #include "qemu/error-report.h" |
6c18744d GH |
3 | #include "ui/egl-context.h" |
4 | ||
5e79d516 | 5 | QEMUGLContext qemu_egl_create_context(DisplayGLCtx *dgc, |
6c18744d GH |
6 | QEMUGLParams *params) |
7 | { | |
8 | EGLContext ctx; | |
54d208ff | 9 | EGLint ctx_att_core[] = { |
bc8c946f GH |
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 | |
6c18744d | 14 | }; |
54d208ff GH |
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 | |
19 | }; | |
20 | bool gles = (qemu_egl_mode == DISPLAYGL_MODE_ES); | |
6c18744d GH |
21 | |
22 | ctx = eglCreateContext(qemu_egl_display, qemu_egl_config, | |
54d208ff GH |
23 | eglGetCurrentContext(), |
24 | gles ? ctx_att_gles : ctx_att_core); | |
6c18744d GH |
25 | return ctx; |
26 | } | |
27 | ||
5e79d516 | 28 | void qemu_egl_destroy_context(DisplayGLCtx *dgc, QEMUGLContext ctx) |
6c18744d GH |
29 | { |
30 | eglDestroyContext(qemu_egl_display, ctx); | |
31 | } | |
32 | ||
5e79d516 | 33 | int qemu_egl_make_context_current(DisplayGLCtx *dgc, |
6c18744d GH |
34 | QEMUGLContext ctx) |
35 | { | |
1d48c9fd MAL |
36 | if (!eglMakeCurrent(qemu_egl_display, |
37 | EGL_NO_SURFACE, EGL_NO_SURFACE, ctx)) { | |
38 | error_report("egl: eglMakeCurrent failed: %s", qemu_egl_get_error_string()); | |
39 | return -1; | |
40 | } | |
41 | ||
42 | return 0; | |
6c18744d | 43 | } |