2015-06-21 17:33:46 +02:00
|
|
|
/*
|
|
|
|
|
Simple DirectMedia Layer
|
2025-01-01 07:45:41 -08:00
|
|
|
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
|
2015-06-21 17:33:46 +02:00
|
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
|
warranty. In no event will the authors be held liable for any damages
|
|
|
|
|
arising from the use of this software.
|
|
|
|
|
|
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
|
|
|
including commercial applications, and to alter it and redistribute it
|
|
|
|
|
freely, subject to the following restrictions:
|
|
|
|
|
|
|
|
|
|
1. The origin of this software must not be misrepresented; you must not
|
|
|
|
|
claim that you wrote the original software. If you use this software
|
|
|
|
|
in a product, an acknowledgment in the product documentation would be
|
|
|
|
|
appreciated but is not required.
|
|
|
|
|
2. Altered source versions must be plainly marked as such, and must not be
|
|
|
|
|
misrepresented as being the original software.
|
|
|
|
|
3. This notice may not be removed or altered from any source distribution.
|
|
|
|
|
*/
|
2022-11-29 18:34:15 -08:00
|
|
|
#include "SDL_internal.h"
|
2015-06-21 17:33:46 +02:00
|
|
|
|
2023-03-29 21:49:01 +00:00
|
|
|
#if defined(SDL_VIDEO_DRIVER_ANDROID) && defined(SDL_VIDEO_OPENGL_EGL)
|
2015-06-21 17:33:46 +02:00
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Android SDL video driver implementation
|
2015-06-21 17:33:46 +02:00
|
|
|
|
|
|
|
|
#include "../SDL_egl_c.h"
|
|
|
|
|
#include "SDL_androidwindow.h"
|
|
|
|
|
|
|
|
|
|
#include "SDL_androidvideo.h"
|
2024-07-24 12:43:44 -07:00
|
|
|
#include "SDL_androidevents.h"
|
2016-12-02 02:25:12 -08:00
|
|
|
#include "SDL_androidgl.h"
|
2015-06-21 17:33:46 +02:00
|
|
|
#include "../../core/android/SDL_android.h"
|
|
|
|
|
|
|
|
|
|
#include <android/log.h>
|
|
|
|
|
|
|
|
|
|
#include <dlfcn.h>
|
|
|
|
|
|
2024-08-22 17:33:49 -07:00
|
|
|
bool Android_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context)
|
2019-06-28 16:05:20 +02:00
|
|
|
{
|
|
|
|
|
if (window && context) {
|
2024-07-16 11:09:18 -07:00
|
|
|
return SDL_EGL_MakeCurrent(_this, window->internal->egl_surface, context);
|
2019-06-28 16:05:20 +02:00
|
|
|
} else {
|
|
|
|
|
return SDL_EGL_MakeCurrent(_this, NULL, NULL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-23 11:29:41 -07:00
|
|
|
SDL_GLContext Android_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window)
|
2019-06-28 16:05:20 +02:00
|
|
|
{
|
2024-08-22 17:33:49 -07:00
|
|
|
SDL_GLContext result;
|
2019-06-28 16:38:42 +02:00
|
|
|
|
2024-08-22 17:33:49 -07:00
|
|
|
if (!Android_WaitActiveAndLockActivity()) {
|
2024-07-24 12:43:44 -07:00
|
|
|
return NULL;
|
|
|
|
|
}
|
2019-06-28 16:38:42 +02:00
|
|
|
|
2024-08-22 17:33:49 -07:00
|
|
|
result = SDL_EGL_CreateContext(_this, window->internal->egl_surface);
|
2019-06-28 16:38:42 +02:00
|
|
|
|
2024-07-23 20:55:24 -07:00
|
|
|
Android_UnlockActivityMutex();
|
2019-06-28 16:38:42 +02:00
|
|
|
|
2024-08-22 17:33:49 -07:00
|
|
|
return result;
|
2019-06-28 16:05:20 +02:00
|
|
|
}
|
2015-06-21 17:33:46 +02:00
|
|
|
|
2024-08-22 17:33:49 -07:00
|
|
|
bool Android_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
2015-06-21 17:33:46 +02:00
|
|
|
{
|
2024-08-22 17:33:49 -07:00
|
|
|
bool result;
|
2019-01-03 23:22:50 +01:00
|
|
|
|
2024-07-23 20:55:24 -07:00
|
|
|
Android_LockActivityMutex();
|
2019-01-03 23:22:50 +01:00
|
|
|
|
2015-06-21 17:33:46 +02:00
|
|
|
/* The following two calls existed in the original Java code
|
|
|
|
|
* If you happen to have a device that's affected by their removal,
|
2021-02-12 14:46:49 -05:00
|
|
|
* please report to our bug tracker. -- Gabriel
|
2015-06-21 17:33:46 +02:00
|
|
|
*/
|
2019-01-03 23:22:50 +01:00
|
|
|
|
2015-06-21 17:33:46 +02:00
|
|
|
/*_this->egl_data->eglWaitNative(EGL_CORE_NATIVE_ENGINE);
|
|
|
|
|
_this->egl_data->eglWaitGL();*/
|
2024-08-22 17:33:49 -07:00
|
|
|
result = SDL_EGL_SwapBuffers(_this, window->internal->egl_surface);
|
2019-01-03 23:22:50 +01:00
|
|
|
|
2024-07-23 20:55:24 -07:00
|
|
|
Android_UnlockActivityMutex();
|
2019-01-03 23:22:50 +01:00
|
|
|
|
2024-08-22 17:33:49 -07:00
|
|
|
return result;
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
|
|
2024-08-22 17:33:49 -07:00
|
|
|
bool Android_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path)
|
2022-11-30 12:51:59 -08:00
|
|
|
{
|
|
|
|
|
return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)0, 0);
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
#endif // SDL_VIDEO_DRIVER_ANDROID
|