Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions RGFW.h
Original file line number Diff line number Diff line change
Expand Up @@ -11874,9 +11874,16 @@ RGFW_bool RGFW_createSurfacePtr(u8* data, i32 w, i32 h, RGFW_format format, RGFW
void RGFW_surface_freePtr(RGFW_surface* surface) { RGFW_FREE(surface->native.buffer); }

void RGFW_window_blitSurface(RGFW_window* win, RGFW_surface* surface) {
id pool = objc_msgSend_class(objc_getClass("NSAutoreleasePool"), sel_registerName("alloc"));
pool = objc_msgSend_id(pool, sel_registerName("init"));

int minX = RGFW_MIN(win->w, surface->w);
int minY = RGFW_MIN(win->h, surface->h);

RGFW_monitor mon = RGFW_window_getMonitor(win);
minX = (i32)((float)minX * mon.pixelRatio);
minY = (i32)((float)minY * mon.pixelRatio);

RGFW_copyImageData(surface->native.buffer, surface->w, minY, surface->native.format, surface->data, surface->format);

id image = ((id (*)(Class, SEL))objc_msgSend)(objc_getClass("NSImage"), sel_getUid("alloc"));
Expand All @@ -11896,6 +11903,8 @@ void RGFW_window_blitSurface(RGFW_window* win, RGFW_surface* surface) {

NSRelease(rep);
NSRelease(image);

objc_msgSend_bool_void(pool, sel_registerName("drain"));
}

void* RGFW_window_getView_OSX(RGFW_window* win) { return win->src.view; }
Expand Down