Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ $(TARGET):

endif

ifeq ($(PLATFORM_OS),ios)
INCLUDE_IOS_API := 1
else
INCLUDE_IOS_API := 0
endif

# Parse platform.h to find all AX_API functions, generate a C test that asserts
# each function pointer is non-NULL (i.e. the symbol is defined), then compile,
# link and run that test against the built library.
Expand All @@ -156,7 +162,7 @@ test:
else
test: $(TARGET)
@printf '#include "platform.h"\n#include <assert.h>\nint main(void) {\n' > $(TEST_SRC)
@awk '/^AX_API[[:space:]]/{getline; sub(/[(].*/,""); printf " assert(%s != NULL);\n", $$1}' platform.h >> $(TEST_SRC)
@awk -v include_ios=$(INCLUDE_IOS_API) '/^#ifdef AX_PLATFORM_IOS/ { ios=1; next } /^#endif/ && ios { ios=0; next } ios && include_ios != 1 { next } /^AX_API[[:space:]]/ { line=$$0; while (line !~ /;/ && (getline nl) > 0) line=line " " nl; sub(/^AX_API[[:space:]]+/, "", line); n=split(line, parts, "("); if (n < 2) next; m=split(parts[1], toks, /[^A-Za-z0-9_]+/); name=toks[m]; if (name != "") printf " assert(%s != NULL);\n", name }' platform.h >> $(TEST_SRC)
@printf ' return 0;\n}\n' >> $(TEST_SRC)
@$(CC) -I. $(TEST_SRC) $(TEST_LDFLAGS) -o $(TEST_BIN)
@$(TEST_BIN)
Expand Down
7 changes: 7 additions & 0 deletions ios/ios_window.m
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,13 @@ bool_t axCreateWindow(const char *title, uint32_t w, uint32_t h, uint32_t flags)
ios_view.contentScaleFactor = ios_scale;
CAEAGLLayer *layer = (CAEAGLLayer *)ios_view.layer;
layer.opaque = YES;
CGColorSpaceRef color_space = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
if (color_space) {
layer.colorspace = color_space;
CGColorSpaceRelease(color_space);
} else {
IOS_TRACE("sRGB drawable color space unavailable; using platform default");
}
layer.drawableProperties = @{kEAGLDrawablePropertyRetainedBacking: @YES, kEAGLDrawablePropertyColorFormat: kEAGLColorFormatRGBA8};
glGenFramebuffers(1, &ios_framebuffer);
glGenRenderbuffers(1, &ios_color);
Expand Down
3 changes: 2 additions & 1 deletion macos/macos_window.m
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ static void ConfigureOpenGLView(NSOpenGLView *openglView, uint32_t flags) {

[delegate setWindow:window];

[window setFrameOrigin:windowRect.origin];
[window setFrameOrigin:windowRect.origin];
[window setColorSpace:[NSColorSpace sRGBColorSpace]];
[window setTitle:windowTitle];
[window setReleasedWhenClosed:NO];
[window setAcceptsMouseMovedEvents:YES];
Expand Down
15 changes: 10 additions & 5 deletions wayland/wayland_egl.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "wayland_local.h"
#include <EGL/eglext.h>

#define WIDTH 640
#define HEIGHT 480
Expand Down Expand Up @@ -131,14 +132,18 @@ create_window(struct _WND* window, int32_t width, int32_t height)
EGL_NONE
};
window->egl_surface = eglCreateWindowSurface(egl_display, config, window->egl_window, surface_attributes);
if (!window->egl_window) {
printf("Failed to create sRGB EGL surface, trying regular RGB!\n");
if (window->egl_surface == EGL_NO_SURFACE) {
fprintf(stderr, "[wayland] sRGB EGL surface failed error=0x%x; trying default RGB surface\n",
eglGetError());
fflush(stderr);
window->egl_surface = eglCreateWindowSurface(egl_display, config, window->egl_window, NULL);
} else {
printf("Created sRGB EGL surface\n");
fprintf(stderr, "[wayland] created sRGB EGL surface\n");
fflush(stderr);
}
if (!window->egl_window) {
printf("Failed to create EGL surface!\n");
if (window->egl_surface == EGL_NO_SURFACE) {
fprintf(stderr, "[wayland] EGL surface creation failed error=0x%x\n", eglGetError());
fflush(stderr);
return;
}
eglMakeCurrent(egl_display, window->egl_surface, window->egl_surface, window->egl_context);
Expand Down
25 changes: 24 additions & 1 deletion x11/x11_egl.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "x11_local.h"
#include "../platform.h"
#include <EGL/eglext.h>

#define WIDTH 640
#define HEIGHT 480
Expand Down Expand Up @@ -87,8 +88,30 @@ create_window(struct _WND* win, int32_t width, int32_t height)
XFlush(x_display);

win->egl_context = eglCreateContext(egl_display, egl_config, EGL_NO_CONTEXT, NULL);
EGLint surface_attributes[] = {
EGL_GL_COLORSPACE, EGL_GL_COLORSPACE_SRGB,
EGL_NONE
};
int surface_srgb = 1;
win->egl_surface = eglCreateWindowSurface(egl_display, egl_config,
(EGLNativeWindowType)x_window, NULL);
(EGLNativeWindowType)x_window,
surface_attributes);
if (win->egl_surface == EGL_NO_SURFACE) {
surface_srgb = 0;
fprintf(stderr, "[x11] sRGB EGL surface failed error=0x%x; trying default RGB surface\n",
eglGetError());
fflush(stderr);
win->egl_surface = eglCreateWindowSurface(egl_display, egl_config,
(EGLNativeWindowType)x_window, NULL);
}
if (win->egl_surface == EGL_NO_SURFACE) {
fprintf(stderr, "[x11] EGL surface creation failed error=0x%x\n", eglGetError());
fflush(stderr);
return;
}
fprintf(stderr, "[x11] EGL output surface color space=%s\n",
surface_srgb ? "sRGB" : "platform default fallback");
fflush(stderr);
eglMakeCurrent(egl_display, win->egl_surface, win->egl_surface, win->egl_context);

win->width = width;
Expand Down
Loading