mirror of https://github.com/liamg/aminal.git
Add another workaround for darwin SDL blank window bug
As for me it's much better then moving window at one pixel (Based on the https://github.com/Noofbiz/glfwMojaveFix)
This commit is contained in:
parent
06c5ca65b1
commit
731fcf5b08
|
@ -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()
|
||||
showMessage := true
|
||||
|
||||
darwinRenderFixRequired := runtime.GOOS == "darwin"
|
||||
|
||||
for !gui.window.ShouldClose() {
|
||||
|
||||
select {
|
||||
|
@ -269,14 +267,7 @@ Buffer Size: %d lines
|
|||
}
|
||||
}
|
||||
|
||||
gui.window.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)
|
||||
}
|
||||
gui.SwapBuffers()
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -487,3 +478,8 @@ func (gui *GUI) launchTarget(target string) {
|
|||
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