diff --git a/Makefile b/Makefile index 8db8a78c..d16d7e00 100644 --- a/Makefile +++ b/Makefile @@ -82,8 +82,6 @@ else ifneq ($(CC),g++) LIBS += -std=c99 endif -LIBS += -lOSMesa - EXAMPLE_OUTPUTS = \ examples/basic/basic \ examples/gamepad/gamepad \ diff --git a/RGFW.h b/RGFW.h index f3d709df..b4694cf8 100644 --- a/RGFW.h +++ b/RGFW.h @@ -56,9 +56,9 @@ #define RGFW_NO_DPI - Do not include calculate DPI (no XRM nor libShcore included) #define RGFW_ALLOC_DROPFILES (optional) if room should be allocating for drop files (by default it's global data) - #define RGFW_MALLOC x - choose what function to use to allocate, by default the standard malloc is used - #define RGFW_CALLOC x - choose what function to use to allocate (calloc), by default the standard calloc is used - #define RGFW_FREE x - choose what function to use to allocated memory, by default the standard free is used + #define RGFW_alloc(userptr, size) x - choose what default function to use to allocate, by default the standard malloc is used + #define RGFW_free(userptr, ptr) x - choose what default function to use to allocated memory, by default the standard free is used + #define RGFW_USERPTR x - choose the default userptr sent to the malloc call, (NULL by default) #define RGFW_EXPORT - Use when building RGFW #define RGFW_IMPORT - Use when linking with RGFW (not as a single-header) @@ -166,7 +166,15 @@ int main() { #pragma comment(lib, "user32") #endif -#ifndef RGFW_MALLOC +#ifndef RGFW_UNUSED + #define RGFW_UNUSED(x) (void)(x) +#endif + +#ifndef RGFW_USERPTR + #define RGFW_USERPTR NULL +#endif + +#ifndef RGFW_ALLOC #include #ifndef __USE_POSIX199309 @@ -174,9 +182,8 @@ int main() { #endif #include - #define RGFW_MALLOC malloc - #define RGFW_CALLOC calloc - #define RGFW_FREE free + #define RGFW_ALLOC(userptr, size) (RGFW_UNUSED(userptr),malloc(size)) + #define RGFW_FREE(userptr, ptr) (RGFW_UNUSED(userptr),free(ptr)) #endif #if !_MSC_VER @@ -218,9 +225,6 @@ int main() { #define RGFW_ENUM(type, name) type name; enum #endif -#ifndef RGFW_UNUSED - #define RGFW_UNUSED(x) (void)(x); -#endif #if defined(__cplusplus) && !defined(__EMSCRIPTEN__) #ifdef __clang__ @@ -371,27 +375,31 @@ int main() { #endif #ifndef RGFW_ALPHA - #define RGFW_ALPHA 128 /* alpha value for RGFW_TRANSPARENT_WINDOW (WINAPI ONLY, macOS + linux don't need this) */ + #define RGFW_ALPHA 128 /* alpha value for RGFW_transparent (WINAPI ONLY, macOS + linux don't need this) */ #endif -/*! Optional arguments for making a windows */ -#define RGFW_TRANSPARENT_WINDOW (1L<<9) /*!< the window is transparent (only properly works on X11 and MacOS, although it's although for windows) */ -#define RGFW_NO_BORDER (1L<<3) /*!< the window doesn't have border */ -#define RGFW_NO_RESIZE (1L<<4) /*!< the window cannot be resized by the user */ -#define RGFW_ALLOW_DND (1L<<5) /*!< the window supports drag and drop*/ -#define RGFW_HIDE_MOUSE (1L<<6) /*! the window should hide the mouse or not (can be toggled later on) using `RGFW_window_mouseShow*/ -#define RGFW_FULLSCREEN (1L<<8) /* the window is fullscreen by default or not */ -#define RGFW_CENTER (1L<<10) /*! center the window on the screen */ -#define RGFW_OPENGL_SOFTWARE (1L<<11) /*! use OpenGL software rendering */ -#define RGFW_COCOA_MOVE_TO_RESOURCE_DIR (1L << 12) /* (cocoa only), move to resource folder */ -#define RGFW_SCALE_TO_MONITOR (1L << 13) /* scale the window to the screen */ -#define RGFW_NO_INIT_API (1L << 2) /* DO not init an API (mostly for bindings, you should use `#define RGFW_NO_API` in C */ - -#define RGFW_NO_GPU_RENDER (1L<<14) /* don't render (using the GPU based API)*/ -#define RGFW_NO_CPU_RENDER (1L<<15) /* don't render (using the CPU based buffer rendering)*/ -#define RGFW_WINDOW_HIDE (1L << 16)/* the window is hidden */ - -typedef RGFW_ENUM(u8, RGFW_event_types) { +/* + RGFW_allocator (optional) + you can ignore this if you use standard malloc/free +*/ +typedef void* (* RGFW_allocatorMallocfunc)(void* userdata, size_t size); +typedef void (* RGFW_allocatorFreefunc)(void* userdata, void* ptr); + +typedef struct RGFW_allocator { + void* userdata; + RGFW_allocatorMallocfunc alloc; + RGFW_allocatorFreefunc free; +} RGFW_allocator; + +RGFWDEF void RGFW_loadAllocator(RGFW_allocator allocator); +RGFWDEF void* RGFW_alloc(size_t len); +RGFWDEF void RGFW_free(void* ptr); + +/* + regular RGFW stuff +*/ + +typedef RGFW_ENUM(u8, RGFW_eventTypes) { /*! event codes */ RGFW_noEvent = 0, /*!< no event has been sent */ RGFW_keyPressed, /* a key has been pressed */ @@ -475,7 +483,7 @@ enum RGFW_mouse_codes { #define RGFW_NUMLOCK (1L << 2) /*! gamepad button codes (based on xbox/playstation), you may need to change these values per controller */ -typedef RGFW_ENUM(u8, RGFW_gamepadcodes) { +typedef RGFW_ENUM(u8, RGFW_gamepadCodes) { RGFW_gamepadNone = 0, /*!< or PS X button */ RGFW_gamepadA, /*!< or PS X button */ RGFW_gamepadB, /*!< or PS circle button */ @@ -665,7 +673,23 @@ typedef struct RGFW_window_src { #endif } RGFW_window_src; - +/*! Optional arguments for making a windows */ +typedef RGFW_ENUM(u16, RGFW_windowArgs) { + RGFW_transparent = (1L<<9), /*!< the window is transparent (only properly works on X11 and MacOS, although it's although for windows) */ + RGFW_noBorder = (1L<<3), /*!< the window doesn't have border */ + RGFW_noResize = (1L<<4), /*!< the window cannot be resized by the user */ + RGFW_allowDND = (1L<<5), /*!< the window supports drag and drop*/ + RGFW_hideMouse = (1L<<6), /*! the window should hide the mouse or not (can be toggled later on) using `RGFW_window_mouseShow*/ + RGFW_fullscreen = (1L<<8), /* the window is fullscreen by default or not */ + RGFW_center = (1L<<10), /*! center the window on the screen */ + RGFW_openglSoftware = (1L<<11), /*! use OpenGL software rendering */ + RGFW_cocoaMoveToResourceDir = (1L << 12), /* (cocoa only), move to resource folder */ + RGFW_scaleToMonitor = (1L << 13), /* scale the window to the screen */ + RGFW_noInitAPI = (1L << 2), /* DO not init an API (mostly for bindings, you should use `#define RGFW_NO_API` in C */ + RGFW_noGPURender = (1L<<14), /* don't render (using the GPU based API)*/ + RGFW_noCPURender = (1L<<15), /* don't render (using the CPU based buffer rendering)*/ + RGFW_windowHide = (1L << 16)/* the window is hidden */ +}; typedef struct RGFW_window { RGFW_window_src src; /*!< src window data */ @@ -709,7 +733,7 @@ RGFWDEF void RGFW_setBufferSize(RGFW_area size); /*!< the buffer cannot be resiz RGFWDEF RGFW_window* RGFW_createWindow( const char* name, /* name of the window */ RGFW_rect rect, /* rect of window */ - u16 args /* extra arguments (NULL / (u16)0 means no args used)*/ + RGFW_windowArgs args /* extra arguments (NULL / (u16)0 means no args used)*/ ); /*!< function to create a window struct */ /*! get the size of the screen to an area struct */ @@ -785,7 +809,7 @@ RGFWDEF void RGFW_window_restore(RGFW_window* win); /*!< restore the window from /*! if the window should have a border or not (borderless) based on bool value of `border` */ RGFWDEF void RGFW_window_setBorder(RGFW_window* win, b8 border); -/*! turn on / off dnd (RGFW_ALLOW_DND stil must be passed to the window)*/ +/*! turn on / off dnd (RGFW_allowDND stil must be passed to the window)*/ RGFWDEF void RGFW_window_setDND(RGFW_window* win, b8 allow); #ifndef RGFW_NO_PASSTHROUGH @@ -862,7 +886,7 @@ RGFWDEF b8 RGFW_window_isMaximized(RGFW_window* win); #ifndef RGFW_NO_MONITOR /* scale the window to the monitor, -this is run by default if the user uses the arg `RGFW_SCALE_TO_MONITOR` during window creation +this is run by default if the user uses the arg `RGFW_scaleToMonitor` during window creation */ RGFWDEF void RGFW_window_scaleToMonitor(RGFW_window* win); /*! get the struct of the window's monitor */ @@ -982,25 +1006,25 @@ RGFWDEF RGFW_gamepadfunc RGFW_setGamepadCallback(RGFW_gamepadfunc func); * @{ */ #ifndef RGFW_NO_THREADS - /*! threading functions*/ +/*! threading functions*/ - /*! NOTE! (for X11/linux) : if you define a window in a thread, it must be run after the original thread's window is created or else there will be a memory error */ - /* - I'd suggest you use sili's threading functions instead - if you're going to use sili - which is a good idea generally - */ +/*! NOTE! (for X11/linux) : if you define a window in a thread, it must be run after the original thread's window is created or else there will be a memory error */ +/* + I'd suggest you use sili's threading functions instead + if you're going to use sili + which is a good idea generally +*/ - #if defined(__unix__) || defined(__APPLE__) || defined(RGFW_WEBASM) - typedef void* (* RGFW_threadFunc_ptr)(void*); - #else - typedef DWORD (__stdcall *RGFW_threadFunc_ptr) (LPVOID lpThreadParameter); - #endif +#if defined(__unix__) || defined(__APPLE__) || defined(RGFW_WEBASM) + typedef void* (* RGFW_threadFunc_ptr)(void*); +#else + typedef DWORD (__stdcall *RGFW_threadFunc_ptr) (LPVOID lpThreadParameter); +#endif - RGFWDEF RGFW_thread RGFW_createThread(RGFW_threadFunc_ptr ptr, void* args); /*!< create a thread*/ - RGFWDEF void RGFW_cancelThread(RGFW_thread thread); /*!< cancels a thread*/ - RGFWDEF void RGFW_joinThread(RGFW_thread thread); /*!< join thread to current thread */ - RGFWDEF void RGFW_setThreadPriority(RGFW_thread thread, u8 priority); /*!< sets the priority priority */ +RGFWDEF RGFW_thread RGFW_createThread(RGFW_threadFunc_ptr ptr, void* args); /*!< create a thread*/ +RGFWDEF void RGFW_cancelThread(RGFW_thread thread); /*!< cancels a thread*/ +RGFWDEF void RGFW_joinThread(RGFW_thread thread); /*!< join thread to current thread */ +RGFWDEF void RGFW_setThreadPriority(RGFW_thread thread, u8 priority); /*!< sets the priority priority */ #endif /** @} */ @@ -1045,32 +1069,33 @@ RGFWDEF void RGFW_window_setCPURender(RGFW_window* win, i8 set); /*! native API functions */ #if defined(RGFW_OPENGL) || defined(RGFW_EGL) - /*! OpenGL init hints */ - RGFWDEF void RGFW_setGLStencil(i32 stencil); /*!< set stencil buffer bit size (8 by default) */ - RGFWDEF void RGFW_setGLSamples(i32 samples); /*!< set number of sampiling buffers (4 by default) */ - RGFWDEF void RGFW_setGLStereo(i32 stereo); /*!< use GL_STEREO (GL_FALSE by default) */ - RGFWDEF void RGFW_setGLAuxBuffers(i32 auxBuffers); /*!< number of aux buffers (0 by default) */ - - /*! which profile to use for the opengl verion */ - typedef RGFW_ENUM(u8, RGFW_GL_profile) { RGFW_glCore = 0, RGFW_glCompatibility }; - /*! Set OpenGL version hint (core or compatibility profile)*/ - RGFWDEF void RGFW_setGLVersion(RGFW_GL_profile profile, i32 major, i32 minor); - RGFWDEF void RGFW_setDoubleBuffer(b8 useDoubleBuffer); - RGFWDEF void* RGFW_getProcAddress(const char* procname); /*!< get native opengl proc address */ - RGFWDEF void RGFW_window_makeCurrent_OpenGL(RGFW_window* win); /*!< to be called by RGFW_window_makeCurrent */ +/*! OpenGL init hints */ +RGFWDEF void RGFW_setGLStencil(i32 stencil); /*!< set stencil buffer bit size (8 by default) */ +RGFWDEF void RGFW_setGLSamples(i32 samples); /*!< set number of sampiling buffers (4 by default) */ +RGFWDEF void RGFW_setGLStereo(i32 stereo); /*!< use GL_STEREO (GL_FALSE by default) */ +RGFWDEF void RGFW_setGLAuxBuffers(i32 auxBuffers); /*!< number of aux buffers (0 by default) */ + +/*! which profile to use for the opengl verion */ +typedef RGFW_ENUM(u8, RGFW_glProfile) { RGFW_glCore = 0, RGFW_glCompatibility }; +/*! Set OpenGL version hint (core or compatibility profile)*/ +RGFWDEF void RGFW_setGLVersion(RGFW_glProfile profile, i32 major, i32 minor); +RGFWDEF void RGFW_setDoubleBuffer(b8 useDoubleBuffer); +RGFWDEF void* RGFW_getProcAddress(const char* procname); /*!< get native opengl proc address */ +RGFWDEF void RGFW_window_makeCurrent_OpenGL(RGFW_window* win); /*!< to be called by RGFW_window_makeCurrent */ + #elif defined(RGFW_DIRECTX) - typedef struct { - IDXGIFactory* pFactory; - IDXGIAdapter* pAdapter; - ID3D11Device* pDevice; - ID3D11DeviceContext* pDeviceContext; - } RGFW_directXinfo; +typedef struct { + IDXGIFactory* pFactory; + IDXGIAdapter* pAdapter; + ID3D11Device* pDevice; + ID3D11DeviceContext* pDeviceContext; +} RGFW_directXinfo; - /* - RGFW stores a global instance of RGFW_directXinfo, - you can use this function to get a pointer the instance - */ - RGFWDEF RGFW_directXinfo* RGFW_getDirectXInfo(void); +/* + RGFW stores a global instance of RGFW_directXinfo, + you can use this function to get a pointer the instance +*/ +RGFWDEF RGFW_directXinfo* RGFW_getDirectXInfo(void); #endif /** @} */ @@ -1236,6 +1261,22 @@ typedef RGFW_ENUM(u8, RGFW_mouseIcons) { #include #include +/* + RGFW_allocator, (optional) + you can ignore this if you use standard malloc/free +*/ + +void* RGFW_allocatorMalloc(void* userdata, size_t size) { return RGFW_ALLOC(userdata, size); } +void RGFW_allocatorFree(void* userdata, void* ptr) { RGFW_FREE(userdata, ptr); } +RGFW_allocator RGFW_current_allocator = {RGFW_USERPTR, RGFW_allocatorMalloc, RGFW_allocatorFree}; + +void RGFW_loadAllocator(RGFW_allocator allocator) { + RGFW_current_allocator = allocator; +} + +void* RGFW_alloc(size_t len) { return RGFW_current_allocator.alloc(RGFW_current_allocator.userdata, len); } +void RGFW_free(void* ptr) { RGFW_current_allocator.free(RGFW_current_allocator.userdata, ptr); } + /* RGFW_IMPLEMENTATION starts with generic RGFW defines @@ -1586,18 +1627,20 @@ void RGFW_setBufferSize(RGFW_area size) { } -RGFWDEF RGFW_window* RGFW_window_basic_init(RGFW_rect rect, u16 args); +RGFWDEF RGFW_window* RGFW_window_basic_init(RGFW_rect rect, RGFW_windowArgs args); /* do a basic initialization for RGFW_window, this is to standard it for each OS */ -RGFW_window* RGFW_window_basic_init(RGFW_rect rect, u16 args) { - RGFW_window* win = (RGFW_window*) RGFW_MALLOC(sizeof(RGFW_window)); /*!< make a new RGFW struct */ +RGFW_window* RGFW_window_basic_init(RGFW_rect rect, RGFW_windowArgs args) { + RGFW_window* win = (RGFW_window*) RGFW_alloc(sizeof(RGFW_window)); /*!< make a new RGFW struct */ /* clear out dnd info */ #ifdef RGFW_ALLOC_DROPFILES - win->event.droppedFiles = (char**) RGFW_MALLOC(sizeof(char*) * RGFW_MAX_DROPS); + win->event.droppedFiles = (char**) RGFW_alloc(sizeof(char*) * RGFW_MAX_DROPS); u32 i; - for (i = 0; i < RGFW_MAX_DROPS; i++) - win->event.droppedFiles[i] = (char*) RGFW_CALLOC(RGFW_MAX_PATH, sizeof(char)); + for (i = 0; i < RGFW_MAX_DROPS; i++) { + win->event.droppedFiles[i] = (char*) RGFW_alloc(RGFW_MAX_PATH); + memset(win->event.droppedFiles[i], 0, RGFW_MAX_PATH); + } #endif /* X11 requires us to have a display to get the screen size */ @@ -1612,7 +1655,7 @@ RGFW_window* RGFW_window_basic_init(RGFW_rect rect, u16 args) { #endif /* rect based the requested args */ - if (args & RGFW_FULLSCREEN) + if (args & RGFW_fullscreen) rect = RGFW_RECT(0, 0, screenR.w, screenR.h); /* set and init the new window's data */ @@ -1649,7 +1692,7 @@ void RGFW_setClassName(const char* name) { RGFW_className = (char*)name; } -void RGFW_clipboardFree(char* str) { RGFW_FREE(str); } +void RGFW_clipboardFree(char* str) { RGFW_free(str); } RGFW_keyState RGFW_mouseButtons[5] = { {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} }; @@ -1702,24 +1745,24 @@ void RGFW_window_makeCurrent(RGFW_window* win) { #elif defined(RGFW_OPENGL) RGFW_window_makeCurrent_OpenGL(win); #else - RGFW_UNUSED(win) + RGFW_UNUSED(win); #endif } void RGFW_window_setGPURender(RGFW_window* win, i8 set) { - if (!set && !(win->_winArgs & RGFW_NO_GPU_RENDER)) - win->_winArgs |= RGFW_NO_GPU_RENDER; + if (!set && !(win->_winArgs & RGFW_noGPURender)) + win->_winArgs |= RGFW_noGPURender; - else if (set && win->_winArgs & RGFW_NO_GPU_RENDER) - win->_winArgs ^= RGFW_NO_GPU_RENDER; + else if (set && win->_winArgs & RGFW_noGPURender) + win->_winArgs ^= RGFW_noGPURender; } void RGFW_window_setCPURender(RGFW_window* win, i8 set) { - if (!set && !(win->_winArgs & RGFW_NO_CPU_RENDER)) - win->_winArgs |= RGFW_NO_CPU_RENDER; + if (!set && !(win->_winArgs & RGFW_noCPURender)) + win->_winArgs |= RGFW_noCPURender; - else if (set && win->_winArgs & RGFW_NO_CPU_RENDER) - win->_winArgs ^= RGFW_NO_CPU_RENDER; + else if (set && win->_winArgs & RGFW_noCPURender) + win->_winArgs ^= RGFW_noCPURender; } void RGFW_window_maximize(RGFW_window* win) { @@ -1852,11 +1895,11 @@ int clock_gettime(clockid_t clk_id, struct timespec* tp); int setenv(const char *name, const char *value, int overwrite); void RGFW_window_setDND(RGFW_window* win, b8 allow) { - if (allow && !(win->_winArgs & RGFW_ALLOW_DND)) - win->_winArgs |= RGFW_ALLOW_DND; + if (allow && !(win->_winArgs & RGFW_allowDND)) + win->_winArgs |= RGFW_allowDND; - else if (!allow && (win->_winArgs & RGFW_ALLOW_DND)) - win->_winArgs ^= RGFW_ALLOW_DND; + else if (!allow && (win->_winArgs & RGFW_allowDND)) + win->_winArgs ^= RGFW_allowDND; } #endif @@ -2242,8 +2285,7 @@ RGFWDEF void RGFW_OSMesa_reorganize(RGFW_window* win); /* reorganize buffer for osmesa */ void RGFW_OSMesa_reorganize(RGFW_window* win) { - return; - u8* row = (u8*) RGFW_MALLOC(RGFW_bufferSize.w * 3); + u8* row = (u8*) RGFW_alloc(RGFW_bufferSize.w * 3); i32 half_height = RGFW_bufferSize.h / 2; i32 stride = RGFW_bufferSize.w * 3; @@ -2257,7 +2299,7 @@ void RGFW_OSMesa_reorganize(RGFW_window* win) { memcpy(win->buffer + bottom_offset, row, stride); } - RGFW_FREE(row); + RGFW_free(row); } #endif /* RGFW_OSMesa */ @@ -2479,7 +2521,7 @@ void RGFW_init_buffer(RGFW_window* win, XVisualInfo* vi) { if (RGFW_bufferSize.w == 0 && RGFW_bufferSize.h == 0) RGFW_bufferSize = RGFW_getScreenSize(); - win->buffer = (u8*)RGFW_MALLOC(RGFW_bufferSize.w * RGFW_bufferSize.h * 4); + win->buffer = (u8*)RGFW_alloc(RGFW_bufferSize.w * RGFW_bufferSize.h * 4); #ifdef RGFW_DEBUG printf("RGFW INFO: createing a 4 channel %i by %i buffer\n", RGFW_bufferSize.w, RGFW_bufferSize.h); @@ -2501,7 +2543,7 @@ void RGFW_init_buffer(RGFW_window* win, XVisualInfo* vi) { #else RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ - RGFW_UNUSED(vi) + RGFW_UNUSED(vi); #endif } @@ -2554,7 +2596,7 @@ void RGFW_captureCursor(RGFW_window* win, RGFW_rect r) { RGFW_window_moveMouse(win, RGFW_POINT(win->r.x + (i32)(r.w / 2), win->r.y + (i32)(r.h / 2))); } -RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { +RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, RGFW_windowArgs args) { #if !defined(RGFW_NO_X11_CURSOR) && !defined(RGFW_NO_X11_CURSOR_PRELOAD) if (X11Cursorhandle == NULL) { #if defined(__CYGWIN__) @@ -2587,7 +2629,7 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { XInitThreads(); /*!< init X11 threading*/ - if (args & RGFW_OPENGL_SOFTWARE) + if (args & RGFW_openglSoftware) setenv("LIBGL_ALWAYS_SOFTWARE", "1", 1); RGFW_window* win = RGFW_window_basic_init(rect, args); @@ -2595,7 +2637,7 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { u64 event_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask | StructureNotifyMask | FocusChangeMask | LeaveWindowMask | EnterWindowMask | ExposureMask; /*!< X11 events accepted*/ #ifdef RGFW_OPENGL - u32* visual_attribs = RGFW_initFormatAttribs(args & RGFW_OPENGL_SOFTWARE); + u32* visual_attribs = RGFW_initFormatAttribs(args & RGFW_openglSoftware); i32 fbcount; GLXFBConfig* fbc = glXChooseFBConfig((Display*) win->src.display, DefaultScreen(win->src.display), (i32*) visual_attribs, &fbcount); @@ -2618,7 +2660,7 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { glXGetFBConfigAttrib((Display*) win->src.display, fbc[i], GLX_SAMPLE_BUFFERS, &samp_buf); glXGetFBConfigAttrib((Display*) win->src.display, fbc[i], GLX_SAMPLES, &samples); - if ((!(args & RGFW_TRANSPARENT_WINDOW) || vi->depth == 32) && + if ((!(args & RGFW_transparent) || vi->depth == 32) && (best_fbc < 0 || samp_buf) && (samples == RGFW_SAMPLES || best_fbc == -1)) { best_fbc = i; } @@ -2684,7 +2726,7 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { XSetClassHint((Display*) win->src.display, win->src.window, hint); XFree(hint); - if ((args & RGFW_NO_INIT_API) == 0) { + if ((args & RGFW_noInitAPI) == 0) { #ifdef RGFW_OPENGL /* This is the second part of setting up opengl. This is where we ask OpenGL for a specific version. */ i32 context_attribs[7] = { 0, 0, 0, 0, 0, 0, 0 }; context_attribs[0] = GLX_CONTEXT_PROFILE_MASK_ARB; @@ -2718,16 +2760,16 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { } #ifndef RGFW_NO_MONITOR - if (args & RGFW_SCALE_TO_MONITOR) + if (args & RGFW_scaleToMonitor) RGFW_window_scaleToMonitor(win); #endif - if (args & RGFW_CENTER) { + if (args & RGFW_center) { RGFW_area screenR = RGFW_getScreenSize(); RGFW_window_move(win, RGFW_POINT((screenR.w - win->r.w) / 2, (screenR.h - win->r.h) / 2)); } - if (args & RGFW_NO_RESIZE) { /* make it so the user can't resize the window*/ + if (args & RGFW_noResize) { /* make it so the user can't resize the window*/ XSizeHints sh = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; sh.flags = (1L << 4) | (1L << 5); sh.min_width = sh.max_width = win->r.w; @@ -2735,10 +2777,10 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { XSetWMSizeHints((Display*) win->src.display, (Drawable) win->src.window, &sh, XA_WM_NORMAL_HINTS); - win->_winArgs |= RGFW_NO_RESIZE; + win->_winArgs |= RGFW_noResize; } - if (args & RGFW_NO_BORDER) { + if (args & RGFW_noBorder) { RGFW_window_setBorder(win, 0); } @@ -2752,7 +2794,7 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { /* connect the context to the window*/ #ifdef RGFW_OPENGL - if ((args & RGFW_NO_INIT_API) == 0) + if ((args & RGFW_noInitAPI) == 0) glXMakeCurrent((Display*) win->src.display, (Drawable) win->src.window, (GLXContext) win->src.ctx); #endif @@ -2762,8 +2804,8 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { XMapWindow((Display*) win->src.display, (Drawable) win->src.window); /* draw the window*/ XMoveWindow((Display*) win->src.display, (Drawable) win->src.window, win->r.x, win->r.y); /*!< move the window to it's proper cords*/ - if (args & RGFW_ALLOW_DND) { /* init drag and drop atoms and turn on drag and drop for this window */ - win->_winArgs |= RGFW_ALLOW_DND; + if (args & RGFW_allowDND) { /* init drag and drop atoms and turn on drag and drop for this window */ + win->_winArgs |= RGFW_allowDND; XdndTypeList = XInternAtom((Display*) win->src.display, "XdndTypeList", False); XdndSelection = XInternAtom((Display*) win->src.display, "XdndSelection", False); @@ -2791,7 +2833,7 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { } #ifdef RGFW_EGL - if ((args & RGFW_NO_INIT_API) == 0) + if ((args & RGFW_noInitAPI) == 0) RGFW_createOpenGLContext(win); #endif @@ -3021,7 +3063,7 @@ RGFW_Event* RGFW_window_checkEvent(RGFW_window* win) { win->event.droppedFilesCount = 0; - if ((win->_winArgs & RGFW_ALLOW_DND) == 0) + if ((win->_winArgs & RGFW_allowDND) == 0) break; reply.xclient.window = xdnd.source; @@ -3154,7 +3196,7 @@ RGFW_Event* RGFW_window_checkEvent(RGFW_window* win) { break; case SelectionNotify: { /* this is only for checking for xdnd drops */ - if (E.xselection.property != XdndSelection || !(win->_winArgs | RGFW_ALLOW_DND)) + if (E.xselection.property != XdndSelection || !(win->_winArgs | RGFW_allowDND)) break; char* data; @@ -3317,7 +3359,7 @@ void RGFW_window_resize(RGFW_window* win, RGFW_area a) { XResizeWindow((Display*) win->src.display, (Window) win->src.window, a.w, a.h); - if (!(win->_winArgs & RGFW_NO_RESIZE)) + if (!(win->_winArgs & RGFW_noResize)) return; XSizeHints sh = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; @@ -3436,7 +3478,7 @@ void RGFW_window_setIcon(RGFW_window* win, u8* icon, RGFW_area a, i32 channels) i32 longCount = 2 + a.w * a.h; - u64* X11Icon = (u64*) RGFW_MALLOC(longCount * sizeof(u64)); + u64* X11Icon = (u64*) RGFW_alloc(longCount * sizeof(u64)); u64* target = X11Icon; *target++ = a.w; @@ -3469,7 +3511,7 @@ void RGFW_window_setIcon(RGFW_window* win, u8* icon, RGFW_area a, i32 channels) (u8*) X11Icon, longCount); - RGFW_FREE(X11Icon); + RGFW_free(X11Icon); XFlush((Display*) win->src.display); } @@ -3583,7 +3625,7 @@ char* RGFW_readClipboard(size_t* size) { &format, &sizeN, &N, (unsigned char**) &data); if (target == UTF8 || target == XA_STRING) { - s = (char*)RGFW_MALLOC(sizeof(char) * sizeN); + s = (char*)RGFW_alloc(sizeof(char) * sizeN); strncpy(s, data, sizeN); s[sizeN] = '\0'; XFree(data); @@ -3944,7 +3986,7 @@ RGFW_monitor RGFW_window_getMonitor(RGFW_window* win) { return (RGFW_monitor){}; } - for (size_t i = 0; i < screenRes->ncrtc; i++) { + for (int i = 0; i < screenRes->ncrtc; i++) { XRRCrtcInfo* crtcInfo = XRRGetCrtcInfo(win->src.display, screenRes, screenRes->crtcs[i]); if (!crtcInfo) continue; @@ -3984,7 +4026,7 @@ void RGFW_window_swapBuffers(RGFW_window* win) { assert(win != NULL); /* clear the window*/ - if (!(win->_winArgs & RGFW_NO_CPU_RENDER)) { + if (!(win->_winArgs & RGFW_noCPURender)) { #if defined(RGFW_OSMESA) || defined(RGFW_BUFFER) RGFW_area area = RGFW_bufferSize; #ifdef RGFW_OSMESA @@ -4009,7 +4051,7 @@ void RGFW_window_swapBuffers(RGFW_window* win) { #endif } - if (!(win->_winArgs & RGFW_NO_GPU_RENDER)) { + if (!(win->_winArgs & RGFW_noGPURender)) { #ifdef RGFW_EGL eglSwapBuffers(win->src.EGL_display, win->src.EGL_surface); #elif defined(RGFW_OPENGL) @@ -4067,10 +4109,10 @@ void RGFW_window_close(RGFW_window* win) { { u32 i; for (i = 0; i < RGFW_MAX_DROPS; i++) - RGFW_FREE(win->event.droppedFiles[i]); + RGFW_free(win->event.droppedFiles[i]); - RGFW_FREE(win->event.droppedFiles); + RGFW_free(win->event.droppedFiles); } #endif @@ -4112,7 +4154,7 @@ void RGFW_window_close(RGFW_window* win) { win->src.display = (Display*) 0; win->src.window = (Window) 0; - RGFW_FREE(win); /*!< free collected window data */ + RGFW_free(win); /*!< free collected window data */ } @@ -4241,9 +4283,9 @@ Wayland TODO: RGFW_dnd_init - window args: - #define RGFW_NO_RESIZE the window cannot be resized by the user - #define RGFW_ALLOW_DND the window supports drag and drop - #define RGFW_SCALE_TO_MONITOR scale the window to the screen + #define RGFW_noResize the window cannot be resized by the user + #define RGFW_allowDND the window supports drag and drop + #define RGFW_scaleToMonitor scale the window to the screen - other missing functions functions ("TODO wayland") (~30 functions) - fix buffer rendering weird behavior @@ -4648,7 +4690,7 @@ static void wl_surface_frame_done(void *data, struct wl_callback *cb, uint32_t t #ifdef RGFW_BUFFER RGFW_window* win = (RGFW_window*)data; - if ((win->_winArgs & RGFW_NO_CPU_RENDER)) + if ((win->_winArgs & RGFW_noCPURender)) return; #ifndef RGFW_X11_DONT_CONVERT_BGR @@ -4744,7 +4786,7 @@ void RGFW_init_buffer(RGFW_window* win) { #endif } -RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { +RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, RGFW_windowArgs args) { RGFW_window* win = RGFW_window_basic_init(rect, args); fprintf(stderr, "Warning: RGFW Wayland support is experimental\n"); @@ -4803,17 +4845,17 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { xdg_surface_set_window_geometry(win->src.xdg_surface, 0, 0, win->r.w, win->r.h); - if (!(args & RGFW_NO_BORDER)) { + if (!(args & RGFW_noBorder)) { win->src.decoration = zxdg_decoration_manager_v1_get_toplevel_decoration( decoration_manager, win->src.xdg_toplevel); } - if (args & RGFW_CENTER) { + if (args & RGFW_center) { RGFW_area screenR = RGFW_getScreenSize(); RGFW_window_move(win, RGFW_POINT((screenR.w - win->r.w) / 2, (screenR.h - win->r.h) / 2)); } - if (args & RGFW_OPENGL_SOFTWARE) + if (args & RGFW_openglSoftware) setenv("LIBGL_ALWAYS_SOFTWARE", "1", 1); wl_display_roundtrip(win->src.display); @@ -4825,7 +4867,7 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { #ifdef RGFW_OPENGL - if ((args & RGFW_NO_INIT_API) == 0) { + if ((args & RGFW_noInitAPI) == 0) { win->src.window = wl_egl_window_create(win->src.surface, win->r.w, win->r.h); RGFW_createOpenGLContext(win); } @@ -4837,7 +4879,7 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { wl_callback_add_listener(callback, &wl_surface_frame_listener, win); wl_surface_commit(win->src.surface); - if (args & RGFW_HIDE_MOUSE) { + if (args & RGFW_hideMouse) { RGFW_window_showMouse(win, 0); } @@ -4856,7 +4898,7 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { } RGFW_Event* RGFW_window_checkEvent(RGFW_window* win) { - if (win->_winArgs & RGFW_WINDOW_HIDE) + if (win->_winArgs & RGFW_windowHide) return NULL; if (win->src.eventIndex == 0) { @@ -4978,14 +5020,14 @@ void RGFW_window_show(RGFW_window* win) { //wl_surface_attach(win->src.surface, win->rc., 0, 0); wl_surface_commit(win->src.surface); - if (win->_winArgs & RGFW_WINDOW_HIDE) - win->_winArgs ^= RGFW_WINDOW_HIDE; + if (win->_winArgs & RGFW_windowHide) + win->_winArgs ^= RGFW_windowHide; } void RGFW_window_hide(RGFW_window* win) { wl_surface_attach(win->src.surface, NULL, 0, 0); wl_surface_commit(win->src.surface); - win->_winArgs |= RGFW_WINDOW_HIDE; + win->_winArgs |= RGFW_windowHide; } void RGFW_window_setMouseDefault(RGFW_window* win) { @@ -5076,7 +5118,7 @@ void RGFW_window_swapBuffers(RGFW_window* win) { /* clear the window*/ #ifdef RGFW_BUFFER wl_surface_frame_done(win, NULL, 0); - if (!(win->_winArgs & RGFW_NO_GPU_RENDER)) + if (!(win->_winArgs & RGFW_noGPURender)) #endif { #ifdef RGFW_OPENGL @@ -5105,7 +5147,7 @@ void RGFW_window_close(RGFW_window* win) { #endif wl_display_disconnect(win->src.display); - RGFW_FREE(win); + RGFW_free(win); } RGFW_monitor RGFW_getPrimaryMonitor(void) { @@ -5371,7 +5413,7 @@ void RGFW_captureCursor(RGFW_window* win, RGFW_rect rect) { RegisterRawInputDevices(&id, 1, sizeof(id)); } -RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { +RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, RGFW_windowArgs args) { #ifndef RGFW_NO_XINPUT if (RGFW_XInput_dll == NULL) RGFW_loadXInput(); @@ -5437,10 +5479,10 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { RECT windowRect, clientRect; - if (!(args & RGFW_NO_BORDER)) { + if (!(args & RGFW_noBorder)) { window_style |= WS_CAPTION | WS_SYSMENU | WS_BORDER | WS_MINIMIZEBOX; - if (!(args & RGFW_NO_RESIZE)) + if (!(args & RGFW_noResize)) window_style |= WS_SIZEBOX | WS_MAXIMIZEBOX | WS_THICKFRAME; } else window_style |= WS_POPUP | WS_VISIBLE | WS_SYSMENU | WS_MINIMIZEBOX; @@ -5454,13 +5496,13 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { win->src.hOffset = (windowRect.bottom - windowRect.top) - (clientRect.bottom - clientRect.top); win->src.window = CreateWindowA(Class.lpszClassName, name, window_style, win->r.x, win->r.y, win->r.w, win->r.h + win->src.hOffset, 0, 0, inh, 0); - if (args & RGFW_ALLOW_DND) { - win->_winArgs |= RGFW_ALLOW_DND; + if (args & RGFW_allowDND) { + win->_winArgs |= RGFW_allowDND; RGFW_window_setDND(win, 1); } win->src.hdc = GetDC(win->src.window); - if ((args & RGFW_NO_INIT_API) == 0) { + if ((args & RGFW_noInitAPI) == 0) { #ifdef RGFW_DIRECTX assert(FAILED(CreateDXGIFactory(&__uuidof(IDXGIFactory), (void**) &RGFW_dxInfo.pFactory)) == 0); @@ -5565,11 +5607,11 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { if (wglCreateContextAttribsARB != NULL) { PIXELFORMATDESCRIPTOR pfd = {sizeof(pfd), 1, pfd_flags, PFD_TYPE_RGBA, 32, 8, PFD_MAIN_PLANE, 24, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - if (args & RGFW_OPENGL_SOFTWARE) + if (args & RGFW_openglSoftware) pfd.dwFlags |= PFD_GENERIC_FORMAT | PFD_GENERIC_ACCELERATED; if (wglChoosePixelFormatARB != NULL) { - i32* pixel_format_attribs = (i32*)RGFW_initFormatAttribs(args & RGFW_OPENGL_SOFTWARE); + i32* pixel_format_attribs = (i32*)RGFW_initFormatAttribs(args & RGFW_openglSoftware); int pixel_format; UINT num_formats; @@ -5625,7 +5667,7 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { #endif #ifdef RGFW_OPENGL - if ((args & RGFW_NO_INIT_API) == 0) { + if ((args & RGFW_noInitAPI) == 0) { ReleaseDC(win->src.window, win->src.hdc); win->src.hdc = GetDC(win->src.window); wglMakeCurrent(win->src.hdc, win->src.ctx); @@ -5637,24 +5679,24 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { #ifndef RGFW_NO_MONITOR - if (args & RGFW_SCALE_TO_MONITOR) + if (args & RGFW_scaleToMonitor) RGFW_window_scaleToMonitor(win); #endif - if (args & RGFW_CENTER) { + if (args & RGFW_center) { RGFW_area screenR = RGFW_getScreenSize(); RGFW_window_move(win, RGFW_POINT((screenR.w - win->r.w) / 2, (screenR.h - win->r.h) / 2)); } #ifdef RGFW_EGL - if ((args & RGFW_NO_INIT_API) == 0) + if ((args & RGFW_noInitAPI) == 0) RGFW_createOpenGLContext(win); #endif - if (args & RGFW_HIDE_MOUSE) + if (args & RGFW_hideMouse) RGFW_window_showMouse(win, 0); - if (args & RGFW_TRANSPARENT_WINDOW) { + if (args & RGFW_transparent) { SetWindowLong(win->src.window, GWL_EXSTYLE, GetWindowLong(win->src.window, GWL_EXSTYLE) | WS_EX_LAYERED); SetLayeredWindowAttributes(win->src.window, RGB(255, 255, 255), RGFW_ALPHA, LWA_ALPHA); } @@ -5917,17 +5959,17 @@ RGFW_Event* RGFW_window_checkEvent(RGFW_window* win) { win->event.droppedFilesCount = 0; win->event.droppedFilesCount = DragQueryFileW(drop, 0xffffffff, NULL, 0); - //win->event.droppedFiles = (char**)RGFW_CALLOC(win->event.droppedFilesCount, sizeof(char*)); u32 i; for (i = 0; i < win->event.droppedFilesCount; i++) { const UINT length = DragQueryFileW(drop, i, NULL, 0); - WCHAR* buffer = (WCHAR*) RGFW_CALLOC((size_t) length + 1, sizeof(WCHAR)); + WCHAR* buffer = (WCHAR*) RGFW_alloc((size_t) length + 1, sizeof(WCHAR)); + memset(buffer, 0, length + 1); DragQueryFileW(drop, i, buffer, length + 1); strncpy(win->event.droppedFiles[i], createUTF8FromWideStringWin32(buffer), RGFW_MAX_PATH); win->event.droppedFiles[i][RGFW_MAX_PATH - 1] = '\0'; - RGFW_FREE(buffer); + RGFW_free(buffer); } DragFinish(drop); @@ -6584,21 +6626,21 @@ void RGFW_window_close(RGFW_window* win) { #if defined(RGFW_OSMESA) if (win->buffer != NULL) - RGFW_FREE(win->buffer); + RGFW_free(win->buffer); #endif #ifdef RGFW_ALLOC_DROPFILES { u32 i; for (i = 0; i < RGFW_MAX_DROPS; i++) - RGFW_FREE(win->event.droppedFiles[i]); + RGFW_free(win->event.droppedFiles[i]); - RGFW_FREE(win->event.droppedFiles); + RGFW_free(win->event.droppedFiles); } #endif - RGFW_FREE(win); + RGFW_free(win); } void RGFW_window_move(RGFW_window* win, RGFW_point v) { @@ -6701,7 +6743,7 @@ char* RGFW_readClipboard(size_t* size) { if (textLen == 0) return (char*) ""; - text = (char*) RGFW_MALLOC((textLen * sizeof(char)) + 1); + text = (char*) RGFW_alloc((textLen * sizeof(char)) + 1); wcstombs(text, wstr, (textLen) +1); @@ -6793,7 +6835,7 @@ void RGFW_window_swapBuffers(RGFW_window* win) { //assert(win != NULL); /* clear the window*/ - if (!(win->_winArgs & RGFW_NO_CPU_RENDER)) { + if (!(win->_winArgs & RGFW_noCPURender)) { #if defined(RGFW_OSMESA) || defined(RGFW_BUFFER) #ifdef RGFW_OSMESA RGFW_OSMesa_reorganize(); @@ -6804,7 +6846,7 @@ void RGFW_window_swapBuffers(RGFW_window* win) { #endif } - if (!(win->_winArgs & RGFW_NO_GPU_RENDER)) { + if (!(win->_winArgs & RGFW_noGPURender)) { #ifdef RGFW_EGL eglSwapBuffers(win->src.EGL_display, win->src.EGL_surface); #elif defined(RGFW_OPENGL) @@ -6826,10 +6868,11 @@ char* createUTF8FromWideStringWin32(const WCHAR* source) { return NULL; } - target = (char*) RGFW_CALLOC(size, 1); + target = (char*) RGFW_alloc(size); + memset(target, 0, size); if (!WideCharToMultiByte(CP_UTF8, 0, source, -1, target, size, NULL, NULL)) { - RGFW_FREE(target); + RGFW_free(target); return NULL; } @@ -6978,7 +7021,7 @@ typedef struct siArrayHeader { #define SI_ARRAY_HEADER(s) ((siArrayHeader*)s - 1) void* si_array_init_reserve(size_t sizeof_element, size_t count) { - siArrayHeader* ptr = (siArrayHeader*)RGFW_MALLOC(sizeof(siArrayHeader) + (sizeof_element * count)); + siArrayHeader* ptr = (siArrayHeader*)RGFW_alloc(sizeof(siArrayHeader) + (sizeof_element * count)); void* array = ptr + sizeof(siArrayHeader); siArrayHeader* header = SI_ARRAY_HEADER(array); @@ -7273,7 +7316,7 @@ NSDragOperation draggingUpdated(id self, SEL sel, id sender) { if (win == NULL) return 0; - if (!(win->_winArgs & RGFW_ALLOW_DND)) { + if (!(win->_winArgs & RGFW_allowDND)) { return 0; } @@ -7293,7 +7336,7 @@ bool prepareForDragOperation(id self) { if (win == NULL) return true; - if (!(win->_winArgs & RGFW_ALLOW_DND)) { + if (!(win->_winArgs & RGFW_allowDND)) { return false; } @@ -7591,7 +7634,7 @@ void RGFW_init_buffer(RGFW_window* win) { if (RGFW_bufferSize.w == 0 && RGFW_bufferSize.h == 0) RGFW_bufferSize = RGFW_getScreenSize(); - win->buffer = RGFW_MALLOC(RGFW_bufferSize.w * RGFW_bufferSize.h * 4); + win->buffer = RGFW_alloc(RGFW_bufferSize.w * RGFW_bufferSize.h * 4); #ifdef RGFW_OSMESA win->src.ctx = OSMesaCreateContext(OSMESA_RGBA, NULL); OSMesaMakeCurrent(win->src.ctx, win->buffer, GL_UNSIGNED_BYTE, win->r.w, win->r.h); @@ -7652,7 +7695,7 @@ void RGFW_osxInitIOKit(void) { NSPasteboardType const NSPasteboardTypeURL = "public.url"; NSPasteboardType const NSPasteboardTypeFileURL = "public.file-url"; -RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { +RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, RGFW_windowArgs args) { static u8 RGFW_loaded = 0; /* NOTE(EimaMei): Why does Apple hate good code? Like wtf, who thought of methods being a great idea??? @@ -7689,9 +7732,9 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { NSBackingStoreType macArgs = NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSBackingStoreBuffered | NSWindowStyleMaskTitled; - if (!(args & RGFW_NO_RESIZE)) + if (!(args & RGFW_noResize)) macArgs |= NSWindowStyleMaskResizable; - if (!(args & RGFW_NO_BORDER)) + if (!(args & RGFW_noBorder)) macArgs |= NSWindowStyleMaskTitled; else macArgs = NSWindowStyleMaskBorderless; @@ -7707,14 +7750,14 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { objc_msgSend_void_id((id)win->src.window, sel_registerName("setTitle:"), str); #ifdef RGFW_EGL - if ((args & RGFW_NO_INIT_API) == 0) + if ((args & RGFW_noInitAPI) == 0) RGFW_createOpenGLContext(win); #endif #ifdef RGFW_OPENGL - if ((args & RGFW_NO_INIT_API) == 0) { - void* attrs = RGFW_initFormatAttribs(args & RGFW_OPENGL_SOFTWARE); + if ((args & RGFW_noInitAPI) == 0) { + void* attrs = RGFW_initFormatAttribs(args & RGFW_openglSoftware); void* format = NSOpenGLPixelFormat_initWithAttributes((uint32_t*)attrs); if (format == NULL) { @@ -7748,13 +7791,13 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { objc_msgSend_void_id((id)win->src.window, sel_registerName("setContentView:"), win->src.view); #ifdef RGFW_OPENGL - if ((args & RGFW_NO_INIT_API) == 0) + if ((args & RGFW_noInitAPI) == 0) objc_msgSend_void(win->src.ctx, sel_registerName("makeCurrentContext")); #endif - if (args & RGFW_TRANSPARENT_WINDOW) { + if (args & RGFW_transparent) { #ifdef RGFW_OPENGL - if ((args & RGFW_NO_INIT_API) == 0) { + if ((args & RGFW_noInitAPI) == 0) { i32 opacity = 0; #define NSOpenGLCPSurfaceOpacity 236 NSOpenGLContext_setValues((id)win->src.ctx, &opacity, NSOpenGLCPSurfaceOpacity); @@ -7770,19 +7813,19 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { RGFW_init_buffer(win); #ifndef RGFW_NO_MONITOR - if (args & RGFW_SCALE_TO_MONITOR) + if (args & RGFW_scaleToMonitor) RGFW_window_scaleToMonitor(win); #endif - if (args & RGFW_CENTER) { + if (args & RGFW_center) { RGFW_area screenR = RGFW_getScreenSize(); RGFW_window_move(win, RGFW_POINT((screenR.w - win->r.w) / 2, (screenR.h - win->r.h) / 2)); } - if (args & RGFW_HIDE_MOUSE) + if (args & RGFW_hideMouse) RGFW_window_showMouse(win, 0); - if (args & RGFW_COCOA_MOVE_TO_RESOURCE_DIR) + if (args & RGFW_cocoaMoveToResourceDir) NSMoveToResourceDir(); Class delegateClass = objc_allocateClassPair(objc_getClass("NSObject"), "WindowDelegate", 0); @@ -7810,8 +7853,8 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { objc_msgSend_void_id((id)win->src.window, sel_registerName("setDelegate:"), delegate); - if (args & RGFW_ALLOW_DND) { - win->_winArgs |= RGFW_ALLOW_DND; + if (args & RGFW_allowDND) { + win->_winArgs |= RGFW_allowDND; NSPasteboardType types[] = {NSPasteboardTypeURL, NSPasteboardTypeFileURL, NSPasteboardTypeString}; NSregisterForDraggedTypes((id)win->src.window, types, 3); @@ -7849,7 +7892,7 @@ void RGFW_window_setBorder(RGFW_window* win, u8 border) { if (!border) { storeType = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable; } - if (!(win->_winArgs & RGFW_NO_RESIZE)) { + if (!(win->_winArgs & RGFW_noResize)) { storeType |= NSWindowStyleMaskResizable; } @@ -8577,7 +8620,7 @@ char* RGFW_readClipboard(size_t* size) { clip_len = strlen(clip) + 1; } - char* str = (char*)RGFW_MALLOC(sizeof(char) * clip_len); + char* str = (char*)RGFW_alloc(sizeof(char) * clip_len); if (clip != NULL) { strncpy(str, clip, clip_len); @@ -8646,7 +8689,7 @@ void RGFW_window_swapBuffers(RGFW_window* win) { assert(win != NULL); /* clear the window*/ - if (!(win->_winArgs & RGFW_NO_CPU_RENDER)) { + if (!(win->_winArgs & RGFW_noCPURender)) { #if defined(RGFW_OSMESA) || defined(RGFW_BUFFER) #ifdef RGFW_OSMESA RGFW_OSMesa_reorganize(); @@ -8677,7 +8720,7 @@ void RGFW_window_swapBuffers(RGFW_window* win) { #endif } - if (!(win->_winArgs & RGFW_NO_GPU_RENDER)) { + if (!(win->_winArgs & RGFW_noGPURender)) { #ifdef RGFW_EGL eglSwapBuffers(win->src.EGL_display, win->src.EGL_surface); #elif defined(RGFW_OPENGL) @@ -8694,10 +8737,10 @@ void RGFW_window_close(RGFW_window* win) { { u32 i; for (i = 0; i < RGFW_MAX_DROPS; i++) - RGFW_FREE(win->event.droppedFiles[i]); + RGFW_free(win->event.droppedFiles[i]); - RGFW_FREE(win->event.droppedFiles); + RGFW_free(win->event.droppedFiles); } #endif @@ -8706,7 +8749,7 @@ void RGFW_window_close(RGFW_window* win) { NSRelease(win->src.image); #endif - RGFW_FREE(win); + RGFW_free(win); } u64 RGFW_getTimeNS(void) { @@ -9100,12 +9143,12 @@ void EMSCRIPTEN_KEEPALIVE RGFW_handleKeyEvent(char* key, char* code, b8 press) { RGFW_keyCallback(RGFW_root, physicalKey, mappedKey, RGFW_events[RGFW_eventLen].keyName, 0, press); - RGFW_FREE(key); - RGFW_FREE(code); + RGFW_free(key); + RGFW_free(code); } void EMSCRIPTEN_KEEPALIVE Emscripten_onDrop(size_t count) { - if (!(RGFW_root->_winArgs & RGFW_ALLOW_DND)) + if (!(RGFW_root->_winArgs & RGFW_allowDND)) return; RGFW_events[RGFW_eventLen].droppedFilesCount = count; @@ -9141,7 +9184,7 @@ void RGFW_init_buffer(RGFW_window* win) { if (RGFW_bufferSize.w == 0 && RGFW_bufferSize.h == 0) RGFW_bufferSize = RGFW_getScreenSize(); - win->buffer = RGFW_MALLOC(RGFW_bufferSize.w * RGFW_bufferSize.h * 4); + win->buffer = RGFW_alloc(RGFW_bufferSize.w * RGFW_bufferSize.h * 4); #ifdef RGFW_OSMESA win->src.ctx = OSMesaCreateContext(OSMESA_RGBA, NULL); OSMesaMakeCurrent(win->src.ctx, win->buffer, GL_UNSIGNED_BYTE, win->r.w, win->r.h); @@ -9176,7 +9219,7 @@ void EMSCRIPTEN_KEEPALIVE RGFW_writeFile(const char *path, const char *data, siz fclose(file); } -RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { +RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, RGFW_windowArgs args) { RGFW_UNUSED(name) RGFW_UNUSED(RGFW_initFormatAttribs); @@ -9237,8 +9280,8 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { emscripten_set_gamepadconnected_callback(NULL, 1, Emscripten_on_gamepad); emscripten_set_gamepaddisconnected_callback(NULL, 1, Emscripten_on_gamepad); - if (args & RGFW_ALLOW_DND) { - win->_winArgs |= RGFW_ALLOW_DND; + if (args & RGFW_allowDND) { + win->_winArgs |= RGFW_allowDND; } EM_ASM({ @@ -9312,11 +9355,11 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { RGFW_root = win; - if (args & RGFW_HIDE_MOUSE) { + if (args & RGFW_hideMouse) { RGFW_window_showMouse(win, 0); } - if (args & RGFW_FULLSCREEN) { + if (args & RGFW_fullscreen) { RGFW_window_resize(win, RGFW_getScreenSize()); } @@ -9502,7 +9545,7 @@ char* RGFW_readClipboard(size_t* size) { if (size != NULL) *size = len; - char* str = (char*)RGFW_MALLOC(1); + char* str = (char*)RGFW_alloc(1); str[len] = '\0'; return str; @@ -9512,7 +9555,7 @@ void RGFW_window_swapBuffers(RGFW_window* win) { RGFW_UNUSED(win); #ifdef RGFW_BUFFER - if (!(win->_winArgs & RGFW_NO_CPU_RENDER)) { + if (!(win->_winArgs & RGFW_noCPURender)) { glEnable(GL_TEXTURE_2D); GLuint texture; @@ -9572,7 +9615,7 @@ void RGFW_window_close(RGFW_window* win) { emscripten_webgl_destroy_context(win->src.ctx); #endif - RGFW_FREE(win); + RGFW_free(win); } int RGFW_innerWidth(void) { return EM_ASM_INT({ return window.innerWidth; }); } diff --git a/examples/basic/basic.c b/examples/basic/basic.c index 920d5b75..9b5bf152 100644 --- a/examples/basic/basic.c +++ b/examples/basic/basic.c @@ -29,7 +29,7 @@ RGFW_window* win2; int main(void) { RGFW_setClassName("RGFW Basic"); - RGFW_window* win = RGFW_createWindow("RGFW Example Window", RGFW_RECT(500, 500, 500, 500), RGFW_ALLOW_DND | RGFW_CENTER); + RGFW_window* win = RGFW_createWindow("RGFW Example Window", RGFW_RECT(500, 500, 500, 500), RGFW_allowDND | RGFW_center); RGFW_window_makeCurrent(win); RGFW_window_setIcon(win, icon, RGFW_AREA(3, 3), 4); diff --git a/examples/buffer/buffer.c b/examples/buffer/buffer.c index 9b522c3d..1e86d485 100644 --- a/examples/buffer/buffer.c +++ b/examples/buffer/buffer.c @@ -65,7 +65,7 @@ void drawRect(RGFW_window* win, RGFW_rect r, u8 color[4]) { } int main(void) { - RGFW_window* win = RGFW_createWindow("Basic buffer example", RGFW_RECT(0, 0, 500, 500), RGFW_CENTER | RGFW_TRANSPARENT_WINDOW); + RGFW_window* win = RGFW_createWindow("Basic buffer example", RGFW_RECT(0, 0, 500, 500), RGFW_center| RGFW_transparent); screenSize = RGFW_getScreenSize(); diff --git a/examples/callbacks/callbacks.c b/examples/callbacks/callbacks.c index 67f5d2ca..0ffc0ddc 100644 --- a/examples/callbacks/callbacks.c +++ b/examples/callbacks/callbacks.c @@ -82,7 +82,7 @@ void mousebuttonfunc(RGFW_window* win, u8 button, double scroll, u8 pressed) { int main(void) { - window = RGFW_createWindow("RGFW Callbacks", RGFW_RECT(500, 500, 500, 500), (u64)RGFW_CENTER | RGFW_ALLOW_DND); + window = RGFW_createWindow("RGFW Callbacks", RGFW_RECT(500, 500, 500, 500), RGFW_center | RGFW_allowDND); RGFW_setWindowMoveCallback(windowmovefunc); RGFW_setWindowResizeCallback(windowresizefunc); diff --git a/examples/events/events.c b/examples/events/events.c index dc7cfbf7..e118ac41 100644 --- a/examples/events/events.c +++ b/examples/events/events.c @@ -2,7 +2,7 @@ #include "RGFW.h" int main(void) { - RGFW_window* win = RGFW_createWindow("RGFW Events", RGFW_RECT(500, 500, 500, 500), (u64)RGFW_CENTER | RGFW_ALLOW_DND | RGFW_TRANSPARENT_WINDOW); + RGFW_window* win = RGFW_createWindow("RGFW Events", RGFW_RECT(500, 500, 500, 500), RGFW_center | RGFW_allowDND | RGFW_transparent); while (RGFW_window_shouldClose(win) == 0) { glClearColor(0.25, 0, 0.15, 0.25); diff --git a/examples/first-person-camera/camera.c b/examples/first-person-camera/camera.c index cb162973..449f8c5c 100644 --- a/examples/first-person-camera/camera.c +++ b/examples/first-person-camera/camera.c @@ -10,7 +10,7 @@ RGFWDEF void update_camera(void); RGFWDEF void glPerspective(double fovY, double aspect, double zNear, double zFar); int main(void) { - RGFW_window* win = RGFW_createWindow("First person camera", RGFW_RECT(0, 0, 800, 450), RGFW_CENTER | RGFW_NO_RESIZE ); + RGFW_window* win = RGFW_createWindow("First person camera", RGFW_RECT(0, 0, 800, 450), RGFW_center | RGFW_noResize ); RGFW_window_showMouse(win, 0); glEnable(GL_DEPTH_TEST); diff --git a/examples/gamepad/gamepad.c b/examples/gamepad/gamepad.c index 019b9a63..770e591f 100644 --- a/examples/gamepad/gamepad.c +++ b/examples/gamepad/gamepad.c @@ -8,7 +8,7 @@ void drawGamepad(RGFW_window* w, size_t gamepad); int main(void) { - RGFW_window* win = RGFW_createWindow("RGFW Example Window", RGFW_RECT(0, 0, 800, 450), RGFW_CENTER); + RGFW_window* win = RGFW_createWindow("RGFW Example Window", RGFW_RECT(0, 0, 800, 450), RGFW_center); RGFW_window_makeCurrent(win); size_t gamepad = 0; diff --git a/examples/gl33/gl33.c b/examples/gl33/gl33.c index 7f351b3b..00a69ee7 100644 --- a/examples/gl33/gl33.c +++ b/examples/gl33/gl33.c @@ -69,7 +69,7 @@ int main(void) { RGFW_setGLVersion(RGFW_glCore, 3, 3); - RGFW_window* window = RGFW_createWindow("LearnOpenGL", RGFW_RECT(SCR_WIDTH, SCR_HEIGHT, SCR_WIDTH, SCR_HEIGHT), RGFW_ALLOW_DND | RGFW_CENTER | RGFW_SCALE_TO_MONITOR); + RGFW_window* window = RGFW_createWindow("LearnOpenGL", RGFW_RECT(SCR_WIDTH, SCR_HEIGHT, SCR_WIDTH, SCR_HEIGHT), RGFW_allowDND | RGFW_center | RGFW_scaleToMonitor); if (window == NULL) { printf("Failed to create RGFW window\n"); diff --git a/examples/gles2/gles2.c b/examples/gles2/gles2.c index 46bf999c..509238f8 100644 --- a/examples/gles2/gles2.c +++ b/examples/gles2/gles2.c @@ -23,7 +23,7 @@ GLuint load_shader(const char *shaderSource, GLenum type) { } int main(void) { - RGFW_window* win = RGFW_createWindow("name", RGFW_RECT(0, 0, 500, 500), RGFW_CENTER); + RGFW_window* win = RGFW_createWindow("name", RGFW_RECT(0, 0, 500, 500), RGFW_center); /////// the openGL part /////////////////////////////////////////////////////////////// diff --git a/examples/microui_demo/microui_demo.c b/examples/microui_demo/microui_demo.c index 177dcb62..67deafae 100644 --- a/examples/microui_demo/microui_demo.c +++ b/examples/microui_demo/microui_demo.c @@ -242,7 +242,7 @@ static int text_height(mu_Font font) { int main(int argc, char **argv) { RGFW_UNUSED(argc); RGFW_UNUSED(argv); /* init RGFW window */ - RGFW_window* window = RGFW_createWindow("", RGFW_RECT(0, 0, width, height), RGFW_CENTER | RGFW_SCALE_TO_MONITOR); + RGFW_window* window = RGFW_createWindow("", RGFW_RECT(0, 0, width, height), RGFW_center | RGFW_scaleToMonitor); r_init(); /* init microui */ diff --git a/examples/portableGL/pgl.c b/examples/portableGL/pgl.c index 38bc821a..fbd8fc0b 100644 --- a/examples/portableGL/pgl.c +++ b/examples/portableGL/pgl.c @@ -29,7 +29,7 @@ int main() { RGFW_area area = RGFW_AREA(500, 500); RGFW_setBufferSize(area); - RGFW_window* win = RGFW_createWindow("name", RGFW_RECT(500, 500, 500, 500), (u64)RGFW_CENTER | RGFW_NO_RESIZE); + RGFW_window* win = RGFW_createWindow("name", RGFW_RECT(500, 500, 500, 500), (u64)RGFW_center | RGFW_noResize); glContext context; init_glContext(&context, (u32**)&win->buffer, area.w, 500, 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF); diff --git a/examples/silk/silk.c b/examples/silk/silk.c index bcc8c0c3..431bbd73 100644 --- a/examples/silk/silk.c +++ b/examples/silk/silk.c @@ -21,7 +21,7 @@ typedef int64_t i64; int main(void) { RGFW_setBufferSize(RGFW_AREA(500, 500)); - RGFW_window* win = RGFW_createWindow("Basic buffer example", RGFW_RECT(0, 0, 500, 500), RGFW_CENTER | RGFW_TRANSPARENT_WINDOW | RGFW_NO_RESIZE); + RGFW_window* win = RGFW_createWindow("Basic buffer example", RGFW_RECT(0, 0, 500, 500), RGFW_center | RGFW_transparent | RGFW_noResize); u32 angle = 0; diff --git a/examples/vk10/RGFW_vulkan.h b/examples/vk10/RGFW_vulkan.h index 016b7902..d91d2c02 100644 --- a/examples/vk10/RGFW_vulkan.h +++ b/examples/vk10/RGFW_vulkan.h @@ -183,14 +183,14 @@ int RGFW_deviceInitialization(RGFW_window* win, RGFW_window_vulkanInfo* vulkWin) u32 deviceCount = 0; vkEnumeratePhysicalDevices(RGFW_vulkan_info.instance, &deviceCount, NULL); - VkPhysicalDevice* devices = (VkPhysicalDevice*) RGFW_MALLOC(sizeof(VkPhysicalDevice) * deviceCount); + VkPhysicalDevice* devices = (VkPhysicalDevice*) RGFW_alloc(sizeof(VkPhysicalDevice) * deviceCount); vkEnumeratePhysicalDevices(RGFW_vulkan_info.instance, &deviceCount, devices); RGFW_vulkan_info.physical_device = devices[0]; u32 queue_family_count = 0; vkGetPhysicalDeviceQueueFamilyProperties(RGFW_vulkan_info.physical_device, &queue_family_count, NULL); - VkQueueFamilyProperties* queueFamilies = (VkQueueFamilyProperties*) RGFW_MALLOC(sizeof(VkQueueFamilyProperties) * queue_family_count); + VkQueueFamilyProperties* queueFamilies = (VkQueueFamilyProperties*) RGFW_alloc(sizeof(VkQueueFamilyProperties) * queue_family_count); vkGetPhysicalDeviceQueueFamilyProperties(RGFW_vulkan_info.physical_device, &queue_family_count, queueFamilies); float queuePriority = 1.0f; @@ -267,10 +267,10 @@ int RGFW_createSwapchain(RGFW_window* win, RGFW_window_vulkanInfo* vulkWin) { u32 imageCount; vkGetSwapchainImagesKHR(RGFW_vulkan_info.device, vulkWin->swapchain, &imageCount, NULL); - vulkWin->swapchain_images = (VkImage*) RGFW_MALLOC(sizeof(VkImage) * imageCount); + vulkWin->swapchain_images = (VkImage*) RGFW_alloc(sizeof(VkImage) * imageCount); vkGetSwapchainImagesKHR(RGFW_vulkan_info.device, vulkWin->swapchain, &imageCount, vulkWin->swapchain_images); - vulkWin->swapchain_image_views = (VkImageView*) RGFW_MALLOC(sizeof(VkImageView) * imageCount); + vulkWin->swapchain_image_views = (VkImageView*) RGFW_alloc(sizeof(VkImageView) * imageCount); for (u32 i = 0; i < imageCount; i++) { VkImageViewCreateInfo image_view_cre_infos = { 0 }; image_view_cre_infos.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; @@ -354,7 +354,7 @@ int RGFW_createCommandPool(void) { int RGFW_createCommandBuffers(RGFW_window_vulkanInfo* vulkWin) { assert(vulkWin != NULL); - RGFW_vulkan_info.command_buffers = (VkCommandBuffer*) RGFW_MALLOC(sizeof(VkCommandBuffer) * vulkWin->image_count); + RGFW_vulkan_info.command_buffers = (VkCommandBuffer*) RGFW_alloc(sizeof(VkCommandBuffer) * vulkWin->image_count); VkCommandBufferAllocateInfo allocInfo = { 0 }; allocInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; @@ -372,10 +372,10 @@ int RGFW_createCommandBuffers(RGFW_window_vulkanInfo* vulkWin) { int RGFW_createSyncObjects(RGFW_window_vulkanInfo* vulkWin) { assert(vulkWin != NULL); - RGFW_vulkan_info.available_semaphores = (VkSemaphore*) RGFW_MALLOC(sizeof(VkSemaphore) * RGFW_MAX_FRAMES_IN_FLIGHT); - RGFW_vulkan_info.finished_semaphore = (VkSemaphore*) RGFW_MALLOC(sizeof(VkSemaphore) * RGFW_MAX_FRAMES_IN_FLIGHT); - RGFW_vulkan_info.in_flight_fences = (VkFence*) RGFW_MALLOC(sizeof(VkFence) * RGFW_MAX_FRAMES_IN_FLIGHT); - RGFW_vulkan_info.image_in_flight = (VkFence*) RGFW_MALLOC(sizeof(VkFence) * vulkWin->image_count); + RGFW_vulkan_info.available_semaphores = (VkSemaphore*) RGFW_alloc(sizeof(VkSemaphore) * RGFW_MAX_FRAMES_IN_FLIGHT); + RGFW_vulkan_info.finished_semaphore = (VkSemaphore*) RGFW_alloc(sizeof(VkSemaphore) * RGFW_MAX_FRAMES_IN_FLIGHT); + RGFW_vulkan_info.in_flight_fences = (VkFence*) RGFW_alloc(sizeof(VkFence) * RGFW_MAX_FRAMES_IN_FLIGHT); + RGFW_vulkan_info.image_in_flight = (VkFence*) RGFW_alloc(sizeof(VkFence) * vulkWin->image_count); VkSemaphoreCreateInfo semaphore_info = { 0 }; semaphore_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; @@ -403,7 +403,7 @@ int RGFW_createSyncObjects(RGFW_window_vulkanInfo* vulkWin) { int RGFW_createFramebuffers(RGFW_window* win, RGFW_window_vulkanInfo* vulkWin) { assert(vulkWin != NULL); - RGFW_vulkan_info.framebuffers = (VkFramebuffer*) RGFW_MALLOC(sizeof(VkFramebuffer) * vulkWin->image_count); + RGFW_vulkan_info.framebuffers = (VkFramebuffer*) RGFW_alloc(sizeof(VkFramebuffer) * vulkWin->image_count); for (size_t i = 0; i < vulkWin->image_count; i++) { VkImageView attachments[] = { vulkWin->swapchain_image_views[i] }; @@ -435,8 +435,8 @@ void RGFW_freeVulkan(RGFW_window_vulkanInfo* vulkWin) { vkDestroySwapchainKHR(RGFW_vulkan_info.device, vulkWin->swapchain, NULL); vkDestroySurfaceKHR(RGFW_vulkan_info.instance, vulkWin->rSurf, NULL); - RGFW_FREE(vulkWin->swapchain_image_views); - RGFW_FREE(vulkWin->swapchain_images); + RGFW_free(vulkWin->swapchain_image_views); + RGFW_free(vulkWin->swapchain_images); vkDeviceWaitIdle(RGFW_vulkan_info.device); @@ -462,12 +462,12 @@ void RGFW_freeVulkan(RGFW_window_vulkanInfo* vulkWin) { vkDestroyDevice(RGFW_vulkan_info.device, NULL); vkDestroyInstance(RGFW_vulkan_info.instance, NULL); - RGFW_FREE(RGFW_vulkan_info.framebuffers); - RGFW_FREE(RGFW_vulkan_info.command_buffers); - RGFW_FREE(RGFW_vulkan_info.available_semaphores); - RGFW_FREE(RGFW_vulkan_info.finished_semaphore); - RGFW_FREE(RGFW_vulkan_info.in_flight_fences); - RGFW_FREE(RGFW_vulkan_info.image_in_flight); + RGFW_free(RGFW_vulkan_info.framebuffers); + RGFW_free(RGFW_vulkan_info.command_buffers); + RGFW_free(RGFW_vulkan_info.available_semaphores); + RGFW_free(RGFW_vulkan_info.finished_semaphore); + RGFW_free(RGFW_vulkan_info.in_flight_fences); + RGFW_free(RGFW_vulkan_info.image_in_flight); } VkShaderModule RGFW_createShaderModule(const u32* code, size_t code_size) { diff --git a/examples/vk10/vk10.c b/examples/vk10/vk10.c index a8e6d37a..ac8fdef4 100644 --- a/examples/vk10/vk10.c +++ b/examples/vk10/vk10.c @@ -31,7 +31,7 @@ int draw_frame(RGFW_window_vulkanInfo* vulkWin); int main(void) { - RGFW_window* win = RGFW_createWindow("Vulkan Example", RGFW_RECT(0, 0, 500, 500), RGFW_ALLOW_DND | RGFW_CENTER);; + RGFW_window* win = RGFW_createWindow("Vulkan Example", RGFW_RECT(0, 0, 500, 500), RGFW_allowDND | RGFW_center);; RGFW_window_vulkanInfo vulkWin; vulkan_info = RGFW_initVulkan(win, &vulkWin);