mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 15:45:38 +00:00
10c1b2cb8d
Signed-off-by: Elias Naur <mail@eliasnaur.com>
102 lines
2.6 KiB
Go
102 lines
2.6 KiB
Go
// SPDX-License-Identifier: Unlicense OR MIT
|
|
|
|
package window
|
|
|
|
/*
|
|
#cgo LDFLAGS: -lEGL
|
|
#cgo CFLAGS: -DMESA_EGL_NO_X11_HEADERS
|
|
|
|
#include <EGL/egl.h>
|
|
#include <EGL/eglext.h>
|
|
#include <GLES2/gl2.h>
|
|
#include <GLES3/gl3.h>
|
|
*/
|
|
import "C"
|
|
|
|
import "gioui.org/app/internal/gl"
|
|
|
|
type (
|
|
_EGLint = C.EGLint
|
|
_EGLDisplay = C.EGLDisplay
|
|
_EGLConfig = C.EGLConfig
|
|
_EGLContext = C.EGLContext
|
|
_EGLSurface = C.EGLSurface
|
|
_EGLNativeDisplayType = C.EGLNativeDisplayType
|
|
_EGLNativeWindowType = C.EGLNativeWindowType
|
|
)
|
|
|
|
func eglChooseConfig(disp _EGLDisplay, attribs []_EGLint) (_EGLConfig, bool) {
|
|
var cfg C.EGLConfig
|
|
var ncfg C.EGLint
|
|
if C.eglChooseConfig(disp, &attribs[0], &cfg, 1, &ncfg) != C.EGL_TRUE {
|
|
return nil, false
|
|
}
|
|
return _EGLConfig(cfg), true
|
|
}
|
|
|
|
func eglCreateContext(disp _EGLDisplay, cfg _EGLConfig, shareCtx _EGLContext, attribs []_EGLint) _EGLContext {
|
|
ctx := C.eglCreateContext(disp, cfg, shareCtx, &attribs[0])
|
|
return _EGLContext(ctx)
|
|
}
|
|
|
|
func eglDestroySurface(disp _EGLDisplay, surf _EGLSurface) bool {
|
|
return C.eglDestroySurface(disp, surf) == C.EGL_TRUE
|
|
}
|
|
|
|
func eglDestroyContext(disp _EGLDisplay, ctx _EGLContext) bool {
|
|
return C.eglDestroyContext(disp, ctx) == C.EGL_TRUE
|
|
}
|
|
|
|
func eglGetConfigAttrib(disp _EGLDisplay, cfg _EGLConfig, attr _EGLint) (_EGLint, bool) {
|
|
var val _EGLint
|
|
ret := C.eglGetConfigAttrib(disp, cfg, attr, &val)
|
|
return val, ret == C.EGL_TRUE
|
|
}
|
|
|
|
func eglGetError() _EGLint {
|
|
return C.eglGetError()
|
|
}
|
|
|
|
func eglInitialize(disp _EGLDisplay) (_EGLint, _EGLint, bool) {
|
|
var maj, min _EGLint
|
|
ret := C.eglInitialize(disp, &maj, &min)
|
|
return maj, min, ret == C.EGL_TRUE
|
|
}
|
|
|
|
func eglMakeCurrent(disp _EGLDisplay, draw, read _EGLSurface, ctx _EGLContext) bool {
|
|
return C.eglMakeCurrent(disp, draw, read, ctx) == C.EGL_TRUE
|
|
}
|
|
|
|
func eglReleaseThread() bool {
|
|
return C.eglReleaseThread() == C.EGL_TRUE
|
|
}
|
|
|
|
func eglSwapBuffers(disp _EGLDisplay, surf _EGLSurface) bool {
|
|
return C.eglSwapBuffers(disp, surf) == C.EGL_TRUE
|
|
}
|
|
|
|
func eglSwapInterval(disp _EGLDisplay, interval _EGLint) bool {
|
|
return C.eglSwapInterval(disp, interval) == C.EGL_TRUE
|
|
}
|
|
|
|
func eglTerminate(disp _EGLDisplay) bool {
|
|
return C.eglTerminate(disp) == C.EGL_TRUE
|
|
}
|
|
|
|
func eglQueryString(disp _EGLDisplay, name _EGLint) string {
|
|
return C.GoString(C.eglQueryString(disp, name))
|
|
}
|
|
|
|
func eglGetDisplay(disp _EGLNativeDisplayType) _EGLDisplay {
|
|
return C.eglGetDisplay(disp)
|
|
}
|
|
|
|
func eglCreateWindowSurface(disp _EGLDisplay, conf _EGLConfig, win _EGLNativeWindowType, attribs []_EGLint) _EGLSurface {
|
|
eglSurf := C.eglCreateWindowSurface(disp, conf, win, &attribs[0])
|
|
return eglSurf
|
|
}
|
|
|
|
func (w *window) NewContext() (gl.Context, error) {
|
|
return newContext(w)
|
|
}
|