26e72da39b9cf39ac67620396f923f97a4ac0c27
[platform/upstream/SDL.git] / src / video / tizen / SDL_tizenopengles.c
1 /*
2   Simple DirectMedia Layer
3   Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
4   Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
5
6   This software is provided 'as-is', without any express or implied
7   warranty.  In no event will the authors be held liable for any damages
8   arising from the use of this software.
9
10   Permission is granted to anyone to use this software for any purpose,
11   including commercial applications, and to alter it and redistribute it
12   freely, subject to the following restrictions:
13
14   1. The origin of this software must not be misrepresented; you must not
15      claim that you wrote the original software. If you use this software
16      in a product, an acknowledgment in the product documentation would be
17      appreciated but is not required.
18   2. Altered source versions must be plainly marked as such, and must not be
19      misrepresented as being the original software.
20   3. This notice may not be removed or altered from any source distribution.
21 */
22 #include "../../SDL_internal.h"
23
24 #if SDL_VIDEO_OPENGL_EGL
25
26 #include "SDL_tizenvideo.h"
27 #include "SDL_tizenopengles.h"
28 #include "SDL_tizenwindow.h"
29 #include "SDL_tizenevents_c.h"
30
31 /* EGL implementation of SDL OpenGL ES support */
32
33 int
34 Tizen_GLES_LoadLibrary(_THIS, const char *path)
35 {
36     int ret;
37
38     ret = SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)ecore_wl_display_get());
39     return ret;
40 }
41
42
43 SDL_GLContext
44 Tizen_GLES_CreateContext(_THIS, SDL_Window *window)
45 {
46     SDL_GLContext context;
47
48     context = SDL_EGL_CreateContext(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);
49     return context;
50 }
51
52 void
53 Tizen_GLES_SwapWindow(_THIS, SDL_Window *window)
54 {
55     SDL_WindowData* wdata = (SDL_WindowData*)window->driverdata;
56     if (wdata->received_rotation == 1) {
57         ecore_wl_window_rotation_change_done_send(wdata->window);
58         wdata->received_rotation = 0;
59     }
60
61     SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);
62 }
63
64
65 int
66 Tizen_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context)
67 {
68     int ret;
69
70     if (window && context) {
71         ret = SDL_EGL_MakeCurrent(_this, ((SDL_WindowData *) window->driverdata)->egl_surface, context);
72     } else {
73         ret = SDL_EGL_MakeCurrent(_this, NULL, NULL);
74     }
75
76     return ret;
77 }
78
79 void
80 Tizen_GLES_DeleteContext(_THIS, SDL_GLContext context)
81 {
82     SDL_EGL_DeleteContext(_this, context);
83 }
84
85 #endif /* SDL_VIDEO_DRIVER_TIZEN && SDL_VIDEO_OPENGL_EGL */
86
87 /* vi: set ts=4 sw=4 expandtab: */