mirror of https://github.com/liamg/aminal.git
Merge pull request #110 from vkravets/native_fix_mojave_darwin
Add another workaround for darwin SDL blank window bug
This commit is contained in:
commit
b960a679b8
|
@ -0,0 +1,28 @@
|
||||||
|
//+build darwin
|
||||||
|
|
||||||
|
package gui
|
||||||
|
|
||||||
|
/*
|
||||||
|
#cgo darwin CFLAGS: -x objective-c -Wno-deprecated-declarations
|
||||||
|
#cgo darwin LDFLAGS: -framework Foundation
|
||||||
|
#include <Cocoa/Cocoa.h>
|
||||||
|
void cocoa_update_nsgl_context(void* id) {
|
||||||
|
NSOpenGLContext *ctx = id;
|
||||||
|
[ctx update];
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
import "C"
|
||||||
|
import (
|
||||||
|
"github.com/go-gl/glfw/v3.2/glfw"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
var nsglContextUpdateCounter int
|
||||||
|
|
||||||
|
func UpdateNSGLContext(window *glfw.Window) {
|
||||||
|
if nsglContextUpdateCounter < 2 {
|
||||||
|
ctx := window.GetNSGLContext()
|
||||||
|
C.cocoa_update_nsgl_context(unsafe.Pointer(ctx))
|
||||||
|
nsglContextUpdateCounter++
|
||||||
|
}
|
||||||
|
}
|
16
gui/gui.go
16
gui/gui.go
|
@ -215,8 +215,6 @@ func (gui *GUI) Render() error {
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
showMessage := true
|
showMessage := true
|
||||||
|
|
||||||
darwinRenderFixRequired := runtime.GOOS == "darwin"
|
|
||||||
|
|
||||||
for !gui.window.ShouldClose() {
|
for !gui.window.ShouldClose() {
|
||||||
|
|
||||||
select {
|
select {
|
||||||
|
@ -269,14 +267,7 @@ Buffer Size: %d lines
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gui.window.SwapBuffers()
|
gui.SwapBuffers()
|
||||||
|
|
||||||
// Workaround for https://github.com/glfw/glfw/issues/1334
|
|
||||||
if darwinRenderFixRequired {
|
|
||||||
darwinRenderFixRequired = false
|
|
||||||
x, y := gui.window.GetPos()
|
|
||||||
gui.window.SetPos(x+1, y)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -487,3 +478,8 @@ func (gui *GUI) launchTarget(target string) {
|
||||||
gui.logger.Errorf("Failed to launch external command %s: %s", cmd, err)
|
gui.logger.Errorf("Failed to launch external command %s: %s", cmd, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gui *GUI) SwapBuffers() {
|
||||||
|
UpdateNSGLContext(gui.window)
|
||||||
|
gui.window.SwapBuffers()
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
// +build !darwin
|
||||||
|
|
||||||
|
package gui
|
||||||
|
|
||||||
|
import "github.com/go-gl/glfw/v3.2/glfw"
|
||||||
|
|
||||||
|
func UpdateNSGLContext(window *glfw.Window) {
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue