mirror of
https://github.com/raysan5/raylib.git
synced 2025-09-25 04:28:30 +00:00
REVIEWED: Reorganize functions
`TakeScreenshot()` moved to `rcore.c`
This commit is contained in:
@@ -137,7 +137,7 @@ static void CursorEnterCallback(GLFWwindow *window, int enter);
|
||||
// NOTE: Functions declaration is provided by raylib.h
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Definition
|
||||
// Module Functions Definition: Window and Graphics Device
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Initialize window and OpenGL context
|
||||
@@ -1168,6 +1168,16 @@ void DisableCursor(void)
|
||||
CORE.Input.Mouse.cursorHidden = true;
|
||||
}
|
||||
|
||||
// Swap back buffer with front buffer (screen drawing)
|
||||
void SwapScreenBuffer(void)
|
||||
{
|
||||
glfwSwapBuffers(platform.handle);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Definition: Misc
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Get elapsed time measure in seconds since InitTimer()
|
||||
double GetTime(void)
|
||||
{
|
||||
@@ -1175,30 +1185,6 @@ double GetTime(void)
|
||||
return time;
|
||||
}
|
||||
|
||||
// Takes a screenshot of current screen (saved a .png)
|
||||
// WARNING: This function requires [rtextures] module functionality
|
||||
void TakeScreenshot(const char *fileName)
|
||||
{
|
||||
#if defined(SUPPORT_MODULE_RTEXTURES)
|
||||
// Security check to (partially) avoid malicious code
|
||||
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.
|
||||
@@ -1341,12 +1327,6 @@ Vector2 GetTouchPosition(int index)
|
||||
return position;
|
||||
}
|
||||
|
||||
// Swap back buffer with front buffer (screen drawing)
|
||||
void SwapScreenBuffer(void)
|
||||
{
|
||||
glfwSwapBuffers(platform.handle);
|
||||
}
|
||||
|
||||
// Register all input events
|
||||
void PollInputEvents(void)
|
||||
{
|
||||
|
Reference in New Issue
Block a user