From 07a36d71d9b0e6c89b6d750b03bb026500ff2dd7 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Wed, 2 Oct 2019 23:20:44 +0200 Subject: [PATCH] app: (linux,android) merge EGLNative* types and functions Signed-off-by: Elias Naur --- app/egl_android.go | 14 -------------- app/egl_linux.go | 22 +++++++++++++++++----- app/egl_wayland.go | 22 ++++------------------ 3 files changed, 21 insertions(+), 37 deletions(-) diff --git a/app/egl_android.go b/app/egl_android.go index 9986e018..f12fb8b7 100644 --- a/app/egl_android.go +++ b/app/egl_android.go @@ -7,20 +7,6 @@ package app */ import "C" -type ( - _EGLNativeDisplayType = C.EGLNativeDisplayType - _EGLNativeWindowType = C.EGLNativeWindowType -) - -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) eglDestroy() { } diff --git a/app/egl_linux.go b/app/egl_linux.go index 051c2292..eac74c30 100644 --- a/app/egl_linux.go +++ b/app/egl_linux.go @@ -4,6 +4,7 @@ package app /* #cgo LDFLAGS: -lEGL +#cgo CFLAGS: -DMESA_EGL_NO_X11_HEADERS #include #include @@ -13,11 +14,13 @@ package app import "C" type ( - _EGLint = C.EGLint - _EGLDisplay = C.EGLDisplay - _EGLConfig = C.EGLConfig - _EGLContext = C.EGLContext - _EGLSurface = C.EGLSurface + _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) { @@ -81,3 +84,12 @@ func eglTerminate(disp _EGLDisplay) bool { 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 +} diff --git a/app/egl_wayland.go b/app/egl_wayland.go index 15a439eb..0fa3774f 100644 --- a/app/egl_wayland.go +++ b/app/egl_wayland.go @@ -7,23 +7,18 @@ package app import ( "errors" "sync" + "unsafe" ) /* #cgo LDFLAGS: -lwayland-egl -#cgo CFLAGS: -DWL_EGL_PLATFORM +#include #include #include -#include */ import "C" -type ( - _EGLNativeDisplayType = C.EGLNativeDisplayType - _EGLNativeWindowType = C.EGLNativeWindowType -) - var eglWindows struct { mu sync.Mutex windows map[*C.struct_wl_surface]*C.struct_wl_egl_window @@ -43,7 +38,7 @@ func (w *window) eglDestroy() { } func (w *window) eglDisplay() _EGLNativeDisplayType { - return w.display() + return _EGLNativeDisplayType(w.display()) } func (w *window) eglWindow(visID int) (_EGLNativeWindowType, int, int, error) { @@ -65,14 +60,5 @@ func (w *window) eglWindow(visID int) (_EGLNativeWindowType, int, int, error) { eglWindows.windows[surf] = eglWin } C.wl_egl_window_resize(eglWin, C.int(width), C.int(height), 0, 0) - return eglWin, width, height, nil -} - -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 + return _EGLNativeWindowType(uintptr(unsafe.Pointer(eglWin))), width, height, nil }