mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-08-03 07:13:08 +00:00
Add basic N64 support on Mac (#205)
Note: mupen64plus lib unload is not working properly on Mac, so stopping and restarting N64 emulation will cause a crash
This commit is contained in:
parent
5f653de602
commit
c23347db08
5 changed files with 33 additions and 12 deletions
BIN
assets/emulator/libretro/cores/mupen64plus_next_libretro.dylib
vendored
Executable file
BIN
assets/emulator/libretro/cores/mupen64plus_next_libretro.dylib
vendored
Executable file
Binary file not shown.
|
|
@ -7,15 +7,15 @@ import (
|
|||
"os/signal"
|
||||
"time"
|
||||
|
||||
"github.com/faiface/mainthread"
|
||||
config "github.com/giongto35/cloud-game/pkg/config/worker"
|
||||
|
||||
"github.com/giongto35/cloud-game/pkg/util/logging"
|
||||
"github.com/giongto35/cloud-game/pkg/worker"
|
||||
"github.com/golang/glog"
|
||||
"github.com/spf13/pflag"
|
||||
)
|
||||
|
||||
func main() {
|
||||
func run() {
|
||||
rand.Seed(time.Now().UTC().UnixNano())
|
||||
|
||||
cfg := config.NewDefaultConfig()
|
||||
|
|
@ -43,3 +43,8 @@ func main() {
|
|||
cancelCtx()
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
// enables mainthread package and runs run in a separate goroutine
|
||||
mainthread.Run(run)
|
||||
}
|
||||
|
|
|
|||
1
go.mod
vendored
1
go.mod
vendored
|
|
@ -5,6 +5,7 @@ go 1.12
|
|||
require (
|
||||
cloud.google.com/go v0.43.0
|
||||
github.com/disintegration/imaging v1.6.2
|
||||
github.com/faiface/mainthread v0.0.0-20171120011319-8b78f0a41ae3
|
||||
github.com/gen2brain/x264-go v0.0.0-20200517120223-c08131f6fc8a
|
||||
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7
|
||||
github.com/gofrs/uuid v3.2.0+incompatible
|
||||
|
|
|
|||
2
go.sum
vendored
2
go.sum
vendored
|
|
@ -19,6 +19,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
|
|||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c=
|
||||
github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4=
|
||||
github.com/faiface/mainthread v0.0.0-20171120011319-8b78f0a41ae3 h1:baVdMKlASEHrj19iqjARrPbaRisD7EuZEVJj6ZMLl1Q=
|
||||
github.com/faiface/mainthread v0.0.0-20171120011319-8b78f0a41ae3/go.mod h1:VEPNJUlxl5KdWjDvz6Q1l+rJlxF2i6xqDeGuGAxa87M=
|
||||
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/gen2brain/x264-go v0.0.0-20200517120223-c08131f6fc8a h1:O6MN0Yik9iXHlC5t/NUznAgt18d0yAKIPZTihxLBIDE=
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import (
|
|||
"unsafe"
|
||||
|
||||
"github.com/disintegration/imaging"
|
||||
"github.com/faiface/mainthread"
|
||||
"github.com/giongto35/cloud-game/pkg/config"
|
||||
"github.com/giongto35/cloud-game/pkg/emulator/libretro/image"
|
||||
"github.com/go-gl/gl/v4.1-core/gl"
|
||||
|
|
@ -367,15 +368,20 @@ func initVideo() {
|
|||
fmt.Println("Unsupported hw context:", video.hw.context_type)
|
||||
}
|
||||
|
||||
video.window, err = sdl.CreateWindow(winTitle, sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED, winWidth, winHeight, sdl.WINDOW_OPENGL)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
// In OSX 10.14+ window creation and context creation must happen in the main thread
|
||||
mainthread.Call(func() {
|
||||
video.window, err = sdl.CreateWindow(winTitle, sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED, winWidth, winHeight, sdl.WINDOW_OPENGL)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
video.context, err = video.window.GLCreateContext()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
video.context, err = video.window.GLCreateContext()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
})
|
||||
// Bind context to current thread
|
||||
video.window.GLMakeCurrent(video.context)
|
||||
|
||||
if err = gl.InitWithProcAddrFunc(sdl.GLGetProcAddress); err != nil {
|
||||
panic(err)
|
||||
|
|
@ -431,13 +437,18 @@ func initVideo() {
|
|||
|
||||
//export deinitVideo
|
||||
func deinitVideo() {
|
||||
C.bridge_context_reset(video.hw.context_destroy)
|
||||
if video.hw.depth {
|
||||
gl.DeleteRenderbuffers(1, &video.rbo);
|
||||
}
|
||||
gl.DeleteFramebuffers(1, &video.fbo)
|
||||
gl.DeleteTextures(1, &video.tex)
|
||||
sdl.GLDeleteContext(video.context)
|
||||
video.window.Destroy()
|
||||
// In OSX 10.14+ window deletion must happen in the main thread
|
||||
mainthread.Call(func() {
|
||||
video.window.GLMakeCurrent(video.context)
|
||||
sdl.GLDeleteContext(video.context)
|
||||
video.window.Destroy()
|
||||
})
|
||||
video.isGl = false
|
||||
}
|
||||
|
||||
|
|
@ -626,7 +637,9 @@ func coreLoadGame(filename string) {
|
|||
if usesLibCo {
|
||||
C.bridge_execute(C.initVideo_cgo)
|
||||
} else {
|
||||
runtime.LockOSThread()
|
||||
initVideo()
|
||||
runtime.UnlockOSThread()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue