Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ColleagueRiley committed Jan 6, 2025
2 parents 6206cf5 + c16c50d commit 9711142
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 14 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 -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 @@ -1906,8 +1906,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 @@ -7872,14 +7875,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
8 changes: 5 additions & 3 deletions examples/metal/metal.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@
int main(void)
{
id<MTLDevice> device = MTLCreateSystemDefaultDevice();
if (!device)
if (!device) {
printf("faield to create metal device");
exit(EXIT_FAILURE);
}

RGFW_window* window = RGFW_createWindow("RGFW Metal example", RGFW_RECT(0, 0, 640, 480), RGFW_CENTER);
RGFW_window* window = RGFW_createWindow("RGFW Metal example", RGFW_RECT(0, 0, 640, 480), RGFW_center);

CAMetalLayer* layer = [CAMetalLayer layer];
layer.device = device;
Expand All @@ -60,7 +62,7 @@ int main(void)
NSView* view = (NSView*)window->src.view;
[view setLayer: layer];
// [view setWantsLayer: YES]; (I think RGFW already sets this)

MTLCompileOptions* compileOptions = [MTLCompileOptions new];
compileOptions.languageVersion = MTLLanguageVersion1_1;
NSError* compileError;
Expand Down
3 changes: 2 additions & 1 deletion examples/minimal_links/minimal_links.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#define RGFW_IMPLEMENTATION
#define RGFW_NO_API
#define RGFW_WGL_LOAD
#define RGFW_NO_IOKIT

#ifdef __linux__
#define XDL_IMPLEMENTATION
Expand All @@ -27,4 +28,4 @@ int main(void) {
#ifdef __linux__
XDL_close();
#endif
}
}
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 @@ -69,4 +70,4 @@ int main(void) {
RGFW_window_close(win);

return 0;
}
}

0 comments on commit 9711142

Please sign in to comment.