mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
Revert "app/internal/egl: accept zero EGLDisplay values as valid"
This reverts commit 66138e7890.
Reason: According to #77, it didn't work and the proposed fix
(retry when EGL_NO_DISPLAY is returned) is correct.
This commit is contained in:
+13
-18
@@ -33,6 +33,7 @@ type eglContext struct {
|
||||
}
|
||||
|
||||
var (
|
||||
nilEGLDisplay _EGLDisplay
|
||||
nilEGLSurface _EGLSurface
|
||||
nilEGLContext _EGLContext
|
||||
nilEGLConfig _EGLConfig
|
||||
@@ -55,7 +56,6 @@ const (
|
||||
_EGL_OPENGL_ES2_BIT = 0x4
|
||||
_EGL_RED_SIZE = 0x3024
|
||||
_EGL_RENDERABLE_TYPE = 0x3040
|
||||
_EGL_SUCCESS = 0x3000
|
||||
_EGL_SURFACE_TYPE = 0x3033
|
||||
_EGL_WINDOW_BIT = 0x4
|
||||
)
|
||||
@@ -72,6 +72,7 @@ func (c *Context) Release() {
|
||||
eglReleaseThread()
|
||||
c.eglCtx = nil
|
||||
}
|
||||
c.disp = nilEGLDisplay
|
||||
}
|
||||
|
||||
func (c *Context) Present() error {
|
||||
@@ -79,7 +80,7 @@ func (c *Context) Present() error {
|
||||
c.srgbFBO.Blit()
|
||||
}
|
||||
if !eglSwapBuffers(c.disp, c.eglSurf) {
|
||||
return fmt.Errorf("eglSwapBuffers: %v", eglErr())
|
||||
return fmt.Errorf("eglSwapBuffers failed (%x)", eglGetError())
|
||||
}
|
||||
if c.srgbFBO != nil {
|
||||
c.srgbFBO.AfterPresent()
|
||||
@@ -92,8 +93,8 @@ func NewContext(disp NativeDisplayType) (*Context, error) {
|
||||
return nil, err
|
||||
}
|
||||
eglDisp := eglGetDisplay(disp)
|
||||
if err := eglErr(); err != nil {
|
||||
return nil, fmt.Errorf("eglGetDisplay: %v", err)
|
||||
if eglDisp == nilEGLDisplay {
|
||||
return nil, fmt.Errorf("eglGetDisplay failed: 0x%x", eglGetError())
|
||||
}
|
||||
eglCtx, err := createContext(eglDisp)
|
||||
if err != nil {
|
||||
@@ -107,14 +108,6 @@ func NewContext(disp NativeDisplayType) (*Context, error) {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
func eglErr() error {
|
||||
errCode := eglGetError()
|
||||
if errCode == _EGL_SUCCESS {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("EGL error 0x%x", errCode)
|
||||
}
|
||||
|
||||
func (c *Context) Functions() *gl.Functions {
|
||||
return c.c
|
||||
}
|
||||
@@ -144,7 +137,9 @@ func (c *Context) CreateSurface(win NativeWindowType, width, height int) error {
|
||||
}
|
||||
|
||||
func (c *Context) ReleaseCurrent() {
|
||||
eglMakeCurrent(c.disp, nilEGLSurface, nilEGLSurface, nilEGLContext)
|
||||
if c.disp != nilEGLDisplay {
|
||||
eglMakeCurrent(c.disp, nilEGLSurface, nilEGLSurface, nilEGLContext)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Context) MakeCurrent() error {
|
||||
@@ -152,7 +147,7 @@ func (c *Context) MakeCurrent() error {
|
||||
return errors.New("no surface created yet EGL_KHR_surfaceless_context is not supported")
|
||||
}
|
||||
if !eglMakeCurrent(c.disp, c.eglSurf, c.eglSurf, c.eglCtx.ctx) {
|
||||
return fmt.Errorf("eglMakeCurrent: %v", eglErr())
|
||||
return fmt.Errorf("eglMakeCurrent error 0x%x", eglGetError())
|
||||
}
|
||||
if c.eglCtx.srgb || c.eglSurf == nilEGLSurface {
|
||||
return nil
|
||||
@@ -191,7 +186,7 @@ func hasExtension(exts []string, ext string) bool {
|
||||
func createContext(disp _EGLDisplay) (*eglContext, error) {
|
||||
major, minor, ret := eglInitialize(disp)
|
||||
if !ret {
|
||||
return nil, fmt.Errorf("eglInitialize: %v", eglErr())
|
||||
return nil, fmt.Errorf("eglInitialize failed: 0x%x", eglGetError())
|
||||
}
|
||||
// sRGB framebuffer support on EGL 1.5 or if EGL_KHR_gl_colorspace is supported.
|
||||
exts := strings.Split(eglQueryString(disp, _EGL_EXTENSIONS), " ")
|
||||
@@ -216,7 +211,7 @@ func createContext(disp _EGLDisplay) (*eglContext, error) {
|
||||
attribs = append(attribs, _EGL_NONE)
|
||||
eglCfg, ret := eglChooseConfig(disp, attribs)
|
||||
if !ret {
|
||||
return nil, fmt.Errorf("eglChooseConfig: %v", eglErr())
|
||||
return nil, fmt.Errorf("eglChooseConfig failed: 0x%x", eglGetError())
|
||||
}
|
||||
if eglCfg == nilEGLConfig {
|
||||
return nil, errors.New("eglChooseConfig returned 0 configs")
|
||||
@@ -238,7 +233,7 @@ func createContext(disp _EGLDisplay) (*eglContext, error) {
|
||||
}
|
||||
eglCtx = eglCreateContext(disp, eglCfg, nilEGLContext, ctxAttribs)
|
||||
if eglCtx == nilEGLContext {
|
||||
return nil, fmt.Errorf("eglCreateContext: %v", eglErr())
|
||||
return nil, fmt.Errorf("eglCreateContext failed: 0x%x", eglGetError())
|
||||
}
|
||||
}
|
||||
return &eglContext{
|
||||
@@ -264,7 +259,7 @@ func createSurface(disp _EGLDisplay, eglCtx *eglContext, win NativeWindowType) (
|
||||
eglSurf = eglCreateWindowSurface(disp, eglCtx.config, win, surfAttribs)
|
||||
}
|
||||
if eglSurf == nilEGLSurface {
|
||||
return nilEGLSurface, fmt.Errorf("newContext: eglCreateWindowSurface (sRGB=%v): %v", eglCtx.srgb, eglErr())
|
||||
return nilEGLSurface, fmt.Errorf("newContext: eglCreateWindowSurface failed 0x%x (sRGB=%v)", eglGetError(), eglCtx.srgb)
|
||||
}
|
||||
return eglSurf, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user