[SDL_Tizen] Delete build warnings
[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_log.h"
27 #include "SDL_hints.h"
28 #include "SDL_tizenopengles.h"
29 #include "SDL_tizenvideo.h"
30 #include "SDL_tizenwindow.h"
31
32 #include "../../events/SDL_windowevents_c.h"
33
34 #if SDL_VIDEO_OPENGL
35 #include "SDL_opengl.h"
36 #endif /* SDL_VIDEO_OPENGL */
37
38 #if SDL_VIDEO_OPENGL_ES
39 #include "SDL_opengles.h"
40 #endif /* SDL_VIDEO_OPENGL_ES */
41
42 /* GL and GLES2 headers conflict on Linux 32 bits */
43 #if SDL_VIDEO_OPENGL_ES2 && !SDL_VIDEO_OPENGL
44 #include "SDL_opengles2.h"
45 #endif /* SDL_VIDEO_OPENGL_ES2 && !SDL_VIDEO_OPENGL */
46
47 int
48 Tizen_GLES_LoadLibrary(_THIS, const char *path)
49 {
50     int ret;
51
52     ret = SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)ecore_wl_display_get());
53     return ret;
54 }
55
56 SDL_GLContext
57 Tizen_GLES_CreateContext(_THIS, SDL_Window *window)
58 {
59     SDL_GLContext context = SDL_EGL_CreateContext(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);
60     return context;
61 }
62
63 void
64 Tizen_GLES_SwapWindow(_THIS, SDL_Window *window)
65 {
66     SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);
67     SDL_WindowData* wdata = (SDL_WindowData*)window->driverdata;
68     if (wdata->received_rotation == 1) {
69         Tizen_rotate_update(wdata);
70         ecore_wl_window_rotation_change_done_send(wdata->window);
71         wdata->received_rotation = 0;
72     }
73 }
74
75 int
76 Tizen_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context)
77 {
78     int ret;
79
80     if (window && context) {
81         ret = SDL_EGL_MakeCurrent(_this, ((SDL_WindowData *) window->driverdata)->egl_surface, context);
82     }
83     else if(!window && context) {
84         ret = SDL_EGL_MakeCurrent(_this, NULL, context);
85     }
86     else {
87         ret = SDL_EGL_MakeCurrent(_this, NULL, NULL);
88     }
89
90     return ret;
91 }
92
93 void
94 Tizen_GLES_DeleteContext(_THIS, SDL_GLContext context)
95 {
96     SDL_EGL_DeleteContext(_this, context);
97 }
98
99 int
100 Tizen_GLES_GetAlphaSize(_THIS)
101 {
102     EGLint alpha_size = 0;
103
104     if (!_this->egl_data) {
105         /* The EGL library wasn't loaded, SDL_GetError() should have info */
106         SDL_Log("egl_data is NULL");
107         return 0;
108     }
109
110     if (_this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display,
111                                             _this->egl_data->egl_config,
112                                             EGL_ALPHA_SIZE,
113                                             &alpha_size) == EGL_FALSE || !alpha_size) {
114         alpha_size = 0;
115     }
116     return alpha_size;
117 }
118
119 #endif /* SDL_VIDEO_DRIVER_TIZEN && SDL_VIDEO_OPENGL_EGL */
120
121 /* vi: set ts=4 sw=4 expandtab: */