Merge branch 'pure' of https://github.com/ColleagueRiley/raylib
This commit is contained in:
commit
f1cf7bf349
15 changed files with 1305 additions and 394 deletions
51
src/config.h
51
src/config.h
|
|
@ -71,6 +71,30 @@
|
|||
// Enabling this flag allows manual control of the frame processes, use at your own risk
|
||||
//#define SUPPORT_CUSTOM_FRAME_CONTROL 1
|
||||
|
||||
// Support for clipboard image loading
|
||||
// NOTE: Only working on SDL3, GLFW (Windows) and RGFW (Windows)
|
||||
#define SUPPORT_CLIPBOARD_IMAGE 1
|
||||
|
||||
// NOTE: Clipboard image loading requires support for some image file formats
|
||||
// TODO: Those defines should probably be removed from here, I prefer to let the user manage them
|
||||
#if defined(SUPPORT_CLIPBOARD_IMAGE)
|
||||
#ifndef SUPPORT_MODULE_RTEXTURES
|
||||
#define SUPPORT_MODULE_RTEXTURES 1
|
||||
#endif
|
||||
#ifndef STBI_REQUIRED
|
||||
#define STBI_REQUIRED
|
||||
#endif
|
||||
#ifndef SUPPORT_FILEFORMAT_BMP // For clipboard image on Windows
|
||||
#define SUPPORT_FILEFORMAT_BMP 1
|
||||
#endif
|
||||
#ifndef SUPPORT_FILEFORMAT_PNG // Wayland uses png for prints, at least it was on 22 LTS ubuntu
|
||||
#define SUPPORT_FILEFORMAT_PNG 1
|
||||
#endif
|
||||
#ifndef SUPPORT_FILEFORMAT_JPG
|
||||
#define SUPPORT_FILEFORMAT_JPG 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
// rcore: Configuration values
|
||||
//------------------------------------------------------------------------------------
|
||||
|
|
@ -273,31 +297,4 @@
|
|||
//------------------------------------------------------------------------------------
|
||||
#define MAX_TRACELOG_MSG_LENGTH 256 // Max length of one trace-log message
|
||||
|
||||
|
||||
// Enable partial support for clipboard image, only working on SDL3 or
|
||||
// being on both Windows OS + GLFW or Windows OS + RGFW
|
||||
#define SUPPORT_CLIPBOARD_IMAGE 1
|
||||
|
||||
#if defined(SUPPORT_CLIPBOARD_IMAGE)
|
||||
#ifndef STBI_REQUIRED
|
||||
#define STBI_REQUIRED
|
||||
#endif
|
||||
|
||||
#ifndef SUPPORT_FILEFORMAT_BMP // For clipboard image on Windows
|
||||
#define SUPPORT_FILEFORMAT_BMP 1
|
||||
#endif
|
||||
|
||||
#ifndef SUPPORT_FILEFORMAT_PNG // Wayland uses png for prints, at least it was on 22 LTS ubuntu
|
||||
#define SUPPORT_FILEFORMAT_PNG 1
|
||||
#endif
|
||||
|
||||
#ifndef SUPPORT_FILEFORMAT_JPG
|
||||
#define SUPPORT_FILEFORMAT_JPG 1
|
||||
#endif
|
||||
|
||||
#ifndef SUPPORT_MODULE_RTEXTURES
|
||||
#define SUPPORT_MODULE_RTEXTURES 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // CONFIG_H
|
||||
|
|
|
|||
348
src/external/RGFW.h
vendored
348
src/external/RGFW.h
vendored
|
|
@ -88,6 +88,7 @@
|
|||
Joshua Rowe (omnisci3nce) - bug fix, review (macOS)
|
||||
@lesleyrs -> bug fix, review (OpenGL)
|
||||
Nick Porcino (meshula) - testing, organization, review (MacOS, examples)
|
||||
@DarekParodia -> code review (X11) (C++)
|
||||
*/
|
||||
|
||||
#if _MSC_VER
|
||||
|
|
@ -344,12 +345,12 @@ typedef RGFW_ENUM(u8, RGFW_event_types) {
|
|||
|
||||
RGFW_Event.button holds which mouse button was pressed
|
||||
*/
|
||||
RGFW_jsButtonPressed, /*!< a joystick button was pressed */
|
||||
RGFW_jsButtonReleased, /*!< a joystick button was released */
|
||||
RGFW_jsAxisMove, /*!< an axis of a joystick was moved*/
|
||||
/*! joystick event note
|
||||
RGFW_Event.joystick holds which joystick was altered, if any
|
||||
RGFW_Event.button holds which joystick button was pressed
|
||||
RGFW_gpButtonPressed, /*!< a gamepad button was pressed */
|
||||
RGFW_gpButtonReleased, /*!< a gamepad button was released */
|
||||
RGFW_gpAxisMove, /*!< an axis of a gamepad was moved*/
|
||||
/*! gamepad event note
|
||||
RGFW_Event.gamepad holds which gamepad was altered, if any
|
||||
RGFW_Event.button holds which gamepad button was pressed
|
||||
|
||||
RGFW_Event.axis holds the data of all the axis
|
||||
RGFW_Event.axisCount says how many axis there are
|
||||
|
|
@ -398,26 +399,26 @@ typedef RGFW_ENUM(u8, RGFW_event_types) {
|
|||
#define RGFW_CAPSLOCK (1L << 1)
|
||||
#define RGFW_NUMLOCK (1L << 2)
|
||||
|
||||
/*! joystick button codes (based on xbox/playstation), you may need to change these values per controller */
|
||||
#ifndef RGFW_joystick_codes
|
||||
typedef RGFW_ENUM(u8, RGFW_joystick_codes) {
|
||||
RGFW_JS_A = 0, /*!< or PS X button */
|
||||
RGFW_JS_B = 1, /*!< or PS circle button */
|
||||
RGFW_JS_Y = 2, /*!< or PS triangle button */
|
||||
RGFW_JS_X = 3, /*!< or PS square button */
|
||||
RGFW_JS_START = 9, /*!< start button */
|
||||
RGFW_JS_SELECT = 8, /*!< select button */
|
||||
RGFW_JS_HOME = 10, /*!< home button */
|
||||
RGFW_JS_UP = 13, /*!< dpad up */
|
||||
RGFW_JS_DOWN = 14, /*!< dpad down*/
|
||||
RGFW_JS_LEFT = 15, /*!< dpad left */
|
||||
RGFW_JS_RIGHT = 16, /*!< dpad right */
|
||||
RGFW_JS_L1 = 4, /*!< left bump */
|
||||
RGFW_JS_L2 = 5, /*!< left trigger*/
|
||||
RGFW_JS_R1 = 6, /*!< right bumper */
|
||||
RGFW_JS_R2 = 7, /*!< right trigger */
|
||||
RGFW_JS_L3 = 11, /* left thumb stick */
|
||||
RGFW_JS_R3 = 12 /*!< right thumb stick */
|
||||
/*! gamepad button codes (based on xbox/playstation), you may need to change these values per controller */
|
||||
#ifndef RGFW_gamepad_codes
|
||||
typedef RGFW_ENUM(u8, RGFW_gamepad_codes) {
|
||||
RGFW_GP_A = 0, /*!< or PS X button */
|
||||
RGFW_GP_B = 1, /*!< or PS circle button */
|
||||
RGFW_GP_Y = 2, /*!< or PS triangle button */
|
||||
RGFW_GP_X = 3, /*!< or PS square button */
|
||||
RGFW_GP_START = 9, /*!< start button */
|
||||
RGFW_GP_SELECT = 8, /*!< select button */
|
||||
RGFW_GP_HOME = 10, /*!< home button */
|
||||
RGFW_GP_UP = 13, /*!< dpad up */
|
||||
RGFW_GP_DOWN = 14, /*!< dpad down*/
|
||||
RGFW_GP_LEFT = 15, /*!< dpad left */
|
||||
RGFW_GP_RIGHT = 16, /*!< dpad right */
|
||||
RGFW_GP_L1 = 4, /*!< left bump */
|
||||
RGFW_GP_L2 = 5, /*!< left trigger*/
|
||||
RGFW_GP_R1 = 6, /*!< right bumper */
|
||||
RGFW_GP_R2 = 7, /*!< right trigger */
|
||||
RGFW_GP_L3 = 11, /* left thumb stick */
|
||||
RGFW_GP_R3 = 12 /*!< right thumb stick */
|
||||
};
|
||||
#endif
|
||||
|
||||
|
|
@ -489,10 +490,10 @@ typedef struct RGFW_Event {
|
|||
|
||||
u8 lockState;
|
||||
|
||||
u8 button; /* !< which mouse (or joystick) button was pressed */
|
||||
u8 button; /* !< which mouse (or gamepad) button was pressed */
|
||||
double scroll; /*!< the raw mouse scroll value */
|
||||
|
||||
u16 joystick; /*! which joystick this event applies to (if applicable to any) */
|
||||
u16 gamepad; /*! which gamepad this event applies to (if applicable to any) */
|
||||
u8 axisesCount; /*!< number of axises */
|
||||
|
||||
u8 whichAxis; /* which axis was effected */
|
||||
|
|
@ -634,6 +635,8 @@ RGFWDEF void RGFW_setClassName(char* name);
|
|||
/*! this has to be set before createWindow is called, else the fulscreen size is used */
|
||||
RGFWDEF void RGFW_setBufferSize(RGFW_area size); /*!< the buffer cannot be resized (by RGFW) */
|
||||
|
||||
/* NOTE: (windows)If the executable has an icon resource named RGFW_ICON, it will be set as the initial icon for the window.*/
|
||||
|
||||
RGFWDEF RGFW_window* RGFW_createWindow(
|
||||
const char* name, /* name of the window */
|
||||
RGFW_rect rect, /* rect of window */
|
||||
|
|
@ -873,10 +876,10 @@ typedef void (* RGFW_windowrefreshfunc)(RGFW_window* win);
|
|||
typedef void (* RGFW_keyfunc)(RGFW_window* win, u32 keycode, char keyName[16], u8 lockState, b8 pressed);
|
||||
/*! RGFW_mouseButtonPressed / RGFW_mouseButtonReleased, the window that got the event, the button that was pressed, the scroll value, if it was a press (else it's a release) */
|
||||
typedef void (* RGFW_mousebuttonfunc)(RGFW_window* win, u8 button, double scroll, b8 pressed);
|
||||
/*! RGFW_jsButtonPressed / RGFW_jsButtonReleased, the window that got the event, the button that was pressed, the scroll value, if it was a press (else it's a release) */
|
||||
typedef void (* RGFW_jsButtonfunc)(RGFW_window* win, u16 joystick, u8 button, b8 pressed);
|
||||
/*! RGFW_jsAxisMove, the window that got the event, the joystick in question, the axis values and the amount of axises */
|
||||
typedef void (* RGFW_jsAxisfunc)(RGFW_window* win, u16 joystick, RGFW_point axis[2], u8 axisesCount);
|
||||
/*!gp /gp, the window that got the event, the button that was pressed, the scroll value, if it was a press (else it's a release) */
|
||||
typedef void (* RGFW_gpButtonfunc)(RGFW_window* win, u16 gamepad, u8 button, b8 pressed);
|
||||
/*! RGFW_gpAxisMove, the window that got the event, the gamepad in question, the axis values and the amount of axises */
|
||||
typedef void (* RGFW_gpAxisfunc)(RGFW_window* win, u16 gamepad, RGFW_point axis[2], u8 axisesCount);
|
||||
|
||||
|
||||
/*! RGFW_dnd, the window that had the drop, the drop data and the amount files dropped returns previous callback function (if it was set) */
|
||||
|
|
@ -908,9 +911,9 @@ RGFWDEF RGFW_keyfunc RGFW_setKeyCallback(RGFW_keyfunc func);
|
|||
/*! set callback for a mouse button (press / release ) event returns previous callback function (if it was set) */
|
||||
RGFWDEF RGFW_mousebuttonfunc RGFW_setMouseButtonCallback(RGFW_mousebuttonfunc func);
|
||||
/*! set callback for a controller button (press / release ) event returns previous callback function (if it was set) */
|
||||
RGFWDEF RGFW_jsButtonfunc RGFW_setjsButtonCallback(RGFW_jsButtonfunc func);
|
||||
/*! set callback for a joystick axis mov event returns previous callback function (if it was set) */
|
||||
RGFWDEF RGFW_jsAxisfunc RGFW_setjsAxisCallback(RGFW_jsAxisfunc func);
|
||||
RGFWDEF RGFW_gpButtonfunc RGFW_setgpButtonCallback(RGFW_gpButtonfunc func);
|
||||
/*! set callback for a gamepad axis mov event returns previous callback function (if it was set) */
|
||||
RGFWDEF RGFW_gpAxisfunc RGFW_setgpAxisCallback(RGFW_gpAxisfunc func);
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
@ -941,15 +944,15 @@ RGFWDEF RGFW_jsAxisfunc RGFW_setjsAxisCallback(RGFW_jsAxisfunc func);
|
|||
|
||||
/** @} */
|
||||
|
||||
/** * @defgroup joystick
|
||||
/** * @defgroup gamepad
|
||||
* @{ */
|
||||
|
||||
/*! joystick count starts at 0*/
|
||||
/*!< register joystick to window based on a number (the number is based on when it was connected eg. /dev/js0)*/
|
||||
RGFWDEF u16 RGFW_registerJoystick(RGFW_window* win, i32 jsNumber);
|
||||
RGFWDEF u16 RGFW_registerJoystickF(RGFW_window* win, char* file);
|
||||
/*! gamepad count starts at 0*/
|
||||
/*!< register gamepad to window based on a number (the number is based on when it was connected eg. /dev/js0)*/
|
||||
RGFWDEF u16 RGFW_registerGamepad(RGFW_window* win, i32 gpNumber);
|
||||
RGFWDEF u16 RGFW_registerGamepadF(RGFW_window* win, char* file);
|
||||
|
||||
RGFWDEF u32 RGFW_isPressedJS(RGFW_window* win, u16 controller, u8 button);
|
||||
RGFWDEF u32 RGFW_isPressedGP(RGFW_window* win, u16 controller, u8 button);
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
@ -1446,11 +1449,11 @@ char RGFW_keyCodeToCharAuto(u32 keycode, u8 lockState) { return RGFW_keyCodeToCh
|
|||
this is the end of keycode data
|
||||
*/
|
||||
|
||||
/* joystick data */
|
||||
u8 RGFW_jsPressed[4][16]; /*!< if a key is currently pressed or not (per joystick) */
|
||||
/* gamepad data */
|
||||
u8 RGFW_gpPressed[4][16]; /*!< if a key is currently pressed or not (per gamepad) */
|
||||
|
||||
i32 RGFW_joysticks[4]; /*!< limit of 4 joysticks at a time */
|
||||
u16 RGFW_joystickCount; /*!< the actual amount of joysticks */
|
||||
i32 RGFW_gamepads[4]; /*!< limit of 4 gamepads at a time */
|
||||
u16 RGFW_gamepadCount; /*!< the actual amount of gamepads */
|
||||
|
||||
/*
|
||||
event callback defines start here
|
||||
|
|
@ -1472,8 +1475,8 @@ void RGFW_dndInitfuncEMPTY(RGFW_window* win, RGFW_point point) {RGFW_UNUSED(win)
|
|||
void RGFW_windowrefreshfuncEMPTY(RGFW_window* win) {RGFW_UNUSED(win); }
|
||||
void RGFW_keyfuncEMPTY(RGFW_window* win, u32 keycode, char keyName[16], u8 lockState, b8 pressed) {RGFW_UNUSED(win); RGFW_UNUSED(keycode); RGFW_UNUSED(keyName); RGFW_UNUSED(lockState); RGFW_UNUSED(pressed);}
|
||||
void RGFW_mousebuttonfuncEMPTY(RGFW_window* win, u8 button, double scroll, b8 pressed) {RGFW_UNUSED(win); RGFW_UNUSED(button); RGFW_UNUSED(scroll); RGFW_UNUSED(pressed);}
|
||||
void RGFW_jsButtonfuncEMPTY(RGFW_window* win, u16 joystick, u8 button, b8 pressed){RGFW_UNUSED(win); RGFW_UNUSED(joystick); RGFW_UNUSED(button); RGFW_UNUSED(pressed); }
|
||||
void RGFW_jsAxisfuncEMPTY(RGFW_window* win, u16 joystick, RGFW_point axis[2], u8 axisesCount){RGFW_UNUSED(win); RGFW_UNUSED(joystick); RGFW_UNUSED(axis); RGFW_UNUSED(axisesCount); }
|
||||
void RGFW_gpButtonfuncEMPTY(RGFW_window* win, u16 gamepad, u8 button, b8 pressed){RGFW_UNUSED(win); RGFW_UNUSED(gamepad); RGFW_UNUSED(button); RGFW_UNUSED(pressed); }
|
||||
void RGFW_gpAxisfuncEMPTY(RGFW_window* win, u16 gamepad, RGFW_point axis[2], u8 axisesCount){RGFW_UNUSED(win); RGFW_UNUSED(gamepad); RGFW_UNUSED(axis); RGFW_UNUSED(axisesCount); }
|
||||
|
||||
#ifdef RGFW_ALLOC_DROPFILES
|
||||
void RGFW_dndfuncEMPTY(RGFW_window* win, char** droppedFiles, u32 droppedFilesCount) {RGFW_UNUSED(win); RGFW_UNUSED(droppedFiles); RGFW_UNUSED(droppedFilesCount);}
|
||||
|
|
@ -1492,8 +1495,8 @@ RGFW_dndfunc RGFW_dndCallback = RGFW_dndfuncEMPTY;
|
|||
RGFW_dndInitfunc RGFW_dndInitCallback = RGFW_dndInitfuncEMPTY;
|
||||
RGFW_keyfunc RGFW_keyCallback = RGFW_keyfuncEMPTY;
|
||||
RGFW_mousebuttonfunc RGFW_mouseButtonCallback = RGFW_mousebuttonfuncEMPTY;
|
||||
RGFW_jsButtonfunc RGFW_jsButtonCallback = RGFW_jsButtonfuncEMPTY;
|
||||
RGFW_jsAxisfunc RGFW_jsAxisCallback = RGFW_jsAxisfuncEMPTY;
|
||||
RGFW_gpButtonfunc RGFW_gpButtonCallback = RGFW_gpButtonfuncEMPTY;
|
||||
RGFW_gpAxisfunc RGFW_gpAxisCallback = RGFW_gpAxisfuncEMPTY;
|
||||
|
||||
void RGFW_window_checkEvents(RGFW_window* win, i32 waitMS) {
|
||||
RGFW_window_eventWait(win, waitMS);
|
||||
|
|
@ -1564,14 +1567,14 @@ RGFW_mousebuttonfunc RGFW_setMouseButtonCallback(RGFW_mousebuttonfunc func) {
|
|||
RGFW_mouseButtonCallback = func;
|
||||
return prev;
|
||||
}
|
||||
RGFW_jsButtonfunc RGFW_setjsButtonCallback(RGFW_jsButtonfunc func) {
|
||||
RGFW_jsButtonfunc prev = (RGFW_jsButtonCallback == RGFW_jsButtonfuncEMPTY) ? NULL : RGFW_jsButtonCallback;
|
||||
RGFW_jsButtonCallback = func;
|
||||
RGFW_gpButtonfunc RGFW_setgpButtonCallback(RGFW_gpButtonfunc func) {
|
||||
RGFW_gpButtonfunc prev = (RGFW_gpButtonCallback == RGFW_gpButtonfuncEMPTY) ? NULL : RGFW_gpButtonCallback;
|
||||
RGFW_gpButtonCallback = func;
|
||||
return prev;
|
||||
}
|
||||
RGFW_jsAxisfunc RGFW_setjsAxisCallback(RGFW_jsAxisfunc func) {
|
||||
RGFW_jsAxisfunc prev = (RGFW_jsAxisCallback == RGFW_jsAxisfuncEMPTY) ? NULL : RGFW_jsAxisCallback;
|
||||
RGFW_jsAxisCallback = func;
|
||||
RGFW_gpAxisfunc RGFW_setgpAxisCallback(RGFW_gpAxisfunc func) {
|
||||
RGFW_gpAxisfunc prev = (RGFW_gpAxisCallback == RGFW_gpAxisfuncEMPTY) ? NULL : RGFW_gpAxisCallback;
|
||||
RGFW_gpAxisCallback = func;
|
||||
return prev;
|
||||
}
|
||||
/*
|
||||
|
|
@ -1633,7 +1636,7 @@ RGFW_window* RGFW_window_basic_init(RGFW_rect rect, u16 args) {
|
|||
win->r = rect;
|
||||
win->event.inFocus = 1;
|
||||
win->event.droppedFilesCount = 0;
|
||||
RGFW_joystickCount = 0;
|
||||
RGFW_gamepadCount = 0;
|
||||
win->_winArgs = 0;
|
||||
win->event.lockState = 0;
|
||||
|
||||
|
|
@ -1812,9 +1815,9 @@ u32 RGFW_window_checkFPS(RGFW_window* win, u32 fpsCap) {
|
|||
return output_fps;
|
||||
}
|
||||
|
||||
u32 RGFW_isPressedJS(RGFW_window* win, u16 c, u8 button) {
|
||||
u32 RGFW_isPressedGP(RGFW_window* win, u16 c, u8 button) {
|
||||
RGFW_UNUSED(win);
|
||||
return RGFW_jsPressed[c][button];
|
||||
return RGFW_gpPressed[c][button];
|
||||
}
|
||||
|
||||
#if defined(RGFW_X11) || defined(RGFW_WINDOWS)
|
||||
|
|
@ -2272,33 +2275,33 @@ This is where OS specific stuff starts
|
|||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
RGFW_Event* RGFW_linux_updateJoystick(RGFW_window* win) {
|
||||
RGFW_Event* RGFW_linux_updateGamepad(RGFW_window* win) {
|
||||
u8 i;
|
||||
for (i = 0; i < RGFW_joystickCount; i++) {
|
||||
for (i = 0; i < RGFW_gamepadCount; i++) {
|
||||
struct js_event e;
|
||||
|
||||
|
||||
if (RGFW_joysticks[i] == 0)
|
||||
if (RGFW_gamepads[i] == 0)
|
||||
continue;
|
||||
|
||||
i32 flags = fcntl(RGFW_joysticks[i], F_GETFL, 0);
|
||||
fcntl(RGFW_joysticks[i], F_SETFL, flags | O_NONBLOCK);
|
||||
i32 flags = fcntl(RGFW_gamepads[i], F_GETFL, 0);
|
||||
fcntl(RGFW_gamepads[i], F_SETFL, flags | O_NONBLOCK);
|
||||
|
||||
ssize_t bytes;
|
||||
while ((bytes = read(RGFW_joysticks[i], &e, sizeof(e))) > 0) {
|
||||
while ((bytes = read(RGFW_gamepads[i], &e, sizeof(e))) > 0) {
|
||||
switch (e.type) {
|
||||
case JS_EVENT_BUTTON:
|
||||
win->event.type = e.value ? RGFW_jsButtonPressed : RGFW_jsButtonReleased;
|
||||
win->event.type = e.value ? RGFW_gpButtonPressed : RGFW_gpButtonReleased;
|
||||
win->event.button = e.number;
|
||||
RGFW_jsPressed[i][e.number + 1] = e.value;
|
||||
RGFW_jsButtonCallback(win, i, e.number, e.value);
|
||||
RGFW_gpPressed[i][e.number + 1] = e.value;
|
||||
RGFW_gpButtonCallback(win, i, e.number, e.value);
|
||||
|
||||
return &win->event;
|
||||
case JS_EVENT_AXIS: {
|
||||
size_t axis = e.number / 2;
|
||||
if (axis == 2) axis = 1;
|
||||
|
||||
ioctl(RGFW_joysticks[i], JSIOCGAXES, &win->event.axisesCount);
|
||||
ioctl(RGFW_gamepads[i], JSIOCGAXES, &win->event.axisesCount);
|
||||
win->event.axisesCount = 2;
|
||||
|
||||
if (axis < 3) {
|
||||
|
|
@ -2309,10 +2312,10 @@ This is where OS specific stuff starts
|
|||
}
|
||||
}
|
||||
|
||||
win->event.type = RGFW_jsAxisMove;
|
||||
win->event.joystick = i;
|
||||
win->event.type = RGFW_gpAxisMove;
|
||||
win->event.gamepad = i;
|
||||
win->event.whichAxis = axis;
|
||||
RGFW_jsAxisCallback(win, i, win->event.axis, win->event.axisesCount);
|
||||
RGFW_gpAxisCallback(win, i, win->event.axis, win->event.axisesCount);
|
||||
return &win->event;
|
||||
}
|
||||
default: break;
|
||||
|
|
@ -2785,7 +2788,7 @@ Start of Linux / Unix defines
|
|||
win->event.type = 0;
|
||||
|
||||
#ifdef __linux__
|
||||
RGFW_Event* event = RGFW_linux_updateJoystick(win);
|
||||
RGFW_Event* event = RGFW_linux_updateGamepad(win);
|
||||
if (event != NULL)
|
||||
return event;
|
||||
#endif
|
||||
|
|
@ -2805,7 +2808,7 @@ Start of Linux / Unix defines
|
|||
|
||||
u32 i;
|
||||
win->event.type = 0;
|
||||
|
||||
XEvent reply = { ClientMessage };
|
||||
|
||||
switch (E.type) {
|
||||
case KeyPress:
|
||||
|
|
@ -2944,7 +2947,6 @@ Start of Linux / Unix defines
|
|||
if ((win->_winArgs & RGFW_ALLOW_DND) == 0)
|
||||
break;
|
||||
|
||||
XEvent reply = { ClientMessage };
|
||||
reply.xclient.window = xdnd.source;
|
||||
reply.xclient.format = 32;
|
||||
reply.xclient.data.l[0] = (long) win->src.window;
|
||||
|
|
@ -3963,8 +3965,8 @@ Start of Linux / Unix defines
|
|||
}
|
||||
|
||||
u8 i;
|
||||
for (i = 0; i < RGFW_joystickCount; i++)
|
||||
close(RGFW_joysticks[i]);
|
||||
for (i = 0; i < RGFW_gamepadCount; i++)
|
||||
close(RGFW_gamepads[i]);
|
||||
}
|
||||
|
||||
/* set cleared display / window to NULL for error checking */
|
||||
|
|
@ -3987,43 +3989,43 @@ Start of Linux / Unix defines
|
|||
#include <fcntl.h>
|
||||
#include <poll.h>
|
||||
#include <unistd.h>
|
||||
u16 RGFW_registerJoystickF(RGFW_window* win, char* file) {
|
||||
u16 RGFW_registerGamepadF(RGFW_window* win, char* file) {
|
||||
assert(win != NULL);
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
i32 js = open(file, O_RDONLY);
|
||||
|
||||
if (js && RGFW_joystickCount < 4) {
|
||||
RGFW_joystickCount++;
|
||||
if (js && RGFW_gamepadCount < 4) {
|
||||
RGFW_gamepadCount++;
|
||||
|
||||
RGFW_joysticks[RGFW_joystickCount - 1] = open(file, O_RDONLY);
|
||||
RGFW_gamepads[RGFW_gamepadCount - 1] = open(file, O_RDONLY);
|
||||
|
||||
u8 i;
|
||||
for (i = 0; i < 16; i++)
|
||||
RGFW_jsPressed[RGFW_joystickCount - 1][i] = 0;
|
||||
RGFW_gpPressed[RGFW_gamepadCount - 1][i] = 0;
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
#ifdef RGFW_PRINT_ERRORS
|
||||
RGFW_error = 1;
|
||||
fprintf(stderr, "Error RGFW_registerJoystickF : Cannot open file %s\n", file);
|
||||
fprintf(stderr, "Error RGFW_registerGamepadF : Cannot open file %s\n", file);
|
||||
#endif
|
||||
}
|
||||
|
||||
return RGFW_joystickCount - 1;
|
||||
return RGFW_gamepadCount - 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
u16 RGFW_registerJoystick(RGFW_window* win, i32 jsNumber) {
|
||||
u16 RGFW_registerGamepad(RGFW_window* win, i32 gpNumber) {
|
||||
assert(win != NULL);
|
||||
|
||||
#ifdef __linux__
|
||||
char file[15];
|
||||
sprintf(file, "/dev/input/js%i", jsNumber);
|
||||
sprintf(file, "/dev/input/js%i", gpNumber);
|
||||
|
||||
return RGFW_registerJoystickF(win, file);
|
||||
return RGFW_registerGamepadF(win, file);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -4059,7 +4061,7 @@ Start of Linux / Unix defines
|
|||
{ ConnectionNumber(win->src.display), POLLIN, 0 },
|
||||
#endif
|
||||
{ RGFW_eventWait_forceStop[0], POLLIN, 0 },
|
||||
#ifdef __linux__ /* blank space for 4 joystick files*/
|
||||
#ifdef __linux__ /* blank space for 4 gamepad files*/
|
||||
{ -1, POLLIN, 0 }, {-1, POLLIN, 0 }, {-1, POLLIN, 0 }, {-1, POLLIN, 0}
|
||||
#endif
|
||||
};
|
||||
|
|
@ -4067,11 +4069,11 @@ Start of Linux / Unix defines
|
|||
u8 index = 2;
|
||||
|
||||
#if defined(__linux__)
|
||||
for (i = 0; i < RGFW_joystickCount; i++) {
|
||||
if (RGFW_joysticks[i] == 0)
|
||||
for (i = 0; i < RGFW_gamepadCount; i++) {
|
||||
if (RGFW_gamepads[i] == 0)
|
||||
continue;
|
||||
|
||||
fds[index].fd = RGFW_joysticks[i];
|
||||
fds[index].fd = RGFW_gamepads[i];
|
||||
index++;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -4757,7 +4759,7 @@ static const struct wl_callback_listener wl_surface_frame_listener = {
|
|||
}
|
||||
|
||||
#ifdef __linux__
|
||||
RGFW_Event* event = RGFW_linux_updateJoystick(win);
|
||||
RGFW_Event* event = RGFW_linux_updateGamepad(win);
|
||||
if (event != NULL)
|
||||
return event;
|
||||
#endif
|
||||
|
|
@ -5083,7 +5085,7 @@ static const struct wl_callback_listener wl_surface_frame_listener = {
|
|||
#define wglGetSwapIntervalEXT wglGetSwapIntervalEXTSrc
|
||||
|
||||
|
||||
void* RGFWjoystickApi = NULL;
|
||||
void* RGFWgamepadApi = NULL;
|
||||
|
||||
/* these two wgl functions need to be preloaded */
|
||||
typedef HGLRC (WINAPI *PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC hdc, HGLRC hglrc, const int *attribList);
|
||||
|
|
@ -5198,22 +5200,29 @@ static HMODULE wglinstance = NULL;
|
|||
u32 i;
|
||||
static const char* names[] = {
|
||||
"xinput1_4.dll",
|
||||
"xinput1_3.dll",
|
||||
"xinput9_1_0.dll",
|
||||
"xinput1_2.dll",
|
||||
"xinput1_1.dll"
|
||||
};
|
||||
|
||||
for (i = 0; i < sizeof(names) / sizeof(const char*); i++) {
|
||||
for (i = 0; i < sizeof(names) / sizeof(const char*) && (XInputGetStateSRC == NULL || XInputGetStateSRC != NULL); i++) {
|
||||
RGFW_XInput_dll = LoadLibraryA(names[i]);
|
||||
|
||||
if (RGFW_XInput_dll) {
|
||||
if (RGFW_XInput_dll == NULL)
|
||||
continue;
|
||||
|
||||
if (XInputGetStateSRC == NULL)
|
||||
XInputGetStateSRC = (PFN_XInputGetState)(void*)GetProcAddress(RGFW_XInput_dll, "XInputGetState");
|
||||
|
||||
if (XInputGetStateSRC == NULL)
|
||||
printf("Failed to load XInputGetState");
|
||||
}
|
||||
|
||||
if (XInputGetKeystrokeSRC == NULL)
|
||||
XInputGetKeystrokeSRC = (PFN_XInputGetKeystroke)(void*)GetProcAddress(RGFW_XInput_dll, "XInputGetKeystroke");
|
||||
}
|
||||
|
||||
if (XInputGetStateSRC == NULL)
|
||||
printf("RGFW ERR: Failed to load XInputGetState\n");
|
||||
if (XInputGetKeystrokeSRC == NULL)
|
||||
printf("RGFW ERR: Failed to load XInputGetKeystroke\n");
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -5288,7 +5297,7 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
|
|||
if (RGFW_Shcore_dll == NULL) {
|
||||
RGFW_Shcore_dll = LoadLibraryA("shcore.dll");
|
||||
GetDpiForMonitorSRC = (PFN_GetDpiForMonitor)(void*)GetProcAddress(RGFW_Shcore_dll, "GetDpiForMonitor");
|
||||
#if defined(_WIN64) || (_WIN32_WINNT >= 0x0600)
|
||||
#if (_WIN32_WINNT >= 0x0600)
|
||||
SetProcessDPIAware();
|
||||
#endif
|
||||
}
|
||||
|
|
@ -5333,6 +5342,11 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
|
|||
Class.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
Class.lpfnWndProc = WndProc;
|
||||
|
||||
Class.hIcon = LoadImageA(GetModuleHandleW(NULL), "RGFW_ICON", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED);
|
||||
if (Class.hIcon == NULL) {
|
||||
Class.hIcon = LoadImageA(NULL, IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED);
|
||||
}
|
||||
|
||||
RegisterClassA(&Class);
|
||||
|
||||
DWORD window_style = WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
|
||||
|
|
@ -5345,7 +5359,8 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
|
|||
if (!(args & RGFW_NO_RESIZE))
|
||||
window_style |= WS_SIZEBOX | WS_MAXIMIZEBOX | WS_THICKFRAME;
|
||||
} else
|
||||
window_style |= WS_POPUP | WS_VISIBLE | WS_SYSMENU | WS_MINIMIZEBOX;
|
||||
window_style |= WS_POPUP | WS_VISIBLE | WS_SYSMENU | WS_MINIMIZEBOX;
|
||||
|
||||
|
||||
HWND dummyWin = CreateWindowA(Class.lpszClassName, name, window_style, win->r.x, win->r.y, win->r.w, win->r.h, 0, 0, inh, 0);
|
||||
|
||||
|
|
@ -5637,26 +5652,27 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
|
|||
|
||||
|
||||
u8 RGFW_xinput2RGFW[] = {
|
||||
RGFW_JS_A, /* or PS X button */
|
||||
RGFW_JS_B, /* or PS circle button */
|
||||
RGFW_JS_X, /* or PS square button */
|
||||
RGFW_JS_Y, /* or PS triangle button */
|
||||
RGFW_JS_R1, /* right bumper */
|
||||
RGFW_JS_L1, /* left bump */
|
||||
RGFW_JS_L2, /* left trigger*/
|
||||
RGFW_JS_R2, /* right trigger */
|
||||
RGFW_GP_A, /* or PS X button */
|
||||
RGFW_GP_B, /* or PS circle button */
|
||||
RGFW_GP_X, /* or PS square button */
|
||||
RGFW_GP_Y, /* or PS triangle button */
|
||||
RGFW_GP_R1, /* right bumper */
|
||||
RGFW_GP_L1, /* left bump */
|
||||
RGFW_GP_L2, /* left trigger*/
|
||||
RGFW_GP_R2, /* right trigger */
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
RGFW_JS_UP, /* dpad up */
|
||||
RGFW_JS_DOWN, /* dpad down*/
|
||||
RGFW_JS_LEFT, /* dpad left */
|
||||
RGFW_JS_RIGHT, /* dpad right */
|
||||
RGFW_JS_START, /* start button */
|
||||
RGFW_JS_SELECT/* select button */
|
||||
RGFW_GP_UP, /* dpad up */
|
||||
RGFW_GP_DOWN, /* dpad down*/
|
||||
RGFW_GP_LEFT, /* dpad left */
|
||||
RGFW_GP_RIGHT, /* dpad right */
|
||||
RGFW_GP_START, /* start button */
|
||||
RGFW_GP_SELECT,/* select button */
|
||||
RGFW_GP_L3,
|
||||
RGFW_GP_R3,
|
||||
};
|
||||
|
||||
static i32 RGFW_checkXInput(RGFW_window* win, RGFW_Event* e) {
|
||||
RGFW_UNUSED(win)
|
||||
|
||||
size_t i;
|
||||
for (i = 0; i < 4; i++) {
|
||||
XINPUT_KEYSTROKE keystroke;
|
||||
|
|
@ -5669,14 +5685,14 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
|
|||
if ((keystroke.Flags & XINPUT_KEYSTROKE_REPEAT) == 0 && result != ERROR_EMPTY) {
|
||||
if (result != ERROR_SUCCESS)
|
||||
return 0;
|
||||
|
||||
if (keystroke.VirtualKey > VK_PAD_BACK)
|
||||
|
||||
if (keystroke.VirtualKey > VK_PAD_RTHUMB_PRESS)
|
||||
continue;
|
||||
|
||||
// RGFW_jsButtonPressed + 1 = RGFW_jsButtonReleased
|
||||
e->type = RGFW_jsButtonPressed + !(keystroke.Flags & XINPUT_KEYSTROKE_KEYDOWN);
|
||||
|
||||
//gp + 1 = RGFW_gpButtonReleased
|
||||
e->type = RGFW_gpButtonPressed + !(keystroke.Flags & XINPUT_KEYSTROKE_KEYDOWN);
|
||||
e->button = RGFW_xinput2RGFW[keystroke.VirtualKey - 0x5800];
|
||||
RGFW_jsPressed[i][e->button] = !(keystroke.Flags & XINPUT_KEYSTROKE_KEYDOWN);
|
||||
RGFW_gpPressed[i][e->button] = !(keystroke.Flags & XINPUT_KEYSTROKE_KEYDOWN);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -5686,6 +5702,7 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
|
|||
XInputGetState((DWORD) i, &state) == ERROR_DEVICE_NOT_CONNECTED
|
||||
)
|
||||
return 0;
|
||||
|
||||
#define INPUT_DEADZONE ( 0.24f * (float)(0x7FFF) ) // Default to 24% of the +/- 32767 range. This is a reasonable default value but can be altered if needed.
|
||||
|
||||
if ((state.Gamepad.sThumbLX < INPUT_DEADZONE &&
|
||||
|
|
@ -5707,22 +5724,26 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
|
|||
}
|
||||
|
||||
e->axisesCount = 2;
|
||||
RGFW_point axis1 = RGFW_POINT(state.Gamepad.sThumbLX, state.Gamepad.sThumbLY);
|
||||
RGFW_point axis2 = RGFW_POINT(state.Gamepad.sThumbRX, state.Gamepad.sThumbRY);
|
||||
RGFW_point axis1 = RGFW_POINT(((float)state.Gamepad.sThumbLX / 32768.0f) * 100, ((float)state.Gamepad.sThumbLY / -32768.0f) * 100);
|
||||
RGFW_point axis2 = RGFW_POINT(((float)state.Gamepad.sThumbRX / 32768.0f) * 100, ((float)state.Gamepad.sThumbRY / -32768.0f) * 100);
|
||||
|
||||
if (axis1.x != e->axis[0].x || axis1.y != e->axis[0].y || axis2.x != e->axis[1].x || axis2.y != e->axis[1].y) {
|
||||
win->event.whichAxis = (axis1.x != e->axis[0].x || axis1.y != e->axis[0].y) ? 0 : 1;
|
||||
if (axis1.x != e->axis[0].x || axis1.y != e->axis[0].y){
|
||||
win->event.whichAxis = 0;
|
||||
|
||||
e->type = RGFW_jsAxisMove;
|
||||
e->type = RGFW_gpAxisMove;
|
||||
|
||||
e->axis[0] = axis1;
|
||||
e->axis[1] = axis2;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
e->axis[0] = axis1;
|
||||
e->axis[1] = axis2;
|
||||
if (axis2.x != e->axis[1].x || axis2.y != e->axis[1].y) {
|
||||
win->event.whichAxis = 1;
|
||||
e->type = RGFW_gpAxisMove;
|
||||
e->axis[1] = axis2;
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
@ -6517,19 +6538,19 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
|
|||
CloseClipboard();
|
||||
}
|
||||
|
||||
u16 RGFW_registerJoystick(RGFW_window* win, i32 jsNumber) {
|
||||
u16 RGFW_registerGamepad(RGFW_window* win, i32 gpNumber) {
|
||||
assert(win != NULL);
|
||||
|
||||
RGFW_UNUSED(jsNumber)
|
||||
RGFW_UNUSED(gpNumber)
|
||||
|
||||
return RGFW_registerJoystickF(win, (char*) "");
|
||||
return RGFW_registerGamepadF(win, (char*) "");
|
||||
}
|
||||
|
||||
u16 RGFW_registerJoystickF(RGFW_window* win, char* file) {
|
||||
u16 RGFW_registerGamepadF(RGFW_window* win, char* file) {
|
||||
assert(win != NULL);
|
||||
RGFW_UNUSED(file)
|
||||
|
||||
return RGFW_joystickCount - 1;
|
||||
return RGFW_gamepadCount - 1;
|
||||
}
|
||||
|
||||
void RGFW_window_moveMouse(RGFW_window* win, RGFW_point p) {
|
||||
|
|
@ -8127,20 +8148,20 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
|
|||
NSPasteBoard_setString(NSPasteboard_generalPasteboard(), text, NSPasteboardTypeString);
|
||||
}
|
||||
|
||||
u16 RGFW_registerJoystick(RGFW_window* win, i32 jsNumber) {
|
||||
RGFW_UNUSED(jsNumber);
|
||||
u16 RGFW_registerGamepad(RGFW_window* win, i32 gpNumber) {
|
||||
RGFW_UNUSED(gpNumber);
|
||||
|
||||
assert(win != NULL);
|
||||
|
||||
return RGFW_registerJoystickF(win, (char*) "");
|
||||
return RGFW_registerGamepadF(win, (char*) "");
|
||||
}
|
||||
|
||||
u16 RGFW_registerJoystickF(RGFW_window* win, char* file) {
|
||||
u16 RGFW_registerGamepadF(RGFW_window* win, char* file) {
|
||||
RGFW_UNUSED(file);
|
||||
|
||||
assert(win != NULL);
|
||||
|
||||
return RGFW_joystickCount - 1;
|
||||
return RGFW_gamepadCount - 1;
|
||||
}
|
||||
|
||||
#ifdef RGFW_OPENGL
|
||||
|
|
@ -8343,17 +8364,28 @@ EM_BOOL Emscripten_on_fullscreenchange(int eventType, const EmscriptenFullscreen
|
|||
|
||||
RGFW_root->r = RGFW_RECT(0, 0, e->screenWidth, e->screenHeight);
|
||||
|
||||
EM_ASM("Module.canvas.focus();");
|
||||
|
||||
if (fullscreen == RGFW_FALSE) {
|
||||
RGFW_root->r = RGFW_RECT(0, 0, ogRect.w, ogRect.h);
|
||||
// emscripten_request_fullscreen("#canvas", 0);
|
||||
} else {
|
||||
#if __EMSCRIPTEN_major__ >= 1 && __EMSCRIPTEN_minor__ >= 29 && __EMSCRIPTEN_tiny__ >= 0
|
||||
EmscriptenFullscreenStrategy FSStrat = {0};
|
||||
FSStrat.scaleMode = EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH;//EMSCRIPTEN_FULLSCREEN_SCALE_ASPECT;// : EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH;
|
||||
FSStrat.canvasResolutionScaleMode = EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_HIDEF;
|
||||
FSStrat.filteringMode = EMSCRIPTEN_FULLSCREEN_FILTERING_DEFAULT;
|
||||
emscripten_request_fullscreen_strategy("#canvas", 1, &FSStrat);
|
||||
#else
|
||||
emscripten_request_fullscreen("#canvas", 1);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
emscripten_set_canvas_element_size("#canvas", RGFW_root->r.w, RGFW_root->r.h);
|
||||
|
||||
#ifdef LEGACY_GL_EMULATION
|
||||
EM_ASM("Module.canvas.focus()");
|
||||
#endif
|
||||
|
||||
RGFW_windowResizeCallback(RGFW_root, RGFW_root->r);
|
||||
|
||||
return EM_TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -8509,7 +8541,7 @@ EM_BOOL Emscripten_on_gamepad(int eventType, const EmscriptenGamepadEvent *gamep
|
|||
if (gamepadEvent->index >= 4)
|
||||
return 0;
|
||||
|
||||
RGFW_joysticks[gamepadEvent->index] = gamepadEvent->connected;
|
||||
RGFW_gamepads[gamepadEvent->index] = gamepadEvent->connected;
|
||||
|
||||
return 1; // The event was consumed by the callback handler
|
||||
}
|
||||
|
|
@ -8729,7 +8761,7 @@ RGFW_Event* RGFW_window_checkEvent(RGFW_window* win) {
|
|||
emscripten_sample_gamepad_data();
|
||||
/* check gamepads */
|
||||
for (int i = 0; (i < emscripten_get_num_gamepads()) && (i < 4); i++) {
|
||||
if (RGFW_joysticks[i] == 0)
|
||||
if (RGFW_gamepads[i] == 0)
|
||||
continue;
|
||||
EmscriptenGamepadEvent gamepadState;
|
||||
|
||||
|
|
@ -8739,11 +8771,11 @@ RGFW_Event* RGFW_window_checkEvent(RGFW_window* win) {
|
|||
// Register buttons data for every connected gamepad
|
||||
for (int j = 0; (j < gamepadState.numButtons) && (j < 16); j++) {
|
||||
u32 map[] = {
|
||||
RGFW_JS_A, RGFW_JS_B, RGFW_JS_X, RGFW_JS_Y,
|
||||
RGFW_JS_L1, RGFW_JS_R1, RGFW_JS_L2, RGFW_JS_R2,
|
||||
RGFW_JS_SELECT, RGFW_JS_START,
|
||||
RGFW_JS_L3, RGFW_JS_R3,
|
||||
RGFW_JS_UP, RGFW_JS_DOWN, RGFW_JS_LEFT, RGFW_JS_RIGHT
|
||||
RGFW_GP_A, RGFW_GP_B, RGFW_GP_X, RGFW_GP_Y,
|
||||
RGFW_GP_L1, RGFW_GP_R1, RGFW_GP_L2, RGFW_GP_R2,
|
||||
RGFW_GP_SELECT, RGFW_GP_START,
|
||||
RGFW_GP_L3, RGFW_GP_R3,
|
||||
RGFW_GP_UP, RGFW_GP_DOWN, RGFW_GP_LEFT, RGFW_GP_RIGHT
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -8751,15 +8783,15 @@ RGFW_Event* RGFW_window_checkEvent(RGFW_window* win) {
|
|||
if (button == 404)
|
||||
continue;
|
||||
|
||||
if (RGFW_jsPressed[i][button] != gamepadState.digitalButton[j]) {
|
||||
if (RGFW_gpPressed[i][button] != gamepadState.digitalButton[j]) {
|
||||
if (gamepadState.digitalButton[j])
|
||||
win->event.type = RGFW_jsButtonPressed;
|
||||
win->event.type = RGFW_gpButtonPressed;
|
||||
else
|
||||
win->event.type = RGFW_jsButtonReleased;
|
||||
win->event.type = RGFW_gpButtonReleased;
|
||||
|
||||
win->event.joystick = i;
|
||||
win->event.gamepad = i;
|
||||
win->event.button = map[j];
|
||||
RGFW_jsPressed[i][button] = gamepadState.digitalButton[j];
|
||||
RGFW_gpPressed[i][button] = gamepadState.digitalButton[j];
|
||||
return &win->event;
|
||||
}
|
||||
}
|
||||
|
|
@ -8771,8 +8803,8 @@ RGFW_Event* RGFW_window_checkEvent(RGFW_window* win) {
|
|||
) {
|
||||
win->event.axis[j / 2].x = (i8)(gamepadState.axis[j] * 100.0f);
|
||||
win->event.axis[j / 2].y = (i8)(gamepadState.axis[j + 1] * 100.0f);
|
||||
win->event.type = RGFW_jsAxisMove;
|
||||
win->event.joystick = i;
|
||||
win->event.type = RGFW_gpAxisMove;
|
||||
win->event.gamepad = i;
|
||||
win->event.whichAxis = j / 2;
|
||||
return &win->event;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -515,6 +515,16 @@ const char *GetClipboardText(void)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
// Get clipboard image
|
||||
Image GetClipboardImage(void)
|
||||
{
|
||||
Image image = { 0 };
|
||||
|
||||
TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform");
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
// Show mouse cursor
|
||||
void ShowCursor(void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@
|
|||
// NOTE: Those functions require linking with winmm library
|
||||
//#pragma warning(disable: 4273)
|
||||
__declspec(dllimport) unsigned int __stdcall timeEndPeriod(unsigned int uPeriod);
|
||||
//#pragma warning(default: 4273)
|
||||
//#pragma warning(default: 4273)
|
||||
#endif
|
||||
#endif
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
|
|
@ -967,32 +967,29 @@ const char *GetClipboardText(void)
|
|||
return glfwGetClipboardString(platform.handle);
|
||||
}
|
||||
|
||||
#if defined(SUPPORT_CLIPBOARD_IMAGE)
|
||||
// Get clipboard image
|
||||
Image GetClipboardImage(void)
|
||||
{
|
||||
Image image = {0};
|
||||
Image image = { 0 };
|
||||
|
||||
#if defined(SUPPORT_CLIPBOARD_IMAGE)
|
||||
#if defined(_WIN32)
|
||||
unsigned long long int dataSize = 0;
|
||||
void* fileData = NULL;
|
||||
void *fileData = NULL;
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
|
||||
#ifdef _WIN32
|
||||
int width, height;
|
||||
fileData = (void*)Win32GetClipboardImageData(&width, &height, &dataSize);
|
||||
#else
|
||||
TRACELOG(LOG_WARNING, "Clipboard image: PLATFORM_DESKTOP_GLFW doesn't implement `GetClipboardImage` for this OS");
|
||||
#endif
|
||||
|
||||
if (fileData == NULL)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "Clipboard image: Couldn't get clipboard data.");
|
||||
}
|
||||
else
|
||||
{
|
||||
image = LoadImageFromMemory(".bmp", fileData, (int)dataSize);
|
||||
}
|
||||
if (fileData == NULL) TRACELOG(LOG_WARNING, "Clipboard image: Couldn't get clipboard data.");
|
||||
else image = LoadImageFromMemory(".bmp", fileData, (int)dataSize);
|
||||
#else
|
||||
TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform");
|
||||
#endif
|
||||
#endif // SUPPORT_CLIPBOARD_IMAGE
|
||||
|
||||
return image;
|
||||
}
|
||||
#endif // SUPPORT_CLIPBOARD_IMAGE
|
||||
|
||||
// Show mouse cursor
|
||||
void ShowCursor(void)
|
||||
|
|
|
|||
|
|
@ -865,24 +865,24 @@ char RSGL_keystrToChar(const char *str)
|
|||
return '\0';
|
||||
}
|
||||
|
||||
int RGFW_jsConvTable[18] = {
|
||||
[RGFW_JS_Y] = GAMEPAD_BUTTON_RIGHT_FACE_UP,
|
||||
[RGFW_JS_B] = GAMEPAD_BUTTON_RIGHT_FACE_RIGHT,
|
||||
[RGFW_JS_A] = GAMEPAD_BUTTON_RIGHT_FACE_DOWN,
|
||||
[RGFW_JS_X] = GAMEPAD_BUTTON_RIGHT_FACE_LEFT,
|
||||
[RGFW_JS_L1] = GAMEPAD_BUTTON_LEFT_TRIGGER_1,
|
||||
[RGFW_JS_R1] = GAMEPAD_BUTTON_RIGHT_TRIGGER_1,
|
||||
[RGFW_JS_L2] = GAMEPAD_BUTTON_LEFT_TRIGGER_2,
|
||||
[RGFW_JS_R2] = GAMEPAD_BUTTON_RIGHT_TRIGGER_2,
|
||||
[RGFW_JS_SELECT] = GAMEPAD_BUTTON_MIDDLE_LEFT,
|
||||
[RGFW_JS_HOME] = GAMEPAD_BUTTON_MIDDLE,
|
||||
[RGFW_JS_START] = GAMEPAD_BUTTON_MIDDLE_RIGHT,
|
||||
[RGFW_JS_UP] = GAMEPAD_BUTTON_LEFT_FACE_UP,
|
||||
[RGFW_JS_RIGHT] = GAMEPAD_BUTTON_LEFT_FACE_RIGHT,
|
||||
[RGFW_JS_DOWN] = GAMEPAD_BUTTON_LEFT_FACE_DOWN,
|
||||
[RGFW_JS_LEFT] = GAMEPAD_BUTTON_LEFT_FACE_LEFT,
|
||||
[RGFW_JS_L3] = GAMEPAD_BUTTON_LEFT_THUMB,
|
||||
[RGFW_JS_R3] = GAMEPAD_BUTTON_RIGHT_THUMB,
|
||||
int RGFW_gpConvTable[18] = {
|
||||
[RGFW_GP_Y] = GAMEPAD_BUTTON_RIGHT_FACE_UP,
|
||||
[RGFW_GP_B] = GAMEPAD_BUTTON_RIGHT_FACE_RIGHT,
|
||||
[RGFW_GP_A] = GAMEPAD_BUTTON_RIGHT_FACE_DOWN,
|
||||
[RGFW_GP_X] = GAMEPAD_BUTTON_RIGHT_FACE_LEFT,
|
||||
[RGFW_GP_L1] = GAMEPAD_BUTTON_LEFT_TRIGGER_1,
|
||||
[RGFW_GP_R1] = GAMEPAD_BUTTON_RIGHT_TRIGGER_1,
|
||||
[RGFW_GP_L2] = GAMEPAD_BUTTON_LEFT_TRIGGER_2,
|
||||
[RGFW_GP_R2] = GAMEPAD_BUTTON_RIGHT_TRIGGER_2,
|
||||
[RGFW_GP_SELECT] = GAMEPAD_BUTTON_MIDDLE_LEFT,
|
||||
[RGFW_GP_HOME] = GAMEPAD_BUTTON_MIDDLE,
|
||||
[RGFW_GP_START] = GAMEPAD_BUTTON_MIDDLE_RIGHT,
|
||||
[RGFW_GP_UP] = GAMEPAD_BUTTON_LEFT_FACE_UP,
|
||||
[RGFW_GP_RIGHT] = GAMEPAD_BUTTON_LEFT_FACE_RIGHT,
|
||||
[RGFW_GP_DOWN] = GAMEPAD_BUTTON_LEFT_FACE_DOWN,
|
||||
[RGFW_GP_LEFT] = GAMEPAD_BUTTON_LEFT_FACE_LEFT,
|
||||
[RGFW_GP_L3] = GAMEPAD_BUTTON_LEFT_THUMB,
|
||||
[RGFW_GP_R3] = GAMEPAD_BUTTON_RIGHT_THUMB,
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -959,15 +959,15 @@ void PollInputEvents(void)
|
|||
|
||||
while (RGFW_window_checkEvent(platform.window))
|
||||
{
|
||||
if ((platform.window->event.type >= RGFW_jsButtonPressed) && (platform.window->event.type <= RGFW_jsAxisMove))
|
||||
if ((platform.window->event.type >= RGFW_gpButtonPressed) && (platform.window->event.type <= RGFW_gpAxisMove))
|
||||
{
|
||||
if (!CORE.Input.Gamepad.ready[platform.window->event.joystick])
|
||||
if (!CORE.Input.Gamepad.ready[platform.window->event.gamepad])
|
||||
{
|
||||
CORE.Input.Gamepad.ready[platform.window->event.joystick] = true;
|
||||
CORE.Input.Gamepad.axisCount[platform.window->event.joystick] = platform.window->event.axisesCount;
|
||||
CORE.Input.Gamepad.name[platform.window->event.joystick][0] = '\0';
|
||||
CORE.Input.Gamepad.axisState[platform.window->event.joystick][GAMEPAD_AXIS_LEFT_TRIGGER] = -1.0f;
|
||||
CORE.Input.Gamepad.axisState[platform.window->event.joystick][GAMEPAD_AXIS_RIGHT_TRIGGER] = -1.0f;
|
||||
CORE.Input.Gamepad.ready[platform.window->event.gamepad] = true;
|
||||
CORE.Input.Gamepad.axisCount[platform.window->event.gamepad] = platform.window->event.axisesCount;
|
||||
CORE.Input.Gamepad.name[platform.window->event.gamepad][0] = '\0';
|
||||
CORE.Input.Gamepad.axisState[platform.window->event.gamepad][GAMEPAD_AXIS_LEFT_TRIGGER] = -1.0f;
|
||||
CORE.Input.Gamepad.axisState[platform.window->event.gamepad][GAMEPAD_AXIS_RIGHT_TRIGGER] = -1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1112,24 +1112,24 @@ void PollInputEvents(void)
|
|||
CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition;
|
||||
touchAction = 2;
|
||||
} break;
|
||||
case RGFW_jsButtonPressed:
|
||||
case RGFW_gpButtonPressed:
|
||||
{
|
||||
int button = RGFW_jsConvTable[event->button];
|
||||
int button = RGFW_gpConvTable[event->button];
|
||||
|
||||
if (button >= 0)
|
||||
{
|
||||
CORE.Input.Gamepad.currentButtonState[event->joystick][button] = 1;
|
||||
CORE.Input.Gamepad.currentButtonState[event->gamepad][button] = 1;
|
||||
CORE.Input.Gamepad.lastButtonPressed = button;
|
||||
}
|
||||
} break;
|
||||
case RGFW_jsButtonReleased:
|
||||
case RGFW_gpButtonReleased:
|
||||
{
|
||||
int button = RGFW_jsConvTable[event->button];
|
||||
int button = RGFW_gpConvTable[event->button];
|
||||
|
||||
CORE.Input.Gamepad.currentButtonState[event->joystick][button] = 0;
|
||||
CORE.Input.Gamepad.currentButtonState[event->gamepad][button] = 0;
|
||||
if (CORE.Input.Gamepad.lastButtonPressed == button) CORE.Input.Gamepad.lastButtonPressed = 0;
|
||||
} break;
|
||||
case RGFW_jsAxisMove:
|
||||
case RGFW_gpAxisMove:
|
||||
{
|
||||
int axis = -1;
|
||||
|
||||
|
|
@ -1137,19 +1137,19 @@ void PollInputEvents(void)
|
|||
switch(event->whichAxis) {
|
||||
case 0:
|
||||
{
|
||||
CORE.Input.Gamepad.axisState[event->joystick][GAMEPAD_AXIS_LEFT_X] = event->axis[0].x / 100.0f;
|
||||
CORE.Input.Gamepad.axisState[event->joystick][GAMEPAD_AXIS_LEFT_Y] = event->axis[0].y / 100.0f;
|
||||
CORE.Input.Gamepad.axisState[event->gamepad][GAMEPAD_AXIS_LEFT_X] = event->axis[0].x / 100.0f;
|
||||
CORE.Input.Gamepad.axisState[event->gamepad][GAMEPAD_AXIS_LEFT_Y] = event->axis[0].y / 100.0f;
|
||||
} break;
|
||||
case 1:
|
||||
{
|
||||
CORE.Input.Gamepad.axisState[event->joystick][GAMEPAD_AXIS_RIGHT_X] = event->axis[1].x / 100.0f;
|
||||
CORE.Input.Gamepad.axisState[event->joystick][GAMEPAD_AXIS_RIGHT_Y] = event->axis[1].y / 100.0f;
|
||||
CORE.Input.Gamepad.axisState[event->gamepad][GAMEPAD_AXIS_RIGHT_X] = event->axis[1].x / 100.0f;
|
||||
CORE.Input.Gamepad.axisState[event->gamepad][GAMEPAD_AXIS_RIGHT_Y] = event->axis[1].y / 100.0f;
|
||||
} break;
|
||||
case 2: axis = GAMEPAD_AXIS_LEFT_TRIGGER;
|
||||
case 3: { if (axis == -1) axis = GAMEPAD_AXIS_RIGHT_TRIGGER;
|
||||
int button = (axis == GAMEPAD_AXIS_LEFT_TRIGGER)? GAMEPAD_BUTTON_LEFT_TRIGGER_2 : GAMEPAD_BUTTON_RIGHT_TRIGGER_2;
|
||||
int pressed = (value > 0.1f);
|
||||
CORE.Input.Gamepad.currentButtonState[event->joystick][button] = pressed;
|
||||
CORE.Input.Gamepad.currentButtonState[event->gamepad][button] = pressed;
|
||||
|
||||
if (pressed) CORE.Input.Gamepad.lastButtonPressed = button;
|
||||
else if (CORE.Input.Gamepad.lastButtonPressed == button) CORE.Input.Gamepad.lastButtonPressed = 0;
|
||||
|
|
@ -1316,7 +1316,7 @@ int InitPlatform(void)
|
|||
#ifdef RGFW_X11
|
||||
for (int i = 0; (i < 4) && (i < MAX_GAMEPADS); i++)
|
||||
{
|
||||
RGFW_registerJoystick(platform.window, i);
|
||||
RGFW_registergamepad(platform.window, i);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,6 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Types and Structures Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
@ -240,16 +239,15 @@ static const int CursorsLUT[] = {
|
|||
|
||||
|
||||
// SDL3 Migration Layer made to avoid `ifdefs` inside functions when we can.
|
||||
#ifdef PLATFORM_DESKTOP_SDL3
|
||||
#if defined(PLATFORM_DESKTOP_SDL3)
|
||||
|
||||
// SDL3 Migration:
|
||||
// SDL_WINDOW_FULLSCREEN_DESKTOP has been removed,
|
||||
// and you can call SDL_GetWindowFullscreenMode()
|
||||
// to see whether an exclusive fullscreen mode will be used
|
||||
// to see whether an exclusive fullscreen mode will be used
|
||||
// or the borderless fullscreen desktop mode will be used
|
||||
#define SDL_WINDOW_FULLSCREEN_DESKTOP SDL_WINDOW_FULLSCREEN
|
||||
|
||||
|
||||
#define SDL_IGNORE false
|
||||
#define SDL_DISABLE false
|
||||
#define SDL_ENABLE true
|
||||
|
|
@ -260,27 +258,29 @@ static const int CursorsLUT[] = {
|
|||
// SDL3 Migration: The SDL_WINDOW_SHOWN flag has been removed. Windows are shown by default and can be created hidden by using the SDL_WINDOW_HIDDEN flag.
|
||||
#define SDL_WINDOW_SHOWN 0x0 // It's a flag, so no problem in setting it to zero if we use in a bitor (|)
|
||||
|
||||
//
|
||||
// SDL3 Migration: Renamed
|
||||
// IMPORTANT:
|
||||
// Might need to call SDL_CleanupEvent somewhere see :https://github.com/libsdl-org/SDL/issues/3540#issuecomment-1793449852
|
||||
//
|
||||
// IMPORTANT: Might need to call SDL_CleanupEvent somewhere see :https://github.com/libsdl-org/SDL/issues/3540#issuecomment-1793449852
|
||||
#define SDL_DROPFILE SDL_EVENT_DROP_FILE
|
||||
|
||||
|
||||
const char* SDL_GameControllerNameForIndex(int joystickIndex)
|
||||
// SDL2 implementation for SDL3 function
|
||||
const char *SDL_GameControllerNameForIndex(int joystickIndex)
|
||||
{
|
||||
// NOTE: SDL3 uses the IDs itself (SDL_JoystickID) instead of SDL2 joystick_index
|
||||
const char* name = NULL;
|
||||
const char *name = NULL;
|
||||
int numJoysticks = 0;
|
||||
SDL_JoystickID *joysticks = SDL_GetJoysticks(&numJoysticks);
|
||||
if (joysticks) {
|
||||
if (joystickIndex < numJoysticks) {
|
||||
|
||||
if (joysticks)
|
||||
{
|
||||
if (joystickIndex < numJoysticks)
|
||||
{
|
||||
SDL_JoystickID instance_id = joysticks[joystickIndex];
|
||||
name = SDL_GetGamepadNameForID(instance_id);
|
||||
}
|
||||
|
||||
SDL_free(joysticks);
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
|
|
@ -288,45 +288,40 @@ int SDL_GetNumVideoDisplays(void)
|
|||
{
|
||||
int monitorCount = 0;
|
||||
SDL_DisplayID *displays = SDL_GetDisplays(&monitorCount);
|
||||
// Safe because If `mem` is NULL, SDL_free does nothing.
|
||||
|
||||
// Safe because If `mem` is NULL, SDL_free does nothing
|
||||
SDL_free(displays);
|
||||
|
||||
return monitorCount;
|
||||
}
|
||||
|
||||
|
||||
// SLD3 Migration:
|
||||
// To emulate SDL2 this function should return `SDL_DISABLE` or `SDL_ENABLE`
|
||||
// representing the *processing state* of the event before this function makes any changes to it.
|
||||
Uint8 SDL_EventState(Uint32 type, int state) {
|
||||
|
||||
// SLD3 Migration: To emulate SDL2 this function should return `SDL_DISABLE` or `SDL_ENABLE`
|
||||
// representing the *processing state* of the event before this function makes any changes to it
|
||||
Uint8 SDL_EventState(Uint32 type, int state)
|
||||
{
|
||||
Uint8 stateBefore = SDL_EventEnabled(type);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case SDL_DISABLE: SDL_SetEventEnabled(type, false); break;
|
||||
case SDL_ENABLE: SDL_SetEventEnabled(type, true); break;
|
||||
default: TRACELOG(LOG_WARNING, "Event sate: unknow type");
|
||||
}
|
||||
|
||||
return stateBefore;
|
||||
}
|
||||
|
||||
void SDL_GetCurrentDisplayMode_Adapter(SDL_DisplayID displayID, SDL_DisplayMode* mode)
|
||||
{
|
||||
const SDL_DisplayMode* currMode = SDL_GetCurrentDisplayMode(displayID);
|
||||
if (currMode == NULL)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "No current display mode");
|
||||
}
|
||||
else
|
||||
{
|
||||
*mode = *currMode;
|
||||
}
|
||||
|
||||
if (currMode == NULL) TRACELOG(LOG_WARNING, "No current display mode");
|
||||
else *mode = *currMode;
|
||||
}
|
||||
|
||||
// SDL3 Migration: Renamed
|
||||
#define SDL_GetCurrentDisplayMode SDL_GetCurrentDisplayMode_Adapter
|
||||
|
||||
|
||||
SDL_Surface *SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
|
||||
{
|
||||
return SDL_CreateSurface(width, height, SDL_GetPixelFormatForMasks(depth, Rmask, Gmask, Bmask, Amask));
|
||||
|
|
@ -337,11 +332,14 @@ SDL_Surface *SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth
|
|||
// not reliable across platforms, approximately replaced by multiplying
|
||||
// SDL_GetWindowDisplayScale() times 160 on iPhone and Android, and 96 on other platforms.
|
||||
// returns 0 on success or a negative error code on failure
|
||||
int SDL_GetDisplayDPI(int displayIndex, float * ddpi, float * hdpi, float * vdpi) {
|
||||
float dpi = SDL_GetWindowDisplayScale(platform.window) * 96.0;
|
||||
int SDL_GetDisplayDPI(int displayIndex, float *ddpi, float *hdpi, float *vdpi)
|
||||
{
|
||||
float dpi = SDL_GetWindowDisplayScale(platform.window)*96.0;
|
||||
|
||||
if (ddpi != NULL) *ddpi = dpi;
|
||||
if (hdpi != NULL) *hdpi = dpi;
|
||||
if (vdpi != NULL) *vdpi = dpi;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -368,17 +366,13 @@ int SDL_NumJoysticks(void)
|
|||
return numJoysticks;
|
||||
}
|
||||
|
||||
|
||||
// SDL_SetRelativeMouseMode
|
||||
// returns 0 on success or a negative error code on failure
|
||||
// If relative mode is not supported, this returns -1.
|
||||
int SDL_SetRelativeMouseMode_Adapter(SDL_bool enabled)
|
||||
{
|
||||
|
||||
//
|
||||
// SDL_SetWindowRelativeMouseMode(SDL_Window *window, bool enabled)
|
||||
// \returns true on success or false on failure; call SDL_GetError() for more
|
||||
//
|
||||
if (SDL_SetWindowRelativeMouseMode(platform.window, enabled))
|
||||
{
|
||||
return 0; // success
|
||||
|
|
@ -398,7 +392,6 @@ bool SDL_GetRelativeMouseMode_Adapter(void)
|
|||
|
||||
#define SDL_GetRelativeMouseMode SDL_GetRelativeMouseMode_Adapter
|
||||
|
||||
|
||||
int SDL_GetNumTouchFingers(SDL_TouchID touchID)
|
||||
{
|
||||
// SDL_Finger **SDL_GetTouchFingers(SDL_TouchID touchID, int *count)
|
||||
|
|
@ -412,16 +405,16 @@ int SDL_GetNumTouchFingers(SDL_TouchID touchID)
|
|||
|
||||
// Since SDL2 doesn't have this function we leave a stub
|
||||
// SDL_GetClipboardData function is available since SDL 3.1.3. (e.g. SDL3)
|
||||
void* SDL_GetClipboardData(const char *mime_type, size_t *size) {
|
||||
void* SDL_GetClipboardData(const char *mime_type, size_t *size)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "Getting clipboard data that is not text is only available in SDL3");
|
||||
|
||||
// We could possibly implement it ourselves in this case for some easier platforms
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif // PLATFORM_DESKTOP_SDL3
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Internal Functions Declaration
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
@ -452,7 +445,7 @@ void ToggleFullscreen(void)
|
|||
const int monitor = SDL_GetWindowDisplayIndex(platform.window);
|
||||
const int monitorCount = SDL_GetNumVideoDisplays();
|
||||
|
||||
#ifdef PLATFORM_DESKTOP_SDL3 // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure
|
||||
#if defined(PLATFORM_DESKTOP_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure
|
||||
if ((monitor > 0) && (monitor <= monitorCount))
|
||||
#else
|
||||
if ((monitor >= 0) && (monitor < monitorCount))
|
||||
|
|
@ -479,7 +472,8 @@ void ToggleBorderlessWindowed(void)
|
|||
{
|
||||
const int monitor = SDL_GetWindowDisplayIndex(platform.window);
|
||||
const int monitorCount = SDL_GetNumVideoDisplays();
|
||||
#ifdef PLATFORM_DESKTOP_SDL3 // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure
|
||||
|
||||
#if defined(PLATFORM_DESKTOP_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure
|
||||
if ((monitor > 0) && (monitor <= monitorCount))
|
||||
#else
|
||||
if ((monitor >= 0) && (monitor < monitorCount))
|
||||
|
|
@ -532,7 +526,8 @@ void SetWindowState(unsigned int flags)
|
|||
{
|
||||
const int monitor = SDL_GetWindowDisplayIndex(platform.window);
|
||||
const int monitorCount = SDL_GetNumVideoDisplays();
|
||||
#ifdef PLATFORM_DESKTOP_SDL3 // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure
|
||||
|
||||
#if defined(PLATFORM_DESKTOP_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure
|
||||
if ((monitor > 0) && (monitor <= monitorCount))
|
||||
#else
|
||||
if ((monitor >= 0) && (monitor < monitorCount))
|
||||
|
|
@ -595,7 +590,8 @@ void SetWindowState(unsigned int flags)
|
|||
{
|
||||
const int monitor = SDL_GetWindowDisplayIndex(platform.window);
|
||||
const int monitorCount = SDL_GetNumVideoDisplays();
|
||||
#ifdef PLATFORM_DESKTOP_SDL3 // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure
|
||||
|
||||
#if defined(PLATFORM_DESKTOP_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure
|
||||
if ((monitor > 0) && (monitor <= monitorCount))
|
||||
#else
|
||||
if ((monitor >= 0) && (monitor < monitorCount))
|
||||
|
|
@ -818,7 +814,8 @@ void SetWindowMonitor(int monitor)
|
|||
const int screenWidth = CORE.Window.screen.width;
|
||||
const int screenHeight = CORE.Window.screen.height;
|
||||
SDL_Rect usableBounds;
|
||||
#ifdef PLATFORM_DESKTOP_SDL3 // Different style for success checking
|
||||
|
||||
#if defined(PLATFORM_DESKTOP_SDL3) // Different style for success checking
|
||||
if (SDL_GetDisplayUsableBounds(monitor, &usableBounds))
|
||||
#else
|
||||
if (SDL_GetDisplayUsableBounds(monitor, &usableBounds) == 0)
|
||||
|
|
@ -933,7 +930,8 @@ Vector2 GetMonitorPosition(int monitor)
|
|||
if ((monitor >= 0) && (monitor < monitorCount))
|
||||
{
|
||||
SDL_Rect displayBounds;
|
||||
#ifdef PLATFORM_DESKTOP_SDL3
|
||||
|
||||
#if defined(PLATFORM_DESKTOP_SDL3)
|
||||
if (SDL_GetDisplayUsableBounds(monitor, &displayBounds))
|
||||
#else
|
||||
if (SDL_GetDisplayUsableBounds(monitor, &displayBounds) == 0)
|
||||
|
|
@ -1104,53 +1102,55 @@ const char *GetClipboardText(void)
|
|||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
#if defined(SUPPORT_CLIPBOARD_IMAGE)
|
||||
// Get clipboard image
|
||||
Image GetClipboardImage(void)
|
||||
{
|
||||
Image image = { 0 };
|
||||
|
||||
#if defined(SUPPORT_CLIPBOARD_IMAGE)
|
||||
// Let's hope compiler put these arrays in static memory
|
||||
const char *image_formats[] = {
|
||||
const char *imageFormats[] = {
|
||||
"image/bmp",
|
||||
"image/png",
|
||||
"image/jpg",
|
||||
"image/tiff",
|
||||
};
|
||||
const char *image_extensions[] = {
|
||||
const char *imageExtensions[] = {
|
||||
".bmp",
|
||||
".png",
|
||||
".jpg",
|
||||
".tiff",
|
||||
};
|
||||
|
||||
|
||||
Image image = {0};
|
||||
size_t dataSize = 0;
|
||||
void *fileData = NULL;
|
||||
for (int i = 0; i < SDL_arraysize(image_formats); ++i)
|
||||
|
||||
for (int i = 0; i < SDL_arraysize(imageFormats); ++i)
|
||||
{
|
||||
// NOTE: This pointer should be free with SDL_free() at some point.
|
||||
fileData = SDL_GetClipboardData(image_formats[i], &dataSize);
|
||||
if (fileData) {
|
||||
image = LoadImageFromMemory(image_extensions[i], fileData, dataSize);
|
||||
// NOTE: This pointer should be free with SDL_free() at some point
|
||||
fileData = SDL_GetClipboardData(imageFormats[i], &dataSize);
|
||||
|
||||
if (fileData)
|
||||
{
|
||||
image = LoadImageFromMemory(imageExtensions[i], fileData, dataSize);
|
||||
if (IsImageValid(image))
|
||||
{
|
||||
TRACELOG(LOG_INFO, "Clipboard image: Got image from clipboard as a `%s` successfully", image_extensions[i]);
|
||||
TRACELOG(LOG_INFO, "Clipboard image: Got image from clipboard as a `%s` successfully", imageExtensions[i]);
|
||||
return image;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TRACELOG(LOG_WARNING, "Clipboard image: Couldn't get clipboard data. %s", SDL_GetError());
|
||||
return image;
|
||||
}
|
||||
if (!IsImageValid(image)) TRACELOG(LOG_WARNING, "Clipboard image: Couldn't get clipboard data. Error: %s", SDL_GetError());
|
||||
#endif
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
// Show mouse cursor
|
||||
void ShowCursor(void)
|
||||
{
|
||||
#ifdef PLATFORM_DESKTOP_SDL3
|
||||
#if defined(PLATFORM_DESKTOP_SDL3)
|
||||
SDL_ShowCursor();
|
||||
#else
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
|
|
@ -1161,7 +1161,7 @@ void ShowCursor(void)
|
|||
// Hides mouse cursor
|
||||
void HideCursor(void)
|
||||
{
|
||||
#ifdef PLATFORM_DESKTOP_SDL3
|
||||
#if defined(PLATFORM_DESKTOP_SDL3)
|
||||
SDL_HideCursor();
|
||||
#else
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
|
|
@ -1174,7 +1174,7 @@ void EnableCursor(void)
|
|||
{
|
||||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||
|
||||
#ifdef PLATFORM_DESKTOP_SDL3
|
||||
#if defined(PLATFORM_DESKTOP_SDL3)
|
||||
// SDL_ShowCursor() has been split into three functions: SDL_ShowCursor(), SDL_HideCursor(), and SDL_CursorVisible()
|
||||
SDL_ShowCursor();
|
||||
#else
|
||||
|
|
@ -1275,7 +1275,7 @@ const char *GetKeyName(int key)
|
|||
|
||||
static void UpdateTouchPointsSDL(SDL_TouchFingerEvent event)
|
||||
{
|
||||
#ifdef PLATFORM_DESKTOP_SDL3 // SDL3
|
||||
#if defined(PLATFORM_DESKTOP_SDL3) // SDL3
|
||||
int count = 0;
|
||||
SDL_Finger **fingers = SDL_GetTouchFingers(event.touchID, &count);
|
||||
CORE.Input.Touch.pointCount = count;
|
||||
|
|
@ -1288,7 +1288,9 @@ static void UpdateTouchPointsSDL(SDL_TouchFingerEvent event)
|
|||
CORE.Input.Touch.position[i].y = finger->y*CORE.Window.screen.height;
|
||||
CORE.Input.Touch.currentTouchState[i] = 1;
|
||||
}
|
||||
|
||||
SDL_free(fingers);
|
||||
|
||||
#else // SDL2
|
||||
|
||||
CORE.Input.Touch.pointCount = SDL_GetNumTouchFingers(event.touchId);
|
||||
|
|
@ -1393,7 +1395,8 @@ void PollInputEvents(void)
|
|||
CORE.Window.dropFilepaths = (char **)RL_CALLOC(1024, sizeof(char *));
|
||||
|
||||
CORE.Window.dropFilepaths[CORE.Window.dropFileCount] = (char *)RL_CALLOC(MAX_FILEPATH_LENGTH, sizeof(char));
|
||||
#ifdef PLATFORM_DESKTOP_SDL3
|
||||
|
||||
#if defined(PLATFORM_DESKTOP_SDL3)
|
||||
// const char *data; /**< The text for SDL_EVENT_DROP_TEXT and the file name for SDL_EVENT_DROP_FILE, NULL for other events */
|
||||
// Event memory is now managed by SDL, so you should not free the data in SDL_EVENT_DROP_FILE, and if you want to hold onto the text in SDL_EVENT_TEXT_EDITING and SDL_EVENT_TEXT_INPUT events, you should make a copy of it. SDL_TEXTINPUTEVENT_TEXT_SIZE is no longer necessary and has been removed.
|
||||
strcpy(CORE.Window.dropFilepaths[CORE.Window.dropFileCount], event.drop.data);
|
||||
|
|
@ -1407,7 +1410,8 @@ void PollInputEvents(void)
|
|||
else if (CORE.Window.dropFileCount < 1024)
|
||||
{
|
||||
CORE.Window.dropFilepaths[CORE.Window.dropFileCount] = (char *)RL_CALLOC(MAX_FILEPATH_LENGTH, sizeof(char));
|
||||
#ifdef PLATFORM_DESKTOP_SDL3
|
||||
|
||||
#if defined(PLATFORM_DESKTOP_SDL3)
|
||||
strcpy(CORE.Window.dropFilepaths[CORE.Window.dropFileCount], event.drop.data);
|
||||
#else
|
||||
strcpy(CORE.Window.dropFilepaths[CORE.Window.dropFileCount], event.drop.file);
|
||||
|
|
@ -1460,7 +1464,7 @@ void PollInputEvents(void)
|
|||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||
case SDL_WINDOWEVENT_MAXIMIZED:
|
||||
case SDL_WINDOWEVENT_RESTORED:
|
||||
#ifdef PLATFORM_DESKTOP_SDL3
|
||||
#if defined(PLATFORM_DESKTOP_SDL3)
|
||||
break;
|
||||
#else
|
||||
default: break;
|
||||
|
|
@ -1471,7 +1475,7 @@ void PollInputEvents(void)
|
|||
// Keyboard events
|
||||
case SDL_KEYDOWN:
|
||||
{
|
||||
#ifdef PLATFORM_DESKTOP_SDL3
|
||||
#if defined(PLATFORM_DESKTOP_SDL3)
|
||||
// SDL3 Migration: The following structures have been removed: * SDL_Keysym
|
||||
KeyboardKey key = ConvertScancodeToKey(event.key.scancode);
|
||||
#else
|
||||
|
|
@ -1502,7 +1506,7 @@ void PollInputEvents(void)
|
|||
case SDL_KEYUP:
|
||||
{
|
||||
|
||||
#ifdef PLATFORM_DESKTOP_SDL3
|
||||
#if defined(PLATFORM_DESKTOP_SDL3)
|
||||
KeyboardKey key = ConvertScancodeToKey(event.key.scancode);
|
||||
#else
|
||||
KeyboardKey key = ConvertScancodeToKey(event.key.keysym.scancode);
|
||||
|
|
@ -1858,7 +1862,7 @@ int InitPlatform(void)
|
|||
}
|
||||
|
||||
// Init window
|
||||
#ifdef PLATFORM_DESKTOP_SDL3
|
||||
#if defined(PLATFORM_DESKTOP_SDL3)
|
||||
platform.window = SDL_CreateWindow(CORE.Window.title, CORE.Window.screen.width, CORE.Window.screen.height, flags);
|
||||
#else
|
||||
platform.window = SDL_CreateWindow(CORE.Window.title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, CORE.Window.screen.width, CORE.Window.screen.height, flags);
|
||||
|
|
@ -1946,11 +1950,10 @@ int InitPlatform(void)
|
|||
CORE.Storage.basePath = SDL_GetBasePath(); // Alternative: GetWorkingDirectory();
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifdef PLATFORM_DESKTOP_SDL3
|
||||
#if defined(PLATFORM_DESKTOP_SDL3)
|
||||
TRACELOG(LOG_INFO, "PLATFORM: DESKTOP (SDL3): Initialized successfully");
|
||||
#else
|
||||
TRACELOG(LOG_INFO, "PLATFORM: DESKTOP (SDL): Initialized successfully");
|
||||
TRACELOG(LOG_INFO, "PLATFORM: DESKTOP (SDL2): Initialized successfully");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -509,6 +509,16 @@ const char *GetClipboardText(void)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
// Get clipboard image
|
||||
Image GetClipboardImage(void)
|
||||
{
|
||||
Image image = { 0 };
|
||||
|
||||
TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform");
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
// Show mouse cursor
|
||||
void ShowCursor(void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -292,6 +292,16 @@ const char *GetClipboardText(void)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
// Get clipboard image
|
||||
Image GetClipboardImage(void)
|
||||
{
|
||||
Image image = { 0 };
|
||||
|
||||
TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform");
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
// Show mouse cursor
|
||||
void ShowCursor(void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -771,8 +771,11 @@ Vector2 GetWindowPosition(void)
|
|||
// Get window scale DPI factor for current monitor
|
||||
Vector2 GetWindowScaleDPI(void)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "GetWindowScaleDPI() not implemented on target platform");
|
||||
return (Vector2){ 1.0f, 1.0f };
|
||||
// NOTE: Returned scale is relative to the current monitor where the browser window is located
|
||||
Vector2 scale = { 1.0f, 1.0f };
|
||||
scale.x = (float)EM_ASM_DOUBLE( { return window.devicePixelRatio; } );
|
||||
scale.y = scale.x;
|
||||
return scale;
|
||||
}
|
||||
|
||||
// Set clipboard text content
|
||||
|
|
@ -805,6 +808,16 @@ const char *GetClipboardText(void)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
// Get clipboard image
|
||||
Image GetClipboardImage(void)
|
||||
{
|
||||
Image image = { 0 };
|
||||
|
||||
TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform");
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
// Show mouse cursor
|
||||
void ShowCursor(void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1855,6 +1855,8 @@ void SeekMusicStream(Music music, float position)
|
|||
|
||||
ma_mutex_lock(&AUDIO.System.lock);
|
||||
music.stream.buffer->framesProcessed = positionInFrames;
|
||||
music.stream.buffer->isSubBufferProcessed[0] = true;
|
||||
music.stream.buffer->isSubBufferProcessed[1] = true;
|
||||
ma_mutex_unlock(&AUDIO.System.lock);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/**********************************************************************************************
|
||||
*
|
||||
* raylib v5.5 - A simple and easy-to-use library to enjoy videogames programming (www.raylib.com)
|
||||
* raylib v5.6-dev - A simple and easy-to-use library to enjoy videogames programming (www.raylib.com)
|
||||
*
|
||||
* FEATURES:
|
||||
* - NO external dependencies, all required libraries included with raylib
|
||||
|
|
@ -88,9 +88,9 @@
|
|||
#include <stdarg.h> // Required for: va_list - Only used by TraceLogCallback
|
||||
|
||||
#define RAYLIB_VERSION_MAJOR 5
|
||||
#define RAYLIB_VERSION_MINOR 5
|
||||
#define RAYLIB_VERSION_MINOR 6
|
||||
#define RAYLIB_VERSION_PATCH 0
|
||||
#define RAYLIB_VERSION "5.5"
|
||||
#define RAYLIB_VERSION "5.6-dev"
|
||||
|
||||
// Function specifiers in case library is build/used as a shared library
|
||||
// NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll
|
||||
|
|
|
|||
|
|
@ -304,6 +304,14 @@ RMAPI float Vector2DotProduct(Vector2 v1, Vector2 v2)
|
|||
return result;
|
||||
}
|
||||
|
||||
// Calculate two vectors cross product
|
||||
RMAPI float Vector2CrossProduct(Vector2 v1, Vector2 v2)
|
||||
{
|
||||
float result = (v1.x*v2.y - v1.y*v2.x);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Calculate distance between two vectors
|
||||
RMAPI float Vector2Distance(Vector2 v1, Vector2 v2)
|
||||
{
|
||||
|
|
@ -2648,7 +2656,7 @@ inline Vector2 operator * (const Vector2& lhs, const Matrix& rhs)
|
|||
return Vector2Transform(lhs, rhs);
|
||||
}
|
||||
|
||||
inline const Vector2& operator -= (Vector2& lhs, const Matrix& rhs)
|
||||
inline const Vector2& operator *= (Vector2& lhs, const Matrix& rhs)
|
||||
{
|
||||
lhs = Vector2Transform(lhs, rhs);
|
||||
return lhs;
|
||||
|
|
@ -2661,7 +2669,7 @@ inline Vector2 operator / (const Vector2& lhs, const float& rhs)
|
|||
|
||||
inline const Vector2& operator /= (Vector2& lhs, const float& rhs)
|
||||
{
|
||||
lhs = Vector2Scale(lhs, rhs);
|
||||
lhs = Vector2Scale(lhs, 1.0f / rhs);
|
||||
return lhs;
|
||||
}
|
||||
|
||||
|
|
@ -2742,7 +2750,7 @@ inline Vector3 operator * (const Vector3& lhs, const Matrix& rhs)
|
|||
return Vector3Transform(lhs, rhs);
|
||||
}
|
||||
|
||||
inline const Vector3& operator -= (Vector3& lhs, const Matrix& rhs)
|
||||
inline const Vector3& operator *= (Vector3& lhs, const Matrix& rhs)
|
||||
{
|
||||
lhs = Vector3Transform(lhs, rhs);
|
||||
return lhs;
|
||||
|
|
@ -2755,7 +2763,7 @@ inline Vector3 operator / (const Vector3& lhs, const float& rhs)
|
|||
|
||||
inline const Vector3& operator /= (Vector3& lhs, const float& rhs)
|
||||
{
|
||||
lhs = Vector3Scale(lhs, rhs);
|
||||
lhs = Vector3Scale(lhs, 1.0f / rhs);
|
||||
return lhs;
|
||||
}
|
||||
|
||||
|
|
@ -2839,7 +2847,7 @@ inline Vector4 operator / (const Vector4& lhs, const float& rhs)
|
|||
|
||||
inline const Vector4& operator /= (Vector4& lhs, const float& rhs)
|
||||
{
|
||||
lhs = Vector4Scale(lhs, rhs);
|
||||
lhs = Vector4Scale(lhs, 1.0f / rhs);
|
||||
return lhs;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* rlgl v5.0 - A multi-OpenGL abstraction layer with an immediate-mode style API
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* An abstraction layer for multiple OpenGL versions (1.1, 2.1, 3.3 Core, 4.3 Core, ES 2.0)
|
||||
* An abstraction layer for multiple OpenGL versions (1.1, 2.1, 3.3 Core, 4.3 Core, ES 2.0, ES 3.0)
|
||||
* that provides a pseudo-OpenGL 1.1 immediate-mode style API (rlVertex, rlTranslate, rlRotate...)
|
||||
*
|
||||
* ADDITIONAL NOTES:
|
||||
|
|
@ -3417,9 +3417,9 @@ unsigned int rlLoadTextureCubemap(const void *data, int size, int format, int mi
|
|||
{
|
||||
if (format < RL_PIXELFORMAT_COMPRESSED_DXT1_RGB)
|
||||
{
|
||||
if ((format == RL_PIXELFORMAT_UNCOMPRESSED_R32) ||
|
||||
if ((format == RL_PIXELFORMAT_UNCOMPRESSED_R32) ||
|
||||
(format == RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32A32) ||
|
||||
(format == RL_PIXELFORMAT_UNCOMPRESSED_R16) ||
|
||||
(format == RL_PIXELFORMAT_UNCOMPRESSED_R16) ||
|
||||
(format == RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16)) TRACELOG(RL_LOG_WARNING, "TEXTURES: Cubemap requested format not supported");
|
||||
else glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, mipmapLevel, glInternalFormat, mipSize, mipSize, 0, glFormat, glType, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1943,13 +1943,14 @@ bool ExportMesh(Mesh mesh, const char *fileName)
|
|||
if (IsFileExtension(fileName, ".obj"))
|
||||
{
|
||||
// Estimated data size, it should be enough...
|
||||
int dataSize = mesh.vertexCount*(int)strlen("v 0000.00f 0000.00f 0000.00f") +
|
||||
mesh.vertexCount*(int)strlen("vt 0.000f 0.00f") +
|
||||
mesh.vertexCount*(int)strlen("vn 0.000f 0.00f 0.00f") +
|
||||
mesh.triangleCount*(int)strlen("f 00000/00000/00000 00000/00000/00000 00000/00000/00000");
|
||||
int vc = mesh.vertexCount;
|
||||
int dataSize = vc*(int)strlen("v -0000.000000f -0000.000000f -0000.000000f\n") +
|
||||
vc*(int)strlen("vt -0.000000f -0.000000f\n") +
|
||||
vc*(int)strlen("vn -0.0000f -0.0000f -0.0000f\n") +
|
||||
mesh.triangleCount*snprintf(NULL, 0, "f %i/%i/%i %i/%i/%i %i/%i/%i\n", vc, vc, vc, vc, vc, vc, vc, vc, vc);
|
||||
|
||||
// NOTE: Text data buffer size is estimated considering mesh data size
|
||||
char *txtData = (char *)RL_CALLOC(dataSize*2 + 2000, sizeof(char));
|
||||
char *txtData = (char *)RL_CALLOC(dataSize + 1000, sizeof(char));
|
||||
|
||||
int byteCount = 0;
|
||||
byteCount += sprintf(txtData + byteCount, "# //////////////////////////////////////////////////////////////////////////////////\n");
|
||||
|
|
@ -1969,17 +1970,17 @@ bool ExportMesh(Mesh mesh, const char *fileName)
|
|||
|
||||
for (int i = 0, v = 0; i < mesh.vertexCount; i++, v += 3)
|
||||
{
|
||||
byteCount += sprintf(txtData + byteCount, "v %.2f %.2f %.2f\n", mesh.vertices[v], mesh.vertices[v + 1], mesh.vertices[v + 2]);
|
||||
byteCount += sprintf(txtData + byteCount, "v %.6f %.6f %.6f\n", mesh.vertices[v], mesh.vertices[v + 1], mesh.vertices[v + 2]);
|
||||
}
|
||||
|
||||
for (int i = 0, v = 0; i < mesh.vertexCount; i++, v += 2)
|
||||
{
|
||||
byteCount += sprintf(txtData + byteCount, "vt %.3f %.3f\n", mesh.texcoords[v], mesh.texcoords[v + 1]);
|
||||
byteCount += sprintf(txtData + byteCount, "vt %.6f %.6f\n", mesh.texcoords[v], mesh.texcoords[v + 1]);
|
||||
}
|
||||
|
||||
for (int i = 0, v = 0; i < mesh.vertexCount; i++, v += 3)
|
||||
{
|
||||
byteCount += sprintf(txtData + byteCount, "vn %.3f %.3f %.3f\n", mesh.normals[v], mesh.normals[v + 1], mesh.normals[v + 2]);
|
||||
byteCount += sprintf(txtData + byteCount, "vn %.4f %.4f %.4f\n", mesh.normals[v], mesh.normals[v + 1], mesh.normals[v + 2]);
|
||||
}
|
||||
|
||||
if (mesh.indices != NULL)
|
||||
|
|
@ -2000,8 +2001,6 @@ bool ExportMesh(Mesh mesh, const char *fileName)
|
|||
}
|
||||
}
|
||||
|
||||
byteCount += sprintf(txtData + byteCount, "\n");
|
||||
|
||||
// NOTE: Text data length exported is determined by '\0' (NULL) character
|
||||
success = SaveFileText(fileName, txtData);
|
||||
|
||||
|
|
|
|||
|
|
@ -1339,6 +1339,7 @@ Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing
|
|||
int GetGlyphIndex(Font font, int codepoint)
|
||||
{
|
||||
int index = 0;
|
||||
if (!IsFontValid(font)) return index;
|
||||
|
||||
#define SUPPORT_UNORDERED_CHARSET
|
||||
#if defined(SUPPORT_UNORDERED_CHARSET)
|
||||
|
|
|
|||
Loading…
Reference in a new issue