internal/graphicsdriver/opengl/gl: load OpenGLES.framework if possible on Darwin

Closes #2449
This commit is contained in:
Hajime Hoshi 2022-11-13 19:51:36 +09:00
parent b6ed95750b
commit 78f8ddbda8
3 changed files with 14 additions and 17 deletions

View File

@ -12,25 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build android || ios || opengles
//go:build android || opengles
package gl
// #cgo !darwin CFLAGS: -Dos_notdarwin
// #cgo darwin CFLAGS: -Dos_darwin
// #cgo !android,!darwin pkg-config: glesv2
// #cgo !android pkg-config: glesv2
// #cgo android LDFLAGS: -lGLESv2
// #cgo darwin LDFLAGS: -framework OpenGLES
//
// #if defined(os_darwin)
// #define GLES_SILENCE_DEPRECATION
// #include <OpenGLES/ES2/glext.h>
// #endif
//
// #if defined(os_notdarwin)
// #include <GLES2/gl2.h>
// #endif
//
// #include <stdlib.h>
import "C"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build (darwin || windows) && !ios && !opengles
//go:build darwin || windows
package gl

View File

@ -7,7 +7,15 @@ import (
"github.com/ebitengine/purego"
)
var opengl = purego.Dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", purego.RTLD_GLOBAL)
var opengl uintptr
func init() {
opengl = purego.Dlopen("/System/Library/Frameworks/OpenGLES.framework/Versions/Current/OpenGLES", purego.RTLD_GLOBAL)
if opengl != 0 {
return
}
opengl = purego.Dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", purego.RTLD_GLOBAL)
}
func getProcAddress(name string) uintptr {
return purego.Dlsym(opengl, name)