gpu/internal/opengl,app/internal/wm: generalize desktop OpenGL support

This changes moves the macOS specific setup for desktop OpenGL to the
portable opengl package. The opengl package already takes care of the
desktop OpenGL setup for sRGB framebuffers, and by moving the code we
avoid calling the wrong OpenGL functions in case both OpenGL.framework
and ANGLE libGLESv2.dylib is linked into the program.

Remove the interface casting expressions for gl.Functions; it wasn't
worth the trouble to keep updated.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2021-06-01 17:47:13 +02:00
parent c21897620b
commit 476d2269a6
9 changed files with 98 additions and 102 deletions
+3 -12
View File
@@ -15,10 +15,8 @@ import (
#include <CoreFoundation/CoreFoundation.h>
#include <CoreGraphics/CoreGraphics.h>
#include <AppKit/AppKit.h>
#include <OpenGL/gl3.h>
__attribute__ ((visibility ("hidden"))) CFTypeRef gio_createGLContext(void);
__attribute__ ((visibility ("hidden"))) void gio_prepareContext(void);
__attribute__ ((visibility ("hidden"))) void gio_setContextView(CFTypeRef ctx, CFTypeRef view);
__attribute__ ((visibility ("hidden"))) void gio_makeCurrentContext(CFTypeRef ctx);
__attribute__ ((visibility ("hidden"))) void gio_flushContextBuffer(CFTypeRef ctx);
@@ -29,10 +27,9 @@ __attribute__ ((visibility ("hidden"))) void gio_unlockContext(CFTypeRef ctxRef)
import "C"
type context struct {
c *gl.Functions
ctx C.CFTypeRef
view C.CFTypeRef
prepared bool
c *gl.Functions
ctx C.CFTypeRef
view C.CFTypeRef
}
func newContext(w *window) (*context, error) {
@@ -66,8 +63,6 @@ func (c *context) Release() {
}
func (c *context) Present() error {
// Assume the caller already locked the context.
C.glFlush()
return nil
}
@@ -83,10 +78,6 @@ func (c *context) MakeCurrent() error {
c.Lock()
defer c.Unlock()
C.gio_makeCurrentContext(c.ctx)
if !c.prepared {
c.prepared = true
C.gio_prepareContext()
}
return nil
}
-8
View File
@@ -6,7 +6,6 @@
#include <CoreFoundation/CoreFoundation.h>
#include <OpenGL/OpenGL.h>
#include <OpenGL/gl3.h>
#include "_cgo_export.h"
@interface GioGLContext : NSOpenGLContext
@@ -79,10 +78,3 @@ void gio_unlockContext(CFTypeRef ctxRef) {
CGLUnlockContext([ctx CGLContextObj]);
}
}
void gio_prepareContext(void) {
// Bind a default VBA to emulate OpenGL ES 2.
GLuint defVBA;
glGenVertexArrays(1, &defVBA);
glBindVertexArray(defVBA);
}