Files
gio/ui/app/gl_macos.go
T
Elias Naur 0f05231c35 all: initial import
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-03-31 10:47:22 +02:00

60 lines
973 B
Go

// SPDX-License-Identifier: Unlicense OR MIT
// +build darwin,!ios
package app
import (
"gioui.org/ui/app/internal/gl"
)
/*
#cgo CFLAGS: -DGL_SILENCE_DEPRECATION -fmodules -fobjc-arc -x objective-c
#include <CoreFoundation/CoreFoundation.h>
#include <CoreGraphics/CoreGraphics.h>
#include <AppKit/AppKit.h>
#include <OpenGL/gl3.h>
#include "gl_macos.h"
*/
import "C"
type context struct {
c *gl.Functions
ctx C.CFTypeRef
}
func init() {
viewFactory = func() uintptr {
return uintptr(C.gio_createGLView())
}
}
func newContext(w *window) (*context, error) {
ctx := C.gio_contextForView(w.contextView())
c := &context{
ctx: ctx,
}
return c, nil
}
func (c *context) Functions() *gl.Functions {
return c.c
}
func (c *context) Release() {
C.gio_clearCurrentContext()
C.CFRelease(c.ctx)
c.ctx = 0
}
func (c *context) Present() error {
C.glFlush()
return nil
}
func (c *context) MakeCurrent() error {
C.gio_makeCurrentContext(c.ctx)
return nil
}