mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 10:25:37 +00:00
app/headless: prepare OpenGL context on macOS
The macOS backend uses a desktop OpenGL context, not a OpenGL ES context. The main difference is that sRGB have to be enabled and a vertex buffer must be bound. Do that and fix Window.Screenshot for scenes more complex than a glClear. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
@import AppKit;
|
||||
@import OpenGL;
|
||||
@import OpenGL.GL;
|
||||
@import OpenGL.GL3;
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include "headless_darwin.h"
|
||||
@@ -40,6 +41,13 @@ void gio_headless_clearCurrentContext(CFTypeRef ctxRef) {
|
||||
void gio_headless_makeCurrentContext(CFTypeRef ctxRef) {
|
||||
NSOpenGLContext *ctx = (__bridge NSOpenGLContext *)ctxRef;
|
||||
[ctx makeCurrentContext];
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
CGLLockContext([ctx CGLContextObj]);
|
||||
}
|
||||
|
||||
void gio_headless_prepareContext(CFTypeRef ctxRef) {
|
||||
// Bind a default VBA to emulate OpenGL ES 2.
|
||||
GLuint defVBA;
|
||||
glGenVertexArrays(1, &defVBA);
|
||||
glBindVertexArray(defVBA);
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user