Fix MSVC errors for PLATFORM_DESKTOP_RGFW (#4441)
* (rcore_desktop_rgfw.c) fix errors when compiling with mingw * define WideCharToMultiByte * update RGFW * move stdcall def to windows only * fix raw cursor input * Fix warnings, update RGFW, fix msvc errors (make sure windows macro _WIN32 is correct)
This commit is contained in:
parent
38cf9f3224
commit
7fe5f7126b
3 changed files with 49 additions and 21 deletions
42
src/external/RGFW.h
vendored
42
src/external/RGFW.h
vendored
|
@ -38,6 +38,7 @@
|
||||||
#define RGFW_OPENGL_ES2 - (optional) use OpenGL ES (version 2)
|
#define RGFW_OPENGL_ES2 - (optional) use OpenGL ES (version 2)
|
||||||
#define RGFW_OPENGL_ES3 - (optional) use OpenGL ES (version 3)
|
#define RGFW_OPENGL_ES3 - (optional) use OpenGL ES (version 3)
|
||||||
#define RGFW_DIRECTX - (optional) use directX for the rendering backend (rather than opengl) (windows only, defaults to opengl for unix)
|
#define RGFW_DIRECTX - (optional) use directX for the rendering backend (rather than opengl) (windows only, defaults to opengl for unix)
|
||||||
|
#define RGFW_WEBGPU - (optional) use webGPU for rendering (Web ONLY)
|
||||||
#define RGFW_NO_API - (optional) don't use any rendering API (no opengl, no vulkan, no directX)
|
#define RGFW_NO_API - (optional) don't use any rendering API (no opengl, no vulkan, no directX)
|
||||||
|
|
||||||
#define RGFW_LINK_EGL (optional) (windows only) if EGL is being used, if EGL functions should be defined dymanically (using GetProcAddress)
|
#define RGFW_LINK_EGL (optional) (windows only) if EGL is being used, if EGL functions should be defined dymanically (using GetProcAddress)
|
||||||
|
@ -84,6 +85,9 @@
|
||||||
Rob Rohan -> X11 bugs and missing features, MacOS/Cocoa fixing memory issues/bugs
|
Rob Rohan -> X11 bugs and missing features, MacOS/Cocoa fixing memory issues/bugs
|
||||||
AICDG (@THISISAGOODNAME) -> vulkan support (example)
|
AICDG (@THISISAGOODNAME) -> vulkan support (example)
|
||||||
@Easymode -> support, testing/debugging, bug fixes and reviews
|
@Easymode -> support, testing/debugging, bug fixes and reviews
|
||||||
|
Joshua Rowe (omnisci3nce) - bug fix, review (macOS)
|
||||||
|
@lesleyrs -> bug fix, review (OpenGL)
|
||||||
|
Nick Porcino (meshula) - testing, organization, review (MacOS, examples)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if _MSC_VER
|
#if _MSC_VER
|
||||||
|
@ -201,7 +205,7 @@
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
#define RGFW_WEBASM
|
#define RGFW_WEBASM
|
||||||
|
|
||||||
#ifndef RGFW_NO_API
|
#if !defined(RGFW_NO_API) && !defined(RGFW_WEBGPU)
|
||||||
#define RGFW_OPENGL
|
#define RGFW_OPENGL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -211,6 +215,10 @@
|
||||||
|
|
||||||
#include <emscripten/html5.h>
|
#include <emscripten/html5.h>
|
||||||
#include <emscripten/key_codes.h>
|
#include <emscripten/key_codes.h>
|
||||||
|
|
||||||
|
#ifdef RGFW_WEBGPU
|
||||||
|
#include <emscripten/html5_webgpu.h>
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(RGFW_X11) && defined(__APPLE__)
|
#if defined(RGFW_X11) && defined(__APPLE__)
|
||||||
|
@ -573,8 +581,14 @@ typedef struct RGFW_window_src {
|
||||||
void* image;
|
void* image;
|
||||||
#endif
|
#endif
|
||||||
#elif defined(RGFW_WEBASM)
|
#elif defined(RGFW_WEBASM)
|
||||||
|
#ifdef RGFW_WEBGPU
|
||||||
|
WGPUInstance ctx;
|
||||||
|
WGPUDevice device;
|
||||||
|
WGPUQueue queue;
|
||||||
|
#else
|
||||||
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx;
|
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
} RGFW_window_src;
|
} RGFW_window_src;
|
||||||
|
|
||||||
|
|
||||||
|
@ -1180,9 +1194,9 @@ int main() {
|
||||||
static : ar rcs RGFW.a RGFW.o
|
static : ar rcs RGFW.a RGFW.o
|
||||||
shared :
|
shared :
|
||||||
windows:
|
windows:
|
||||||
gcc -shared RGFW.o -lopengl32 -lshell32 -lgdi32 -o RGFW.dll
|
gcc -shared RGFW.o -lwinmm -lopengl32 -lshell32 -lgdi32 -o RGFW.dll
|
||||||
linux:
|
linux:
|
||||||
gcc -shared RGFW.o -lX11 -lXcursor -lGL -o RGFW.so
|
gcc -shared RGFW.o -lX11 -lXcursor -lGL -lXrandr -o RGFW.so
|
||||||
macos:
|
macos:
|
||||||
gcc -shared RGFW.o -framework Foundation -framework AppKit -framework OpenGL -framework CoreVideo
|
gcc -shared RGFW.o -framework Foundation -framework AppKit -framework OpenGL -framework CoreVideo
|
||||||
*/
|
*/
|
||||||
|
@ -1406,7 +1420,7 @@ char RGFW_keyCodeToChar(u32 keycode, b8 shift) {
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '`', '0', '1', '2', '3', '4', '5', '6', '7', '8',
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '`', '0', '1', '2', '3', '4', '5', '6', '7', '8',
|
||||||
'9', '-', '=', 0, '\t', 0, 0, 0, 0, 0, 0, 0, 0, 0, ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
|
'9', '-', '=', 0, '\t', 0, 0, 0, 0, 0, 0, 0, 0, 0, ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
|
||||||
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '.', ',', '/', '[', ']', ';', '\n', '\'', '\\',
|
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '.', ',', '/', '[', ']', ';', '\n', '\'', '\\',
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '/', '*', '-', '1', '2', '3', '3', '5', '6', '7', '8', '9', '0', '\n'
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '/', '*', '-', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '\n'
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char mapCaps[] = {
|
static const char mapCaps[] = {
|
||||||
|
@ -2522,7 +2536,8 @@ Start of Linux / Unix defines
|
||||||
glXGetFBConfigAttrib((Display*) win->src.display, fbc[i], GLX_SAMPLE_BUFFERS, &samp_buf);
|
glXGetFBConfigAttrib((Display*) win->src.display, fbc[i], GLX_SAMPLE_BUFFERS, &samp_buf);
|
||||||
glXGetFBConfigAttrib((Display*) win->src.display, fbc[i], GLX_SAMPLES, &samples);
|
glXGetFBConfigAttrib((Display*) win->src.display, fbc[i], GLX_SAMPLES, &samples);
|
||||||
|
|
||||||
if ((best_fbc < 0 || samp_buf) && (samples == RGFW_SAMPLES || best_fbc == -1)) {
|
if ((!(args & RGFW_TRANSPARENT_WINDOW) || vi->depth == 32) &&
|
||||||
|
(best_fbc < 0 || samp_buf) && (samples == RGFW_SAMPLES || best_fbc == -1)) {
|
||||||
best_fbc = i;
|
best_fbc = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2538,11 +2553,6 @@ Start of Linux / Unix defines
|
||||||
XVisualInfo* vi = glXGetVisualFromFBConfig((Display*) win->src.display, bestFbc);
|
XVisualInfo* vi = glXGetVisualFromFBConfig((Display*) win->src.display, bestFbc);
|
||||||
|
|
||||||
XFree(fbc);
|
XFree(fbc);
|
||||||
|
|
||||||
if (args & RGFW_TRANSPARENT_WINDOW) {
|
|
||||||
XMatchVisualInfo((Display*) win->src.display, DefaultScreen((Display*) win->src.display), 32, TrueColor, vi); /*!< for RGBA backgrounds*/
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
XVisualInfo viNorm;
|
XVisualInfo viNorm;
|
||||||
|
|
||||||
|
@ -8548,6 +8558,7 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) {
|
||||||
|
|
||||||
RGFW_window* win = RGFW_window_basic_init(rect, args);
|
RGFW_window* win = RGFW_window_basic_init(rect, args);
|
||||||
|
|
||||||
|
#ifndef RGFW_WEBGPU
|
||||||
EmscriptenWebGLContextAttributes attrs;
|
EmscriptenWebGLContextAttributes attrs;
|
||||||
attrs.alpha = EM_TRUE;
|
attrs.alpha = EM_TRUE;
|
||||||
attrs.depth = EM_TRUE;
|
attrs.depth = EM_TRUE;
|
||||||
|
@ -8576,6 +8587,11 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) {
|
||||||
#ifdef LEGACY_GL_EMULATION
|
#ifdef LEGACY_GL_EMULATION
|
||||||
EM_ASM("Module.useWebGL = true; GLImmediate.init();");
|
EM_ASM("Module.useWebGL = true; GLImmediate.init();");
|
||||||
#endif
|
#endif
|
||||||
|
#else
|
||||||
|
win->src.ctx = wgpuCreateInstance(NULL);
|
||||||
|
win->src.device = emscripten_webgpu_get_device();
|
||||||
|
win->src.queue = wgpuDeviceGetQueue(win->src.device);
|
||||||
|
#endif
|
||||||
|
|
||||||
emscripten_set_canvas_element_size("#canvas", rect.w, rect.h);
|
emscripten_set_canvas_element_size("#canvas", rect.w, rect.h);
|
||||||
emscripten_set_window_title(name);
|
emscripten_set_window_title(name);
|
||||||
|
@ -8871,16 +8887,20 @@ void RGFW_window_swapBuffers(RGFW_window* win) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef RGFW_WEBGPU
|
||||||
emscripten_webgl_commit_frame();
|
emscripten_webgl_commit_frame();
|
||||||
|
#endif
|
||||||
emscripten_sleep(0);
|
emscripten_sleep(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RGFW_window_makeCurrent_OpenGL(RGFW_window* win) {
|
void RGFW_window_makeCurrent_OpenGL(RGFW_window* win) {
|
||||||
|
#ifndef RGFW_WEBGPU
|
||||||
if (win == NULL)
|
if (win == NULL)
|
||||||
emscripten_webgl_make_context_current(0);
|
emscripten_webgl_make_context_current(0);
|
||||||
else
|
else
|
||||||
emscripten_webgl_make_context_current(win->src.ctx);
|
emscripten_webgl_make_context_current(win->src.ctx);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef RGFW_EGL
|
#ifndef RGFW_EGL
|
||||||
|
@ -8888,7 +8908,9 @@ void RGFW_window_swapInterval(RGFW_window* win, i32 swapInterval) { RGFW_UNUSED(
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void RGFW_window_close(RGFW_window* win) {
|
void RGFW_window_close(RGFW_window* win) {
|
||||||
|
#ifndef RGFW_WEBGPU
|
||||||
emscripten_webgl_destroy_context(win->src.ctx);
|
emscripten_webgl_destroy_context(win->src.ctx);
|
||||||
|
#endif
|
||||||
|
|
||||||
free(win);
|
free(win);
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,12 +63,15 @@ void CloseWindow(void);
|
||||||
|
|
||||||
#define RGFW_IMPLEMENTATION
|
#define RGFW_IMPLEMENTATION
|
||||||
|
|
||||||
#if defined(__WIN32) || defined(__WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#define Rectangle rectangle_win32
|
#define Rectangle rectangle_win32
|
||||||
#define CloseWindow CloseWindow_win32
|
#define CloseWindow CloseWindow_win32
|
||||||
#define ShowCursor __imp_ShowCursor
|
#define ShowCursor __imp_ShowCursor
|
||||||
#define _APISETSTRING_
|
#define _APISETSTRING_
|
||||||
|
|
||||||
|
#undef MAX_PATH
|
||||||
|
|
||||||
__declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int CodePage, unsigned long dwFlags, const char *lpMultiByteStr, int cbMultiByte, wchar_t *lpWideCharStr, int cchWideChar);
|
__declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int CodePage, unsigned long dwFlags, const char *lpMultiByteStr, int cbMultiByte, wchar_t *lpWideCharStr, int cchWideChar);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -79,11 +82,14 @@ void CloseWindow(void);
|
||||||
|
|
||||||
#include "../external/RGFW.h"
|
#include "../external/RGFW.h"
|
||||||
|
|
||||||
#if defined(__WIN32) || defined(__WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
#undef DrawText
|
#undef DrawText
|
||||||
#undef ShowCursor
|
#undef ShowCursor
|
||||||
#undef CloseWindow
|
#undef CloseWindow
|
||||||
#undef Rectangle
|
#undef Rectangle
|
||||||
|
|
||||||
|
#undef MAX_PATH
|
||||||
|
#define MAX_PATH 1025
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
|
|
|
@ -161,8 +161,8 @@
|
||||||
__declspec(dllimport) unsigned long __stdcall GetModuleFileNameA(void *hModule, void *lpFilename, unsigned long nSize);
|
__declspec(dllimport) unsigned long __stdcall GetModuleFileNameA(void *hModule, void *lpFilename, unsigned long nSize);
|
||||||
__declspec(dllimport) unsigned long __stdcall GetModuleFileNameW(void *hModule, void *lpFilename, unsigned long nSize);
|
__declspec(dllimport) unsigned long __stdcall GetModuleFileNameW(void *hModule, void *lpFilename, unsigned long nSize);
|
||||||
__declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, void *widestr, int cchwide, void *str, int cbmb, void *defchar, int *used_default);
|
__declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, void *widestr, int cchwide, void *str, int cbmb, void *defchar, int *used_default);
|
||||||
unsigned int __stdcall timeBeginPeriod(unsigned int uPeriod);
|
__declspec(dllimport) unsigned int __stdcall timeBeginPeriod(unsigned int uPeriod);
|
||||||
unsigned int __stdcall timeEndPeriod(unsigned int uPeriod);
|
__declspec(dllimport) unsigned int __stdcall timeEndPeriod(unsigned int uPeriod);
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#elif defined(__FreeBSD__)
|
#elif defined(__FreeBSD__)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue