internal/graphicsdriver/opengl/gl: use PureGo version for Android again

This is basically a revert for 297efea68b.
This updates PureGo for the Android issue.

Updates #3052
Updates ebitengine/purego#262
This commit is contained in:
Hajime Hoshi 2024-08-05 21:18:51 +09:00
parent 1e3ab9e5fc
commit 2a34d1d47b
6 changed files with 17 additions and 78 deletions

2
go.mod
View File

@ -6,7 +6,7 @@ require (
github.com/ebitengine/gomobile v0.0.0-20240802043200-192f051f4fcc github.com/ebitengine/gomobile v0.0.0-20240802043200-192f051f4fcc
github.com/ebitengine/hideconsole v1.0.0 github.com/ebitengine/hideconsole v1.0.0
github.com/ebitengine/oto/v3 v3.3.0-alpha.3 github.com/ebitengine/oto/v3 v3.3.0-alpha.3
github.com/ebitengine/purego v0.8.0-alpha.3 github.com/ebitengine/purego v0.8.0-alpha.3.0.20240805123034-6cc30db8f187
github.com/gen2brain/mpeg v0.3.2-0.20240412154320-a2ac4fc8a46f github.com/gen2brain/mpeg v0.3.2-0.20240412154320-a2ac4fc8a46f
github.com/go-text/typesetting v0.1.1 github.com/go-text/typesetting v0.1.1
github.com/hajimehoshi/bitmapfont/v3 v3.2.0-alpha.3 github.com/hajimehoshi/bitmapfont/v3 v3.2.0-alpha.3

4
go.sum
View File

@ -4,8 +4,8 @@ github.com/ebitengine/hideconsole v1.0.0 h1:5J4U0kXF+pv/DhiXt5/lTz0eO5ogJ1iXb8Yj
github.com/ebitengine/hideconsole v1.0.0/go.mod h1:hTTBTvVYWKBuxPr7peweneWdkUwEuHuB3C1R/ielR1A= github.com/ebitengine/hideconsole v1.0.0/go.mod h1:hTTBTvVYWKBuxPr7peweneWdkUwEuHuB3C1R/ielR1A=
github.com/ebitengine/oto/v3 v3.3.0-alpha.3 h1:L8Odh8gVr4F+0CzSfqOfw/nEnXXWkB+UhGOKUYrP+Nk= github.com/ebitengine/oto/v3 v3.3.0-alpha.3 h1:L8Odh8gVr4F+0CzSfqOfw/nEnXXWkB+UhGOKUYrP+Nk=
github.com/ebitengine/oto/v3 v3.3.0-alpha.3/go.mod h1:yYvXK7mgNwsFawY5RsvGI6yhMHtD+0MfaPkDTl9/uv8= github.com/ebitengine/oto/v3 v3.3.0-alpha.3/go.mod h1:yYvXK7mgNwsFawY5RsvGI6yhMHtD+0MfaPkDTl9/uv8=
github.com/ebitengine/purego v0.8.0-alpha.3 h1:qoFlpGuVwJ6J85kuj6Qpyp0DBgxsNYfSY9efidSNFgA= github.com/ebitengine/purego v0.8.0-alpha.3.0.20240805123034-6cc30db8f187 h1:vXEgFw8Ni26tlWLmeI8nFXa7pMLKUTR9hfXcQPCYpQg=
github.com/ebitengine/purego v0.8.0-alpha.3/go.mod h1:b94LtM1jUWDZPKDyENVhB0WsLdLWFApjbNw5AyxmKyI= github.com/ebitengine/purego v0.8.0-alpha.3.0.20240805123034-6cc30db8f187/go.mod h1:SQ56/omnSL8DdaBSKswoBvsMjgaWQyxyeMtb48sOskI=
github.com/gen2brain/mpeg v0.3.2-0.20240412154320-a2ac4fc8a46f h1:ysqRe+lvUiL0dH5XzkH0Bz68bFMPJ4f5Si4L/HD9SGk= github.com/gen2brain/mpeg v0.3.2-0.20240412154320-a2ac4fc8a46f h1:ysqRe+lvUiL0dH5XzkH0Bz68bFMPJ4f5Si4L/HD9SGk=
github.com/gen2brain/mpeg v0.3.2-0.20240412154320-a2ac4fc8a46f/go.mod h1:i/ebyRRv/IoHixuZ9bElZnXbmfoUVPGQpdsJ4sVuX38= github.com/gen2brain/mpeg v0.3.2-0.20240412154320-a2ac4fc8a46f/go.mod h1:i/ebyRRv/IoHixuZ9bElZnXbmfoUVPGQpdsJ4sVuX38=
github.com/go-text/typesetting v0.1.1 h1:bGAesCuo85nXnEN5LmFMVGAGpGkCPtHrZLi//qD7EJo= github.com/go-text/typesetting v0.1.1 h1:bGAesCuo85nXnEN5LmFMVGAGpGkCPtHrZLi//qD7EJo=

View File

@ -2,7 +2,7 @@
// SPDX-FileCopyrightText: 2014 Eric Woroshow // SPDX-FileCopyrightText: 2014 Eric Woroshow
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
//go:build android || nintendosdk //go:build nintendosdk
package gl package gl

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//go:build (darwin || freebsd || (linux && !android) || netbsd || openbsd || windows) && !nintendosdk && !playstation5 //go:build (darwin || freebsd || linux || netbsd || openbsd || windows) && !nintendosdk && !playstation5
package gl package gl

View File

@ -1,67 +0,0 @@
// Copyright 2024 The Ebitengine Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package gl
// Unfortunately, PureGo's dlopen didn't work well on some Android devices (#3052).
// Use Cgo instead until PureGo is fixed.
// #include <dlfcn.h>
// #include <stdlib.h>
import "C"
import (
"fmt"
"strings"
"unsafe"
)
var (
libGLES unsafe.Pointer
)
func (c *defaultContext) init() error {
// TODO: Use multiple %w-s as of Go 1.20.
var errors []string
// Try OpenGL ES.
for _, name := range []string{"libGLESv2.so", "libGLESv2.so.2", "libGLESv2.so.1", "libGLESv2.so.0"} {
cname := C.CString(name)
defer C.free(unsafe.Pointer(cname))
lib := C.dlopen(cname, C.RTLD_LAZY|C.RTLD_GLOBAL)
if lib != nil {
libGLES = lib
c.isES = true
return nil
}
if cerr := C.dlerror(); cerr != nil {
errors = append(errors, fmt.Sprintf("%s: %v", name, C.GoString(cerr)))
}
}
return fmt.Errorf("gl: failed to load libGLESv2.so: %s", strings.Join(errors, ", "))
}
func (c *defaultContext) getProcAddress(name string) (uintptr, error) {
cname := C.CString(name)
defer C.free(unsafe.Pointer(cname))
addr := C.dlsym(libGLES, cname)
if addr == nil {
if cerr := C.dlerror(); cerr != nil {
return 0, fmt.Errorf("gl: failed to load %s: %v", name, C.GoString(cerr))
}
return 0, fmt.Errorf("gl: failed to load %s", name)
}
return uintptr(addr), nil
}

View File

@ -12,13 +12,14 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//go:build (freebsd || (linux && !android) || netbsd || openbsd) && !nintendosdk && !playstation5 //go:build (freebsd || linux || netbsd || openbsd) && !nintendosdk && !playstation5
package gl package gl
import ( import (
"fmt" "fmt"
"os" "os"
"runtime"
"strings" "strings"
"github.com/ebitengine/purego" "github.com/ebitengine/purego"
@ -31,11 +32,16 @@ var (
func (c *defaultContext) init() error { func (c *defaultContext) init() error {
var preferES bool var preferES bool
for _, t := range strings.Split(os.Getenv("EBITENGINE_OPENGL"), ",") { if runtime.GOOS == "android" {
switch strings.TrimSpace(t) { preferES = true
case "es": }
preferES = true if !preferES {
break for _, t := range strings.Split(os.Getenv("EBITENGINE_OPENGL"), ",") {
switch strings.TrimSpace(t) {
case "es":
preferES = true
break
}
} }
} }