Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/mobile/gl: use EGL to determine the version of OpenGL ES #69

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
bail out of init early if an error is encountered for maximum correct…
…ness

call eglTerminate before init returns. if another init on the same OS thread has already created a context, eglTerminate is a no-op until the context is destroyed. otherwise, this allows scenarios where a program that imports x/mobile/gl might want to call eglInitialize on a different display.
  • Loading branch information
BenLubar committed Jul 9, 2021
commit daa7304706cba35e6ddeca416a40d8e84adb357a
9 changes: 7 additions & 2 deletions gl/egl.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import "C"
func init() {
display := C.eglGetDisplay(C.EGL_DEFAULT_DISPLAY)

C.eglInitialize(display, nil, nil)
if C.eglInitialize(display, nil, nil) == C.EGL_FALSE {
return
}
defer C.eglTerminate(display)

attributes := []C.EGLint{
C.EGL_RED_SIZE, 1,
Expand All @@ -27,7 +30,9 @@ func init() {
config C.EGLConfig
count C.EGLint
)
C.eglChooseConfig(display, &attributes[0], &config, 1, &count)
if C.eglChooseConfig(display, &attributes[0], &config, 1, &count) == C.EGL_FALSE {
return
}

C.eglBindAPI(C.EGL_OPENGL_ES_API)

Expand Down