-
-
Notifications
You must be signed in to change notification settings - Fork 65
Open
Description
Hi, there appears to be an issue with RGFW_window_blitSurface on macos. I just now cloned this repo, ran make, and ran "./examples/surface/surface". Here is what it looks like (I removed the transparency here):
This is the patch I applied to fix it:
--- a/RGFW_nonpatch.h
+++ b/RGFW_nonpatch.h
@@ -12047,17 +12047,21 @@ 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) {
- int minX = RGFW_MIN(win->w, surface->w);
- int minY = RGFW_MIN(win->h, surface->h);
+ // int minX = RGFW_MIN(win->w, surface->w);
+ // int minY = RGFW_MIN(win->h, surface->h);
+ // In the example, surface is always size of monitor, so do this
+ int minX = surface->h;
+ int minY = surface->w;
- RGFW_copyImageData(surface->native.buffer, surface->w, minY, surface->native.format, surface->data, surface->format);
+ // 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"));
NSSize size = (NSSize){(double)surface->w, (double)surface->h};
image = ((id (*)(id, SEL, NSSize))objc_msgSend)((id)image, sel_getUid("initWithSize:"), size);
id rep = NSBitmapImageRep_initWithBitmapData(&surface->native.buffer, minX, minY, 8, 4, true, false, "NSDeviceRGBColorSpace", 1 << 1, (u32)surface->w * 4, 32);
- RGFW_copyImageData(NSBitmapImageRep_bitmapData(rep), minX, minY , RGFW_formatRGBA8, surface->native.buffer, surface->native.format);
+ // No need to copy image twice I think
+ RGFW_copyImageData(NSBitmapImageRep_bitmapData(rep), minX, minY , RGFW_formatRGBA8, surface->data, surface->format);
((void (*)(id, SEL, id))objc_msgSend)((id)image, sel_getUid("addRepresentation:"), rep);
id contentView = ((id (*)(id, SEL))objc_msgSend)((id)win->src.window, sel_getUid("contentView"));Now not exactly sure what is causing the issue, maybe some issue in the RGFW_copyImageData? Because ultimately that is the only real big difference. Or maybe the example is out of date?
I removed the first call to RGFW_copyImageData because it seemed a little redundant to me.
Metadata
Metadata
Assignees
Labels
No labels
