Skip to content

Commit

Permalink
limit stl usage (macOS)
Browse files Browse the repository at this point in the history
  • Loading branch information
ColleagueRiley committed Jan 6, 2025
1 parent 2947475 commit c16c50d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ else ifeq ($(detected_OS),Linux)
else ifeq ($(detected_OS),windows)
$(CC) $(CFLAGS) $(WARNINGS) -I. $< -lkernel32 -lgdi32 -lshell32 -lUser32 -nostdlib -o $@$(EXT)
else ifeq ($(detected_OS),Darwin)
$(CC) $(CFLAGS) $(WARNINGS) -nostdlib -I. $< -framework Foundation -framework AppKit -o $@$(EXT)
$(CC) $(CFLAGS) -fno-stack-protector $(WARNINGS) -I. $< -framework Foundation -framework AppKit -framework CoreServices -o $@$(EXT)
else
@echo nostl is not supported on this platform
endif
Expand Down
10 changes: 9 additions & 1 deletion RGFW.h
Original file line number Diff line number Diff line change
Expand Up @@ -1911,8 +1911,11 @@ void RGFW_updateLockState(RGFW_window* win, b8 capital, b8 numlock) {
#if defined(RGFW_X11) || defined(RGFW_MACOS) || defined(RGFW_WEBASM) || defined(RGFW_WAYLAND)
struct timespec;

#ifndef RGFW_NO_UNIX_CLOCK
int nanosleep(const struct timespec* duration, struct timespec* rem);
int clock_gettime(clockid_t clk_id, struct timespec* tp);
#endif

int setenv(const char *name, const char *value, int overwrite);

void RGFW_window_setDND(RGFW_window* win, b8 allow) {
Expand Down Expand Up @@ -7884,14 +7887,19 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, RGFW_windowArgs
void* format = NSOpenGLPixelFormat_initWithAttributes((uint32_t*)attrs);

if (format == NULL) {
#ifdef RGFW_DEBUG
printf("Failed to load pixel format for OpenGL\n");

#endif

void* attrs = RGFW_initFormatAttribs(1);
format = NSOpenGLPixelFormat_initWithAttributes((uint32_t*)attrs);

#ifdef RGFW_DEBUG
if (format == NULL)
printf("and loading software rendering OpenGL failed\n");
else
printf("Switching to software rendering\n");
#endif
}

/* the pixel format can be passed directly to opengl context creation to create a context
Expand Down
12 changes: 6 additions & 6 deletions examples/buffer/buffer.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#define RGFW_IMPLEMENTATION
#define RGFW_BUFFER
#define RGFW_OPENGL
//#define RGFW_OPENGL

#include "RGFW.h"

Expand Down Expand Up @@ -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);
RGFW_window* win = RGFW_createWindow("Basic buffer example", RGFW_RECT(0, 0, 500, 500), RGFW_center);

screenSize = RGFW_getScreenSize();

Expand All @@ -77,15 +77,15 @@ int main(void) {
break;
}
}

clear(win, (u8[4]){0, 0, 255, 15});
clear(win, (u8[4]){255, 255, 255, 255});
drawRect(win, RGFW_RECT(200, 200, 200, 200), (u8[4]){255, 0, 0, 255});

drawBitmap(win, icon, RGFW_RECT(100, 100, 3, 3));

RGFW_window_setGPURender(win, 0);
//RGFW_window_setGPURender(win, 0);
RGFW_window_swapBuffers(win);
RGFW_window_checkFPS(win, 60);
RGFW_window_checkFPS(win, 0);
}

RGFW_window_close(win);
Expand Down
5 changes: 3 additions & 2 deletions examples/nostl/nostl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#define RGFW_NO_UNIX_CLOCK
#define RGFW_WGL_LOAD
#define RGFW_NO_DPI
#define RGFW_NO_IOKIT
#include <stddef.h>

char arr[100000];
Expand All @@ -19,7 +20,7 @@ void* myMalloc(size_t size) {
return (char*)out;
}

void myFree(void*) { }
void myFree(void* ptr) { (void)(ptr); }

void* memoryCopy(void* _dist, const void* _src, size_t size) {
const char* src = (char*)_src;
Expand Down Expand Up @@ -74,4 +75,4 @@ int __main(void) {
RGFW_window_close(win);

return 0;
}
}

0 comments on commit c16c50d

Please sign in to comment.