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