app/headless: implement headless windows

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-11-28 12:34:45 +01:00
parent 9df3c76aa2
commit 0b84137f40
10 changed files with 367 additions and 1 deletions
+9 -1
View File
@@ -38,6 +38,7 @@ var (
nilEGLContext _EGLContext
nilEGLConfig _EGLConfig
nilEGLNativeWindowType NativeWindowType
EGL_DEFAULT_DISPLAY NativeDisplayType
)
const (
@@ -71,6 +72,7 @@ func (c *Context) Release() {
eglReleaseThread()
c.eglCtx = nil
}
c.disp = nilEGLDisplay
}
func (c *Context) Present() error {
@@ -116,7 +118,7 @@ func (c *Context) ReleaseSurface() {
}
// Make sure any in-flight GL commands are complete.
c.c.Finish()
eglMakeCurrent(c.disp, nilEGLSurface, nilEGLSurface, nilEGLContext)
c.ReleaseCurrent()
eglDestroySurface(c.disp, c.eglSurf)
c.eglSurf = nilEGLSurface
}
@@ -134,6 +136,12 @@ func (c *Context) CreateSurface(win NativeWindowType, width, height int) error {
return err
}
func (c *Context) ReleaseCurrent() {
if c.disp != nilEGLDisplay {
eglMakeCurrent(c.disp, nilEGLSurface, nilEGLSurface, nilEGLContext)
}
}
func (c *Context) MakeCurrent() error {
if c.eglSurf == nilEGLSurface && !c.eglCtx.surfaceless {
return errors.New("no surface created yet EGL_KHR_surfaceless_context is not supported")