mirror of
https://github.com/raysan5/raylib.git
synced 2026-11-25 09:01:47 -05:00
Compare commits
5 Commits
4880766618
...
fa14dc7792
| Author | SHA1 | Date | |
|---|---|---|---|
| fa14dc7792 | |||
| 88b10152e9 | |||
| 867376c6cb | |||
| b7011ad4d4 | |||
| b4a4f9d360 |
@ -26,15 +26,16 @@ PLATFORM ?= PLATFORM_ANDROID
|
|||||||
RAYLIB_PATH ?= ..\..
|
RAYLIB_PATH ?= ..\..
|
||||||
|
|
||||||
# Define Android architecture (armeabi-v7a, arm64-v8a, x86, x86-64) and API version
|
# Define Android architecture (armeabi-v7a, arm64-v8a, x86, x86-64) and API version
|
||||||
# Starting in 2019 using ARM64 is mandatory for published apps,
|
# NOTE: Starting in 2019 using ARM64 is mandatory for published apps
|
||||||
# Starting on August 2020, minimum required target API is Android 10 (API level 29)
|
# NOTE: Starting on August 2020, minimum required target API is Android 10 (API level 29)
|
||||||
|
# NOTE: Android 13 (API level 33), released on August 2022 should be a safe bet
|
||||||
ANDROID_ARCH ?= ARM64
|
ANDROID_ARCH ?= ARM64
|
||||||
ANDROID_API_VERSION = 29
|
ANDROID_API_VERSION = 33
|
||||||
|
|
||||||
# Android required path variables
|
# Android required path variables
|
||||||
# NOTE: Starting with Android NDK r21, no more toolchain generation is required, NDK is the toolchain on itself
|
# NOTE: Starting with Android NDK r21, no more toolchain generation is required, NDK is the toolchain on itself
|
||||||
ifeq ($(OS),Windows_NT)
|
ifeq ($(OS),Windows_NT)
|
||||||
ANDROID_NDK = C:/android-ndk
|
ANDROID_NDK = C:/android-ndk-r30
|
||||||
ANDROID_TOOLCHAIN = $(ANDROID_NDK)/toolchains/llvm/prebuilt/windows-x86_64
|
ANDROID_TOOLCHAIN = $(ANDROID_NDK)/toolchains/llvm/prebuilt/windows-x86_64
|
||||||
else
|
else
|
||||||
ANDROID_NDK ?= /usr/lib/android/ndk
|
ANDROID_NDK ?= /usr/lib/android/ndk
|
||||||
@ -55,10 +56,10 @@ ifeq ($(ANDROID_ARCH),x86_64)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
# Required path variables
|
# Required path variables
|
||||||
# NOTE: JAVA_HOME must be set to JDK (using OpenJDK 13)
|
# NOTE: JAVA_HOME must be set to JDK (using OpenJDK 27.0.1.1)
|
||||||
JAVA_HOME ?= C:/open-jdk
|
JAVA_HOME ?= C:/open-jdk-27.0.1.1
|
||||||
ANDROID_HOME ?= C:/android-sdk
|
ANDROID_HOME ?= C:/android-sdk
|
||||||
ANDROID_BUILD_TOOLS ?= $(ANDROID_HOME)/build-tools/29.0.3
|
ANDROID_BUILD_TOOLS ?= $(ANDROID_HOME)/build-tools/36.0.0
|
||||||
ANDROID_PLATFORM_TOOLS = $(ANDROID_HOME)/platform-tools
|
ANDROID_PLATFORM_TOOLS = $(ANDROID_HOME)/platform-tools
|
||||||
|
|
||||||
# Android project configuration variables
|
# Android project configuration variables
|
||||||
@ -137,7 +138,9 @@ CFLAGS += -ffunction-sections -funwind-tables -fstack-protector-strong -fPIC
|
|||||||
# Compiler options for the linker
|
# Compiler options for the linker
|
||||||
CFLAGS += -Wall -Wa,--noexecstack -Wformat -Werror=format-security -no-canonical-prefixes
|
CFLAGS += -Wall -Wa,--noexecstack -Wformat -Werror=format-security -no-canonical-prefixes
|
||||||
# Preprocessor macro definitions
|
# Preprocessor macro definitions
|
||||||
CFLAGS += -DANDROID -DPLATFORM_ANDROID -D__ANDROID_API__=$(ANDROID_API_VERSION)
|
CFLAGS += -DANDROID -DPLATFORM_ANDROID
|
||||||
|
# NOTE: API level is already implicit on compiler call, no need for redefinition
|
||||||
|
#-D__ANDROID_API__=$(ANDROID_API_VERSION)
|
||||||
|
|
||||||
# Paths containing required header files
|
# Paths containing required header files
|
||||||
INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(NATIVE_APP_GLUE_PATH)
|
INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(NATIVE_APP_GLUE_PATH)
|
||||||
|
|||||||
@ -52,6 +52,7 @@ int main(void)
|
|||||||
int frameCount = 0;
|
int frameCount = 0;
|
||||||
|
|
||||||
Vector2 glyphPosition[MAX_TEXT_LENGTH] = { 0 };
|
Vector2 glyphPosition[MAX_TEXT_LENGTH] = { 0 };
|
||||||
|
Vector2 glyphDelta[MAX_TEXT_LENGTH] = { 0 };
|
||||||
unsigned char glyphAlpha[MAX_TEXT_LENGTH] = { 0 };
|
unsigned char glyphAlpha[MAX_TEXT_LENGTH] = { 0 };
|
||||||
|
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60);
|
||||||
@ -66,8 +67,8 @@ int main(void)
|
|||||||
|
|
||||||
if (IsKeyPressed(KEY_S)) text.delta = Clamp(text.delta - 2.0f, 10.0f, 60.0f);
|
if (IsKeyPressed(KEY_S)) text.delta = Clamp(text.delta - 2.0f, 10.0f, 60.0f);
|
||||||
else if (IsKeyPressed(KEY_W)) text.delta = Clamp(text.delta + 2.0f, 10.0f, 60.0f);
|
else if (IsKeyPressed(KEY_W)) text.delta = Clamp(text.delta + 2.0f, 10.0f, 60.0f);
|
||||||
if (IsKeyPressed(KEY_A)) text.duration = (int) Clamp((float) text.duration - 5.0f, 20.0f, 120.0f);
|
if (IsKeyPressed(KEY_A)) text.duration = (int) Clamp((float) text.duration - 5.0f, 10.0f, 120.0f);
|
||||||
else if (IsKeyPressed(KEY_D)) text.duration = (int) Clamp((float) text.duration + 5.0f, 20.0f, 120.0f);
|
else if (IsKeyPressed(KEY_D)) text.duration = (int) Clamp((float) text.duration + 5.0f, 10.0f, 120.0f);
|
||||||
if (IsKeyPressed(KEY_Z)) text.offset = Clamp(text.offset - 1.0f, 0.0f, 15.0f);
|
if (IsKeyPressed(KEY_Z)) text.offset = Clamp(text.offset - 1.0f, 0.0f, 15.0f);
|
||||||
else if (IsKeyPressed(KEY_X)) text.offset = Clamp(text.offset + 1.0f, 0.0f, 15.0f);
|
else if (IsKeyPressed(KEY_X)) text.offset = Clamp(text.offset + 1.0f, 0.0f, 15.0f);
|
||||||
if (IsKeyPressed(KEY_Q)) currentAnimation = currentAnimation? currentAnimation - 1 : animationsSize - 1;
|
if (IsKeyPressed(KEY_Q)) currentAnimation = currentAnimation? currentAnimation - 1 : animationsSize - 1;
|
||||||
@ -107,18 +108,21 @@ int main(void)
|
|||||||
for (unsigned int i = 0; i < TextLength(text.str); i++)
|
for (unsigned int i = 0; i < TextLength(text.str); i++)
|
||||||
{
|
{
|
||||||
float time = (int) (frameCount + i*text.offset)%(int)text.duration;
|
float time = (int) (frameCount + i*text.offset)%(int)text.duration;
|
||||||
float deltaX = (float) GetRandomValue(-text.delta/10, text.delta/10);
|
if (time <= 1.0f) // Actives once every `text.duration` frames
|
||||||
float deltaY = (float) GetRandomValue(-text.delta/10, text.delta/10);
|
{
|
||||||
|
glyphDelta[i].x = (float) GetRandomValue(-text.delta/10, text.delta/10);
|
||||||
|
glyphDelta[i].y = (float) GetRandomValue(-text.delta/10, text.delta/10);
|
||||||
|
}
|
||||||
|
|
||||||
if (time < (text.duration/2))
|
if (time < (text.duration/2))
|
||||||
{
|
{
|
||||||
glyphPosition[i].x = EaseLinearNone(time, glyphPosition[i].x, deltaX, text.duration/2);
|
glyphPosition[i].x = EaseLinearNone(time, glyphPosition[i].x, glyphDelta[i].x, text.duration/2);
|
||||||
glyphPosition[i].y = EaseLinearNone(time, text.position.y, deltaY, text.duration/2);
|
glyphPosition[i].y = EaseLinearNone(time, text.position.y, glyphDelta[i].y, text.duration/2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
glyphPosition[i].x = EaseLinearNone(time - text.duration/2, glyphPosition[i].x + deltaX, -deltaX, text.duration/2);
|
glyphPosition[i].x = EaseLinearNone(time - text.duration/2, glyphPosition[i].x + glyphDelta[i].x, -glyphDelta[i].x, text.duration/2);
|
||||||
glyphPosition[i].y = EaseLinearNone(time - text.duration/2, text.position.y + deltaY, -deltaY, text.duration/2);
|
glyphPosition[i].y = EaseLinearNone(time - text.duration/2, text.position.y + glyphDelta[i].y, -glyphDelta[i].y, text.duration/2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|||||||
@ -706,6 +706,16 @@ const char *GetClipboardText(void)
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set clipboard image content
|
||||||
|
bool SetClipboardImage(Image image)
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
TRACELOG(LOG_WARNING, "SetClipboardImage() not implemented on target platform");
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// Get clipboard image
|
// Get clipboard image
|
||||||
Image GetClipboardImage(void)
|
Image GetClipboardImage(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -59,6 +59,7 @@
|
|||||||
typedef struct HWND__ *HWND;
|
typedef struct HWND__ *HWND;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define WIN32_CLIPBOARD_IMPLEMENTATION
|
||||||
#include "../external/win32_clipboard.h" // Clipboard image copy-paste
|
#include "../external/win32_clipboard.h" // Clipboard image copy-paste
|
||||||
|
|
||||||
#define GLFW_EXPOSE_NATIVE_WIN32
|
#define GLFW_EXPOSE_NATIVE_WIN32
|
||||||
@ -796,8 +797,7 @@ void *GetWindowHandle(void)
|
|||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
handle = glfwGetWin32Window(platform.handle); // Type: HWND
|
handle = glfwGetWin32Window(platform.handle); // Type: HWND
|
||||||
#endif
|
#elif defined(__linux__)
|
||||||
#if defined(__linux__)
|
|
||||||
#if defined(_GLFW_WAYLAND)
|
#if defined(_GLFW_WAYLAND)
|
||||||
#if defined(_GLFW_X11)
|
#if defined(_GLFW_X11)
|
||||||
int platformID = glfwGetPlatform();
|
int platformID = glfwGetPlatform();
|
||||||
@ -818,8 +818,7 @@ void *GetWindowHandle(void)
|
|||||||
platform.windowHandleX11 = glfwGetX11Window(platform.handle);
|
platform.windowHandleX11 = glfwGetX11Window(platform.handle);
|
||||||
handle = &platform.windowHandleX11;
|
handle = &platform.windowHandleX11;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#elif defined(__APPLE__)
|
||||||
#if defined(__APPLE__)
|
|
||||||
handle = (void *)glfwGetCocoaWindow(platform.handle); // Type: NSWindow*
|
handle = (void *)glfwGetCocoaWindow(platform.handle); // Type: NSWindow*
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1087,6 +1086,23 @@ const char *GetClipboardText(void)
|
|||||||
return glfwGetClipboardString(platform.handle);
|
return glfwGetClipboardString(platform.handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set clipboard image content
|
||||||
|
bool SetClipboardImage(Image image)
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
|
||||||
|
#elif defined(__linux__)
|
||||||
|
|
||||||
|
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// Get clipboard image
|
// Get clipboard image
|
||||||
Image GetClipboardImage(void)
|
Image GetClipboardImage(void)
|
||||||
{
|
{
|
||||||
@ -1094,7 +1110,6 @@ Image GetClipboardImage(void)
|
|||||||
|
|
||||||
#if SUPPORT_CLIPBOARD_IMAGE && SUPPORT_MODULE_RTEXTURES
|
#if SUPPORT_CLIPBOARD_IMAGE && SUPPORT_MODULE_RTEXTURES
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
|
||||||
unsigned int dataSize = 0;
|
unsigned int dataSize = 0;
|
||||||
void *bmpData = NULL;
|
void *bmpData = NULL;
|
||||||
int width = 0;
|
int width = 0;
|
||||||
@ -1106,13 +1121,10 @@ Image GetClipboardImage(void)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
image = LoadImageFromMemory(".bmp", (const unsigned char *)bmpData, (int)dataSize);
|
image = LoadImageFromMemory(".bmp", (const unsigned char *)bmpData, (int)dataSize);
|
||||||
|
|
||||||
RL_FREE(bmpData);
|
RL_FREE(bmpData);
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(__linux__) && defined(_GLFW_X11)
|
#elif defined(__linux__) && defined(_GLFW_X11)
|
||||||
// REF: https://github.com/ColleagueRiley/Clipboard-Copy-Paste/blob/main/x11.c
|
// REF: https://github.com/ColleagueRiley/Clipboard-Copy-Paste/blob/main/x11.
|
||||||
|
|
||||||
static Atom clipboard = 0;
|
static Atom clipboard = 0;
|
||||||
static Atom targetType = 0;
|
static Atom targetType = 0;
|
||||||
static Atom property = 0;
|
static Atom property = 0;
|
||||||
@ -1150,10 +1162,9 @@ Image GetClipboardImage(void)
|
|||||||
image = LoadImageFromMemory(".png", data, (int)nitems);
|
image = LoadImageFromMemory(".png", data, (int)nitems);
|
||||||
XFree(data);
|
XFree(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform");
|
TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform");
|
||||||
#endif // _WIN32
|
#endif
|
||||||
#else
|
#else
|
||||||
TRACELOG(LOG_WARNING, "Clipboard image: SUPPORT_CLIPBOARD_IMAGE requires SUPPORT_MODULE_RTEXTURES to work properly");
|
TRACELOG(LOG_WARNING, "Clipboard image: SUPPORT_CLIPBOARD_IMAGE requires SUPPORT_MODULE_RTEXTURES to work properly");
|
||||||
#endif // SUPPORT_CLIPBOARD_IMAGE
|
#endif // SUPPORT_CLIPBOARD_IMAGE
|
||||||
@ -1245,11 +1256,9 @@ void OpenURL(const char *url)
|
|||||||
char *cmd = (char *)RL_CALLOC(strlen(url) + 16, sizeof(char));
|
char *cmd = (char *)RL_CALLOC(strlen(url) + 16, sizeof(char));
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
sprintf(cmd, "explorer \"%s\"", url);
|
sprintf(cmd, "explorer \"%s\"", url);
|
||||||
#endif
|
#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
|
||||||
sprintf(cmd, "xdg-open '%s'", url); // Alternatives: firefox, x-www-browser
|
sprintf(cmd, "xdg-open '%s'", url); // Alternatives: firefox, x-www-browser
|
||||||
#endif
|
#elif defined(__APPLE__)
|
||||||
#if defined(__APPLE__)
|
|
||||||
sprintf(cmd, "open '%s'", url);
|
sprintf(cmd, "open '%s'", url);
|
||||||
#endif
|
#endif
|
||||||
int result = system(cmd);
|
int result = system(cmd);
|
||||||
@ -2277,8 +2286,4 @@ static void JoystickCallback(int jid, int event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
# define WIN32_CLIPBOARD_IMPLEMENTATION
|
|
||||||
# include "../external/win32_clipboard.h"
|
|
||||||
#endif
|
|
||||||
// EOF
|
// EOF
|
||||||
|
|||||||
@ -1326,8 +1326,7 @@ Image GetClipboardImage(void)
|
|||||||
Image image = { 0 };
|
Image image = { 0 };
|
||||||
|
|
||||||
#if SUPPORT_CLIPBOARD_IMAGE && SUPPORT_MODULE_RTEXTURES
|
#if SUPPORT_CLIPBOARD_IMAGE && SUPPORT_MODULE_RTEXTURES
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32
|
||||||
|
|
||||||
unsigned int dataSize = 0;
|
unsigned int dataSize = 0;
|
||||||
void *fileData = NULL;
|
void *fileData = NULL;
|
||||||
|
|
||||||
@ -1339,12 +1338,9 @@ Image GetClipboardImage(void)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
image = LoadImageFromMemory(".bmp", (const unsigned char *)fileData, (int)dataSize);
|
image = LoadImageFromMemory(".bmp", (const unsigned char *)fileData, (int)dataSize);
|
||||||
|
|
||||||
RL_FREE(fileData);
|
RL_FREE(fileData);
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(__linux__) && defined(DRGFW_X11)
|
#elif defined(__linux__) && defined(DRGFW_X11)
|
||||||
|
|
||||||
// REF: https://github.com/ColleagueRiley/Clipboard-Copy-Paste/blob/main/x11.c
|
// REF: https://github.com/ColleagueRiley/Clipboard-Copy-Paste/blob/main/x11.c
|
||||||
Display *dpy = XOpenDisplay(NULL);
|
Display *dpy = XOpenDisplay(NULL);
|
||||||
if (!dpy) return image;
|
if (!dpy) return image;
|
||||||
@ -2042,8 +2038,8 @@ static KeyboardKey ConvertScancodeToKey(u32 keycode)
|
|||||||
return (KeyboardKey)RGFW_keyConvertTable[keycode];
|
return (KeyboardKey)RGFW_keyConvertTable[keycode];
|
||||||
}
|
}
|
||||||
|
|
||||||
// assign mouse to touches
|
// Assign mouse input events to touches
|
||||||
// 0-TOUCH_ACTION_UP, 1-TOUCH_ACTION_DOWN, 2-TOUCH_ACTION_MOVE
|
// NOTE: 0-TOUCH_ACTION_UP, 1-TOUCH_ACTION_DOWN, 2-TOUCH_ACTION_MOVE
|
||||||
void RemapMouseToTouch(int touchAction)
|
void RemapMouseToTouch(int touchAction)
|
||||||
{
|
{
|
||||||
#if SUPPORT_GESTURES_SYSTEM
|
#if SUPPORT_GESTURES_SYSTEM
|
||||||
|
|||||||
@ -1200,6 +1200,16 @@ const char *GetClipboardText(void)
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set clipboard image content
|
||||||
|
bool SetClipboardImage(Image image)
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
// TODO: bool SDL_SetClipboardData(SDL_ClipboardDataCallback callback, SDL_ClipboardCleanupCallback cleanup, void *userdata, const char *const *mime_types, size_t num_mime_types);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// Get clipboard image
|
// Get clipboard image
|
||||||
Image GetClipboardImage(void)
|
Image GetClipboardImage(void)
|
||||||
{
|
{
|
||||||
@ -1245,7 +1255,6 @@ Image GetClipboardImage(void)
|
|||||||
if (fileData)
|
if (fileData)
|
||||||
{
|
{
|
||||||
image = LoadImageFromMemory(imageExtensions[i], fileData, (int)dataSize);
|
image = LoadImageFromMemory(imageExtensions[i], fileData, (int)dataSize);
|
||||||
|
|
||||||
SDL_free(fileData);
|
SDL_free(fileData);
|
||||||
|
|
||||||
if (IsImageValid(image))
|
if (IsImageValid(image))
|
||||||
|
|||||||
@ -91,6 +91,14 @@ typedef enum MONITOR_DPI_TYPE {
|
|||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if SUPPORT_CLIPBOARD_IMAGE && SUPPORT_MODULE_RTEXTURES
|
||||||
|
#define WIN32_CLIPBOARD_IMPLEMENTATION
|
||||||
|
#define WINUSER_ALREADY_INCLUDED
|
||||||
|
#define WINBASE_ALREADY_INCLUDED
|
||||||
|
#define WINGDI_ALREADY_INCLUDED
|
||||||
|
#include "../external/win32_clipboard.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Types and Structures Definition
|
// Types and Structures Definition
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
@ -1417,13 +1425,60 @@ const char *GetClipboardText(void)
|
|||||||
return platform.clipboardText;
|
return platform.clipboardText;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SUPPORT_CLIPBOARD_IMAGE && SUPPORT_MODULE_RTEXTURES
|
// Set clipboard image content
|
||||||
#define WIN32_CLIPBOARD_IMPLEMENTATION
|
bool SetClipboardImage(Image image)
|
||||||
#define WINUSER_ALREADY_INCLUDED
|
{
|
||||||
#define WINBASE_ALREADY_INCLUDED
|
bool result = false;
|
||||||
#define WINGDI_ALREADY_INCLUDED
|
|
||||||
#include "../external/win32_clipboard.h"
|
BOOL opened = OpenClipboard(NULL);
|
||||||
#endif
|
if (opened)
|
||||||
|
{
|
||||||
|
EmptyClipboard();
|
||||||
|
|
||||||
|
Image imCopy = { 0 };
|
||||||
|
bool useCopy = false;
|
||||||
|
if (image.format != PIXELFORMAT_UNCOMPRESSED_R8G8B8A8)
|
||||||
|
{
|
||||||
|
// Make sure data is RGBA 32bit
|
||||||
|
imCopy = ImageCopy(image);
|
||||||
|
ImageFormat(&imCopy, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8);
|
||||||
|
useCopy = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate bitmap information size.
|
||||||
|
BITMAPINFOHEADER header = { 0 };
|
||||||
|
header.biSize = sizeof(BITMAPINFOHEADER);
|
||||||
|
header.biWidth = image.width;
|
||||||
|
header.biHeight = -image.height; // Top-down bitmap
|
||||||
|
header.biPlanes = 1;
|
||||||
|
header.biBitCount = 32;
|
||||||
|
header.biCompression = BI_RGB;
|
||||||
|
header.biSizeImage = image.width*image.height*4;
|
||||||
|
|
||||||
|
SIZE_T size = sizeof(header) + header.biSizeImage;
|
||||||
|
|
||||||
|
HGLOBAL memory = GlobalAlloc(GMEM_MOVEABLE, size);
|
||||||
|
|
||||||
|
if (memory)
|
||||||
|
{
|
||||||
|
BYTE *data = (BYTE *)GlobalLock(memory);
|
||||||
|
|
||||||
|
memcpy(data, &header, sizeof(header));
|
||||||
|
memcpy(data + sizeof(header), useCopy? imCopy.data : image.data, header.biSizeImage);
|
||||||
|
|
||||||
|
GlobalUnlock(memory);
|
||||||
|
|
||||||
|
HANDLE clipset = SetClipboardData(CF_DIB, memory);
|
||||||
|
if (clipset == NULL) GlobalFree(memory);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (useCopy) UnloadImage(imCopy);
|
||||||
|
|
||||||
|
CloseClipboard();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// Get clipboard image
|
// Get clipboard image
|
||||||
Image GetClipboardImage(void)
|
Image GetClipboardImage(void)
|
||||||
@ -1446,7 +1501,7 @@ Image GetClipboardImage(void)
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
TRACELOG(LOG_WARNING, "Clipboard image: SUPPORT_CLIPBOARD_IMAGE requires SUPPORT_MODULE_RTEXTURES to work properly");
|
TRACELOG(LOG_WARNING, "Clipboard image: SUPPORT_CLIPBOARD_IMAGE requires SUPPORT_MODULE_RTEXTURES to work properly");
|
||||||
#endif // SUPPORT_CLIPBOARD_IMAGE
|
#endif
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
@ -1777,7 +1832,11 @@ HGLRC InitOpenGL(HWND hwnd, HDC hdc)
|
|||||||
HGLRC tempContext = wglCreateContext(dummyHDC);
|
HGLRC tempContext = wglCreateContext(dummyHDC);
|
||||||
//if (!tempContext) { TRACELOG(LOG_ERROR, "%s failed, error=%lu", "wglCreateContext", GetLastError()); return -1; }
|
//if (!tempContext) { TRACELOG(LOG_ERROR, "%s failed, error=%lu", "wglCreateContext", GetLastError()); return -1; }
|
||||||
BOOL result = wglMakeCurrent(dummyHDC, tempContext);
|
BOOL result = wglMakeCurrent(dummyHDC, tempContext);
|
||||||
//if (!result) { TRACELOG(LOG_ERROR, "%s failed, error=%lu", "wglMakeCurrent", GetLastError()); return -1; }
|
if (!result)
|
||||||
|
{
|
||||||
|
TRACELOG(LOG_ERROR, "GL: Context failed to be set as current, error code: %lu", GetLastError());
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// Load WGL extension entry points
|
// Load WGL extension entry points
|
||||||
wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");
|
wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");
|
||||||
|
|||||||
@ -555,6 +555,16 @@ const char *GetClipboardText(void)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set clipboard image content
|
||||||
|
bool SetClipboardImage(Image image)
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
TRACELOG(LOG_WARNING, "SetClipboardImage() not implemented on target platform");
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// Get clipboard image
|
// Get clipboard image
|
||||||
Image GetClipboardImage(void)
|
Image GetClipboardImage(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -308,6 +308,16 @@ const char *GetClipboardText(void)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set clipboard image content
|
||||||
|
bool SetClipboardImage(Image image)
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
TRACELOG(LOG_WARNING, "SetClipboardImage() not implemented on target platform");
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// Get clipboard image
|
// Get clipboard image
|
||||||
Image GetClipboardImage(void)
|
Image GetClipboardImage(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -287,6 +287,16 @@ const char *GetClipboardText(void)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set clipboard image content
|
||||||
|
bool SetClipboardImage(Image image)
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
TRACELOG(LOG_WARNING, "SetClipboardImage() not implemented on target platform");
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// Get clipboard image
|
// Get clipboard image
|
||||||
Image GetClipboardImage(void)
|
Image GetClipboardImage(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -883,9 +883,20 @@ EM_JS(unsigned char *, GetLastPastedImage, (int *width, int *height), {
|
|||||||
const char *GetClipboardText(void)
|
const char *GetClipboardText(void)
|
||||||
{
|
{
|
||||||
RequestClipboardData();
|
RequestClipboardData();
|
||||||
|
|
||||||
return GetLastPastedText();
|
return GetLastPastedText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set clipboard image content
|
||||||
|
bool SetClipboardImage(Image image)
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
TRACELOG(LOG_WARNING, "SetClipboardImage() not implemented on target platform");
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// Get clipboard image
|
// Get clipboard image
|
||||||
Image GetClipboardImage(void)
|
Image GetClipboardImage(void)
|
||||||
{
|
{
|
||||||
@ -894,6 +905,7 @@ Image GetClipboardImage(void)
|
|||||||
int height = 0;
|
int height = 0;
|
||||||
|
|
||||||
RequestClipboardData();
|
RequestClipboardData();
|
||||||
|
|
||||||
unsigned char *data = GetLastPastedImage(&width, &height);
|
unsigned char *data = GetLastPastedImage(&width, &height);
|
||||||
|
|
||||||
if (data != NULL)
|
if (data != NULL)
|
||||||
|
|||||||
@ -907,6 +907,16 @@ const char *GetClipboardText(void)
|
|||||||
return GetLastPastedText();
|
return GetLastPastedText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set clipboard image content
|
||||||
|
bool SetClipboardImage(Image image)
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
TRACELOG(LOG_WARNING, "SetClipboardImage() not implemented on target platform");
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// Get clipboard image
|
// Get clipboard image
|
||||||
Image GetClipboardImage(void)
|
Image GetClipboardImage(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1031,6 +1031,7 @@ RLAPI Vector2 GetWindowScaleDPI(void); // Get window
|
|||||||
RLAPI const char *GetMonitorName(int monitor); // Get the human-readable, UTF-8 encoded name of the specified monitor
|
RLAPI const char *GetMonitorName(int monitor); // Get the human-readable, UTF-8 encoded name of the specified monitor
|
||||||
RLAPI void SetClipboardText(const char *text); // Set clipboard text content
|
RLAPI void SetClipboardText(const char *text); // Set clipboard text content
|
||||||
RLAPI const char *GetClipboardText(void); // Get clipboard text content
|
RLAPI const char *GetClipboardText(void); // Get clipboard text content
|
||||||
|
RLAPI bool SetClipboardImage(Image image); // Set clipboard image content
|
||||||
RLAPI Image GetClipboardImage(void); // Get clipboard image content
|
RLAPI Image GetClipboardImage(void); // Get clipboard image content
|
||||||
RLAPI void EnableEventWaiting(void); // Enable waiting for events on EndDrawing(), no automatic event polling
|
RLAPI void EnableEventWaiting(void); // Enable waiting for events on EndDrawing(), no automatic event polling
|
||||||
RLAPI void DisableEventWaiting(void); // Disable waiting for events on EndDrawing(), automatic events polling
|
RLAPI void DisableEventWaiting(void); // Disable waiting for events on EndDrawing(), automatic events polling
|
||||||
|
|||||||
14
src/rcore.c
14
src/rcore.c
@ -524,7 +524,7 @@ const char *TextFormat(const char *text, ...); // Formatting of text with variab
|
|||||||
#include "platforms/rcore_desktop_glfw.c"
|
#include "platforms/rcore_desktop_glfw.c"
|
||||||
#elif defined(PLATFORM_DESKTOP_SDL)
|
#elif defined(PLATFORM_DESKTOP_SDL)
|
||||||
#include "platforms/rcore_desktop_sdl.c"
|
#include "platforms/rcore_desktop_sdl.c"
|
||||||
#elif (defined(PLATFORM_DESKTOP_RGFW) || defined(PLATFORM_WEB_RGFW))
|
#elif defined(PLATFORM_DESKTOP_RGFW) || defined(PLATFORM_WEB_RGFW)
|
||||||
#include "platforms/rcore_desktop_rgfw.c"
|
#include "platforms/rcore_desktop_rgfw.c"
|
||||||
#elif defined(PLATFORM_DESKTOP_WIN32)
|
#elif defined(PLATFORM_DESKTOP_WIN32)
|
||||||
#include "platforms/rcore_desktop_win32.c"
|
#include "platforms/rcore_desktop_win32.c"
|
||||||
@ -581,6 +581,8 @@ const char *TextFormat(const char *text, ...); // Formatting of text with variab
|
|||||||
|
|
||||||
//void SetClipboardText(const char *text)
|
//void SetClipboardText(const char *text)
|
||||||
//const char *GetClipboardText(void)
|
//const char *GetClipboardText(void)
|
||||||
|
//bool SetClipboardImage(Image image)
|
||||||
|
//Image GetClipboardImage(void)
|
||||||
|
|
||||||
//void ShowCursor(void)
|
//void ShowCursor(void)
|
||||||
//void HideCursor(void)
|
//void HideCursor(void)
|
||||||
@ -909,7 +911,7 @@ void EndDrawing(void)
|
|||||||
double waitTime = CORE.Time.current - CORE.Time.previous;
|
double waitTime = CORE.Time.current - CORE.Time.previous;
|
||||||
CORE.Time.previous = CORE.Time.current;
|
CORE.Time.previous = CORE.Time.current;
|
||||||
|
|
||||||
CORE.Time.frame += waitTime; // Total frame time: update + draw + wait
|
CORE.Time.frame += waitTime; // Total frame time: update + draw + wait
|
||||||
}
|
}
|
||||||
|
|
||||||
PollInputEvents(); // Poll user events (before next frame update)
|
PollInputEvents(); // Poll user events (before next frame update)
|
||||||
@ -1675,8 +1677,7 @@ void WaitTime(double seconds)
|
|||||||
// System halt functions
|
// System halt functions
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
Sleep((unsigned long)(sleepSeconds*1000.0));
|
Sleep((unsigned long)(sleepSeconds*1000.0));
|
||||||
#endif
|
#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__EMSCRIPTEN__)
|
||||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__EMSCRIPTEN__)
|
|
||||||
struct timespec req = { 0 };
|
struct timespec req = { 0 };
|
||||||
time_t sec = sleepSeconds;
|
time_t sec = sleepSeconds;
|
||||||
long nsec = (sleepSeconds - sec)*1000000000L;
|
long nsec = (sleepSeconds - sec)*1000000000L;
|
||||||
@ -1685,8 +1686,7 @@ void WaitTime(double seconds)
|
|||||||
|
|
||||||
// NOTE: Use nanosleep() on Unix platforms... usleep() it's deprecated
|
// NOTE: Use nanosleep() on Unix platforms... usleep() it's deprecated
|
||||||
while (nanosleep(&req, &req) == -1) continue;
|
while (nanosleep(&req, &req) == -1) continue;
|
||||||
#endif
|
#elif defined(__APPLE__)
|
||||||
#if defined(__APPLE__)
|
|
||||||
usleep(sleepSeconds*1000000.0);
|
usleep(sleepSeconds*1000000.0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -2424,6 +2424,7 @@ bool IsFileExtension(const char *fileName, const char *ext)
|
|||||||
bool IsFileHidden(const char *filePath)
|
bool IsFileHidden(const char *filePath)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
unsigned long attribs = GetFileAttributesA(filePath);
|
unsigned long attribs = GetFileAttributesA(filePath);
|
||||||
|
|
||||||
@ -2435,6 +2436,7 @@ bool IsFileHidden(const char *filePath)
|
|||||||
|
|
||||||
if ((basePath[0] == '.') && (strcmp(basePath, ".") != 0) && (strcmp(basePath, "..") != 0)) result = true;
|
if ((basePath[0] == '.') && (strcmp(basePath, ".") != 0) && (strcmp(basePath, "..") != 0)) result = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5331,7 +5331,7 @@ Color ColorFromHSV(float hue, float saturation, float value)
|
|||||||
k = (t < k)? t : k;
|
k = (t < k)? t : k;
|
||||||
k = (k < 1)? k : 1;
|
k = (k < 1)? k : 1;
|
||||||
k = (k > 0)? k : 0;
|
k = (k > 0)? k : 0;
|
||||||
color.r = (unsigned char)((value - value*saturation*k)*255.0f);
|
color.r = (unsigned char)((value - value*saturation*k)*255.0f + 0.5f);
|
||||||
|
|
||||||
// Green channel
|
// Green channel
|
||||||
k = fmodf((3.0f + hue/60.0f), 6);
|
k = fmodf((3.0f + hue/60.0f), 6);
|
||||||
@ -5339,7 +5339,7 @@ Color ColorFromHSV(float hue, float saturation, float value)
|
|||||||
k = (t < k)? t : k;
|
k = (t < k)? t : k;
|
||||||
k = (k < 1)? k : 1;
|
k = (k < 1)? k : 1;
|
||||||
k = (k > 0)? k : 0;
|
k = (k > 0)? k : 0;
|
||||||
color.g = (unsigned char)((value - value*saturation*k)*255.0f);
|
color.g = (unsigned char)((value - value*saturation*k)*255.0f + 0.5f);
|
||||||
|
|
||||||
// Blue channel
|
// Blue channel
|
||||||
k = fmodf((1.0f + hue/60.0f), 6);
|
k = fmodf((1.0f + hue/60.0f), 6);
|
||||||
@ -5347,7 +5347,7 @@ Color ColorFromHSV(float hue, float saturation, float value)
|
|||||||
k = (t < k)? t : k;
|
k = (t < k)? t : k;
|
||||||
k = (k < 1)? k : 1;
|
k = (k < 1)? k : 1;
|
||||||
k = (k > 0)? k : 0;
|
k = (k > 0)? k : 0;
|
||||||
color.b = (unsigned char)((value - value*saturation*k)*255.0f);
|
color.b = (unsigned char)((value - value*saturation*k)*255.0f + 0.5f);
|
||||||
|
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3550,6 +3550,17 @@
|
|||||||
"description": "Get clipboard text content",
|
"description": "Get clipboard text content",
|
||||||
"returnType": "const char *"
|
"returnType": "const char *"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SetClipboardImage",
|
||||||
|
"description": "Set clipboard image content",
|
||||||
|
"returnType": "bool",
|
||||||
|
"params": [
|
||||||
|
{
|
||||||
|
"type": "Image",
|
||||||
|
"name": "image"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "GetClipboardImage",
|
"name": "GetClipboardImage",
|
||||||
"description": "Get clipboard image content",
|
"description": "Get clipboard image content",
|
||||||
|
|||||||
@ -3427,6 +3427,14 @@ return {
|
|||||||
description = "Get clipboard text content",
|
description = "Get clipboard text content",
|
||||||
returnType = "const char *"
|
returnType = "const char *"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name = "SetClipboardImage",
|
||||||
|
description = "Set clipboard image content",
|
||||||
|
returnType = "bool",
|
||||||
|
params = {
|
||||||
|
{type = "Image", name = "image"}
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name = "GetClipboardImage",
|
name = "GetClipboardImage",
|
||||||
description = "Get clipboard image content",
|
description = "Get clipboard image content",
|
||||||
|
|||||||
@ -2453,6 +2453,12 @@
|
|||||||
(description "Get clipboard text content")
|
(description "Get clipboard text content")
|
||||||
(return-type "const char *"))
|
(return-type "const char *"))
|
||||||
|
|
||||||
|
((name "SetClipboardImage")
|
||||||
|
(description "Set clipboard image content")
|
||||||
|
(return-type "bool")
|
||||||
|
(params
|
||||||
|
((type "Image") (name "image"))))
|
||||||
|
|
||||||
((name "GetClipboardImage")
|
((name "GetClipboardImage")
|
||||||
(description "Get clipboard image content")
|
(description "Get clipboard image content")
|
||||||
(return-type "Image"))
|
(return-type "Image"))
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -681,7 +681,7 @@
|
|||||||
<Param type="unsigned int" name="frames" desc="" />
|
<Param type="unsigned int" name="frames" desc="" />
|
||||||
</Callback>
|
</Callback>
|
||||||
</Callbacks>
|
</Callbacks>
|
||||||
<Functions count="619">
|
<Functions count="620">
|
||||||
<Function name="InitWindow" retType="void" paramCount="3" desc="Initialize window and OpenGL context">
|
<Function name="InitWindow" retType="void" paramCount="3" desc="Initialize window and OpenGL context">
|
||||||
<Param type="int" name="width" desc="" />
|
<Param type="int" name="width" desc="" />
|
||||||
<Param type="int" name="height" desc="" />
|
<Param type="int" name="height" desc="" />
|
||||||
@ -802,6 +802,9 @@
|
|||||||
</Function>
|
</Function>
|
||||||
<Function name="GetClipboardText" retType="const char *" paramCount="0" desc="Get clipboard text content">
|
<Function name="GetClipboardText" retType="const char *" paramCount="0" desc="Get clipboard text content">
|
||||||
</Function>
|
</Function>
|
||||||
|
<Function name="SetClipboardImage" retType="bool" paramCount="1" desc="Set clipboard image content">
|
||||||
|
<Param type="Image" name="image" desc="" />
|
||||||
|
</Function>
|
||||||
<Function name="GetClipboardImage" retType="Image" paramCount="0" desc="Get clipboard image content">
|
<Function name="GetClipboardImage" retType="Image" paramCount="0" desc="Get clipboard image content">
|
||||||
</Function>
|
</Function>
|
||||||
<Function name="EnableEventWaiting" retType="void" paramCount="0" desc="Enable waiting for events on EndDrawing(), no automatic event polling">
|
<Function name="EnableEventWaiting" retType="void" paramCount="0" desc="Enable waiting for events on EndDrawing(), no automatic event polling">
|
||||||
|
|||||||
Reference in New Issue
Block a user