diff options
| author | Ray <[email protected]> | 2023-10-09 09:45:57 +0200 |
|---|---|---|
| committer | Ray <[email protected]> | 2023-10-09 09:45:57 +0200 |
| commit | 682992e868ffd97fa25d432e15ec209a161c26d9 (patch) | |
| tree | 2c19b1e5087f2d23b894b1117a6ec74b9856fb48 /src/rcore_android.c | |
| parent | 5ed7717f0d9e524b72f1bddc6fcd3e2e5f32e217 (diff) | |
| download | raylib-682992e868ffd97fa25d432e15ec209a161c26d9.tar.gz raylib-682992e868ffd97fa25d432e15ec209a161c26d9.zip | |
REVIEWED: Reorganize functions
`TakeScreenshot()` moved to `rcore.c`
Diffstat (limited to 'src/rcore_android.c')
| -rw-r--r-- | src/rcore_android.c | 44 |
1 files changed, 15 insertions, 29 deletions
diff --git a/src/rcore_android.c b/src/rcore_android.c index ad7a905c..a7c8f330 100644 --- a/src/rcore_android.c +++ b/src/rcore_android.c @@ -133,6 +133,10 @@ struct android_app *GetAndroidApp(void) return platform.app; } +//---------------------------------------------------------------------------------- +// Module Functions Definition: Window and Graphics Device +//---------------------------------------------------------------------------------- + // Initialize window and OpenGL context // NOTE: data parameter could be used to pass any kind of required data to the initialization void InitWindow(int width, int height, const char *title) @@ -563,6 +567,16 @@ void DisableCursor(void) CORE.Input.Mouse.cursorHidden = true; } +// Swap back buffer with front buffer (screen drawing) +void SwapScreenBuffer(void) +{ + eglSwapBuffers(platform.device, platform.surface); +} + +//---------------------------------------------------------------------------------- +// Module Functions Definition: Misc +//---------------------------------------------------------------------------------- + // Get elapsed time measure in seconds since InitTimer() double GetTime(void) { @@ -576,29 +590,6 @@ double GetTime(void) return time; } -// Takes a screenshot of current screen (saved a .png) -void TakeScreenshot(const char *fileName) -{ -#if defined(SUPPORT_MODULE_RTEXTURES) - // Security check to (partially) avoid malicious code on PLATFORM_ANDROID - if (strchr(fileName, '\'') != NULL) { TRACELOG(LOG_WARNING, "SYSTEM: Provided fileName could be potentially malicious, avoid [\'] character"); return; } - - Vector2 scale = GetWindowScaleDPI(); - unsigned char *imgData = rlReadScreenPixels((int)((float)CORE.Window.render.width*scale.x), (int)((float)CORE.Window.render.height*scale.y)); - Image image = { imgData, (int)((float)CORE.Window.render.width*scale.x), (int)((float)CORE.Window.render.height*scale.y), 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 }; - - char path[2048] = { 0 }; - strcpy(path, TextFormat("%s/%s", CORE.Storage.basePath, fileName)); - - ExportImage(image, path); // WARNING: Module required: rtextures - RL_FREE(imgData); - - TRACELOG(LOG_INFO, "SYSTEM: [%s] Screenshot taken successfully", path); -#else - TRACELOG(LOG_WARNING,"IMAGE: ExportImage() requires module: rtextures"); -#endif -} - // Open URL with default system browser (if available) // NOTE: This function is only safe to use if you control the URL given. // A user could craft a malicious string performing another action. @@ -726,12 +717,6 @@ Vector2 GetTouchPosition(int index) return position; } -// Swap back buffer with front buffer (screen drawing) -void SwapScreenBuffer(void) -{ - eglSwapBuffers(platform.device, platform.surface); -} - // Register all input events void PollInputEvents(void) { @@ -787,6 +772,7 @@ void PollInputEvents(void) } } + //---------------------------------------------------------------------------------- // Module Internal Functions Definition //---------------------------------------------------------------------------------- |
