mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 18:05:35 +00:00
app: (linux,android) merge EGLNative* types and functions
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -7,20 +7,6 @@ package app
|
|||||||
*/
|
*/
|
||||||
import "C"
|
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() {
|
func (w *window) eglDestroy() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+17
-5
@@ -4,6 +4,7 @@ package app
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
#cgo LDFLAGS: -lEGL
|
#cgo LDFLAGS: -lEGL
|
||||||
|
#cgo CFLAGS: -DMESA_EGL_NO_X11_HEADERS
|
||||||
|
|
||||||
#include <EGL/egl.h>
|
#include <EGL/egl.h>
|
||||||
#include <EGL/eglext.h>
|
#include <EGL/eglext.h>
|
||||||
@@ -13,11 +14,13 @@ package app
|
|||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
type (
|
type (
|
||||||
_EGLint = C.EGLint
|
_EGLint = C.EGLint
|
||||||
_EGLDisplay = C.EGLDisplay
|
_EGLDisplay = C.EGLDisplay
|
||||||
_EGLConfig = C.EGLConfig
|
_EGLConfig = C.EGLConfig
|
||||||
_EGLContext = C.EGLContext
|
_EGLContext = C.EGLContext
|
||||||
_EGLSurface = C.EGLSurface
|
_EGLSurface = C.EGLSurface
|
||||||
|
_EGLNativeDisplayType = C.EGLNativeDisplayType
|
||||||
|
_EGLNativeWindowType = C.EGLNativeWindowType
|
||||||
)
|
)
|
||||||
|
|
||||||
func eglChooseConfig(disp _EGLDisplay, attribs []_EGLint) (_EGLConfig, bool) {
|
func eglChooseConfig(disp _EGLDisplay, attribs []_EGLint) (_EGLConfig, bool) {
|
||||||
@@ -81,3 +84,12 @@ func eglTerminate(disp _EGLDisplay) bool {
|
|||||||
func eglQueryString(disp _EGLDisplay, name _EGLint) string {
|
func eglQueryString(disp _EGLDisplay, name _EGLint) string {
|
||||||
return C.GoString(C.eglQueryString(disp, name))
|
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
|
||||||
|
}
|
||||||
|
|||||||
+4
-18
@@ -7,23 +7,18 @@ package app
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"sync"
|
"sync"
|
||||||
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#cgo LDFLAGS: -lwayland-egl
|
#cgo LDFLAGS: -lwayland-egl
|
||||||
#cgo CFLAGS: -DWL_EGL_PLATFORM
|
|
||||||
|
|
||||||
|
#include <EGL/egl.h>
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
#include <wayland-egl.h>
|
#include <wayland-egl.h>
|
||||||
#include <EGL/egl.h>
|
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
type (
|
|
||||||
_EGLNativeDisplayType = C.EGLNativeDisplayType
|
|
||||||
_EGLNativeWindowType = C.EGLNativeWindowType
|
|
||||||
)
|
|
||||||
|
|
||||||
var eglWindows struct {
|
var eglWindows struct {
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
windows map[*C.struct_wl_surface]*C.struct_wl_egl_window
|
windows map[*C.struct_wl_surface]*C.struct_wl_egl_window
|
||||||
@@ -43,7 +38,7 @@ func (w *window) eglDestroy() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *window) eglDisplay() _EGLNativeDisplayType {
|
func (w *window) eglDisplay() _EGLNativeDisplayType {
|
||||||
return w.display()
|
return _EGLNativeDisplayType(w.display())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *window) eglWindow(visID int) (_EGLNativeWindowType, int, int, error) {
|
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
|
eglWindows.windows[surf] = eglWin
|
||||||
}
|
}
|
||||||
C.wl_egl_window_resize(eglWin, C.int(width), C.int(height), 0, 0)
|
C.wl_egl_window_resize(eglWin, C.int(width), C.int(height), 0, 0)
|
||||||
return eglWin, width, height, nil
|
return _EGLNativeWindowType(uintptr(unsafe.Pointer(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
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user