├── src ├── common │ ├── symbols_opengl.txt │ ├── symbols_software.txt │ ├── symbols_vulkan.txt │ ├── globuf_opengl.c │ ├── globuf_error.h │ ├── symbols_common.txt │ ├── globuf_software.c │ ├── globuf_private.h │ ├── globuf_vulkan.c │ └── globuf.c ├── win │ ├── symbols_wgl.txt │ ├── symbols_vulkan.txt │ ├── symbols_software.txt │ ├── win_software_helpers.c │ ├── win_software_helpers.h │ ├── win_wgl_helpers.h │ ├── win_wgl_helpers.c │ ├── win_vulkan_helpers.h │ ├── symbols_common.txt │ ├── win_vulkan_helpers.c │ ├── win_common_helpers.h │ ├── win_wgl.h │ ├── win_vulkan.h │ ├── win_software.h │ └── win_common.h ├── x11 │ ├── symbols_egl.txt │ ├── symbols_glx.txt │ ├── symbols_vulkan.txt │ ├── symbols_software.txt │ ├── x11_egl_helpers.h │ ├── x11_glx_helpers.h │ ├── x11_software_helpers.h │ ├── x11_vulkan_helpers.h │ ├── symbols_common.txt │ ├── x11_glx_helpers.c │ ├── x11_egl_helpers.c │ ├── x11_common_helpers.h │ ├── x11_egl.h │ ├── x11_glx.h │ ├── x11_vulkan.h │ ├── x11_software.h │ ├── x11_common.h │ └── x11_vulkan_helpers.c ├── wayland │ ├── symbols_egl.txt │ ├── symbols_software.txt │ ├── symbols_vulkan.txt │ ├── wayland_vulkan_helpers.h │ ├── wayland_egl_helpers.h │ ├── wayland_software_helpers.h │ ├── wayland_software_helpers.c │ ├── symbols_common.txt │ ├── wayland_vulkan_helpers.c │ ├── wayland_common_helpers.h │ ├── wayland_egl_helpers.c │ ├── wayland_egl.h │ ├── wayland_vulkan.h │ ├── wayland_software.h │ ├── wayland_common_registry.h │ └── wayland_common.h ├── appkit │ ├── symbols_vulkan.txt │ ├── symbols_software.txt │ ├── symbols_egl.txt │ ├── appkit_software_helpers.h │ ├── appkit_software_helpers.m │ ├── appkit_egl_helpers.h │ ├── appkit_vulkan_helpers.h │ ├── symbols_common.txt │ ├── appkit_egl_helpers.m │ ├── appkit_common_helpers.h │ ├── appkit_vulkan_helpers.m │ ├── appkit_egl.h │ ├── appkit_vulkan.h │ ├── appkit_software.h │ └── appkit_common.h └── include │ ├── globuf_appkit.h │ ├── globuf_win.h │ ├── globuf_win_wgl.h │ ├── globuf_x11_egl.h │ ├── globuf_x11_glx.h │ ├── globuf_win_vulkan.h │ ├── globuf_x11_vulkan.h │ ├── globuf_wayland_egl.h │ ├── globuf_win_software.h │ ├── globuf_x11_software.h │ ├── globuf_appkit_vulkan.h │ ├── globuf_wayland_vulkan.h │ ├── globuf_appkit_software.h │ ├── globuf_wayland_software.h │ ├── globuf_x11.h │ ├── globuf_appkit_egl.h │ ├── globuf_opengl.h │ ├── globuf_wayland.h │ ├── globuf_software.h │ └── globuf_vulkan.h ├── res ├── icon │ ├── 16.data │ ├── 32.data │ ├── 64.data │ ├── iconpix_pe.S │ ├── iconpix_elf.S │ └── iconpix_macho.S ├── app │ ├── icon.icns │ ├── icon.iconset │ │ ├── icon_16x16.png │ │ ├── icon_32x32.png │ │ ├── icon_64x64.png │ │ ├── icon_128x128.png │ │ ├── icon_16x16@2x.png │ │ ├── icon_256x256.png │ │ ├── icon_32x32@2x.png │ │ ├── icon_512x512.png │ │ ├── icon_64x64@2x.png │ │ ├── icon_128x128@2x.png │ │ ├── icon_256x256@2x.png │ │ └── icon_512x512@2x.png │ └── globuf.app │ │ └── Contents │ │ └── Info.plist ├── cursor │ ├── 1.data │ ├── 2.data │ ├── 3.data │ ├── 4.data │ ├── cursorpix_elf.S │ ├── cursorpix_pe.S │ └── cursorpix_macho.S ├── shaders │ ├── vk1 │ │ ├── square_frag_vk1.spv │ │ ├── square_vert_vk1.spv │ │ ├── square_glsl_vk1.frag │ │ ├── square_glsl_vk1.vert │ │ ├── shaders_elf.S │ │ ├── shaders_pe.S │ │ └── shaders_macho.S │ ├── gles2 │ │ ├── square_vert_gles2.glsl │ │ ├── square_frag_gles2.glsl │ │ ├── shaders_elf.S │ │ ├── shaders_pe.S │ │ └── shaders_macho.S │ └── gl1 │ │ ├── square_vert_gl1.glsl │ │ ├── square_frag_gl1.glsl │ │ ├── shaders_elf.S │ │ ├── shaders_pe.S │ │ └── shaders_macho.S └── valgrind │ └── valgrind.supp ├── ci ├── globuf_image_x11_gcc │ ├── build.sh │ ├── Dockerfile │ ├── artifact.sh │ ├── run.sh │ ├── scripts │ │ ├── build_x11.sh │ │ └── install.sh │ └── release.sh ├── globuf_image_win_mingw │ ├── build.sh │ ├── Dockerfile │ ├── artifact.sh │ ├── run.sh │ ├── scripts │ │ ├── build_win.sh │ │ └── install.sh │ └── release.sh ├── globuf_image_wayland_gcc │ ├── build.sh │ ├── Dockerfile │ ├── artifact.sh │ ├── run.sh │ ├── scripts │ │ ├── build_wayland.sh │ │ └── install.sh │ └── release.sh ├── globuf_image_appkit_osxcross │ ├── artifact.sh │ ├── Dockerfile │ ├── run.sh │ ├── build.sh │ ├── scripts │ │ ├── build_appkit.sh │ │ └── install.sh │ └── release.sh └── globuf_scripts_appkit_native │ ├── build_software.sh │ ├── build_egl.sh │ └── build_vulkan.sh ├── make ├── scripts │ ├── clean_ninja.sh │ ├── icon_app.sh │ ├── clean.sh │ ├── release_zip.sh │ ├── prepare.sh │ ├── willis_get.sh │ ├── dpishit_get.sh │ ├── infer_get.sh │ ├── cursoryx_get.sh │ ├── vk_shaders.sh │ ├── leak.sh │ ├── moltenvk_release_get.sh │ ├── angle_release_get.sh │ ├── pixmap.sh │ ├── egl_get.sh │ ├── infer_run.sh │ ├── package_app.sh │ ├── wayland_get.sh │ └── build.sh └── lib │ └── shared │ ├── win.sh │ ├── wayland.sh │ ├── appkit.sh │ └── x11.sh ├── .gitmodules ├── .gitignore ├── license.md ├── example └── helpers │ ├── vulkan_helpers.h │ ├── appkit.m │ └── dynamic_loader.h └── doc └── globuf_documentation.md /src/common/symbols_opengl.txt: -------------------------------------------------------------------------------- 1 | globuf_init_opengl 2 | -------------------------------------------------------------------------------- /src/win/symbols_wgl.txt: -------------------------------------------------------------------------------- 1 | globuf_prepare_init_win_wgl 2 | -------------------------------------------------------------------------------- /src/x11/symbols_egl.txt: -------------------------------------------------------------------------------- 1 | globuf_prepare_init_x11_egl 2 | -------------------------------------------------------------------------------- /src/x11/symbols_glx.txt: -------------------------------------------------------------------------------- 1 | globuf_prepare_init_x11_glx 2 | -------------------------------------------------------------------------------- /src/wayland/symbols_egl.txt: -------------------------------------------------------------------------------- 1 | globuf_prepare_init_wayland_egl 2 | -------------------------------------------------------------------------------- /src/win/symbols_vulkan.txt: -------------------------------------------------------------------------------- 1 | globuf_prepare_init_win_vulkan 2 | -------------------------------------------------------------------------------- /src/x11/symbols_vulkan.txt: -------------------------------------------------------------------------------- 1 | globuf_prepare_init_x11_vulkan 2 | -------------------------------------------------------------------------------- /src/appkit/symbols_vulkan.txt: -------------------------------------------------------------------------------- 1 | globuf_prepare_init_appkit_vulkan 2 | -------------------------------------------------------------------------------- /src/win/symbols_software.txt: -------------------------------------------------------------------------------- 1 | globuf_prepare_init_win_software 2 | -------------------------------------------------------------------------------- /src/x11/symbols_software.txt: -------------------------------------------------------------------------------- 1 | globuf_prepare_init_x11_software 2 | -------------------------------------------------------------------------------- /src/appkit/symbols_software.txt: -------------------------------------------------------------------------------- 1 | globuf_prepare_init_appkit_software 2 | -------------------------------------------------------------------------------- /src/wayland/symbols_software.txt: -------------------------------------------------------------------------------- 1 | globuf_prepare_init_wayland_software 2 | -------------------------------------------------------------------------------- /src/wayland/symbols_vulkan.txt: -------------------------------------------------------------------------------- 1 | globuf_prepare_init_wayland_vulkan 2 | -------------------------------------------------------------------------------- /res/icon/16.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullgemm/globuf/HEAD/res/icon/16.data -------------------------------------------------------------------------------- /res/icon/32.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullgemm/globuf/HEAD/res/icon/32.data -------------------------------------------------------------------------------- /res/icon/64.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullgemm/globuf/HEAD/res/icon/64.data -------------------------------------------------------------------------------- /res/app/icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullgemm/globuf/HEAD/res/app/icon.icns -------------------------------------------------------------------------------- /res/cursor/1.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullgemm/globuf/HEAD/res/cursor/1.data -------------------------------------------------------------------------------- /res/cursor/2.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullgemm/globuf/HEAD/res/cursor/2.data -------------------------------------------------------------------------------- /res/cursor/3.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullgemm/globuf/HEAD/res/cursor/3.data -------------------------------------------------------------------------------- /res/cursor/4.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullgemm/globuf/HEAD/res/cursor/4.data -------------------------------------------------------------------------------- /src/appkit/symbols_egl.txt: -------------------------------------------------------------------------------- 1 | globuf_prepare_init_appkit_egl 2 | globuf_appkit_egl_get_scale 3 | -------------------------------------------------------------------------------- /ci/globuf_image_x11_gcc/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | docker build -t globuf_image_x11_gcc . 4 | -------------------------------------------------------------------------------- /src/common/symbols_software.txt: -------------------------------------------------------------------------------- 1 | globuf_buffer_alloc_software 2 | globuf_buffer_free_software 3 | -------------------------------------------------------------------------------- /ci/globuf_image_win_mingw/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | docker build -t globuf_image_win_mingw . 4 | -------------------------------------------------------------------------------- /ci/globuf_image_wayland_gcc/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | docker build -t globuf_image_wayland_gcc . 4 | -------------------------------------------------------------------------------- /res/app/icon.iconset/icon_16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullgemm/globuf/HEAD/res/app/icon.iconset/icon_16x16.png -------------------------------------------------------------------------------- /res/app/icon.iconset/icon_32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullgemm/globuf/HEAD/res/app/icon.iconset/icon_32x32.png -------------------------------------------------------------------------------- /res/app/icon.iconset/icon_64x64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullgemm/globuf/HEAD/res/app/icon.iconset/icon_64x64.png -------------------------------------------------------------------------------- /res/shaders/vk1/square_frag_vk1.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullgemm/globuf/HEAD/res/shaders/vk1/square_frag_vk1.spv -------------------------------------------------------------------------------- /res/shaders/vk1/square_vert_vk1.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullgemm/globuf/HEAD/res/shaders/vk1/square_vert_vk1.spv -------------------------------------------------------------------------------- /res/app/icon.iconset/icon_128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullgemm/globuf/HEAD/res/app/icon.iconset/icon_128x128.png -------------------------------------------------------------------------------- /res/app/icon.iconset/icon_16x16@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullgemm/globuf/HEAD/res/app/icon.iconset/icon_16x16@2x.png -------------------------------------------------------------------------------- /res/app/icon.iconset/icon_256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullgemm/globuf/HEAD/res/app/icon.iconset/icon_256x256.png -------------------------------------------------------------------------------- /res/app/icon.iconset/icon_32x32@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullgemm/globuf/HEAD/res/app/icon.iconset/icon_32x32@2x.png -------------------------------------------------------------------------------- /res/app/icon.iconset/icon_512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullgemm/globuf/HEAD/res/app/icon.iconset/icon_512x512.png -------------------------------------------------------------------------------- /res/app/icon.iconset/icon_64x64@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullgemm/globuf/HEAD/res/app/icon.iconset/icon_64x64@2x.png -------------------------------------------------------------------------------- /res/app/icon.iconset/icon_128x128@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullgemm/globuf/HEAD/res/app/icon.iconset/icon_128x128@2x.png -------------------------------------------------------------------------------- /res/app/icon.iconset/icon_256x256@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullgemm/globuf/HEAD/res/app/icon.iconset/icon_256x256@2x.png -------------------------------------------------------------------------------- /res/app/icon.iconset/icon_512x512@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullgemm/globuf/HEAD/res/app/icon.iconset/icon_512x512@2x.png -------------------------------------------------------------------------------- /res/shaders/gles2/square_vert_gles2.glsl: -------------------------------------------------------------------------------- 1 | attribute vec4 vPosition; 2 | 3 | void main() 4 | { 5 | gl_Position = vPosition; 6 | } 7 | -------------------------------------------------------------------------------- /src/include/globuf_appkit.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_APPKIT 2 | #define H_GLOBUF_APPKIT 3 | 4 | #include "globuf.h" 5 | 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /res/shaders/gl1/square_vert_gl1.glsl: -------------------------------------------------------------------------------- 1 | #version 130 2 | attribute vec4 vPosition; 3 | 4 | void main() 5 | { 6 | gl_Position = vPosition; 7 | } 8 | -------------------------------------------------------------------------------- /res/shaders/gles2/square_frag_gles2.glsl: -------------------------------------------------------------------------------- 1 | precision mediump float; 2 | 3 | void main() 4 | { 5 | gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); 6 | } 7 | -------------------------------------------------------------------------------- /src/common/symbols_vulkan.txt: -------------------------------------------------------------------------------- 1 | globuf_init_vulkan 2 | globuf_get_extensions_vulkan 3 | globuf_presentation_support_vulkan 4 | globuf_get_surface_vulkan 5 | -------------------------------------------------------------------------------- /res/shaders/gl1/square_frag_gl1.glsl: -------------------------------------------------------------------------------- 1 | #version 130 2 | precision mediump float; 3 | 4 | void main() 5 | { 6 | gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); 7 | } 8 | -------------------------------------------------------------------------------- /res/shaders/vk1/square_glsl_vk1.frag: -------------------------------------------------------------------------------- 1 | #version 450 2 | layout (location = 0) out vec4 fColor; 3 | 4 | void main() 5 | { 6 | fColor = vec4(1.0, 1.0, 1.0, 1.0); 7 | } 8 | -------------------------------------------------------------------------------- /res/icon/iconpix_pe.S: -------------------------------------------------------------------------------- 1 | .global iconpix 2 | .global iconpix_size 3 | .section .rodata 4 | iconpix: 5 | .incbin "iconpix.bin" 6 | 1: 7 | iconpix_size: 8 | .int 1b - iconpix 9 | -------------------------------------------------------------------------------- /res/shaders/vk1/square_glsl_vk1.vert: -------------------------------------------------------------------------------- 1 | #version 450 2 | layout(location = 0) in vec2 vPosition; 3 | 4 | void main() 5 | { 6 | gl_Position = vec4(vPosition, 0.0, 1.0); 7 | } 8 | -------------------------------------------------------------------------------- /res/icon/iconpix_elf.S: -------------------------------------------------------------------------------- 1 | .global iconpix 2 | .global iconpix_size 3 | .section .rodata 4 | iconpix: 5 | .incbin "iconpix.bin" 6 | 1: 7 | iconpix_size: 8 | .int 1b - iconpix 9 | -------------------------------------------------------------------------------- /make/scripts/clean_ninja.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # get in the right folder 4 | path="$(pwd)/$0" 5 | folder=$(dirname "$path") 6 | cd "$folder"/../.. || exit 7 | 8 | rm -rf make/output 9 | -------------------------------------------------------------------------------- /ci/globuf_image_x11_gcc/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:edge 2 | 3 | COPY ./scripts /scripts 4 | 5 | RUN /scripts/install.sh 6 | 7 | CMD /scripts/build_x11.sh development x11 software none native 8 | -------------------------------------------------------------------------------- /res/icon/iconpix_macho.S: -------------------------------------------------------------------------------- 1 | .global _iconpix 2 | .global _iconpix_size 3 | .section __TEXT,__const 4 | _iconpix: 5 | .incbin "iconpix.bin" 6 | 1: 7 | _iconpix_size: 8 | .int 1b - _iconpix 9 | -------------------------------------------------------------------------------- /ci/globuf_image_win_mingw/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:edge 2 | 3 | COPY ./scripts /scripts 4 | 5 | RUN /scripts/install.sh 6 | 7 | CMD /scripts/build_win.sh development win software none native 8 | -------------------------------------------------------------------------------- /res/cursor/cursorpix_elf.S: -------------------------------------------------------------------------------- 1 | .global cursorpix 2 | .global cursorpix_size 3 | .section .rodata 4 | cursorpix: 5 | .incbin "cursorpix.bin" 6 | 1: 7 | cursorpix_size: 8 | .int 1b - cursorpix 9 | -------------------------------------------------------------------------------- /res/cursor/cursorpix_pe.S: -------------------------------------------------------------------------------- 1 | .global cursorpix 2 | .global cursorpix_size 3 | .section .rodata 4 | cursorpix: 5 | .incbin "cursorpix.bin" 6 | 1: 7 | cursorpix_size: 8 | .int 1b - cursorpix 9 | -------------------------------------------------------------------------------- /src/include/globuf_win.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_WIN 2 | #define H_GLOBUF_WIN 3 | 4 | #include "globuf.h" 5 | 6 | void* globuf_get_win_surface( 7 | struct globuf* context); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /ci/globuf_image_wayland_gcc/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:edge 2 | 3 | COPY ./scripts /scripts 4 | 5 | RUN /scripts/install.sh 6 | 7 | CMD /scripts/build_wayland.sh development wayland software none native 8 | -------------------------------------------------------------------------------- /ci/globuf_image_win_mingw/artifact.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | tag=$(git tag --sort v:refname | tail -n 1) 4 | release=globuf_bin_"$tag" 5 | 6 | docker cp globuf_container_win_mingw_"$1":/globuf/"$release" . 7 | -------------------------------------------------------------------------------- /ci/globuf_image_x11_gcc/artifact.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | tag=$(git tag --sort v:refname | tail -n 1) 4 | release=globuf_bin_"$tag" 5 | 6 | docker cp globuf_container_x11_gcc_"$1":/globuf/"$release" . 7 | -------------------------------------------------------------------------------- /make/scripts/icon_app.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # get in the right folder 4 | path="$(pwd)/$0" 5 | folder=$(dirname "$path") 6 | cd "$folder"/../.. || exit 7 | 8 | iconutil -c icns res/app/icon.iconset 9 | -------------------------------------------------------------------------------- /ci/globuf_image_wayland_gcc/artifact.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | tag=$(git tag --sort v:refname | tail -n 1) 4 | release=globuf_bin_"$tag" 5 | 6 | docker cp globuf_container_wayland_gcc_"$1":/globuf/"$release" . 7 | -------------------------------------------------------------------------------- /res/cursor/cursorpix_macho.S: -------------------------------------------------------------------------------- 1 | .global _cursorpix 2 | .global _cursorpix_size 3 | .section __TEXT,__const 4 | _cursorpix: 5 | .incbin "cursorpix.bin" 6 | 1: 7 | _cursorpix_size: 8 | .int 1b - _cursorpix 9 | -------------------------------------------------------------------------------- /src/win/win_software_helpers.c: -------------------------------------------------------------------------------- 1 | #include "include/globuf.h" 2 | #include "common/globuf_private.h" 3 | #include "win/win_software_helpers.h" 4 | #include "win/win_software.h" 5 | #include "win/win_common.h" 6 | -------------------------------------------------------------------------------- /ci/globuf_image_appkit_osxcross/artifact.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | tag=$(git tag --sort v:refname | tail -n 1) 4 | release=globuf_bin_"$tag" 5 | 6 | docker cp globuf_container_appkit_osxcross_"$1":/scripts/globuf/"$release" . 7 | -------------------------------------------------------------------------------- /ci/globuf_image_appkit_osxcross/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:edge 2 | 3 | COPY ./scripts /scripts 4 | 5 | WORKDIR /scripts 6 | RUN /scripts/install.sh 7 | 8 | CMD /scripts/build_appkit.sh development appkit software none osxcross 9 | -------------------------------------------------------------------------------- /ci/globuf_image_x11_gcc/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # example for a release build 4 | # $ ./run.sh /scripts/build_x11.sh release x11 software none 5 | docker run --name globuf_container_x11_gcc_"$4" globuf_image_x11_gcc "$@" &>> log 6 | -------------------------------------------------------------------------------- /ci/globuf_image_win_mingw/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # example for a release build 4 | # $ ./run.sh /scripts/build_win.sh release win software none 5 | docker run --name globuf_container_win_mingw_"$4" globuf_image_win_mingw "$@" &>> log 6 | -------------------------------------------------------------------------------- /ci/globuf_image_wayland_gcc/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # example for a release build 4 | # $ ./run.sh /scripts/build_wayland.sh release wayland software none 5 | docker run --name globuf_container_wayland_gcc_"$4" globuf_image_wayland_gcc "$@" &>> log 6 | -------------------------------------------------------------------------------- /make/scripts/clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # get in the right folder 4 | path="$(pwd)/$0" 5 | folder=$(dirname "$path") 6 | cd "$folder"/../.. || exit 7 | 8 | rm -rf build globuf_bin_* valgrind.log drmemory.log 9 | ./make/scripts/clean_ninja.sh 10 | -------------------------------------------------------------------------------- /src/include/globuf_win_wgl.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_WIN_WGL 2 | #define H_GLOBUF_WIN_WGL 3 | 4 | #include "globuf.h" 5 | #include "globuf_win.h" 6 | #include "globuf_opengl.h" 7 | 8 | void globuf_prepare_init_win_wgl( 9 | struct globuf_config_backend* config, 10 | struct globuf_error_info* error); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /src/include/globuf_x11_egl.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_X11_EGL 2 | #define H_GLOBUF_X11_EGL 3 | 4 | #include "globuf.h" 5 | #include "globuf_x11.h" 6 | #include "globuf_opengl.h" 7 | 8 | void globuf_prepare_init_x11_egl( 9 | struct globuf_config_backend* config, 10 | struct globuf_error_info* error); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /src/include/globuf_x11_glx.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_X11_GLX 2 | #define H_GLOBUF_X11_GLX 3 | 4 | #include "globuf.h" 5 | #include "globuf_x11.h" 6 | #include "globuf_opengl.h" 7 | 8 | void globuf_prepare_init_x11_glx( 9 | struct globuf_config_backend* config, 10 | struct globuf_error_info* error); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /make/scripts/release_zip.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # get in the right folder 4 | path="$(pwd)/$0" 5 | folder=$(dirname "$path") 6 | cd "$folder"/../.. || exit 7 | 8 | tag=$(git tag --sort v:refname | tail -n 1) 9 | release=globuf_bin_"$tag" 10 | 11 | cp license.md "$release/lib/" 12 | zip -r "$release.zip" "$release" 13 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "res/cursoryx"] 2 | path = res/cursoryx 3 | url = https://github.com/nullgemm/cursoryx.git 4 | [submodule "res/dpishit"] 5 | path = res/dpishit 6 | url = https://github.com/nullgemm/dpishit.git 7 | [submodule "res/willis"] 8 | path = res/willis 9 | url = https://github.com/nullgemm/willis.git 10 | -------------------------------------------------------------------------------- /src/appkit/appkit_software_helpers.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_APPKIT_SOFTWARE_HELPERS 2 | #define H_GLOBUF_INTERNAL_APPKIT_SOFTWARE_HELPERS 3 | 4 | #include "include/globuf.h" 5 | #include "appkit/appkit_common.h" 6 | 7 | struct appkit_software_backend 8 | { 9 | struct appkit_platform platform; 10 | }; 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /src/include/globuf_win_vulkan.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_WIN_VULKAN 2 | #define H_GLOBUF_WIN_VULKAN 3 | 4 | #include "globuf.h" 5 | #include "globuf_win.h" 6 | #include "globuf_vulkan.h" 7 | 8 | void globuf_prepare_init_win_vulkan( 9 | struct globuf_config_backend* config, 10 | struct globuf_error_info* error); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /src/include/globuf_x11_vulkan.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_X11_VULKAN 2 | #define H_GLOBUF_X11_VULKAN 3 | 4 | #include "globuf.h" 5 | #include "globuf_x11.h" 6 | #include "globuf_vulkan.h" 7 | 8 | void globuf_prepare_init_x11_vulkan( 9 | struct globuf_config_backend* config, 10 | struct globuf_error_info* error); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /src/include/globuf_wayland_egl.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_WAYLAND_EGL 2 | #define H_GLOBUF_WAYLAND_EGL 3 | 4 | #include "globuf.h" 5 | #include "globuf_wayland.h" 6 | #include "globuf_opengl.h" 7 | 8 | void globuf_prepare_init_wayland_egl( 9 | struct globuf_config_backend* config, 10 | struct globuf_error_info* error); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /src/appkit/appkit_software_helpers.m: -------------------------------------------------------------------------------- 1 | #define _XOPEN_SOURCE 700 2 | 3 | #include "include/globuf.h" 4 | #include "common/globuf_private.h" 5 | #include "appkit/appkit_software_helpers.h" 6 | #include "appkit/appkit_software.h" 7 | #include "appkit/appkit_common.h" 8 | #include 9 | #include 10 | #include 11 | -------------------------------------------------------------------------------- /src/include/globuf_win_software.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_WIN_SOFTWARE 2 | #define H_GLOBUF_WIN_SOFTWARE 3 | 4 | #include "globuf.h" 5 | #include "globuf_win.h" 6 | #include "globuf_software.h" 7 | 8 | void globuf_prepare_init_win_software( 9 | struct globuf_config_backend* config, 10 | struct globuf_error_info* error); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /src/include/globuf_x11_software.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_X11_SOFTWARE 2 | #define H_GLOBUF_X11_SOFTWARE 3 | 4 | #include "globuf.h" 5 | #include "globuf_x11.h" 6 | #include "globuf_software.h" 7 | 8 | void globuf_prepare_init_x11_software( 9 | struct globuf_config_backend* config, 10 | struct globuf_error_info* error); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /ci/globuf_image_x11_gcc/scripts/build_x11.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | git clone https://github.com/nullgemm/globuf.git 4 | cd ./globuf || exit 5 | 6 | if [ "$4" == "complex" ]; then 7 | ./make/scripts/cursoryx_get.sh 8 | ./make/scripts/dpishit_get.sh 9 | ./make/scripts/willis_get.sh 10 | fi 11 | 12 | # test build 13 | ./make/scripts/build.sh "$@" 14 | -------------------------------------------------------------------------------- /src/include/globuf_appkit_vulkan.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_APPKIT_VULKAN 2 | #define H_GLOBUF_APPKIT_VULKAN 3 | 4 | #include "globuf.h" 5 | #include "globuf_appkit.h" 6 | #include "globuf_vulkan.h" 7 | 8 | void globuf_prepare_init_appkit_vulkan( 9 | struct globuf_config_backend* config, 10 | struct globuf_error_info* error); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /ci/globuf_image_appkit_osxcross/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # example for a release build 4 | # $ ./run.sh /scripts/build_appkit.sh release appkit software none osxcross 5 | docker run \ 6 | --privileged \ 7 | --name globuf_container_appkit_osxcross_"$4" \ 8 | -e AR=x86_64-apple-darwin20.2-ar \ 9 | globuf_image_appkit_osxcross "$@" &>> log 10 | -------------------------------------------------------------------------------- /ci/globuf_image_win_mingw/scripts/build_win.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | git clone https://github.com/nullgemm/globuf.git 4 | cd ./globuf || exit 5 | 6 | if [ "$4" == "complex" ]; then 7 | ./make/scripts/cursoryx_get.sh 8 | ./make/scripts/dpishit_get.sh 9 | ./make/scripts/willis_get.sh 10 | fi 11 | 12 | # test build 13 | ./make/scripts/build.sh "$@" 14 | -------------------------------------------------------------------------------- /src/include/globuf_wayland_vulkan.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_WAYLAND_VULKAN 2 | #define H_GLOBUF_WAYLAND_VULKAN 3 | 4 | #include "globuf.h" 5 | #include "globuf_wayland.h" 6 | #include "globuf_vulkan.h" 7 | 8 | void globuf_prepare_init_wayland_vulkan( 9 | struct globuf_config_backend* config, 10 | struct globuf_error_info* error); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /ci/globuf_scripts_appkit_native/build_software.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | git clone https://github.com/nullgemm/globuf.git 4 | cd ./globuf || exit 5 | 6 | # test build 7 | export PATH=/scripts/sdk/target/bin/:/bin:/sbin:/usr/bin:/usr/sbin 8 | export LD_LIBRARY_PATH=/scripts/sdk/target/lib/ 9 | ./make/scripts/build.sh release appkit software none native 10 | -------------------------------------------------------------------------------- /src/include/globuf_appkit_software.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_APPKIT_SOFTWARE 2 | #define H_GLOBUF_APPKIT_SOFTWARE 3 | 4 | #include "globuf.h" 5 | #include "globuf_appkit.h" 6 | #include "globuf_software.h" 7 | 8 | void globuf_prepare_init_appkit_software( 9 | struct globuf_config_backend* config, 10 | struct globuf_error_info* error); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /src/include/globuf_wayland_software.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_WAYLAND_SOFTWARE 2 | #define H_GLOBUF_WAYLAND_SOFTWARE 3 | 4 | #include "globuf.h" 5 | #include "globuf_wayland.h" 6 | #include "globuf_software.h" 7 | 8 | void globuf_prepare_init_wayland_software( 9 | struct globuf_config_backend* config, 10 | struct globuf_error_info* error); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /ci/globuf_scripts_appkit_native/build_egl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | git clone https://github.com/nullgemm/globuf.git 4 | cd ./globuf || exit 5 | 6 | # test build 7 | export PATH=/scripts/sdk/target/bin/:/bin:/sbin:/usr/bin:/usr/sbin 8 | export LD_LIBRARY_PATH=/scripts/sdk/target/lib/ 9 | ./make/scripts/angle_release_get.sh 10 | ./make/scripts/build.sh release appkit egl none native 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | inc 3 | make/output 4 | globuf_bin_v* 5 | infer_* 6 | res/angle 7 | res/objconv 8 | res/egl_headers 9 | res/wayland_headers 10 | res/icon/iconpix.bin 11 | res/cursor/cursorpix.bin 12 | res/infer 13 | res/*.tar.xz 14 | res/*.zip 15 | ci/*/log 16 | ci/globuf_image_appkit_osxcross/scripts/sdk 17 | valgrind.log 18 | drmemory.log 19 | log 20 | vgcore.* 21 | doc/*.bkp 22 | -------------------------------------------------------------------------------- /make/scripts/prepare.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # get in the right folder 4 | path="$(pwd)/$0" 5 | folder=$(dirname "$path") 6 | cd "$folder" || exit 7 | 8 | # get libs 9 | ./cursoryx_get.sh 10 | ./dpishit_get.sh 11 | ./willis_get.sh 12 | 13 | # get dependencies 14 | ./egl_get.sh 15 | ./angle_release_get.sh 16 | ./moltenvk_release_get.sh 17 | 18 | # get local tools 19 | ./infer_get.sh 20 | -------------------------------------------------------------------------------- /src/win/win_software_helpers.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_WIN_SOFTWARE_HELPERS 2 | #define H_GLOBUF_INTERNAL_WIN_SOFTWARE_HELPERS 3 | 4 | #include "include/globuf.h" 5 | #include "win/win_common.h" 6 | #include 7 | 8 | struct win_software_backend 9 | { 10 | struct win_platform platform; 11 | 12 | BITMAPINFO bmp_info; 13 | HBITMAP bmp_handle; 14 | }; 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /ci/globuf_image_wayland_gcc/scripts/build_wayland.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | git clone https://github.com/nullgemm/globuf.git 4 | cd ./globuf || exit 5 | 6 | if [ "$4" == "complex" ]; then 7 | ./make/scripts/cursoryx_get.sh 8 | ./make/scripts/dpishit_get.sh 9 | ./make/scripts/willis_get.sh 10 | fi 11 | 12 | ./make/scripts/wayland_get.sh 13 | 14 | # test build 15 | ./make/scripts/build.sh "$@" 16 | -------------------------------------------------------------------------------- /ci/globuf_scripts_appkit_native/build_vulkan.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | git clone https://github.com/nullgemm/globuf.git 4 | cd ./globuf || exit 5 | 6 | # test build 7 | export PATH=/scripts/sdk/target/bin/:/bin:/sbin:/usr/bin:/usr/sbin 8 | export LD_LIBRARY_PATH=/scripts/sdk/target/lib/ 9 | ./make/scripts/moltenvk_release_get.sh 10 | ./make/scripts/build.sh release appkit vulkan none native 11 | -------------------------------------------------------------------------------- /make/scripts/willis_get.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # get in the right folder 4 | path="$(pwd)/$0" 5 | folder=$(dirname "$path") 6 | cd "$folder"/../.. || exit 7 | 8 | # get libs 9 | version="v0.1.5" 10 | 11 | cd res 12 | curl -L https://github.com/nullgemm/willis/releases/download/"$version"/willis_bin_dbg_"$version".zip -o willis.zip 13 | unzip willis.zip 14 | mv willis_bin_dbg_"$version" willis 15 | -------------------------------------------------------------------------------- /make/scripts/dpishit_get.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # get in the right folder 4 | path="$(pwd)/$0" 5 | folder=$(dirname "$path") 6 | cd "$folder"/../.. || exit 7 | 8 | # get libs 9 | version="v0.1.7" 10 | 11 | cd res 12 | curl -L https://github.com/nullgemm/dpishit/releases/download/"$version"/dpishit_bin_dbg_"$version".zip -o dpishit.zip 13 | unzip dpishit.zip 14 | mv dpishit_bin_dbg_"$version" dpishit 15 | -------------------------------------------------------------------------------- /make/scripts/infer_get.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # get in the right folder 4 | path="$(pwd)/$0" 5 | folder=$(dirname "$path") 6 | cd "$folder"/../.. || exit 7 | 8 | # get infer 9 | version="v1.1.0" 10 | 11 | cd res 12 | curl -L https://github.com/facebook/infer/releases/download/"$version"/infer-linux64-"$version".tar.xz -o infer.tar.xz 13 | tar -xvJf infer.tar.xz 14 | mv infer-linux64-"$version" infer 15 | -------------------------------------------------------------------------------- /src/include/globuf_x11.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_X11 2 | #define H_GLOBUF_X11 3 | 4 | #include "globuf.h" 5 | #include 6 | 7 | xcb_connection_t* globuf_get_x11_conn(struct globuf* context); 8 | xcb_window_t globuf_get_x11_window(struct globuf* context); 9 | xcb_window_t globuf_get_x11_root(struct globuf* context); 10 | xcb_screen_t* globuf_get_x11_screen(struct globuf* context); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /make/scripts/cursoryx_get.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # get in the right folder 4 | path="$(pwd)/$0" 5 | folder=$(dirname "$path") 6 | cd "$folder"/../.. || exit 7 | 8 | # get libs 9 | version="v0.3.5" 10 | 11 | cd res 12 | curl -L https://github.com/nullgemm/cursoryx/releases/download/"$version"/cursoryx_bin_dbg_"$version".zip -o cursoryx.zip 13 | unzip cursoryx.zip 14 | mv cursoryx_bin_dbg_"$version" cursoryx 15 | -------------------------------------------------------------------------------- /res/shaders/vk1/shaders_elf.S: -------------------------------------------------------------------------------- 1 | .global square_frag_vk1 2 | .global square_frag_vk1_size 3 | .global square_vert_vk1 4 | .global square_vert_vk1_size 5 | .section .rodata 6 | square_frag_vk1: 7 | .incbin "square_frag_vk1.spv" 8 | 1: 9 | square_vert_vk1: 10 | .incbin "square_vert_vk1.spv" 11 | 2: 12 | square_frag_vk1_size: 13 | .int 1b - square_frag_vk1 14 | square_vert_vk1_size: 15 | .int 2b - square_vert_vk1 16 | -------------------------------------------------------------------------------- /res/shaders/vk1/shaders_pe.S: -------------------------------------------------------------------------------- 1 | .global square_frag_vk1 2 | .global square_frag_vk1_size 3 | .global square_vert_vk1 4 | .global square_vert_vk1_size 5 | .section .rodata 6 | square_frag_vk1: 7 | .incbin "square_frag_vk1.spv" 8 | 1: 9 | square_vert_vk1: 10 | .incbin "square_vert_vk1.spv" 11 | 2: 12 | square_frag_vk1_size: 13 | .int 1b - square_frag_vk1 14 | square_vert_vk1_size: 15 | .int 2b - square_vert_vk1 16 | -------------------------------------------------------------------------------- /make/scripts/vk_shaders.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # get in the right folder 4 | path="$(pwd)/$0" 5 | folder=$(dirname "$path") 6 | cd "$folder"/../.. || exit 7 | 8 | echo "compiling GLSL shaders with glslangValidator..." 9 | cd res/shaders/vk1 10 | glslangValidator --target-env vulkan1.0 square_glsl_vk1.frag -o square_frag_vk1.spv 11 | glslangValidator --target-env vulkan1.0 square_glsl_vk1.vert -o square_vert_vk1.spv 12 | -------------------------------------------------------------------------------- /res/shaders/gl1/shaders_elf.S: -------------------------------------------------------------------------------- 1 | .global square_frag_gl1 2 | .global square_frag_gl1_size 3 | .global square_vert_gl1 4 | .global square_vert_gl1_size 5 | .section .rodata 6 | square_frag_gl1: 7 | .incbin "square_frag_gl1.glsl" 8 | 1: 9 | square_vert_gl1: 10 | .incbin "square_vert_gl1.glsl" 11 | 2: 12 | square_frag_gl1_size: 13 | .int 1b - square_frag_gl1 14 | square_vert_gl1_size: 15 | .int 2b - square_vert_gl1 16 | -------------------------------------------------------------------------------- /res/shaders/gl1/shaders_pe.S: -------------------------------------------------------------------------------- 1 | .global square_frag_gl1 2 | .global square_frag_gl1_size 3 | .global square_vert_gl1 4 | .global square_vert_gl1_size 5 | .section .rodata 6 | square_frag_gl1: 7 | .incbin "square_frag_gl1.glsl" 8 | 1: 9 | square_vert_gl1: 10 | .incbin "square_vert_gl1.glsl" 11 | 2: 12 | square_frag_gl1_size: 13 | .int 1b - square_frag_gl1 14 | square_vert_gl1_size: 15 | .int 2b - square_vert_gl1 16 | -------------------------------------------------------------------------------- /res/shaders/vk1/shaders_macho.S: -------------------------------------------------------------------------------- 1 | .global _square_frag_vk1 2 | .global _square_frag_vk1_size 3 | .global _square_vert_vk1 4 | .global _square_vert_vk1_size 5 | .section __TEXT,__const 6 | _square_frag_vk1: 7 | .incbin "square_frag_vk1.spv" 8 | 1: 9 | _square_vert_vk1: 10 | .incbin "square_vert_vk1.spv" 11 | 2: 12 | _square_frag_vk1_size: 13 | .int 1b - _square_frag_vk1 14 | _square_vert_vk1_size: 15 | .int 2b - _square_vert_vk1 16 | -------------------------------------------------------------------------------- /make/scripts/leak.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # get in the right folder 4 | path="$(pwd)/$0" 5 | folder=$(dirname "$path") 6 | cd "$folder"/../../build || exit 7 | 8 | valgrind+=("--show-error-list=yes") 9 | valgrind+=("--show-leak-kinds=all") 10 | valgrind+=("--track-origins=yes") 11 | valgrind+=("--leak-check=full") 12 | valgrind+=("--suppressions=../res/valgrind/valgrind.supp") 13 | 14 | valgrind "${valgrind[@]}" 2> ../valgrind.log ../$1 15 | -------------------------------------------------------------------------------- /res/shaders/gl1/shaders_macho.S: -------------------------------------------------------------------------------- 1 | .global _square_frag_gl1 2 | .global _square_frag_gl1_size 3 | .global _square_vert_gl1 4 | .global _square_vert_gl1_size 5 | .section __TEXT,__const 6 | _square_frag_gl1: 7 | .incbin "square_frag_gl1.glsl" 8 | 1: 9 | _square_vert_gl1: 10 | .incbin "square_vert_gl1.glsl" 11 | 2: 12 | _square_frag_gl1_size: 13 | .int 1b - _square_frag_gl1 14 | _square_vert_gl1_size: 15 | .int 2b - _square_vert_gl1 16 | -------------------------------------------------------------------------------- /res/shaders/gles2/shaders_elf.S: -------------------------------------------------------------------------------- 1 | .global square_frag_gles2 2 | .global square_frag_gles2_size 3 | .global square_vert_gles2 4 | .global square_vert_gles2_size 5 | .section .rodata 6 | square_frag_gles2: 7 | .incbin "square_frag_gles2.glsl" 8 | 1: 9 | square_vert_gles2: 10 | .incbin "square_vert_gles2.glsl" 11 | 2: 12 | square_frag_gles2_size: 13 | .int 1b - square_frag_gles2 14 | square_vert_gles2_size: 15 | .int 2b - square_vert_gles2 16 | -------------------------------------------------------------------------------- /res/shaders/gles2/shaders_pe.S: -------------------------------------------------------------------------------- 1 | .global square_frag_gles2 2 | .global square_frag_gles2_size 3 | .global square_vert_gles2 4 | .global square_vert_gles2_size 5 | .section .rodata 6 | square_frag_gles2: 7 | .incbin "square_frag_gles2.glsl" 8 | 1: 9 | square_vert_gles2: 10 | .incbin "square_vert_gles2.glsl" 11 | 2: 12 | square_frag_gles2_size: 13 | .int 1b - square_frag_gles2 14 | square_vert_gles2_size: 15 | .int 2b - square_vert_gles2 16 | -------------------------------------------------------------------------------- /src/include/globuf_appkit_egl.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_APPKIT_EGL 2 | #define H_GLOBUF_APPKIT_EGL 3 | 4 | #include "globuf.h" 5 | #include "globuf_appkit.h" 6 | #include "globuf_opengl.h" 7 | 8 | void globuf_prepare_init_appkit_egl( 9 | struct globuf_config_backend* config, 10 | struct globuf_error_info* error); 11 | 12 | double globuf_appkit_egl_get_scale( 13 | struct globuf* context, 14 | struct globuf_error_info* error); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /src/common/globuf_opengl.c: -------------------------------------------------------------------------------- 1 | #include "include/globuf.h" 2 | #include "include/globuf_opengl.h" 3 | #include "common/globuf_private.h" 4 | #include 5 | 6 | void globuf_init_opengl( 7 | struct globuf* context, 8 | struct globuf_config_opengl* config, 9 | struct globuf_error_info* error) 10 | { 11 | struct globuf_calls_opengl* opengl = context->backend_callbacks.data; 12 | 13 | opengl->init( 14 | context, 15 | config, 16 | error); 17 | } 18 | -------------------------------------------------------------------------------- /res/shaders/gles2/shaders_macho.S: -------------------------------------------------------------------------------- 1 | .global _square_frag_gles2 2 | .global _square_frag_gles2_size 3 | .global _square_vert_gles2 4 | .global _square_vert_gles2_size 5 | .section __TEXT,__const 6 | _square_frag_gles2: 7 | .incbin "square_frag_gles2.glsl" 8 | 1: 9 | _square_vert_gles2: 10 | .incbin "square_vert_gles2.glsl" 11 | 2: 12 | _square_frag_gles2_size: 13 | .int 1b - _square_frag_gles2 14 | _square_vert_gles2_size: 15 | .int 2b - _square_vert_gles2 16 | -------------------------------------------------------------------------------- /ci/globuf_image_win_mingw/scripts/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # git cloning the repo 4 | # bash running the build scripts 5 | # gcc relinking the objects 6 | # ninja building the binaries 7 | # mingw-w64-binutils 8 | # mingw-w64-gcc 9 | # mingw-w64-headers 10 | # mingw-w64-crt 11 | 12 | apk add --no-cache \ 13 | git \ 14 | bash \ 15 | gcc \ 16 | ninja \ 17 | mingw-w64-binutils \ 18 | mingw-w64-gcc \ 19 | mingw-w64-headers \ 20 | mingw-w64-crt 21 | -------------------------------------------------------------------------------- /ci/globuf_image_appkit_osxcross/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mkdir -p ./scripts/sdk 4 | 5 | if [ ! -d "../../res/osxcross" ]; then 6 | echo "please make sure the res/osxcross folder contains a macOS SDK" 7 | echo "please refer to https://github.com/tpoechtrager/osxcross" 8 | echo "or use https://github.com/nullgemm/instant_macos_sdk" 9 | exit 10 | fi 11 | 12 | sudo mount -o bind ../../res/osxcross ./scripts/sdk 13 | docker build -t globuf_image_appkit_osxcross . 14 | sudo umount ./scripts/sdk 15 | -------------------------------------------------------------------------------- /res/valgrind/valgrind.supp: -------------------------------------------------------------------------------- 1 | { 2 | radeon_dri 3 | Memcheck:Leak 4 | ... 5 | obj:/usr/lib/dri/radeonsi_dri.so 6 | ... 7 | } 8 | 9 | { 10 | radeon_llvm 11 | Memcheck:Leak 12 | ... 13 | obj:/usr/lib/libLLVM* 14 | ... 15 | } 16 | 17 | { 18 | egl 19 | Memcheck:Leak 20 | ... 21 | obj:/usr/lib/libEGL* 22 | ... 23 | } 24 | 25 | { 26 | glx 27 | Memcheck:Leak 28 | ... 29 | obj:/usr/lib/libGLX* 30 | ... 31 | } 32 | 33 | { 34 | dl_open 35 | Memcheck:Leak 36 | ... 37 | fun:dl_open_worker 38 | ... 39 | } 40 | -------------------------------------------------------------------------------- /license.md: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | Version 2, December 2004 3 | 4 | Copyright (C) 2004 Sam Hocevar 5 | 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO. 14 | -------------------------------------------------------------------------------- /make/scripts/moltenvk_release_get.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # get into the right folder 4 | cd "$(dirname "$0")" || exit 5 | cd ../.. 6 | 7 | rm -rf res/moltenvk 8 | mkdir -p res/moltenvk/tmp 9 | mkdir -p res/moltenvk/libs 10 | cd res/moltenvk/tmp || exit 11 | 12 | # get binaries 13 | curl \ 14 | -L "https://github.com/KhronosGroup/MoltenVK/releases/latest/download/MoltenVK-all.tar" \ 15 | -o moltenvk.tar 16 | 17 | tar xvf moltenvk.tar 18 | 19 | cp -r MoltenVK/MoltenVK/include .. 20 | cp -r MoltenVK/MoltenVK/dylib/macOS/libMoltenVK.dylib ../libs/ 21 | -------------------------------------------------------------------------------- /src/win/win_wgl_helpers.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_WIN_WGL_HELPERS 2 | #define H_GLOBUF_INTERNAL_WIN_WGL_HELPERS 3 | 4 | #include "include/globuf.h" 5 | #include "include/globuf_opengl.h" 6 | #include "win/win_common.h" 7 | 8 | #include 9 | 10 | struct win_wgl_backend 11 | { 12 | struct win_platform platform; 13 | struct globuf_config_opengl* config; 14 | HGLRC wgl; 15 | HDC device_context; 16 | PIXELFORMATDESCRIPTOR format_descriptor; 17 | }; 18 | 19 | void win_helpers_wgl_render(struct win_thread_render_loop_data* data); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /ci/globuf_image_win_mingw/release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "please clean docker" 4 | 5 | sudo rm -rf globuf_bin_v* log 6 | sudo docker rm globuf_container_win_mingw_software 7 | sudo docker rm globuf_container_win_mingw_wgl 8 | sudo docker rmi globuf_image_win_mingw 9 | sudo docker rmi alpine:edge 10 | 11 | sudo ./build.sh 12 | 13 | sudo ./run.sh /scripts/build_win.sh release win software none native 14 | sudo ./run.sh /scripts/build_win.sh release win wgl none native 15 | 16 | sudo ./artifact.sh software 17 | sudo ./artifact.sh wgl 18 | 19 | sudo chown -R $(id -un):$(id -gn) globuf_bin_v* 20 | -------------------------------------------------------------------------------- /src/common/globuf_error.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_ERROR 2 | #define H_GLOBUF_ERROR 3 | 4 | #include "include/globuf.h" 5 | 6 | #define globuf_error_throw(context, error, code) \ 7 | globuf_error_throw_extra(\ 8 | context,\ 9 | error,\ 10 | code,\ 11 | GLOBUF_ERROR_FILE,\ 12 | GLOBUF_ERROR_LINE) 13 | #define GLOBUF_ERROR_FILE __FILE__ 14 | #define GLOBUF_ERROR_LINE __LINE__ 15 | 16 | void globuf_error_throw_extra( 17 | struct globuf* context, 18 | struct globuf_error_info* error, 19 | enum globuf_error code, 20 | const char* file, 21 | unsigned line); 22 | 23 | void globuf_error_init( 24 | struct globuf* context); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /src/include/globuf_opengl.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_OPENGL 2 | #define H_GLOBUF_OPENGL 3 | 4 | #include "globuf.h" 5 | 6 | // common to all backends supporting OpenGL rendering 7 | 8 | struct globuf_config_opengl 9 | { 10 | int major_version; 11 | int minor_version; 12 | int* attributes; 13 | }; 14 | 15 | struct globuf_calls_opengl 16 | { 17 | void (*init)( 18 | struct globuf* context, 19 | struct globuf_config_opengl* config, 20 | struct globuf_error_info* error); 21 | }; 22 | 23 | void globuf_init_opengl( 24 | struct globuf* context, 25 | struct globuf_config_opengl* config, 26 | struct globuf_error_info* error); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /ci/globuf_image_appkit_osxcross/scripts/build_appkit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | git clone https://github.com/nullgemm/globuf.git 4 | cd ./globuf || exit 5 | 6 | # test build 7 | export PATH=/scripts/sdk/target/bin/:/bin:/sbin:/usr/bin:/usr/sbin 8 | export LD_LIBRARY_PATH=/scripts/sdk/target/lib/ 9 | 10 | if [ "$3" == "egl" ]; then 11 | ./make/scripts/angle_release_get.sh 12 | fi 13 | 14 | if [ "$3" == "vulkan" ]; then 15 | ./make/scripts/moltenvk_release_get.sh 16 | fi 17 | 18 | if [ "$4" == "complex" ]; then 19 | ./make/scripts/cursoryx_get.sh 20 | ./make/scripts/dpishit_get.sh 21 | ./make/scripts/willis_get.sh 22 | fi 23 | 24 | ./make/scripts/build.sh "$@" 25 | -------------------------------------------------------------------------------- /src/appkit/appkit_egl_helpers.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_APPKIT_EGL_HELPERS 2 | #define H_GLOBUF_INTERNAL_APPKIT_EGL_HELPERS 3 | 4 | #include "include/globuf.h" 5 | #include "include/globuf_opengl.h" 6 | #include "appkit/appkit_egl.h" 7 | #include "appkit/appkit_common.h" 8 | #include 9 | 10 | struct appkit_egl_backend 11 | { 12 | struct appkit_platform platform; 13 | struct globuf_config_opengl* config; 14 | 15 | EGLContext egl; 16 | EGLDisplay display; 17 | EGLSurface surface; 18 | EGLConfig attr_config; 19 | EGLint attr_config_size; 20 | }; 21 | 22 | void appkit_helpers_egl_bind( 23 | struct globuf* context, 24 | struct globuf_error_info* error); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /src/common/symbols_common.txt: -------------------------------------------------------------------------------- 1 | globuf_init 2 | globuf_clean 3 | globuf_window_create 4 | globuf_window_destroy 5 | globuf_window_confirm 6 | globuf_window_start 7 | globuf_window_block 8 | globuf_window_stop 9 | globuf_init_render 10 | globuf_init_events 11 | globuf_handle_events 12 | globuf_init_features 13 | globuf_feature_set_interaction 14 | globuf_feature_set_state 15 | globuf_feature_set_title 16 | globuf_feature_set_icon 17 | globuf_get_width 18 | globuf_get_height 19 | globuf_get_expose 20 | globuf_update_content 21 | globuf_error_log 22 | globuf_error_get_msg 23 | globuf_error_get_code 24 | globuf_error_get_file 25 | globuf_error_get_line 26 | globuf_error_ok 27 | globuf_error_throw_extra 28 | -------------------------------------------------------------------------------- /src/x11/x11_egl_helpers.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_X11_EGL_HELPERS 2 | #define H_GLOBUF_INTERNAL_X11_EGL_HELPERS 3 | 4 | #include "include/globuf.h" 5 | #include "include/globuf_opengl.h" 6 | #include "x11/x11_common.h" 7 | #include 8 | 9 | struct x11_egl_backend 10 | { 11 | struct x11_platform platform; 12 | struct globuf_config_opengl* config; 13 | 14 | EGLContext egl; 15 | EGLDisplay display; 16 | EGLSurface surface; 17 | EGLConfig attr_config; 18 | }; 19 | 20 | bool x11_helpers_egl_ext_support( 21 | const char *list, 22 | const char *extension); 23 | 24 | void x11_helpers_egl_bind( 25 | struct globuf* context, 26 | struct globuf_error_info* error); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/x11/x11_glx_helpers.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_X11_GLX_HELPERS 2 | #define H_GLOBUF_INTERNAL_X11_GLX_HELPERS 3 | 4 | #include "include/globuf.h" 5 | #include "include/globuf_opengl.h" 6 | #include "x11/x11_common.h" 7 | #include 8 | #include 9 | 10 | struct x11_glx_backend 11 | { 12 | struct x11_platform platform; 13 | struct globuf_config_opengl* config; 14 | Display* display; 15 | GLXFBConfig fb_config; 16 | GLXContext glx; 17 | GLXWindow win; 18 | int error_base; 19 | int event_base; 20 | }; 21 | 22 | bool x11_helpers_glx_ext_support( 23 | const char *list, 24 | const char *extension); 25 | 26 | void x11_helpers_glx_bind( 27 | struct globuf* context, 28 | struct globuf_error_info* error); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/common/globuf_software.c: -------------------------------------------------------------------------------- 1 | #include "include/globuf.h" 2 | #include "include/globuf_software.h" 3 | #include "common/globuf_private.h" 4 | #include 5 | 6 | uint32_t* globuf_buffer_alloc_software( 7 | struct globuf* context, 8 | unsigned width, 9 | unsigned height, 10 | struct globuf_error_info* error) 11 | { 12 | struct globuf_calls_software* software = context->backend_callbacks.data; 13 | 14 | return software->alloc(context, width, height, error); 15 | } 16 | 17 | void globuf_buffer_free_software( 18 | struct globuf* context, 19 | uint32_t* buffer, 20 | struct globuf_error_info* error) 21 | { 22 | struct globuf_calls_software* software = context->backend_callbacks.data; 23 | 24 | software->free(context, buffer, error); 25 | } 26 | -------------------------------------------------------------------------------- /ci/globuf_image_appkit_osxcross/scripts/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # git cloning the repo 4 | # bash running the build scripts 5 | # samurai building the binaries 6 | # musl-dev standard C library 7 | # clang OSXCross dependency 8 | # libgcc OSXCross dependency 9 | # libstdc++ OSXCross dependency 10 | # unzip extracting ANGLE 11 | # curl downloading ANGLE 12 | # libbsd using Apple's Xcode clang 13 | # fts using Apple's Xcode clang 14 | 15 | apk add --no-cache \ 16 | git \ 17 | bash \ 18 | samurai \ 19 | musl-dev \ 20 | clang \ 21 | libgcc \ 22 | libstdc++ \ 23 | unzip \ 24 | curl \ 25 | libbsd \ 26 | fts 27 | -------------------------------------------------------------------------------- /ci/globuf_image_wayland_gcc/release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "please clean docker" 4 | 5 | sudo rm -rf globuf_bin_v* log 6 | sudo docker rm globuf_container_wayland_gcc_software 7 | sudo docker rm globuf_container_wayland_gcc_vulkan 8 | sudo docker rm globuf_container_wayland_gcc_egl 9 | sudo docker rmi globuf_image_wayland_gcc 10 | sudo docker rmi alpine:edge 11 | 12 | sudo ./build.sh 13 | 14 | sudo ./run.sh /scripts/build_wayland.sh release wayland software none native 15 | sudo ./run.sh /scripts/build_wayland.sh release wayland vulkan none native 16 | sudo ./run.sh /scripts/build_wayland.sh release wayland egl none native 17 | 18 | sudo ./artifact.sh software 19 | sudo ./artifact.sh vulkan 20 | sudo ./artifact.sh egl 21 | 22 | sudo chown -R $(id -un):$(id -gn) globuf_bin_v* 23 | -------------------------------------------------------------------------------- /src/win/win_wgl_helpers.c: -------------------------------------------------------------------------------- 1 | #include "include/globuf.h" 2 | #include "common/globuf_private.h" 3 | #include "win/win_wgl_helpers.h" 4 | #include "win/win_wgl.h" 5 | #include "win/win_common.h" 6 | #include 7 | #include 8 | 9 | void win_helpers_wgl_render(struct win_thread_render_loop_data* data) 10 | { 11 | struct globuf* context = data->globuf; 12 | struct win_platform* platform = data->platform; 13 | struct win_wgl_backend* backend = context->backend_data; 14 | struct globuf_error_info* error = data->error; 15 | 16 | // make wgl context current on the calling thread 17 | BOOL ok = wglMakeCurrent(backend->device_context, backend->wgl); 18 | 19 | if (ok == FALSE) 20 | { 21 | globuf_error_throw(context, error, GLOBUF_ERROR_WIN_WGL_CONTEXT_SET); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ci/globuf_image_appkit_osxcross/release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "please clean docker" 4 | 5 | sudo rm -rf globuf_bin_v* log 6 | sudo docker rm globuf_container_appkit_osxcross_software 7 | sudo docker rm globuf_container_appkit_osxcross_vulkan 8 | sudo docker rm globuf_container_appkit_osxcross_egl 9 | sudo docker rmi globuf_image_appkit_osxcross 10 | sudo docker rmi alpine:edge 11 | 12 | sudo ./build.sh 13 | 14 | sudo ./run.sh /scripts/build_appkit.sh release appkit software none osxcross 15 | sudo ./run.sh /scripts/build_appkit.sh release appkit vulkan none osxcross 16 | sudo ./run.sh /scripts/build_appkit.sh release appkit egl none osxcross 17 | 18 | sudo ./artifact.sh software 19 | sudo ./artifact.sh vulkan 20 | sudo ./artifact.sh egl 21 | 22 | sudo chown -R $(id -un):$(id -gn) globuf_bin_v* 23 | -------------------------------------------------------------------------------- /make/scripts/angle_release_get.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # get into the right folder 4 | cd "$(dirname "$0")" || exit 5 | cd ../.. 6 | 7 | rm -rf res/angle 8 | mkdir -p res/angle/tmp 9 | mkdir -p res/angle/libs 10 | mkdir -p res/angle/include 11 | cd res/angle/tmp || exit 12 | 13 | # get binaries 14 | curl \ 15 | -L "https://download-chromium.appspot.com/dl/Mac?type=snapshots" \ 16 | -o chromium.zip 17 | 18 | unzip chromium.zip 19 | 20 | cp \ 21 | "chrome-mac/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Libraries/libGLESv2.dylib" \ 22 | "chrome-mac/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Libraries/libEGL.dylib" \ 23 | ../libs/ 24 | 25 | # get headers 26 | git clone --depth 1 https://chromium.googlesource.com/angle/angle 27 | 28 | mv angle/include/* ../include/ 29 | -------------------------------------------------------------------------------- /src/win/win_vulkan_helpers.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_WIN_VULKAN_HELPERS 2 | #define H_GLOBUF_INTERNAL_WIN_VULKAN_HELPERS 3 | 4 | #include "include/globuf.h" 5 | #include "include/globuf_vulkan.h" 6 | #include "win/win_common.h" 7 | #include 8 | #include 9 | #include 10 | 11 | struct win_vulkan_backend 12 | { 13 | struct win_platform platform; 14 | struct globuf_config_vulkan* config; 15 | 16 | // vulkan extensions used by globuf 17 | uint32_t ext_len; 18 | const char** ext_needed; 19 | bool* ext_found; 20 | 21 | VkSurfaceKHR surface; 22 | VkWin32SurfaceCreateInfoKHR vulkan_info; 23 | }; 24 | 25 | size_t win_helpers_vulkan_add_extensions( 26 | struct globuf* context, 27 | const char*** ext_needed, 28 | bool** ext_found, 29 | struct globuf_error_info* error); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /make/scripts/pixmap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # get in the right folder 4 | path="$(pwd)/$0" 5 | folder=$(dirname "$path") 6 | cd "$folder"/../.. || exit 7 | 8 | cd res/icon || exit 9 | 10 | # create an icon X11 pixmap 11 | { \ 12 | echo -n -e "\x10\x00\x00\x00\x10\x00\x00\x00"; \ 13 | cat 16.data; \ 14 | echo -n -e "\x20\x00\x00\x00\x20\x00\x00\x00"; \ 15 | cat 32.data; \ 16 | echo -n -e "\x40\x00\x00\x00\x40\x00\x00\x00"; \ 17 | cat 64.data; \ 18 | } > iconpix.bin 19 | 20 | cd ../cursor || exit 21 | 22 | # create an icon X11 pixmap 23 | { \ 24 | echo -n -e "\x10\x00\x00\x00\x16\x00\x00\x00"; \ 25 | cat 1.data; \ 26 | echo -n -e "\x10\x00\x00\x00\x16\x00\x00\x00"; \ 27 | cat 2.data; \ 28 | echo -n -e "\x10\x00\x00\x00\x16\x00\x00\x00"; \ 29 | cat 3.data; \ 30 | echo -n -e "\x10\x00\x00\x00\x16\x00\x00\x00"; \ 31 | cat 4.data; \ 32 | } > cursorpix.bin 33 | -------------------------------------------------------------------------------- /ci/globuf_image_x11_gcc/release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "please clean docker" 4 | 5 | sudo rm -rf globuf_bin_v* log 6 | sudo docker rm globuf_container_x11_gcc_software 7 | sudo docker rm globuf_container_x11_gcc_vulkan 8 | sudo docker rm globuf_container_x11_gcc_egl 9 | sudo docker rm globuf_container_x11_gcc_glx 10 | sudo docker rmi globuf_image_x11_gcc 11 | sudo docker rmi alpine:edge 12 | 13 | sudo ./build.sh 14 | 15 | sudo ./run.sh /scripts/build_x11.sh release x11 software none native 16 | sudo ./run.sh /scripts/build_x11.sh release x11 vulkan none native 17 | sudo ./run.sh /scripts/build_x11.sh release x11 egl none native 18 | sudo ./run.sh /scripts/build_x11.sh release x11 glx none native 19 | 20 | sudo ./artifact.sh software 21 | sudo ./artifact.sh vulkan 22 | sudo ./artifact.sh egl 23 | sudo ./artifact.sh glx 24 | 25 | sudo chown -R $(id -un):$(id -gn) globuf_bin_v* 26 | -------------------------------------------------------------------------------- /src/wayland/wayland_vulkan_helpers.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_WAYLAND_VULKAN_HELPERS 2 | #define H_GLOBUF_INTERNAL_WAYLAND_VULKAN_HELPERS 3 | 4 | #include "include/globuf.h" 5 | #include "include/globuf_vulkan.h" 6 | #include "wayland/wayland_common.h" 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | struct wayland_vulkan_backend 13 | { 14 | struct wayland_platform platform; 15 | struct globuf_config_vulkan* config; 16 | 17 | // vulkan extensions used by globuf 18 | uint32_t ext_len; 19 | const char** ext_needed; 20 | bool* ext_found; 21 | 22 | VkSurfaceKHR surface; 23 | VkWaylandSurfaceCreateInfoKHR vulkan_info; 24 | }; 25 | 26 | size_t wayland_helpers_vulkan_add_extensions( 27 | struct globuf* context, 28 | const char*** ext_needed, 29 | bool** ext_found, 30 | struct globuf_error_info* error); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/x11/x11_software_helpers.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_X11_SOFTWARE_HELPERS 2 | #define H_GLOBUF_INTERNAL_X11_SOFTWARE_HELPERS 3 | 4 | #include "include/globuf.h" 5 | #include "x11/x11_common.h" 6 | 7 | #include 8 | #include 9 | 10 | struct x11_software_backend 11 | { 12 | struct x11_platform platform; 13 | 14 | bool shared_pixmaps; 15 | uint32_t* buffer_ptr; 16 | size_t buffer_len; 17 | 18 | xcb_gcontext_t software_gfx; 19 | xcb_pixmap_t software_pixmap; 20 | xcb_shm_segment_info_t software_shm; 21 | }; 22 | 23 | void x11_helpers_visual_transparent( 24 | struct globuf* context, 25 | struct globuf_error_info* error); 26 | 27 | void x11_helpers_visual_opaque( 28 | struct globuf* context, 29 | struct globuf_error_info* error); 30 | 31 | void x11_helpers_shm_create( 32 | struct globuf* context, 33 | size_t len, 34 | struct globuf_error_info* error); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/include/globuf_wayland.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_WAYLAND 2 | #define H_GLOBUF_WAYLAND 3 | 4 | #include "globuf.h" 5 | #include 6 | #include 7 | 8 | bool globuf_add_wayland_capabilities_handler( 9 | void* data, 10 | void (*capabilities_handler)( 11 | void* data, 12 | void* seat, 13 | uint32_t capabilities), 14 | void* capabilities_handler_data); 15 | 16 | bool globuf_add_wayland_registry_handler( 17 | void* data, 18 | void (*registry_handler)( 19 | void* data, 20 | void* registry, 21 | uint32_t name, 22 | const char* interface, 23 | uint32_t version), 24 | void* registry_handler_data); 25 | 26 | bool globuf_add_wayland_registry_remover( 27 | void* data, 28 | void (*registry_remover)( 29 | void* data, 30 | void* registry, 31 | uint32_t name), 32 | void* registry_remover_data); 33 | 34 | void* globuf_get_wayland_surface( 35 | struct globuf* context); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/wayland/wayland_egl_helpers.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_WAYLAND_EGL_HELPERS 2 | #define H_GLOBUF_INTERNAL_WAYLAND_EGL_HELPERS 3 | 4 | #include "include/globuf.h" 5 | #include "include/globuf_opengl.h" 6 | #include "wayland/wayland_common.h" 7 | 8 | #include 9 | #include 10 | 11 | struct wayland_egl_backend 12 | { 13 | struct wayland_platform platform; 14 | struct globuf_config_opengl* config; 15 | 16 | EGLContext egl; 17 | EGLDisplay display; 18 | EGLSurface surface; 19 | EGLConfig attr_config; 20 | EGLint attr_config_size; 21 | struct wl_egl_window* window; 22 | }; 23 | 24 | void wayland_helpers_egl_bind( 25 | struct globuf* context, 26 | struct globuf_error_info* error); 27 | 28 | void wayland_helpers_egl_toplevel_configure( 29 | void* data, 30 | struct xdg_toplevel* xdg_toplevel, 31 | int32_t width, 32 | int32_t height, 33 | struct wl_array* states); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /res/app/globuf.app/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleExecutable 6 | globuf 7 | 8 | CFBundleIconFile 9 | globuf.icns 10 | 11 | CFBundleIdentifier 12 | fr.nicolussi.globuf_example_app 13 | 14 | CFBundleName 15 | Globuf Example 16 | 17 | CFBundleGetInfoString 18 | Globuf Example App 1.0 19 | 20 | CFBundleVersion 21 | 1.0.0 22 | 23 | CFBundleShortVersionString 24 | 1.0 25 | 26 | NSHumanReadableCopyright 27 | Licensed under WTFPL. No rights reserved. 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/appkit/appkit_vulkan_helpers.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_APPKIT_VULKAN_HELPERS 2 | #define H_GLOBUF_INTERNAL_APPKIT_VULKAN_HELPERS 3 | 4 | #include "include/globuf.h" 5 | #include "include/globuf_vulkan.h" 6 | #include "appkit/appkit_common.h" 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #import 13 | 14 | struct appkit_vulkan_backend 15 | { 16 | struct appkit_platform platform; 17 | struct globuf_config_vulkan* config; 18 | 19 | // vulkan extensions used by globuf 20 | uint32_t ext_len; 21 | const char** ext_needed; 22 | bool* ext_found; 23 | 24 | VkSurfaceKHR surface; 25 | VkMetalSurfaceCreateInfoEXT vulkan_info; 26 | }; 27 | 28 | size_t appkit_helpers_vulkan_add_extensions( 29 | struct globuf* context, 30 | const char*** ext_needed, 31 | bool** ext_found, 32 | struct globuf_error_info* error); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/appkit/symbols_common.txt: -------------------------------------------------------------------------------- 1 | globuf_appkit_common_init 2 | globuf_appkit_common_clean 3 | globuf_appkit_common_window_create 4 | globuf_appkit_common_window_destroy 5 | globuf_appkit_common_window_confirm 6 | globuf_appkit_common_window_start 7 | globuf_appkit_common_window_block 8 | globuf_appkit_common_window_stop 9 | globuf_appkit_common_init_render 10 | globuf_appkit_common_init_events 11 | globuf_appkit_common_handle_events 12 | globuf_appkit_common_init_features 13 | globuf_appkit_common_feature_set_interaction 14 | globuf_appkit_common_feature_set_state 15 | globuf_appkit_common_feature_set_title 16 | globuf_appkit_common_feature_set_icon 17 | globuf_appkit_common_get_width 18 | globuf_appkit_common_get_height 19 | globuf_appkit_common_get_expose 20 | globuf_appkit_helpers_render_loop 21 | globuf_appkit_helpers_features_init 22 | globuf_appkit_helpers_send_app_event 23 | globuf_appkit_helpers_set_state 24 | globuf_appkit_helpers_handle_interaction 25 | -------------------------------------------------------------------------------- /src/include/globuf_software.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_SOFTWARE 2 | #define H_GLOBUF_SOFTWARE 3 | 4 | #include "globuf.h" 5 | 6 | #include 7 | 8 | // common to all backends supporting software rendering 9 | 10 | struct globuf_update_software 11 | { 12 | uint32_t* buf; 13 | 14 | int x; 15 | int y; 16 | 17 | unsigned width; 18 | unsigned height; 19 | }; 20 | 21 | struct globuf_calls_software 22 | { 23 | uint32_t* (*alloc)( 24 | struct globuf* context, 25 | unsigned width, 26 | unsigned height, 27 | struct globuf_error_info* error); 28 | 29 | void (*free)( 30 | struct globuf* context, 31 | uint32_t* buffer, 32 | struct globuf_error_info* error); 33 | }; 34 | 35 | uint32_t* globuf_buffer_alloc_software( 36 | struct globuf* context, 37 | unsigned width, 38 | unsigned height, 39 | struct globuf_error_info* error); 40 | 41 | void globuf_buffer_free_software( 42 | struct globuf* context, 43 | uint32_t* buffer, 44 | struct globuf_error_info* error); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /make/scripts/egl_get.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # get in the right folder 4 | path="$(pwd)/$0" 5 | folder=$(dirname "$path") 6 | cd "$folder"/../.. || exit 7 | 8 | # get EGL 9 | mkdir -p res/egl/GL 10 | mkdir -p res/egl/GLES2 11 | mkdir -p res/egl/EGL 12 | mkdir -p res/egl/KHR 13 | 14 | curl -L "https://www.khronos.org/registry/OpenGL/api/GL/wglext.h" -o \ 15 | res/egl/GL/wglext.h 16 | curl -L "https://www.khronos.org/registry/OpenGL/api/GLES2/gl2.h" -o \ 17 | res/egl/GLES2/gl2.h 18 | curl -L "https://www.khronos.org/registry/OpenGL/api/GLES2/gl2platform.h" -o \ 19 | res/egl/GLES2/gl2platform.h 20 | curl -L "https://www.khronos.org/registry/EGL/api/EGL/egl.h" -o \ 21 | res/egl/EGL/egl.h 22 | curl -L "https://www.khronos.org/registry/EGL/api/EGL/eglext.h" -o \ 23 | res/egl/EGL/eglext.h 24 | curl -L "https://www.khronos.org/registry/EGL/api/EGL/eglplatform.h" -o \ 25 | res/egl/EGL/eglplatform.h 26 | curl -L "https://www.khronos.org/registry/EGL/api/KHR/khrplatform.h" -o \ 27 | res/egl/KHR/khrplatform.h 28 | -------------------------------------------------------------------------------- /src/wayland/wayland_software_helpers.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_WAYLAND_SOFTWARE_HELPERS 2 | #define H_GLOBUF_INTERNAL_WAYLAND_SOFTWARE_HELPERS 3 | 4 | #include "include/globuf.h" 5 | #include "wayland/wayland_common.h" 6 | 7 | #include 8 | #include 9 | 10 | struct wayland_software_backend 11 | { 12 | struct wayland_platform platform; 13 | 14 | // software structures 15 | struct wl_shm* shm; 16 | struct wl_buffer* buffer; 17 | 18 | // mmap'd buffer 19 | size_t buffer_len; 20 | uint32_t* buffer_ptr; 21 | unsigned buffer_width; 22 | unsigned buffer_height; 23 | 24 | // wayland buffer listener 25 | struct wl_buffer_listener listener_buffer; 26 | struct wl_shm_pool* software_pool; 27 | }; 28 | 29 | void wayland_helpers_callback_registry_shm( 30 | void* data, 31 | void* registry, 32 | uint32_t name, 33 | const char* interface, 34 | uint32_t version); 35 | 36 | void wayland_helpers_buffer_release( 37 | void* data, 38 | struct wl_buffer* wl_buffer); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/common/globuf_private.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_PRIVATE 2 | #define H_GLOBUF_PRIVATE 3 | 4 | #include "include/globuf.h" 5 | #include "common/globuf_error.h" 6 | 7 | struct globuf 8 | { 9 | // common 10 | struct globuf_config_features features; 11 | 12 | // not common but neutral in signature 13 | void* backend_data; 14 | struct globuf_config_render render_callback; 15 | struct globuf_config_events event_callbacks; 16 | struct globuf_config_backend backend_callbacks; 17 | struct globuf_rect expose; 18 | 19 | // error handling 20 | char* error_messages[GLOBUF_ERROR_COUNT]; 21 | 22 | // features 23 | struct globuf_feature_interaction* feature_interaction; 24 | struct globuf_feature_state* feature_state; 25 | struct globuf_feature_title* feature_title; 26 | struct globuf_feature_icon* feature_icon; 27 | struct globuf_feature_size* feature_size; 28 | struct globuf_feature_pos* feature_pos; 29 | struct globuf_feature_frame* feature_frame; 30 | struct globuf_feature_background* feature_background; 31 | struct globuf_feature_vsync* feature_vsync; 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/x11/x11_vulkan_helpers.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_X11_VULKAN_HELPERS 2 | #define H_GLOBUF_INTERNAL_X11_VULKAN_HELPERS 3 | 4 | #include "include/globuf.h" 5 | #include "include/globuf_vulkan.h" 6 | #include "x11/x11_common.h" 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | struct x11_vulkan_backend 13 | { 14 | struct x11_platform platform; 15 | struct globuf_config_vulkan* config; 16 | 17 | // vulkan extensions used by globuf 18 | uint32_t ext_len; 19 | const char** ext_needed; 20 | bool* ext_found; 21 | 22 | VkSurfaceKHR surface; 23 | VkXcbSurfaceCreateInfoKHR vulkan_info; 24 | }; 25 | 26 | size_t x11_helpers_vulkan_add_extensions( 27 | struct globuf* context, 28 | const char*** ext_needed, 29 | bool** ext_found, 30 | struct globuf_error_info* error); 31 | 32 | void x11_helpers_vulkan_visual_transparent( 33 | struct globuf* context, 34 | struct globuf_error_info* error); 35 | 36 | void x11_helpers_vulkan_visual_opaque( 37 | struct globuf* context, 38 | struct globuf_error_info* error); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /ci/globuf_image_wayland_gcc/scripts/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # git cloning the repo 4 | # bash running the build scripts 5 | # samurai building the binaries 6 | # gcc compiling the code 7 | # musl-dev standard C library 8 | # curl getting companion libs 9 | # libxkbcommon-dev complex example 10 | # wayland wayland libs for client, cursor, egl 11 | # wayland-dev wayland headers 12 | # wayland-protocols wayland XDG protocols 13 | # plasma-wayland-protocols wayland KDE blur protocol 14 | 15 | apk add --no-cache \ 16 | git \ 17 | bash \ 18 | samurai \ 19 | gcc \ 20 | musl-dev \ 21 | curl \ 22 | libxkbcommon-dev \ 23 | wayland \ 24 | wayland-dev \ 25 | wayland-protocols \ 26 | plasma-wayland-protocols \ 27 | mesa-dev \ 28 | mesa-egl \ 29 | vulkan-tools \ 30 | vulkan-headers \ 31 | vulkan-loader-dev 32 | 33 | apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing/ \ 34 | vulkan-validation-layers-dbg \ 35 | vulkan-validation-layers-dev \ 36 | vulkan-validation-layers-static 37 | -------------------------------------------------------------------------------- /src/x11/symbols_common.txt: -------------------------------------------------------------------------------- 1 | globuf_x11_common_init 2 | globuf_x11_common_clean 3 | globuf_x11_common_window_create 4 | globuf_x11_common_window_destroy 5 | globuf_x11_common_window_confirm 6 | globuf_x11_common_window_start 7 | globuf_x11_common_window_block 8 | globuf_x11_common_window_stop 9 | globuf_x11_common_init_render 10 | globuf_x11_common_init_events 11 | globuf_x11_common_handle_events 12 | globuf_x11_common_init_features 13 | globuf_x11_common_feature_set_interaction 14 | globuf_x11_common_feature_set_state 15 | globuf_x11_common_feature_set_title 16 | globuf_x11_common_feature_set_icon 17 | globuf_x11_common_get_width 18 | globuf_x11_common_get_height 19 | globuf_x11_common_get_expose 20 | globuf_get_x11_conn 21 | globuf_get_x11_window 22 | globuf_get_x11_root 23 | globuf_get_x11_screen 24 | globuf_x11_helpers_render_loop 25 | globuf_x11_helpers_event_loop 26 | globuf_x11_helpers_features_init 27 | globuf_x11_helpers_handle_interaction 28 | globuf_x11_helpers_set_state 29 | globuf_x11_helpers_set_title 30 | globuf_x11_helpers_set_icon 31 | globuf_x11_helpers_set_frame 32 | globuf_x11_helpers_set_background 33 | globuf_x11_helpers_set_vsync 34 | globuf_x11_helpers_get_state 35 | globuf_x11_helpers_get_title 36 | globuf_x11_helpers_xcb_error_log 37 | -------------------------------------------------------------------------------- /src/win/symbols_common.txt: -------------------------------------------------------------------------------- 1 | globuf_win_common_init 2 | globuf_win_common_clean 3 | globuf_win_common_window_create 4 | globuf_win_common_window_destroy 5 | globuf_win_common_window_confirm 6 | globuf_win_common_window_start 7 | globuf_win_common_window_block 8 | globuf_win_common_window_stop 9 | globuf_win_common_init_render 10 | globuf_win_common_init_events 11 | globuf_win_common_handle_events 12 | globuf_win_common_init_features 13 | globuf_win_common_feature_set_interaction 14 | globuf_win_common_feature_set_state 15 | globuf_win_common_feature_set_title 16 | globuf_win_common_feature_set_icon 17 | globuf_win_common_get_width 18 | globuf_win_common_get_height 19 | globuf_win_common_get_expose 20 | globuf_win_helpers_render_loop 21 | globuf_win_helpers_event_loop 22 | globuf_win_helpers_window_procedure 23 | globuf_win_helpers_features_init 24 | globuf_win_helpers_set_state 25 | globuf_win_helpers_utf8_to_wchar 26 | globuf_win_helpers_bitmap_to_icon 27 | globuf_win_helpers_save_window_state 28 | globuf_win_helpers_set_dpi_awareness 29 | globuf_win_helpers_set_title 30 | globuf_win_helpers_set_icon 31 | globuf_win_helpers_set_frame 32 | globuf_win_helpers_set_background 33 | globuf_win_helpers_set_vsync 34 | globuf_win_helpers_win32_error_log 35 | globuf_get_win_surface 36 | -------------------------------------------------------------------------------- /src/appkit/appkit_egl_helpers.m: -------------------------------------------------------------------------------- 1 | #define _XOPEN_SOURCE 700 2 | 3 | #include "include/globuf.h" 4 | #include "common/globuf_private.h" 5 | #include "appkit/appkit_egl_helpers.h" 6 | #include "appkit/appkit_egl.h" 7 | #include "appkit/appkit_common.h" 8 | #include 9 | #include 10 | #include 11 | 12 | void appkit_helpers_egl_bind(struct globuf* context, struct globuf_error_info* error) 13 | { 14 | struct appkit_egl_backend* backend = context->backend_data; 15 | 16 | // bind context to surface 17 | EGLBoolean error_egl; 18 | 19 | error_egl = 20 | eglMakeCurrent( 21 | backend->display, 22 | backend->surface, 23 | backend->surface, 24 | backend->egl); 25 | 26 | if (error_egl == EGL_FALSE) 27 | { 28 | globuf_error_throw(context, error, GLOBUF_ERROR_MACOS_EGL_MAKE_CURRENT); 29 | return; 30 | } 31 | 32 | // set swap interval 33 | int interval; 34 | 35 | if (context->feature_vsync->vsync == true) 36 | { 37 | interval = 1; 38 | } 39 | else 40 | { 41 | interval = 0; 42 | } 43 | 44 | error_egl = eglSwapInterval(backend->display, interval); 45 | 46 | if (error_egl == EGL_FALSE) 47 | { 48 | globuf_error_throw(context, error, GLOBUF_ERROR_MACOS_EGL_SWAP_INTERVAL); 49 | return; 50 | } 51 | 52 | globuf_error_ok(error); 53 | } 54 | -------------------------------------------------------------------------------- /src/wayland/wayland_software_helpers.c: -------------------------------------------------------------------------------- 1 | #define _XOPEN_SOURCE 700 2 | 3 | #include "include/globuf.h" 4 | #include "common/globuf_private.h" 5 | #include "wayland/wayland_software_helpers.h" 6 | #include "wayland/wayland_software.h" 7 | #include "wayland/wayland_common.h" 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | void wayland_helpers_callback_registry_shm( 15 | void* data, 16 | void* registry, 17 | uint32_t name, 18 | const char* interface, 19 | uint32_t version) 20 | { 21 | struct globuf* context = data; 22 | struct wayland_software_backend* backend = context->backend_data; 23 | struct wayland_platform* platform = &(backend->platform); 24 | 25 | int error_posix; 26 | struct globuf_error_info error; 27 | 28 | if (strcmp(interface, wl_shm_interface.name) == 0) 29 | { 30 | backend->shm = 31 | wl_registry_bind( 32 | registry, 33 | name, 34 | &wl_shm_interface, 35 | 1); 36 | 37 | if (backend->shm == NULL) 38 | { 39 | globuf_error_throw( 40 | context, 41 | &error, 42 | GLOBUF_ERROR_WAYLAND_REQUEST); 43 | return; 44 | } 45 | } 46 | } 47 | 48 | void wayland_helpers_buffer_release( 49 | void* data, 50 | struct wl_buffer* buffer) 51 | { 52 | wl_buffer_destroy(buffer); 53 | } 54 | -------------------------------------------------------------------------------- /ci/globuf_image_x11_gcc/scripts/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # git cloning the repo 4 | # bash running the build scripts 5 | # samurai building the binaries 6 | # gcc compiling the code 7 | # musl-dev standard C library 8 | # curl getting companion libs 9 | # libxcb-dev libxcb 10 | # xcb-util-wm-dev xcb_icccm.h 11 | # xcb-util-image-dev xcb_image.h 12 | # libxkbcommon-dev complex example 13 | # xcb-util-xrm-dev complex example 14 | # xcb-util-renderutil-dev complex example 15 | # xcb-util-cursor-dev complex example 16 | # xcb-util-errors-dev xcb_errors.h 17 | 18 | apk add --no-cache \ 19 | git \ 20 | bash \ 21 | samurai \ 22 | gcc \ 23 | musl-dev \ 24 | curl \ 25 | libxcb-dev \ 26 | libxrender-dev \ 27 | xcb-util-wm-dev \ 28 | xcb-util-image-dev \ 29 | libxkbcommon-dev \ 30 | xcb-util-xrm-dev \ 31 | xcb-util-renderutil-dev \ 32 | xcb-util-cursor-dev \ 33 | mesa-dev \ 34 | mesa-egl \ 35 | vulkan-tools \ 36 | vulkan-headers \ 37 | vulkan-loader-dev 38 | 39 | apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing/ \ 40 | vulkan-validation-layers-dbg \ 41 | vulkan-validation-layers-dev \ 42 | vulkan-validation-layers-static 43 | -------------------------------------------------------------------------------- /src/wayland/symbols_common.txt: -------------------------------------------------------------------------------- 1 | globuf_wayland_common_init 2 | globuf_wayland_common_clean 3 | globuf_wayland_common_window_create 4 | globuf_wayland_common_window_destroy 5 | globuf_wayland_common_window_confirm 6 | globuf_wayland_common_window_start 7 | globuf_wayland_common_window_block 8 | globuf_wayland_common_window_stop 9 | globuf_wayland_common_init_render 10 | globuf_wayland_common_init_events 11 | globuf_wayland_common_handle_events 12 | globuf_wayland_common_init_features 13 | globuf_wayland_common_feature_set_interaction 14 | globuf_wayland_common_feature_set_state 15 | globuf_wayland_common_feature_set_title 16 | globuf_wayland_common_feature_set_icon 17 | globuf_wayland_common_get_width 18 | globuf_wayland_common_get_height 19 | globuf_wayland_common_get_expose 20 | globuf_add_wayland_capabilities_handler 21 | globuf_add_wayland_registry_handler 22 | globuf_add_wayland_registry_remover 23 | globuf_get_wayland_surface 24 | globuf_wayland_helpers_render_loop 25 | globuf_wayland_helpers_event_loop 26 | globuf_wayland_helpers_features_init 27 | globuf_wayland_helpers_handle_interaction 28 | globuf_wayland_helpers_set_state 29 | globuf_wayland_helpers_set_title 30 | globuf_wayland_helpers_set_icon 31 | globuf_wayland_helpers_set_frame 32 | globuf_wayland_helpers_set_background 33 | globuf_wayland_helpers_set_vsync 34 | globuf_wayland_helpers_get_state 35 | globuf_wayland_helpers_get_title 36 | -------------------------------------------------------------------------------- /make/scripts/infer_run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # get in the right folder 4 | path="$(pwd)/$0" 5 | folder=$(dirname "$path") 6 | cd "$folder"/../.. || exit 7 | 8 | # get params 9 | build_type=$1 10 | build_platform=$2 11 | build_backend=$3 12 | 13 | # set params default values if needed 14 | if [ -z "$build_type" ]; then 15 | build_type=development 16 | fi 17 | 18 | if [ -z "$build_platform" ]; then 19 | build_platform=x11 20 | fi 21 | 22 | if [ -z "$build_backend" ]; then 23 | build_backend=software 24 | fi 25 | 26 | # clean 27 | json=make/output/build_"$build_platform"_"$build_backend".json 28 | folder=infer_"$build_platform"_"$build_backend" 29 | rm -rf "$folder" "$json" 30 | 31 | # generate ninja files 32 | case $build_platform in 33 | x11) 34 | samu -f make/output/lib_elf.ninja -t compdb ar cc cp clean > "$json" 35 | samu -f make/output/lib_x11_common.ninja -t compdb ar cc cp clean >> "$json" 36 | samu -f make/output/lib_x11_"$build_backend".ninja -t compdb ar cc cp clean >> "$json" 37 | samu -f make/output/example_simple_x11_"$build_backend".ninja -t compdb ar cc cp clean >> "$json" 38 | ;; 39 | 40 | *) 41 | echo "invalid platform: $build_platform" 42 | exit 1 43 | ;; 44 | esac 45 | 46 | jq -s 'add' "$json" > "$json".new 47 | mv "$json".new "$json" 48 | sed -i 's/ar rcs /ar /' "$json" 49 | ./res/infer/bin/infer -o "$folder" --compilation-database "$json" 50 | less "$folder"/report.txt 51 | -------------------------------------------------------------------------------- /src/x11/x11_glx_helpers.c: -------------------------------------------------------------------------------- 1 | #define _XOPEN_SOURCE 700 2 | 3 | #include "include/globuf.h" 4 | #include "common/globuf_private.h" 5 | #include "x11/x11_glx_helpers.h" 6 | #include "x11/x11_glx.h" 7 | #include "x11/x11_common.h" 8 | #include 9 | #include 10 | #include 11 | 12 | bool x11_helpers_glx_ext_support(const char *list, const char *extension) 13 | { 14 | const char* beg = list; 15 | const char* end; 16 | const char* cur; 17 | 18 | cur = strstr(beg, extension); 19 | 20 | while (cur != NULL) 21 | { 22 | end = cur + strlen(extension); 23 | 24 | // the extension name might be a subset of another one so 25 | // we must check the surrouding characters to make sure 26 | if (((cur == beg) || (cur[-1] == ' ')) 27 | && ((end[0] == '\0') || (end[0] == ' '))) 28 | { 29 | return true; 30 | } 31 | 32 | beg = end; 33 | cur = strstr(beg, extension); 34 | } 35 | 36 | return false; 37 | } 38 | 39 | void x11_helpers_glx_bind(struct globuf* context, struct globuf_error_info* error) 40 | { 41 | struct x11_glx_backend* backend = context->backend_data; 42 | 43 | Bool error_glx = 44 | glXMakeContextCurrent( 45 | backend->display, 46 | backend->win, 47 | backend->win, 48 | backend->glx); 49 | 50 | if (error_glx == False) 51 | { 52 | globuf_error_throw(context, error, GLOBUF_ERROR_X11_GLX_MAKE_CURRENT); 53 | return; 54 | } 55 | 56 | globuf_error_ok(error); 57 | } 58 | -------------------------------------------------------------------------------- /src/common/globuf_vulkan.c: -------------------------------------------------------------------------------- 1 | #include "include/globuf.h" 2 | #include "include/globuf_vulkan.h" 3 | #include "common/globuf_private.h" 4 | #include 5 | #include 6 | 7 | void globuf_init_vulkan( 8 | struct globuf* context, 9 | struct globuf_config_vulkan* config, 10 | struct globuf_error_info* error) 11 | { 12 | struct globuf_calls_vulkan* vulkan = context->backend_callbacks.data; 13 | 14 | vulkan->init( 15 | context, 16 | config, 17 | error); 18 | } 19 | 20 | void globuf_get_extensions_vulkan( 21 | struct globuf* context, 22 | uint32_t* len, 23 | const char*** list, 24 | struct globuf_error_info* error) 25 | { 26 | struct globuf_calls_vulkan* vulkan = context->backend_callbacks.data; 27 | 28 | vulkan->get_extensions( 29 | context, 30 | len, 31 | list, 32 | error); 33 | } 34 | 35 | VkBool32 globuf_presentation_support_vulkan( 36 | struct globuf* context, 37 | VkPhysicalDevice physical_device, 38 | uint32_t queue_family_index, 39 | struct globuf_error_info* error) 40 | { 41 | struct globuf_calls_vulkan* vulkan = context->backend_callbacks.data; 42 | 43 | return vulkan->presentation_support( 44 | context, 45 | physical_device, 46 | queue_family_index, 47 | error); 48 | } 49 | 50 | VkSurfaceKHR* globuf_get_surface_vulkan( 51 | struct globuf* context, 52 | struct globuf_error_info* error) 53 | { 54 | struct globuf_calls_vulkan* vulkan = context->backend_callbacks.data; 55 | 56 | return vulkan->get_surface( 57 | context, 58 | error); 59 | } 60 | -------------------------------------------------------------------------------- /src/win/win_vulkan_helpers.c: -------------------------------------------------------------------------------- 1 | #include "include/globuf.h" 2 | #include "common/globuf_private.h" 3 | #include "win/win_vulkan_helpers.h" 4 | #include "win/win_vulkan.h" 5 | #include "win/win_common.h" 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | size_t win_helpers_vulkan_add_extensions( 13 | struct globuf* context, 14 | const char*** ext_needed, 15 | bool** ext_found, 16 | struct globuf_error_info* error) 17 | { 18 | // list vulkan extensions here to make the code cleaner 19 | const char* extensions_names[] = 20 | { 21 | VK_EXT_DEBUG_REPORT_EXTENSION_NAME, 22 | VK_KHR_SURFACE_EXTENSION_NAME, 23 | VK_KHR_WIN32_SURFACE_EXTENSION_NAME, 24 | }; 25 | 26 | size_t extensions_count = 27 | (sizeof (extensions_names)) / (sizeof (const char*)); 28 | 29 | // allocate required extensions list 30 | *ext_needed = malloc(extensions_count * sizeof (char*)); 31 | 32 | if (*ext_needed == NULL) 33 | { 34 | globuf_error_throw(context, error, GLOBUF_ERROR_ALLOC); 35 | return 0; 36 | } 37 | 38 | // allocate found required extensions list 39 | *ext_found = malloc(extensions_count * sizeof (bool)); 40 | 41 | if (*ext_found == NULL) 42 | { 43 | globuf_error_throw(context, error, GLOBUF_ERROR_ALLOC); 44 | return 0; 45 | } 46 | 47 | // initialize values 48 | for (size_t i = 0; i < extensions_count; ++i) 49 | { 50 | (*ext_needed)[i] = extensions_names[i]; 51 | (*ext_found)[i] = false; 52 | } 53 | 54 | globuf_error_ok(error); 55 | 56 | return extensions_count; 57 | } 58 | -------------------------------------------------------------------------------- /make/lib/shared/win.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # get into the script's folder 4 | cd "$(dirname "$0")" || exit 5 | cd ../../.. 6 | 7 | # params 8 | backend=$1 9 | 10 | function syntax { 11 | echo "syntax reminder: $0 " 12 | echo "backend types: software, wgl, vulkan" 13 | } 14 | 15 | # utilitary variables 16 | tag=$(git tag --sort v:refname | tail -n 1) 17 | folder_ninja="build" 18 | folder_objects="$folder_ninja/shared" 19 | folder_globuf="globuf_bin_$tag" 20 | folder_library="$folder_globuf/lib/globuf" 21 | mkdir -p "$folder_objects" 22 | 23 | # list link flags (order matters) 24 | link+=("-lshcore") 25 | link+=("-lgdi32") 26 | link+=("-ldwmapi") 27 | 28 | if [ -z "$backend" ]; then 29 | backend=software 30 | fi 31 | 32 | case $backend in 33 | software) 34 | ;; 35 | 36 | wgl) 37 | link+=("-lopengl32") 38 | ;; 39 | 40 | vulkan) 41 | link+=("-lvulkan-1") 42 | ;; 43 | 44 | *) 45 | echo "invalid backend" 46 | syntax 47 | exit 1 48 | ;; 49 | esac 50 | 51 | # list objs (order matters) 52 | obj+=("$folder_objects/globuf_win_common.o") 53 | obj+=("$folder_objects/globuf_win_$backend.o") 54 | obj+=("$folder_objects/globuf_pe.o") 55 | 56 | # parse soname 57 | soname="$folder_library/win/globuf_win_$backend.dll" 58 | 59 | # extract objects from static archives 60 | ar --output "$folder_objects" -x "$folder_library/win/globuf_win_common.a" 61 | ar --output "$folder_objects" -x "$folder_library/win/globuf_win_$backend.a" 62 | ar --output "$folder_objects" -x "$folder_library/globuf_pe.a" 63 | 64 | # build shared object 65 | x86_64-w64-mingw32-gcc -shared -o $soname "${obj[@]}" "${link[@]}" 66 | -------------------------------------------------------------------------------- /src/include/globuf_vulkan.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_VULKAN 2 | #define H_GLOBUF_VULKAN 3 | 4 | #include "globuf.h" 5 | #include 6 | #include 7 | 8 | // common to all backends supporting Vulkan rendering 9 | 10 | struct globuf_config_vulkan 11 | { 12 | VkInstance instance; 13 | VkAllocationCallbacks* allocator; 14 | }; 15 | 16 | struct globuf_calls_vulkan 17 | { 18 | void (*init)( 19 | struct globuf* context, 20 | struct globuf_config_vulkan* config, 21 | struct globuf_error_info* error); 22 | 23 | void (*get_extensions)( 24 | struct globuf* context, 25 | uint32_t* len, 26 | const char*** list, 27 | struct globuf_error_info* error); 28 | 29 | VkBool32 (*presentation_support)( 30 | struct globuf* context, 31 | VkPhysicalDevice physical_device, 32 | uint32_t queue_family_index, 33 | struct globuf_error_info* error); 34 | 35 | VkSurfaceKHR* (*get_surface)( 36 | struct globuf* context, 37 | struct globuf_error_info* error); 38 | }; 39 | 40 | void globuf_init_vulkan( 41 | struct globuf* context, 42 | struct globuf_config_vulkan* config, 43 | struct globuf_error_info* error); 44 | 45 | void globuf_get_extensions_vulkan( 46 | struct globuf* context, 47 | uint32_t* len, 48 | const char*** list, 49 | struct globuf_error_info* error); 50 | 51 | VkBool32 globuf_presentation_support_vulkan( 52 | struct globuf* context, 53 | VkPhysicalDevice physical_device, 54 | uint32_t queue_family_index, 55 | struct globuf_error_info* error); 56 | 57 | VkSurfaceKHR* globuf_get_surface_vulkan( 58 | struct globuf* context, 59 | struct globuf_error_info* error); 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /src/appkit/appkit_common_helpers.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_APPKIT_COMMON_HELPERS 2 | #define H_GLOBUF_INTERNAL_APPKIT_COMMON_HELPERS 3 | 4 | #include "include/globuf.h" 5 | #include "appkit/appkit_common.h" 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #import 12 | 13 | @interface GlobufWindow: NSWindow 14 | @property struct appkit_thread_event_loop_data* globufEventData; 15 | - (void) sendEvent: (NSEvent*) event; 16 | - (void) zoom: (id) sender; 17 | @end 18 | 19 | @interface GlobufWindowDelegate: NSObject 20 | @property struct appkit_window_delegate_data* globufDelegateData; 21 | @end 22 | 23 | @interface GlobufLayerDelegate: NSObject 24 | @property struct appkit_layer_delegate_data* globufLayerDelegateData; 25 | - (void) displayLayer: (CALayer*) layer; 26 | @end 27 | 28 | void* globuf_appkit_helpers_render_loop( 29 | void* data); 30 | 31 | void globuf_appkit_helpers_features_init( 32 | struct globuf* context, 33 | struct appkit_platform* platform, 34 | struct globuf_config_request* configs, 35 | size_t count, 36 | struct globuf_error_info* error); 37 | 38 | void globuf_appkit_helpers_send_app_event( 39 | struct globuf* context, 40 | struct appkit_platform* platform, 41 | enum globuf_event event); 42 | 43 | void globuf_appkit_helpers_set_state( 44 | struct globuf* context, 45 | id window, 46 | struct globuf_feature_state* config, 47 | struct globuf_error_info* error); 48 | 49 | void globuf_appkit_helpers_handle_interaction( 50 | struct globuf* context, 51 | struct appkit_platform* platform, 52 | struct globuf_error_info* error); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /src/wayland/wayland_vulkan_helpers.c: -------------------------------------------------------------------------------- 1 | #define _XOPEN_SOURCE 700 2 | 3 | #include "include/globuf.h" 4 | #include "common/globuf_private.h" 5 | #include "wayland/wayland_vulkan_helpers.h" 6 | #include "wayland/wayland_vulkan.h" 7 | #include "wayland/wayland_common.h" 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | size_t wayland_helpers_vulkan_add_extensions( 16 | struct globuf* context, 17 | const char*** ext_needed, 18 | bool** ext_found, 19 | struct globuf_error_info* error) 20 | { 21 | // list vulkan extensions here to make the code cleaner 22 | const char* extensions_names[] = 23 | { 24 | VK_EXT_DEBUG_REPORT_EXTENSION_NAME, 25 | VK_KHR_SURFACE_EXTENSION_NAME, 26 | VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME, 27 | }; 28 | 29 | size_t extensions_count = 30 | (sizeof (extensions_names)) / (sizeof (const char*)); 31 | 32 | // allocate required extensions list 33 | *ext_needed = malloc(extensions_count * sizeof (char*)); 34 | 35 | if (*ext_needed == NULL) 36 | { 37 | globuf_error_throw(context, error, GLOBUF_ERROR_ALLOC); 38 | return 0; 39 | } 40 | 41 | // allocate found required extensions list 42 | *ext_found = malloc(extensions_count * sizeof (bool)); 43 | 44 | if (*ext_found == NULL) 45 | { 46 | globuf_error_throw(context, error, GLOBUF_ERROR_ALLOC); 47 | return 0; 48 | } 49 | 50 | // initialize values 51 | for (size_t i = 0; i < extensions_count; ++i) 52 | { 53 | (*ext_needed)[i] = extensions_names[i]; 54 | (*ext_found)[i] = false; 55 | } 56 | 57 | globuf_error_ok(error); 58 | 59 | return extensions_count; 60 | } 61 | -------------------------------------------------------------------------------- /src/appkit/appkit_vulkan_helpers.m: -------------------------------------------------------------------------------- 1 | #define _XOPEN_SOURCE 700 2 | 3 | #include "include/globuf.h" 4 | #include "common/globuf_private.h" 5 | #include "appkit/appkit_vulkan_helpers.h" 6 | #include "appkit/appkit_vulkan.h" 7 | #include "appkit/appkit_common.h" 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #import 16 | 17 | size_t appkit_helpers_vulkan_add_extensions( 18 | struct globuf* context, 19 | const char*** ext_needed, 20 | bool** ext_found, 21 | struct globuf_error_info* error) 22 | { 23 | // list vulkan extensions here to make the code cleaner 24 | const char* extensions_names[] = 25 | { 26 | VK_EXT_DEBUG_REPORT_EXTENSION_NAME, 27 | VK_KHR_SURFACE_EXTENSION_NAME, 28 | VK_EXT_METAL_SURFACE_EXTENSION_NAME, 29 | }; 30 | 31 | size_t extensions_count = 32 | (sizeof (extensions_names)) / (sizeof (const char*)); 33 | 34 | // allocate required extensions list 35 | *ext_needed = malloc(extensions_count * sizeof (char*)); 36 | 37 | if (*ext_needed == NULL) 38 | { 39 | globuf_error_throw(context, error, GLOBUF_ERROR_ALLOC); 40 | return 0; 41 | } 42 | 43 | // allocate found required extensions list 44 | *ext_found = malloc(extensions_count * sizeof (bool)); 45 | 46 | if (*ext_found == NULL) 47 | { 48 | globuf_error_throw(context, error, GLOBUF_ERROR_ALLOC); 49 | return 0; 50 | } 51 | 52 | // initialize values 53 | for (size_t i = 0; i < extensions_count; ++i) 54 | { 55 | (*ext_needed)[i] = extensions_names[i]; 56 | (*ext_found)[i] = false; 57 | } 58 | 59 | globuf_error_ok(error); 60 | 61 | return extensions_count; 62 | } 63 | -------------------------------------------------------------------------------- /make/lib/shared/wayland.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # get into the script's folder 4 | cd "$(dirname "$0")" || exit 5 | cd ../../.. 6 | 7 | # params 8 | backend=$1 9 | 10 | function syntax { 11 | echo "syntax reminder: $0 " 12 | echo "backend types: software, egl, vulkan" 13 | } 14 | 15 | # utilitary variables 16 | tag=$(git tag --sort v:refname | tail -n 1) 17 | folder_ninja="build" 18 | folder_objects="$folder_ninja/shared" 19 | folder_globuf="globuf_bin_$tag" 20 | folder_library="$folder_globuf/lib/globuf" 21 | mkdir -p "$folder_objects" 22 | 23 | # list link flags (order matters) 24 | link+=("-lwayland-client") 25 | link+=("-lwayland-cursor") 26 | link+=("-lxkbcommon") 27 | link+=("-lpthread") 28 | 29 | if [ -z "$backend" ]; then 30 | backend=software 31 | fi 32 | 33 | case $backend in 34 | software) 35 | ;; 36 | 37 | egl) 38 | link+=("-lEGL") 39 | link+=("-lGLESv2") 40 | link+=("-lwayland-egl") 41 | ;; 42 | 43 | vulkan) 44 | link+=("-lvulkan") 45 | link+=("-lxcb-render") 46 | ;; 47 | 48 | *) 49 | echo "invalid backend" 50 | syntax 51 | exit 1 52 | ;; 53 | esac 54 | 55 | # list objs (order matters) 56 | obj+=("$folder_objects/globuf_wayland_common.o") 57 | obj+=("$folder_objects/globuf_wayland_$backend.o") 58 | obj+=("$folder_objects/globuf_elf.o") 59 | 60 | # parse soname 61 | soname="$folder_library/wayland/globuf_wayland_$backend.so" 62 | 63 | # extract objects from static archives 64 | ar --output "$folder_objects" -x "$folder_library/wayland/globuf_wayland_common.a" 65 | ar --output "$folder_objects" -x "$folder_library/wayland/globuf_wayland_$backend.a" 66 | ar --output "$folder_objects" -x "$folder_library/globuf_elf.a" 67 | 68 | # build shared object 69 | gcc -shared -o $soname "${obj[@]}" "${link[@]}" 70 | -------------------------------------------------------------------------------- /make/scripts/package_app.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # get in the right folder 4 | path="$(pwd)/$0" 5 | folder=$(dirname "$path") 6 | cd "$folder"/../.. || exit 7 | 8 | # copy template app 9 | cp -r res/app/globuf.app "$1.app" 10 | 11 | # copy the binary in the app 12 | mkdir "$1.app/Contents/MacOS" 13 | cp "$1" "$1.app/Contents/MacOS/globuf" 14 | 15 | # copy the icons bundle in the app 16 | mkdir "$1.app/Contents/Resources" 17 | cp res/app/icon.icns "$1.app/Contents/Resources/globuf.icns" 18 | 19 | # install the ANGLE dylibs in the app (and copy in the build folder) 20 | if [ "$2" == "egl" ]; then 21 | build=$(dirname "$1") 22 | cp res/angle/libs/* "$build" 23 | cp res/angle/libs/* "$1.app/Contents/MacOS/" 24 | 25 | if [ "$3" == "native" ]; then 26 | install_name_tool -change ./libEGL.dylib @executable_path/libEGL.dylib "$1.app/Contents/MacOS/globuf" 27 | install_name_tool -change ./libGLESv2.dylib @executable_path/libGLESv2.dylib "$1.app/Contents/MacOS/globuf" 28 | else 29 | x86_64-apple-darwin21.4-install_name_tool -change ./libEGL.dylib @executable_path/libEGL.dylib "$1.app/Contents/MacOS/globuf" 30 | x86_64-apple-darwin21.4-install_name_tool -change ./libGLESv2.dylib @executable_path/libGLESv2.dylib "$1.app/Contents/MacOS/globuf" 31 | fi 32 | 33 | fi 34 | 35 | # install the MoltenVK dylibs in the app (and copy in the build folder) 36 | if [ "$2" == "vulkan" ]; then 37 | build=$(dirname "$1") 38 | cp res/moltenvk/libs/* "$build" 39 | cp res/moltenvk/libs/* "$1.app/Contents/MacOS/" 40 | 41 | if [ "$3" == "native" ]; then 42 | install_name_tool -change ./libMoltenVK.dylib @executable_path/libMoltenVK.dylib "$1.app/Contents/MacOS/globuf" 43 | else 44 | x86_64-apple-darwin21.4-install_name_tool -change ./libMoltenVK.dylib @executable_path/libMoltenVK.dylib "$1.app/Contents/MacOS/globuf" 45 | fi 46 | 47 | fi 48 | -------------------------------------------------------------------------------- /src/x11/x11_egl_helpers.c: -------------------------------------------------------------------------------- 1 | #define _XOPEN_SOURCE 700 2 | 3 | #include "include/globuf.h" 4 | #include "common/globuf_private.h" 5 | #include "x11/x11_egl_helpers.h" 6 | #include "x11/x11_egl.h" 7 | #include "x11/x11_common.h" 8 | #include 9 | #include 10 | #include 11 | 12 | bool x11_helpers_egl_ext_support(const char *list, const char *extension) 13 | { 14 | const char* beg = list; 15 | const char* end; 16 | const char* cur; 17 | 18 | cur = strstr(beg, extension); 19 | 20 | while (cur != NULL) 21 | { 22 | end = cur + strlen(extension); 23 | 24 | // the extension name might be a subset of another one so 25 | // we must check the surrouding characters to make sure 26 | if (((cur == beg) || (cur[-1] == ' ')) 27 | && ((end[0] == '\0') || (end[0] == ' '))) 28 | { 29 | return true; 30 | } 31 | 32 | beg = end; 33 | cur = strstr(beg, extension); 34 | } 35 | 36 | return false; 37 | } 38 | 39 | void x11_helpers_egl_bind(struct globuf* context, struct globuf_error_info* error) 40 | { 41 | struct x11_egl_backend* backend = context->backend_data; 42 | 43 | // bind context to surface 44 | EGLBoolean error_egl; 45 | 46 | error_egl = 47 | eglMakeCurrent( 48 | backend->display, 49 | backend->surface, 50 | backend->surface, 51 | backend->egl); 52 | 53 | if (error_egl == EGL_FALSE) 54 | { 55 | globuf_error_throw(context, error, GLOBUF_ERROR_X11_EGL_MAKE_CURRENT); 56 | return; 57 | } 58 | 59 | // set swap interval 60 | int interval; 61 | 62 | if (context->feature_vsync->vsync == true) 63 | { 64 | interval = 1; 65 | } 66 | else 67 | { 68 | interval = 0; 69 | } 70 | 71 | error_egl = eglSwapInterval(backend->display, interval); 72 | 73 | if (error_egl == EGL_FALSE) 74 | { 75 | globuf_error_throw(context, error, GLOBUF_ERROR_X11_EGL_SWAP_INTERVAL); 76 | return; 77 | } 78 | 79 | globuf_error_ok(error); 80 | } 81 | -------------------------------------------------------------------------------- /make/lib/shared/appkit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # get into the script's folder 4 | cd "$(dirname "$0")" || exit 5 | cd ../../.. 6 | 7 | # params 8 | backend=$1 9 | 10 | function syntax { 11 | echo "syntax reminder: $0 " 12 | echo "backend types: software, egl, vulkan" 13 | } 14 | 15 | # utilitary variables 16 | tag=$(git tag --sort v:refname | tail -n 1) 17 | folder_ninja="build" 18 | folder_objects="$folder_ninja/shared" 19 | folder_globuf="globuf_bin_$tag" 20 | folder_library="$folder_globuf/lib/globuf" 21 | mkdir -p "$folder_objects" 22 | 23 | # list link flags (order matters) 24 | link+=("-framework") 25 | link+=("AppKit") 26 | link+=("-framework") 27 | link+=("QuartzCore") 28 | 29 | if [ -z "$backend" ]; then 30 | backend=software 31 | fi 32 | 33 | case $backend in 34 | software) 35 | ;; 36 | 37 | egl) 38 | link+=("-Lres/angle/libs") 39 | link+=("-lEGL") 40 | link+=("-lGLESv2") 41 | ;; 42 | 43 | vulkan) 44 | link+=("-Lres/moltenvk/libs") 45 | link+=("-lc++") 46 | link+=("-framework") 47 | link+=("Metal") 48 | link+=("-framework") 49 | link+=("MetalKit") 50 | link+=("-framework") 51 | link+=("Foundation") 52 | link+=("-framework") 53 | link+=("QuartzCore") 54 | link+=("-framework") 55 | link+=("IOKit") 56 | link+=("-framework") 57 | link+=("IOSurface") 58 | link+=("-lMoltenVK") 59 | ;; 60 | 61 | *) 62 | echo "invalid backend" 63 | syntax 64 | exit 1 65 | ;; 66 | esac 67 | 68 | # parse soname 69 | soname="$folder_library/appkit/globuf_appkit_$backend.dylib" 70 | 71 | # extract objects from static archives 72 | cd "$folder_objects" 73 | ar -x "../../$folder_library/appkit/globuf_appkit_common_native.a" 74 | ar -x "../../$folder_library/appkit/globuf_appkit_""$backend""_native.a" 75 | ar -x "../../$folder_library/globuf_macho_native.a" 76 | cd ../.. 77 | 78 | # build shared object 79 | clang -shared -o $soname $folder_objects/*.o "${link[@]}" 80 | -------------------------------------------------------------------------------- /make/scripts/wayland_get.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # get in the right folder 4 | path="$(pwd)/$0" 5 | folder=$(dirname "$path") 6 | cd "$folder"/../.. || exit 7 | 8 | # get wayland headers 9 | mkdir -p res/wayland_headers 10 | 11 | wayland-scanner private-code \ 12 | < /usr/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml \ 13 | > res/wayland_headers/xdg-shell-protocol.c 14 | wayland-scanner client-header \ 15 | < /usr/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml \ 16 | > res/wayland_headers/xdg-shell-client-protocol.h 17 | 18 | wayland-scanner private-code \ 19 | < /usr/share/wayland-protocols/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml \ 20 | > res/wayland_headers/xdg-decoration-protocol.c 21 | wayland-scanner client-header \ 22 | < /usr/share/wayland-protocols/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml \ 23 | > res/wayland_headers/xdg-decoration-client-protocol.h 24 | 25 | wayland-scanner private-code \ 26 | < /usr/share/plasma-wayland-protocols/blur.xml \ 27 | > res/wayland_headers/kde-blur-protocol.c 28 | wayland-scanner client-header \ 29 | < /usr/share/plasma-wayland-protocols/blur.xml \ 30 | > res/wayland_headers/kde-blur-client-protocol.h 31 | 32 | wayland-scanner private-code \ 33 | < /usr/share/wayland-protocols/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml \ 34 | > res/wayland_headers/zwp-pointer-constraints-protocol.c 35 | wayland-scanner client-header \ 36 | < /usr/share/wayland-protocols/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml \ 37 | > res/wayland_headers/zwp-pointer-constraints-protocol.h 38 | 39 | wayland-scanner private-code \ 40 | < /usr/share/wayland-protocols/unstable/relative-pointer/relative-pointer-unstable-v1.xml \ 41 | > res/wayland_headers/zwp-relative-pointer-protocol.c 42 | wayland-scanner client-header \ 43 | < /usr/share/wayland-protocols/unstable/relative-pointer/relative-pointer-unstable-v1.xml \ 44 | > res/wayland_headers/zwp-relative-pointer-protocol.h 45 | -------------------------------------------------------------------------------- /src/wayland/wayland_common_helpers.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_WAYLAND_COMMON_HELPERS 2 | #define H_GLOBUF_INTERNAL_WAYLAND_COMMON_HELPERS 3 | 4 | #include "include/globuf.h" 5 | #include "wayland/wayland_common.h" 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | void* globuf_wayland_helpers_render_loop( 12 | void* data); 13 | 14 | void* globuf_wayland_helpers_event_loop( 15 | void* data); 16 | 17 | void globuf_wayland_helpers_features_init( 18 | struct globuf* context, 19 | struct wayland_platform* platform, 20 | struct globuf_config_request* configs, 21 | size_t count, 22 | struct globuf_error_info* error); 23 | 24 | void globuf_wayland_helpers_handle_interaction( 25 | struct globuf* context, 26 | struct wayland_platform* platform, 27 | struct globuf_error_info* error); 28 | 29 | void globuf_wayland_helpers_set_state( 30 | struct globuf* context, 31 | struct wayland_platform* platform, 32 | struct globuf_error_info* error); 33 | 34 | void globuf_wayland_helpers_set_title( 35 | struct globuf* context, 36 | struct wayland_platform* platform, 37 | struct globuf_error_info* error); 38 | 39 | void globuf_wayland_helpers_set_icon( 40 | struct globuf* context, 41 | struct wayland_platform* platform, 42 | struct globuf_error_info* error); 43 | 44 | void globuf_wayland_helpers_set_frame( 45 | struct globuf* context, 46 | struct wayland_platform* platform, 47 | struct globuf_error_info* error); 48 | 49 | void globuf_wayland_helpers_set_background( 50 | struct globuf* context, 51 | struct wayland_platform* platform, 52 | struct globuf_error_info* error); 53 | 54 | void globuf_wayland_helpers_set_vsync( 55 | struct globuf* context, 56 | struct wayland_platform* platform, 57 | struct globuf_error_info* error); 58 | 59 | enum globuf_event globuf_wayland_helpers_get_state( 60 | struct globuf* context, 61 | struct wayland_platform* platform, 62 | struct globuf_error_info* error); 63 | 64 | void globuf_wayland_helpers_get_title( 65 | struct globuf* context, 66 | struct wayland_platform* platform, 67 | struct globuf_error_info* error); 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /make/lib/shared/x11.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # get into the script's folder 4 | cd "$(dirname "$0")" || exit 5 | cd ../../.. 6 | 7 | # params 8 | backend=$1 9 | 10 | function syntax { 11 | echo "syntax reminder: $0 " 12 | echo "backend types: software, glx, egl, vulkan" 13 | } 14 | 15 | # utilitary variables 16 | tag=$(git tag --sort v:refname | tail -n 1) 17 | folder_ninja="build" 18 | folder_objects="$folder_ninja/shared" 19 | folder_globuf="globuf_bin_$tag" 20 | folder_library="$folder_globuf/lib/globuf" 21 | mkdir -p "$folder_objects" 22 | 23 | # list link flags (order matters) 24 | link+=("-lxcb-errors") 25 | link+=("-lxcb") 26 | link+=("-lxcb-cursor") 27 | link+=("-lxcb-image") 28 | link+=("-lxcb-render-util") 29 | link+=("-lxcb-sync") 30 | link+=("-lxcb-xfixes") 31 | link+=("-lxcb-xinput") 32 | link+=("-lxcb-xkb") 33 | link+=("-lxcb-xrm") 34 | link+=("-lxkbcommon") 35 | link+=("-lxkbcommon-x11") 36 | link+=("-lpthread") 37 | 38 | if [ -z "$backend" ]; then 39 | backend=software 40 | fi 41 | 42 | case $backend in 43 | software) 44 | link+=("-lxcb-shm") 45 | link+=("-lxcb-randr") 46 | link+=("-lxcb-render") 47 | ;; 48 | 49 | glx) 50 | link+=("-lGL") 51 | link+=("-lGLESv2") 52 | link+=("-lX11") 53 | link+=("-lX11-xcb") 54 | link+=("-lXrender") 55 | ;; 56 | 57 | egl) 58 | link+=("-lEGL") 59 | link+=("-lGLESv2") 60 | ;; 61 | 62 | vulkan) 63 | link+=("-lvulkan") 64 | link+=("-lxcb-render") 65 | ;; 66 | 67 | *) 68 | echo "invalid backend" 69 | syntax 70 | exit 1 71 | ;; 72 | esac 73 | 74 | # list objs (order matters) 75 | obj+=("$folder_objects/globuf_x11_common.o") 76 | obj+=("$folder_objects/globuf_x11_$backend.o") 77 | obj+=("$folder_objects/globuf_elf.o") 78 | 79 | # parse soname 80 | soname="$folder_library/x11/globuf_x11_$backend.so" 81 | 82 | # extract objects from static archives 83 | ar --output "$folder_objects" -x "$folder_library/x11/globuf_x11_common.a" 84 | ar --output "$folder_objects" -x "$folder_library/x11/globuf_x11_$backend.a" 85 | ar --output "$folder_objects" -x "$folder_library/globuf_elf.a" 86 | 87 | # build shared object 88 | gcc -shared -o $soname "${obj[@]}" "${link[@]}" 89 | -------------------------------------------------------------------------------- /src/x11/x11_common_helpers.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_X11_COMMON_HELPERS 2 | #define H_GLOBUF_INTERNAL_X11_COMMON_HELPERS 3 | 4 | #include "include/globuf.h" 5 | #include "x11/x11_common.h" 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | void* globuf_x11_helpers_render_loop( 13 | void* data); 14 | 15 | void* globuf_x11_helpers_event_loop( 16 | void* data); 17 | 18 | void globuf_x11_helpers_features_init( 19 | struct globuf* context, 20 | struct x11_platform* platform, 21 | struct globuf_config_request* configs, 22 | size_t count, 23 | struct globuf_error_info* error); 24 | 25 | void globuf_x11_helpers_handle_interaction( 26 | struct globuf* context, 27 | struct x11_platform* platform, 28 | struct globuf_error_info* error); 29 | 30 | void globuf_x11_helpers_set_state( 31 | struct globuf* context, 32 | struct x11_platform* platform, 33 | struct globuf_error_info* error); 34 | 35 | void globuf_x11_helpers_set_title( 36 | struct globuf* context, 37 | struct x11_platform* platform, 38 | struct globuf_error_info* error); 39 | 40 | void globuf_x11_helpers_set_icon( 41 | struct globuf* context, 42 | struct x11_platform* platform, 43 | struct globuf_error_info* error); 44 | 45 | void globuf_x11_helpers_set_frame( 46 | struct globuf* context, 47 | struct x11_platform* platform, 48 | struct globuf_error_info* error); 49 | 50 | void globuf_x11_helpers_set_background( 51 | struct globuf* context, 52 | struct x11_platform* platform, 53 | struct globuf_error_info* error); 54 | 55 | void globuf_x11_helpers_set_vsync( 56 | struct globuf* context, 57 | struct x11_platform* platform, 58 | struct globuf_error_info* error); 59 | 60 | enum globuf_event globuf_x11_helpers_get_state( 61 | struct globuf* context, 62 | struct x11_platform* platform, 63 | struct globuf_error_info* error); 64 | 65 | void globuf_x11_helpers_get_title( 66 | struct globuf* context, 67 | struct x11_platform* platform, 68 | struct globuf_error_info* error); 69 | 70 | #ifdef GLOBUF_ERROR_HELPER_XCB 71 | void globuf_x11_helpers_xcb_error_log( 72 | struct globuf* context, 73 | struct x11_platform* platform, 74 | xcb_generic_error_t* error); 75 | #endif 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /src/win/win_common_helpers.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_WIN_COMMON_HELPERS 2 | #define H_GLOBUF_INTERNAL_WIN_COMMON_HELPERS 3 | 4 | #include "include/globuf.h" 5 | #include "win/win_common.h" 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | unsigned __stdcall globuf_win_helpers_render_loop(void* data); 12 | 13 | unsigned __stdcall globuf_win_helpers_event_loop(void* data); 14 | 15 | LRESULT CALLBACK globuf_win_helpers_window_procedure( 16 | HWND hwnd, 17 | UINT msg, 18 | WPARAM wParam, 19 | LPARAM lParam); 20 | 21 | void globuf_win_helpers_features_init( 22 | struct globuf* context, 23 | struct win_platform* platform, 24 | struct globuf_config_request* configs, 25 | size_t count, 26 | struct globuf_error_info* error); 27 | 28 | void globuf_win_helpers_set_state( 29 | struct globuf* context, 30 | struct win_platform* platform, 31 | struct globuf_error_info* error); 32 | 33 | LPWSTR globuf_win_helpers_utf8_to_wchar(const char* string); 34 | 35 | HICON globuf_win_helpers_bitmap_to_icon( 36 | struct globuf* context, 37 | struct win_platform* platform, 38 | BITMAP* bmp, 39 | struct globuf_error_info* error); 40 | 41 | void globuf_win_helpers_save_window_state( 42 | struct globuf* context, 43 | struct win_platform* platform, 44 | struct globuf_error_info* error); 45 | 46 | enum win_dpi_api globuf_win_helpers_set_dpi_awareness(); 47 | 48 | void globuf_win_helpers_set_title( 49 | struct globuf* context, 50 | struct win_platform* platform, 51 | struct globuf_error_info* error); 52 | 53 | void globuf_win_helpers_set_icon( 54 | struct globuf* context, 55 | struct win_platform* platform, 56 | struct globuf_error_info* error); 57 | 58 | void globuf_win_helpers_set_frame( 59 | struct globuf* context, 60 | struct win_platform* platform, 61 | struct globuf_error_info* error); 62 | 63 | void globuf_win_helpers_set_background( 64 | struct globuf* context, 65 | struct win_platform* platform, 66 | struct globuf_error_info* error); 67 | 68 | void globuf_win_helpers_set_vsync( 69 | struct globuf* context, 70 | struct win_platform* platform, 71 | struct globuf_error_info* error); 72 | 73 | #ifdef GLOBUF_ERROR_HELPER_WIN 74 | void globuf_win_helpers_win32_error_log(); 75 | #endif 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /example/helpers/vulkan_helpers.h: -------------------------------------------------------------------------------- 1 | #ifndef H_EXAMPLE_VULKAN_HELPERS 2 | #define H_EXAMPLE_VULKAN_HELPERS 3 | 4 | #include "globuf.h" 5 | #include "globuf_vulkan.h" 6 | 7 | #include 8 | #include 9 | 10 | struct globuf_render_data 11 | { 12 | // globuf info 13 | struct globuf* globuf; 14 | struct globuf_config_vulkan config; 15 | 16 | int width; 17 | int height; 18 | bool shaders; 19 | 20 | 21 | // vulkan general info 22 | VkDebugUtilsMessengerEXT debug; 23 | VkInstance instance; 24 | VkDevice device; 25 | VkQueue queue; 26 | 27 | VkShaderModule module_vert; 28 | VkShaderModule module_frag; 29 | 30 | VkSemaphore semaphore_present; 31 | VkSemaphore semaphore_render; 32 | VkFence fence_frame; 33 | 34 | // vulkan physical device 35 | VkPhysicalDevice* phys_devs; 36 | uint32_t phys_devs_index; 37 | uint32_t phys_devs_len; 38 | uint32_t selected_queue; 39 | 40 | // vulkan surface 41 | VkSurfaceKHR* surf; 42 | VkSurfaceCapabilitiesKHR surf_caps; 43 | VkExtent2D extent; 44 | VkFormat format; 45 | VkColorSpaceKHR color_space; 46 | 47 | VkSurfaceFormatKHR* surf_formats; 48 | uint32_t surf_formats_index; 49 | uint32_t surf_formats_len; 50 | 51 | VkPresentModeKHR* surf_modes; 52 | uint32_t surf_modes_index; 53 | uint32_t surf_modes_len; 54 | 55 | VkSwapchainKHR swapchain; 56 | VkImage* swapchain_images; 57 | VkImageView* swapchain_image_views; 58 | uint32_t swapchain_images_len; 59 | 60 | // vulkan pipeline 61 | VkPipelineShaderStageCreateInfo shader_stages[2]; 62 | VkPipelineLayout pipeline_layout; 63 | VkPipeline pipeline; 64 | 65 | VkFramebuffer* framebuffers; 66 | VkRenderPass render_pass; 67 | 68 | VkCommandPool cmd_pool; 69 | VkCommandBuffer cmd_buf; 70 | 71 | VkBuffer vertex_buf; 72 | VkDeviceMemory vertex_buf_mem; 73 | }; 74 | 75 | void free_check(const void* ptr); 76 | void init_vulkan(struct globuf_render_data* data); 77 | void config_vulkan(struct globuf_render_data* data); 78 | void swapchain_free_vulkan(struct globuf_render_data* data); 79 | void swapchain_vulkan(struct globuf_render_data* data); 80 | void pipeline_free_vulkan(struct globuf_render_data* data); 81 | void pipeline_vulkan(struct globuf_render_data* data); 82 | void compile_shaders(struct globuf_render_data* data); 83 | void render_vulkan(struct globuf_render_data* data); 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /doc/globuf_documentation.md: -------------------------------------------------------------------------------- 1 | # Globuf 2 | Globuf is a windowing library designed over the course of several years, 3 | as a way for me to learn to use the four major display systems: 4 | Wayland, X11, DWM (Windows) and Quartz (macOS). 5 | 6 | ## Globuf history 7 | ### The old design 8 | The very first design of Globuf intended it as a single-thread library that 9 | supports asynchronous event handling without using timer-based event pumps to 10 | deal with the modal loops issues impacting Windows and macOS in that case. 11 | 12 | My goal was to prove it is possible to build a fast windowing library 13 | abstraction with existing system libraries without relying on parallelism and 14 | without resorting to this horrible event pump hack to work around a minor issue. 15 | 16 | This design was succesfully implemented, but it comes with its own limits. Most 17 | notably, the techniques used to achieve this goal break desktop integration 18 | under Windows and macOS. Along the way, I also realized it is probably not a 19 | very good idea to fight a system's intended design. It often results in weird 20 | specificities the user is not expecting, which is not what UI programmers want. 21 | 22 | ### The new design 23 | For these reasons, the current design of Globuf diverges dramatically from the 24 | old one, and is much more similar to what already exists in other open-source 25 | windowing libraries like the SDL. 26 | 27 | This new architecture intends Globuf as fundamentally multi-threaded, with event 28 | handling and rendering taking place on different threads, and nothing tampering 29 | with modal loops since they can't block the app, being on a dedicated thread. 30 | 31 | ### What's left of the dream 32 | While the architecture of Globuf changed, the philosophy behind it did not. 33 | Globuf was built around the following opinions: 34 | - all users deserve a qualitative experience whatever their opinions or choices 35 | - any of the programs we write should only do one thing and do it well 36 | - the main purpose of code is to communicate between programmers 37 | Which gives us the following key principles: 38 | - apps built using Globuf should be truly multi-platform. 39 | - the library should be modular and minimalistic. 40 | - the code should be clear and simple 41 | 42 | ## Using globuf 43 | 44 | ## Modifying globuf 45 | ### Adding a new backend 46 | ### Adding a new platform 47 | -------------------------------------------------------------------------------- /src/wayland/wayland_egl_helpers.c: -------------------------------------------------------------------------------- 1 | #define _XOPEN_SOURCE 700 2 | 3 | #include "include/globuf.h" 4 | #include "common/globuf_private.h" 5 | #include "wayland/wayland_egl_helpers.h" 6 | #include "wayland/wayland_egl.h" 7 | #include "wayland/wayland_common.h" 8 | #include 9 | #include 10 | #include 11 | 12 | void wayland_helpers_egl_bind(struct globuf* context, struct globuf_error_info* error) 13 | { 14 | struct wayland_egl_backend* backend = context->backend_data; 15 | 16 | // bind context to surface 17 | EGLBoolean error_egl; 18 | 19 | error_egl = 20 | eglMakeCurrent( 21 | backend->display, 22 | backend->surface, 23 | backend->surface, 24 | backend->egl); 25 | 26 | if (error_egl == EGL_FALSE) 27 | { 28 | globuf_error_throw(context, error, GLOBUF_ERROR_WAYLAND_EGL_MAKE_CURRENT); 29 | return; 30 | } 31 | 32 | // set swap interval 33 | int interval; 34 | 35 | if (context->feature_vsync->vsync == true) 36 | { 37 | interval = 1; 38 | } 39 | else 40 | { 41 | interval = 0; 42 | } 43 | 44 | error_egl = eglSwapInterval(backend->display, interval); 45 | 46 | if (error_egl == EGL_FALSE) 47 | { 48 | globuf_error_throw(context, error, GLOBUF_ERROR_WAYLAND_EGL_SWAP_INTERVAL); 49 | return; 50 | } 51 | 52 | globuf_error_ok(error); 53 | } 54 | 55 | void wayland_helpers_egl_toplevel_configure( 56 | void* data, 57 | struct xdg_toplevel* xdg_toplevel, 58 | int32_t width, 59 | int32_t height, 60 | struct wl_array* states) 61 | { 62 | struct wayland_platform* platform = data; 63 | struct globuf* context = platform->globuf; 64 | struct wayland_egl_backend* backend = context->backend_data; 65 | struct globuf_error_info error; 66 | int error_posix; 67 | 68 | if ((width == 0) || (height == 0)) 69 | { 70 | return; 71 | } 72 | 73 | if (context->feature_vsync->vsync == false) 74 | { 75 | // lock main mutex 76 | error_posix = pthread_mutex_lock(&(platform->mutex_main)); 77 | 78 | if (error_posix != 0) 79 | { 80 | globuf_error_throw(context, &error, GLOBUF_ERROR_POSIX_MUTEX_LOCK); 81 | return; 82 | } 83 | } 84 | 85 | context->feature_size->width = width; 86 | context->feature_size->height = height; 87 | wl_egl_window_resize(backend->window, width, height, 0, 0); 88 | 89 | if (context->feature_vsync->vsync == false) 90 | { 91 | // lock main mutex 92 | error_posix = pthread_mutex_unlock(&(platform->mutex_main)); 93 | 94 | if (error_posix != 0) 95 | { 96 | globuf_error_throw(context, &error, GLOBUF_ERROR_POSIX_MUTEX_UNLOCK); 97 | return; 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/win/win_wgl.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_WIN_WGL 2 | #define H_GLOBUF_INTERNAL_WIN_WGL 3 | 4 | #include "include/globuf.h" 5 | #include 6 | 7 | // # main API (globuf.h) 8 | void globuf_win_wgl_init( 9 | struct globuf* context, 10 | struct globuf_error_info* error); 11 | 12 | void globuf_win_wgl_clean( 13 | struct globuf* context, 14 | struct globuf_error_info* error); 15 | 16 | void globuf_win_wgl_window_create( 17 | struct globuf* context, 18 | struct globuf_config_request* configs, 19 | size_t count, 20 | void (*callback)(struct globuf_config_reply* replies, size_t count, void* data), 21 | void* data, 22 | struct globuf_error_info* error); 23 | 24 | void globuf_win_wgl_window_destroy( 25 | struct globuf* context, 26 | struct globuf_error_info* error); 27 | 28 | void globuf_win_wgl_window_confirm( 29 | struct globuf* context, 30 | struct globuf_error_info* error); 31 | 32 | void globuf_win_wgl_window_start( 33 | struct globuf* context, 34 | struct globuf_error_info* error); 35 | 36 | void globuf_win_wgl_window_block( 37 | struct globuf* context, 38 | struct globuf_error_info* error); 39 | 40 | void globuf_win_wgl_window_stop( 41 | struct globuf* context, 42 | struct globuf_error_info* error); 43 | 44 | 45 | void globuf_win_wgl_init_render( 46 | struct globuf* context, 47 | struct globuf_config_render* config, 48 | struct globuf_error_info* error); 49 | 50 | void globuf_win_wgl_init_events( 51 | struct globuf* context, 52 | struct globuf_config_events* config, 53 | struct globuf_error_info* error); 54 | 55 | enum globuf_event globuf_win_wgl_handle_events( 56 | struct globuf* context, 57 | void* event, 58 | struct globuf_error_info* error); 59 | 60 | 61 | struct globuf_config_features* globuf_win_wgl_init_features( 62 | struct globuf* context, 63 | struct globuf_error_info* error); 64 | 65 | void globuf_win_wgl_feature_set_interaction( 66 | struct globuf* context, 67 | struct globuf_feature_interaction* config, 68 | struct globuf_error_info* error); 69 | 70 | void globuf_win_wgl_feature_set_state( 71 | struct globuf* context, 72 | struct globuf_feature_state* config, 73 | struct globuf_error_info* error); 74 | 75 | void globuf_win_wgl_feature_set_title( 76 | struct globuf* context, 77 | struct globuf_feature_title* config, 78 | struct globuf_error_info* error); 79 | 80 | void globuf_win_wgl_feature_set_icon( 81 | struct globuf* context, 82 | struct globuf_feature_icon* config, 83 | struct globuf_error_info* error); 84 | 85 | 86 | unsigned globuf_win_wgl_get_width( 87 | struct globuf* context, 88 | struct globuf_error_info* error); 89 | 90 | unsigned globuf_win_wgl_get_height( 91 | struct globuf* context, 92 | struct globuf_error_info* error); 93 | 94 | struct globuf_rect globuf_win_wgl_get_expose( 95 | struct globuf* context, 96 | struct globuf_error_info* error); 97 | 98 | 99 | // for this backend, `data` is NULL 100 | void globuf_win_wgl_update_content( 101 | struct globuf* context, 102 | void* data, 103 | struct globuf_error_info* error); 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /src/x11/x11_egl.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_X11_EGL 2 | #define H_GLOBUF_INTERNAL_X11_EGL 3 | 4 | #include "include/globuf.h" 5 | #include 6 | 7 | // # main API (globuf.h) 8 | void globuf_x11_egl_init( 9 | struct globuf* context, 10 | struct globuf_error_info* error); 11 | 12 | void globuf_x11_egl_clean( 13 | struct globuf* context, 14 | struct globuf_error_info* error); 15 | 16 | void globuf_x11_egl_window_create( 17 | struct globuf* context, 18 | struct globuf_config_request* configs, 19 | size_t count, 20 | void (*callback)(struct globuf_config_reply* replies, size_t count, void* data), 21 | void* data, 22 | struct globuf_error_info* error); 23 | 24 | void globuf_x11_egl_window_destroy( 25 | struct globuf* context, 26 | struct globuf_error_info* error); 27 | 28 | void globuf_x11_egl_window_confirm( 29 | struct globuf* context, 30 | struct globuf_error_info* error); 31 | 32 | void globuf_x11_egl_window_start( 33 | struct globuf* context, 34 | struct globuf_error_info* error); 35 | 36 | void globuf_x11_egl_window_block( 37 | struct globuf* context, 38 | struct globuf_error_info* error); 39 | 40 | void globuf_x11_egl_window_stop( 41 | struct globuf* context, 42 | struct globuf_error_info* error); 43 | 44 | 45 | void globuf_x11_egl_init_render( 46 | struct globuf* context, 47 | struct globuf_config_render* config, 48 | struct globuf_error_info* error); 49 | 50 | void globuf_x11_egl_init_events( 51 | struct globuf* context, 52 | struct globuf_config_events* config, 53 | struct globuf_error_info* error); 54 | 55 | enum globuf_event globuf_x11_egl_handle_events( 56 | struct globuf* context, 57 | void* event, 58 | struct globuf_error_info* error); 59 | 60 | 61 | struct globuf_config_features* globuf_x11_egl_init_features( 62 | struct globuf* context, 63 | struct globuf_error_info* error); 64 | 65 | void globuf_x11_egl_feature_set_interaction( 66 | struct globuf* context, 67 | struct globuf_feature_interaction* config, 68 | struct globuf_error_info* error); 69 | 70 | void globuf_x11_egl_feature_set_state( 71 | struct globuf* context, 72 | struct globuf_feature_state* config, 73 | struct globuf_error_info* error); 74 | 75 | void globuf_x11_egl_feature_set_title( 76 | struct globuf* context, 77 | struct globuf_feature_title* config, 78 | struct globuf_error_info* error); 79 | 80 | void globuf_x11_egl_feature_set_icon( 81 | struct globuf* context, 82 | struct globuf_feature_icon* config, 83 | struct globuf_error_info* error); 84 | 85 | 86 | unsigned globuf_x11_egl_get_width( 87 | struct globuf* context, 88 | struct globuf_error_info* error); 89 | 90 | unsigned globuf_x11_egl_get_height( 91 | struct globuf* context, 92 | struct globuf_error_info* error); 93 | 94 | struct globuf_rect globuf_x11_egl_get_expose( 95 | struct globuf* context, 96 | struct globuf_error_info* error); 97 | 98 | 99 | // for this backend, `data` is NULL 100 | void globuf_x11_egl_update_content( 101 | struct globuf* context, 102 | void* data, 103 | struct globuf_error_info* error); 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /src/x11/x11_glx.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_X11_GLX 2 | #define H_GLOBUF_INTERNAL_X11_GLX 3 | 4 | #include "include/globuf.h" 5 | #include 6 | 7 | // # main API (globuf.h) 8 | void globuf_x11_glx_init( 9 | struct globuf* context, 10 | struct globuf_error_info* error); 11 | 12 | void globuf_x11_glx_clean( 13 | struct globuf* context, 14 | struct globuf_error_info* error); 15 | 16 | void globuf_x11_glx_window_create( 17 | struct globuf* context, 18 | struct globuf_config_request* configs, 19 | size_t count, 20 | void (*callback)(struct globuf_config_reply* replies, size_t count, void* data), 21 | void* data, 22 | struct globuf_error_info* error); 23 | 24 | void globuf_x11_glx_window_destroy( 25 | struct globuf* context, 26 | struct globuf_error_info* error); 27 | 28 | void globuf_x11_glx_window_confirm( 29 | struct globuf* context, 30 | struct globuf_error_info* error); 31 | 32 | void globuf_x11_glx_window_start( 33 | struct globuf* context, 34 | struct globuf_error_info* error); 35 | 36 | void globuf_x11_glx_window_block( 37 | struct globuf* context, 38 | struct globuf_error_info* error); 39 | 40 | void globuf_x11_glx_window_stop( 41 | struct globuf* context, 42 | struct globuf_error_info* error); 43 | 44 | 45 | void globuf_x11_glx_init_render( 46 | struct globuf* context, 47 | struct globuf_config_render* config, 48 | struct globuf_error_info* error); 49 | 50 | void globuf_x11_glx_init_events( 51 | struct globuf* context, 52 | struct globuf_config_events* config, 53 | struct globuf_error_info* error); 54 | 55 | enum globuf_event globuf_x11_glx_handle_events( 56 | struct globuf* context, 57 | void* event, 58 | struct globuf_error_info* error); 59 | 60 | 61 | struct globuf_config_features* globuf_x11_glx_init_features( 62 | struct globuf* context, 63 | struct globuf_error_info* error); 64 | 65 | void globuf_x11_glx_feature_set_interaction( 66 | struct globuf* context, 67 | struct globuf_feature_interaction* config, 68 | struct globuf_error_info* error); 69 | 70 | void globuf_x11_glx_feature_set_state( 71 | struct globuf* context, 72 | struct globuf_feature_state* config, 73 | struct globuf_error_info* error); 74 | 75 | void globuf_x11_glx_feature_set_title( 76 | struct globuf* context, 77 | struct globuf_feature_title* config, 78 | struct globuf_error_info* error); 79 | 80 | void globuf_x11_glx_feature_set_icon( 81 | struct globuf* context, 82 | struct globuf_feature_icon* config, 83 | struct globuf_error_info* error); 84 | 85 | 86 | unsigned globuf_x11_glx_get_width( 87 | struct globuf* context, 88 | struct globuf_error_info* error); 89 | 90 | unsigned globuf_x11_glx_get_height( 91 | struct globuf* context, 92 | struct globuf_error_info* error); 93 | 94 | struct globuf_rect globuf_x11_glx_get_expose( 95 | struct globuf* context, 96 | struct globuf_error_info* error); 97 | 98 | 99 | // for this backend, `data` is NULL 100 | void globuf_x11_glx_update_content( 101 | struct globuf* context, 102 | void* data, 103 | struct globuf_error_info* error); 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /src/win/win_vulkan.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_WIN_VULKAN 2 | #define H_GLOBUF_INTERNAL_WIN_VULKAN 3 | 4 | #include "include/globuf.h" 5 | #include 6 | 7 | // # main API (globuf.h) 8 | void globuf_win_vulkan_init( 9 | struct globuf* context, 10 | struct globuf_error_info* error); 11 | 12 | void globuf_win_vulkan_clean( 13 | struct globuf* context, 14 | struct globuf_error_info* error); 15 | 16 | void globuf_win_vulkan_window_create( 17 | struct globuf* context, 18 | struct globuf_config_request* configs, 19 | size_t count, 20 | void (*callback)(struct globuf_config_reply* replies, size_t count, void* data), 21 | void* data, 22 | struct globuf_error_info* error); 23 | 24 | void globuf_win_vulkan_window_destroy( 25 | struct globuf* context, 26 | struct globuf_error_info* error); 27 | 28 | void globuf_win_vulkan_window_confirm( 29 | struct globuf* context, 30 | struct globuf_error_info* error); 31 | 32 | void globuf_win_vulkan_window_start( 33 | struct globuf* context, 34 | struct globuf_error_info* error); 35 | 36 | void globuf_win_vulkan_window_block( 37 | struct globuf* context, 38 | struct globuf_error_info* error); 39 | 40 | void globuf_win_vulkan_window_stop( 41 | struct globuf* context, 42 | struct globuf_error_info* error); 43 | 44 | 45 | void globuf_win_vulkan_init_render( 46 | struct globuf* context, 47 | struct globuf_config_render* config, 48 | struct globuf_error_info* error); 49 | 50 | void globuf_win_vulkan_init_events( 51 | struct globuf* context, 52 | struct globuf_config_events* config, 53 | struct globuf_error_info* error); 54 | 55 | enum globuf_event globuf_win_vulkan_handle_events( 56 | struct globuf* context, 57 | void* event, 58 | struct globuf_error_info* error); 59 | 60 | 61 | struct globuf_config_features* globuf_win_vulkan_init_features( 62 | struct globuf* context, 63 | struct globuf_error_info* error); 64 | 65 | void globuf_win_vulkan_feature_set_interaction( 66 | struct globuf* context, 67 | struct globuf_feature_interaction* config, 68 | struct globuf_error_info* error); 69 | 70 | void globuf_win_vulkan_feature_set_state( 71 | struct globuf* context, 72 | struct globuf_feature_state* config, 73 | struct globuf_error_info* error); 74 | 75 | void globuf_win_vulkan_feature_set_title( 76 | struct globuf* context, 77 | struct globuf_feature_title* config, 78 | struct globuf_error_info* error); 79 | 80 | void globuf_win_vulkan_feature_set_icon( 81 | struct globuf* context, 82 | struct globuf_feature_icon* config, 83 | struct globuf_error_info* error); 84 | 85 | 86 | unsigned globuf_win_vulkan_get_width( 87 | struct globuf* context, 88 | struct globuf_error_info* error); 89 | 90 | unsigned globuf_win_vulkan_get_height( 91 | struct globuf* context, 92 | struct globuf_error_info* error); 93 | 94 | struct globuf_rect globuf_win_vulkan_get_expose( 95 | struct globuf* context, 96 | struct globuf_error_info* error); 97 | 98 | 99 | // for this backend, `data` is NULL 100 | void globuf_win_vulkan_update_content( 101 | struct globuf* context, 102 | void* data, 103 | struct globuf_error_info* error); 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /src/x11/x11_vulkan.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_X11_VULKAN 2 | #define H_GLOBUF_INTERNAL_X11_VULKAN 3 | 4 | #include "include/globuf.h" 5 | #include 6 | 7 | // # main API (globuf.h) 8 | void globuf_x11_vulkan_init( 9 | struct globuf* context, 10 | struct globuf_error_info* error); 11 | 12 | void globuf_x11_vulkan_clean( 13 | struct globuf* context, 14 | struct globuf_error_info* error); 15 | 16 | void globuf_x11_vulkan_window_create( 17 | struct globuf* context, 18 | struct globuf_config_request* configs, 19 | size_t count, 20 | void (*callback)(struct globuf_config_reply* replies, size_t count, void* data), 21 | void* data, 22 | struct globuf_error_info* error); 23 | 24 | void globuf_x11_vulkan_window_destroy( 25 | struct globuf* context, 26 | struct globuf_error_info* error); 27 | 28 | void globuf_x11_vulkan_window_confirm( 29 | struct globuf* context, 30 | struct globuf_error_info* error); 31 | 32 | void globuf_x11_vulkan_window_start( 33 | struct globuf* context, 34 | struct globuf_error_info* error); 35 | 36 | void globuf_x11_vulkan_window_block( 37 | struct globuf* context, 38 | struct globuf_error_info* error); 39 | 40 | void globuf_x11_vulkan_window_stop( 41 | struct globuf* context, 42 | struct globuf_error_info* error); 43 | 44 | 45 | void globuf_x11_vulkan_init_render( 46 | struct globuf* context, 47 | struct globuf_config_render* config, 48 | struct globuf_error_info* error); 49 | 50 | void globuf_x11_vulkan_init_events( 51 | struct globuf* context, 52 | struct globuf_config_events* config, 53 | struct globuf_error_info* error); 54 | 55 | enum globuf_event globuf_x11_vulkan_handle_events( 56 | struct globuf* context, 57 | void* event, 58 | struct globuf_error_info* error); 59 | 60 | 61 | struct globuf_config_features* globuf_x11_vulkan_init_features( 62 | struct globuf* context, 63 | struct globuf_error_info* error); 64 | 65 | void globuf_x11_vulkan_feature_set_interaction( 66 | struct globuf* context, 67 | struct globuf_feature_interaction* config, 68 | struct globuf_error_info* error); 69 | 70 | void globuf_x11_vulkan_feature_set_state( 71 | struct globuf* context, 72 | struct globuf_feature_state* config, 73 | struct globuf_error_info* error); 74 | 75 | void globuf_x11_vulkan_feature_set_title( 76 | struct globuf* context, 77 | struct globuf_feature_title* config, 78 | struct globuf_error_info* error); 79 | 80 | void globuf_x11_vulkan_feature_set_icon( 81 | struct globuf* context, 82 | struct globuf_feature_icon* config, 83 | struct globuf_error_info* error); 84 | 85 | 86 | unsigned globuf_x11_vulkan_get_width( 87 | struct globuf* context, 88 | struct globuf_error_info* error); 89 | 90 | unsigned globuf_x11_vulkan_get_height( 91 | struct globuf* context, 92 | struct globuf_error_info* error); 93 | 94 | struct globuf_rect globuf_x11_vulkan_get_expose( 95 | struct globuf* context, 96 | struct globuf_error_info* error); 97 | 98 | 99 | // for this backend, `data` is NULL 100 | void globuf_x11_vulkan_update_content( 101 | struct globuf* context, 102 | void* data, 103 | struct globuf_error_info* error); 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /src/wayland/wayland_egl.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_WAYLAND_EGL 2 | #define H_GLOBUF_INTERNAL_WAYLAND_EGL 3 | 4 | #include "include/globuf.h" 5 | #include 6 | 7 | // # main API (globuf.h) 8 | void globuf_wayland_egl_init( 9 | struct globuf* context, 10 | struct globuf_error_info* error); 11 | 12 | void globuf_wayland_egl_clean( 13 | struct globuf* context, 14 | struct globuf_error_info* error); 15 | 16 | void globuf_wayland_egl_window_create( 17 | struct globuf* context, 18 | struct globuf_config_request* configs, 19 | size_t count, 20 | void (*callback)(struct globuf_config_reply* replies, size_t count, void* data), 21 | void* data, 22 | struct globuf_error_info* error); 23 | 24 | void globuf_wayland_egl_window_destroy( 25 | struct globuf* context, 26 | struct globuf_error_info* error); 27 | 28 | void globuf_wayland_egl_window_confirm( 29 | struct globuf* context, 30 | struct globuf_error_info* error); 31 | 32 | void globuf_wayland_egl_window_start( 33 | struct globuf* context, 34 | struct globuf_error_info* error); 35 | 36 | void globuf_wayland_egl_window_block( 37 | struct globuf* context, 38 | struct globuf_error_info* error); 39 | 40 | void globuf_wayland_egl_window_stop( 41 | struct globuf* context, 42 | struct globuf_error_info* error); 43 | 44 | 45 | void globuf_wayland_egl_init_render( 46 | struct globuf* context, 47 | struct globuf_config_render* config, 48 | struct globuf_error_info* error); 49 | 50 | void globuf_wayland_egl_init_events( 51 | struct globuf* context, 52 | struct globuf_config_events* config, 53 | struct globuf_error_info* error); 54 | 55 | enum globuf_event globuf_wayland_egl_handle_events( 56 | struct globuf* context, 57 | void* event, 58 | struct globuf_error_info* error); 59 | 60 | 61 | struct globuf_config_features* globuf_wayland_egl_init_features( 62 | struct globuf* context, 63 | struct globuf_error_info* error); 64 | 65 | void globuf_wayland_egl_feature_set_interaction( 66 | struct globuf* context, 67 | struct globuf_feature_interaction* config, 68 | struct globuf_error_info* error); 69 | 70 | void globuf_wayland_egl_feature_set_state( 71 | struct globuf* context, 72 | struct globuf_feature_state* config, 73 | struct globuf_error_info* error); 74 | 75 | void globuf_wayland_egl_feature_set_title( 76 | struct globuf* context, 77 | struct globuf_feature_title* config, 78 | struct globuf_error_info* error); 79 | 80 | void globuf_wayland_egl_feature_set_icon( 81 | struct globuf* context, 82 | struct globuf_feature_icon* config, 83 | struct globuf_error_info* error); 84 | 85 | 86 | unsigned globuf_wayland_egl_get_width( 87 | struct globuf* context, 88 | struct globuf_error_info* error); 89 | 90 | unsigned globuf_wayland_egl_get_height( 91 | struct globuf* context, 92 | struct globuf_error_info* error); 93 | 94 | struct globuf_rect globuf_wayland_egl_get_expose( 95 | struct globuf* context, 96 | struct globuf_error_info* error); 97 | 98 | 99 | // for this backend, `data` is NULL 100 | void globuf_wayland_egl_update_content( 101 | struct globuf* context, 102 | void* data, 103 | struct globuf_error_info* error); 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /src/appkit/appkit_egl.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_APPKIT_EGL 2 | #define H_GLOBUF_INTERNAL_APPKIT_EGL 3 | 4 | #include "include/globuf.h" 5 | #include 6 | 7 | // # main API (globuf.h) 8 | void globuf_appkit_egl_init( 9 | struct globuf* context, 10 | struct globuf_error_info* error); 11 | 12 | void globuf_appkit_egl_clean( 13 | struct globuf* context, 14 | struct globuf_error_info* error); 15 | 16 | void globuf_appkit_egl_window_create( 17 | struct globuf* context, 18 | struct globuf_config_request* configs, 19 | size_t count, 20 | void (*callback)(struct globuf_config_reply* replies, size_t count, void* data), 21 | void* data, 22 | struct globuf_error_info* error); 23 | 24 | void globuf_appkit_egl_window_destroy( 25 | struct globuf* context, 26 | struct globuf_error_info* error); 27 | 28 | void globuf_appkit_egl_window_confirm( 29 | struct globuf* context, 30 | struct globuf_error_info* error); 31 | 32 | void globuf_appkit_egl_window_start( 33 | struct globuf* context, 34 | struct globuf_error_info* error); 35 | 36 | void globuf_appkit_egl_window_block( 37 | struct globuf* context, 38 | struct globuf_error_info* error); 39 | 40 | void globuf_appkit_egl_window_stop( 41 | struct globuf* context, 42 | struct globuf_error_info* error); 43 | 44 | 45 | void globuf_appkit_egl_init_render( 46 | struct globuf* context, 47 | struct globuf_config_render* config, 48 | struct globuf_error_info* error); 49 | 50 | void globuf_appkit_egl_init_events( 51 | struct globuf* context, 52 | struct globuf_config_events* config, 53 | struct globuf_error_info* error); 54 | 55 | enum globuf_event globuf_appkit_egl_handle_events( 56 | struct globuf* context, 57 | void* event, 58 | struct globuf_error_info* error); 59 | 60 | 61 | struct globuf_config_features* globuf_appkit_egl_init_features( 62 | struct globuf* context, 63 | struct globuf_error_info* error); 64 | 65 | void globuf_appkit_egl_feature_set_interaction( 66 | struct globuf* context, 67 | struct globuf_feature_interaction* config, 68 | struct globuf_error_info* error); 69 | 70 | void globuf_appkit_egl_feature_set_state( 71 | struct globuf* context, 72 | struct globuf_feature_state* config, 73 | struct globuf_error_info* error); 74 | 75 | void globuf_appkit_egl_feature_set_title( 76 | struct globuf* context, 77 | struct globuf_feature_title* config, 78 | struct globuf_error_info* error); 79 | 80 | void globuf_appkit_egl_feature_set_icon( 81 | struct globuf* context, 82 | struct globuf_feature_icon* config, 83 | struct globuf_error_info* error); 84 | 85 | 86 | unsigned globuf_appkit_egl_get_width( 87 | struct globuf* context, 88 | struct globuf_error_info* error); 89 | 90 | unsigned globuf_appkit_egl_get_height( 91 | struct globuf* context, 92 | struct globuf_error_info* error); 93 | 94 | struct globuf_rect globuf_appkit_egl_get_expose( 95 | struct globuf* context, 96 | struct globuf_error_info* error); 97 | 98 | 99 | // for this backend, `data` is of type `struct globuf_update_egl*` 100 | void globuf_appkit_egl_update_content( 101 | struct globuf* context, 102 | void* data, 103 | struct globuf_error_info* error); 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /src/win/win_software.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_WIN_SOFTWARE 2 | #define H_GLOBUF_INTERNAL_WIN_SOFTWARE 3 | 4 | #include "include/globuf.h" 5 | #include 6 | 7 | // # main API (globuf.h) 8 | void globuf_win_software_init( 9 | struct globuf* context, 10 | struct globuf_error_info* error); 11 | 12 | void globuf_win_software_clean( 13 | struct globuf* context, 14 | struct globuf_error_info* error); 15 | 16 | void globuf_win_software_window_create( 17 | struct globuf* context, 18 | struct globuf_config_request* configs, 19 | size_t count, 20 | void (*callback)(struct globuf_config_reply* replies, size_t count, void* data), 21 | void* data, 22 | struct globuf_error_info* error); 23 | 24 | void globuf_win_software_window_destroy( 25 | struct globuf* context, 26 | struct globuf_error_info* error); 27 | 28 | void globuf_win_software_window_confirm( 29 | struct globuf* context, 30 | struct globuf_error_info* error); 31 | 32 | void globuf_win_software_window_start( 33 | struct globuf* context, 34 | struct globuf_error_info* error); 35 | 36 | void globuf_win_software_window_block( 37 | struct globuf* context, 38 | struct globuf_error_info* error); 39 | 40 | void globuf_win_software_window_stop( 41 | struct globuf* context, 42 | struct globuf_error_info* error); 43 | 44 | 45 | void globuf_win_software_init_render( 46 | struct globuf* context, 47 | struct globuf_config_render* config, 48 | struct globuf_error_info* error); 49 | 50 | void globuf_win_software_init_events( 51 | struct globuf* context, 52 | struct globuf_config_events* config, 53 | struct globuf_error_info* error); 54 | 55 | enum globuf_event globuf_win_software_handle_events( 56 | struct globuf* context, 57 | void* event, 58 | struct globuf_error_info* error); 59 | 60 | 61 | struct globuf_config_features* globuf_win_software_init_features( 62 | struct globuf* context, 63 | struct globuf_error_info* error); 64 | 65 | void globuf_win_software_feature_set_interaction( 66 | struct globuf* context, 67 | struct globuf_feature_interaction* config, 68 | struct globuf_error_info* error); 69 | 70 | void globuf_win_software_feature_set_state( 71 | struct globuf* context, 72 | struct globuf_feature_state* config, 73 | struct globuf_error_info* error); 74 | 75 | void globuf_win_software_feature_set_title( 76 | struct globuf* context, 77 | struct globuf_feature_title* config, 78 | struct globuf_error_info* error); 79 | 80 | void globuf_win_software_feature_set_icon( 81 | struct globuf* context, 82 | struct globuf_feature_icon* config, 83 | struct globuf_error_info* error); 84 | 85 | 86 | unsigned globuf_win_software_get_width( 87 | struct globuf* context, 88 | struct globuf_error_info* error); 89 | 90 | unsigned globuf_win_software_get_height( 91 | struct globuf* context, 92 | struct globuf_error_info* error); 93 | 94 | struct globuf_rect globuf_win_software_get_expose( 95 | struct globuf* context, 96 | struct globuf_error_info* error); 97 | 98 | 99 | // for this backend, `data` is of type `struct globuf_update_software*` 100 | void globuf_win_software_update_content( 101 | struct globuf* context, 102 | void* data, 103 | struct globuf_error_info* error); 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /src/x11/x11_software.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_X11_SOFTWARE 2 | #define H_GLOBUF_INTERNAL_X11_SOFTWARE 3 | 4 | #include "include/globuf.h" 5 | #include 6 | 7 | // # main API (globuf.h) 8 | void globuf_x11_software_init( 9 | struct globuf* context, 10 | struct globuf_error_info* error); 11 | 12 | void globuf_x11_software_clean( 13 | struct globuf* context, 14 | struct globuf_error_info* error); 15 | 16 | void globuf_x11_software_window_create( 17 | struct globuf* context, 18 | struct globuf_config_request* configs, 19 | size_t count, 20 | void (*callback)(struct globuf_config_reply* replies, size_t count, void* data), 21 | void* data, 22 | struct globuf_error_info* error); 23 | 24 | void globuf_x11_software_window_destroy( 25 | struct globuf* context, 26 | struct globuf_error_info* error); 27 | 28 | void globuf_x11_software_window_confirm( 29 | struct globuf* context, 30 | struct globuf_error_info* error); 31 | 32 | void globuf_x11_software_window_start( 33 | struct globuf* context, 34 | struct globuf_error_info* error); 35 | 36 | void globuf_x11_software_window_block( 37 | struct globuf* context, 38 | struct globuf_error_info* error); 39 | 40 | void globuf_x11_software_window_stop( 41 | struct globuf* context, 42 | struct globuf_error_info* error); 43 | 44 | 45 | void globuf_x11_software_init_render( 46 | struct globuf* context, 47 | struct globuf_config_render* config, 48 | struct globuf_error_info* error); 49 | 50 | void globuf_x11_software_init_events( 51 | struct globuf* context, 52 | struct globuf_config_events* config, 53 | struct globuf_error_info* error); 54 | 55 | enum globuf_event globuf_x11_software_handle_events( 56 | struct globuf* context, 57 | void* event, 58 | struct globuf_error_info* error); 59 | 60 | 61 | struct globuf_config_features* globuf_x11_software_init_features( 62 | struct globuf* context, 63 | struct globuf_error_info* error); 64 | 65 | void globuf_x11_software_feature_set_interaction( 66 | struct globuf* context, 67 | struct globuf_feature_interaction* config, 68 | struct globuf_error_info* error); 69 | 70 | void globuf_x11_software_feature_set_state( 71 | struct globuf* context, 72 | struct globuf_feature_state* config, 73 | struct globuf_error_info* error); 74 | 75 | void globuf_x11_software_feature_set_title( 76 | struct globuf* context, 77 | struct globuf_feature_title* config, 78 | struct globuf_error_info* error); 79 | 80 | void globuf_x11_software_feature_set_icon( 81 | struct globuf* context, 82 | struct globuf_feature_icon* config, 83 | struct globuf_error_info* error); 84 | 85 | 86 | unsigned globuf_x11_software_get_width( 87 | struct globuf* context, 88 | struct globuf_error_info* error); 89 | 90 | unsigned globuf_x11_software_get_height( 91 | struct globuf* context, 92 | struct globuf_error_info* error); 93 | 94 | struct globuf_rect globuf_x11_software_get_expose( 95 | struct globuf* context, 96 | struct globuf_error_info* error); 97 | 98 | 99 | // for this backend, `data` is of type `struct globuf_update_software*` 100 | void globuf_x11_software_update_content( 101 | struct globuf* context, 102 | void* data, 103 | struct globuf_error_info* error); 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /src/wayland/wayland_vulkan.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_WAYLAND_VULKAN 2 | #define H_GLOBUF_INTERNAL_WAYLAND_VULKAN 3 | 4 | #include "include/globuf.h" 5 | #include 6 | 7 | // # main API (globuf.h) 8 | void globuf_wayland_vulkan_init( 9 | struct globuf* context, 10 | struct globuf_error_info* error); 11 | 12 | void globuf_wayland_vulkan_clean( 13 | struct globuf* context, 14 | struct globuf_error_info* error); 15 | 16 | void globuf_wayland_vulkan_window_create( 17 | struct globuf* context, 18 | struct globuf_config_request* configs, 19 | size_t count, 20 | void (*callback)(struct globuf_config_reply* replies, size_t count, void* data), 21 | void* data, 22 | struct globuf_error_info* error); 23 | 24 | void globuf_wayland_vulkan_window_destroy( 25 | struct globuf* context, 26 | struct globuf_error_info* error); 27 | 28 | void globuf_wayland_vulkan_window_confirm( 29 | struct globuf* context, 30 | struct globuf_error_info* error); 31 | 32 | void globuf_wayland_vulkan_window_start( 33 | struct globuf* context, 34 | struct globuf_error_info* error); 35 | 36 | void globuf_wayland_vulkan_window_block( 37 | struct globuf* context, 38 | struct globuf_error_info* error); 39 | 40 | void globuf_wayland_vulkan_window_stop( 41 | struct globuf* context, 42 | struct globuf_error_info* error); 43 | 44 | 45 | void globuf_wayland_vulkan_init_render( 46 | struct globuf* context, 47 | struct globuf_config_render* config, 48 | struct globuf_error_info* error); 49 | 50 | void globuf_wayland_vulkan_init_events( 51 | struct globuf* context, 52 | struct globuf_config_events* config, 53 | struct globuf_error_info* error); 54 | 55 | enum globuf_event globuf_wayland_vulkan_handle_events( 56 | struct globuf* context, 57 | void* event, 58 | struct globuf_error_info* error); 59 | 60 | 61 | struct globuf_config_features* globuf_wayland_vulkan_init_features( 62 | struct globuf* context, 63 | struct globuf_error_info* error); 64 | 65 | void globuf_wayland_vulkan_feature_set_interaction( 66 | struct globuf* context, 67 | struct globuf_feature_interaction* config, 68 | struct globuf_error_info* error); 69 | 70 | void globuf_wayland_vulkan_feature_set_state( 71 | struct globuf* context, 72 | struct globuf_feature_state* config, 73 | struct globuf_error_info* error); 74 | 75 | void globuf_wayland_vulkan_feature_set_title( 76 | struct globuf* context, 77 | struct globuf_feature_title* config, 78 | struct globuf_error_info* error); 79 | 80 | void globuf_wayland_vulkan_feature_set_icon( 81 | struct globuf* context, 82 | struct globuf_feature_icon* config, 83 | struct globuf_error_info* error); 84 | 85 | 86 | unsigned globuf_wayland_vulkan_get_width( 87 | struct globuf* context, 88 | struct globuf_error_info* error); 89 | 90 | unsigned globuf_wayland_vulkan_get_height( 91 | struct globuf* context, 92 | struct globuf_error_info* error); 93 | 94 | struct globuf_rect globuf_wayland_vulkan_get_expose( 95 | struct globuf* context, 96 | struct globuf_error_info* error); 97 | 98 | 99 | // for this backend, `data` is NULL 100 | void globuf_wayland_vulkan_update_content( 101 | struct globuf* context, 102 | void* data, 103 | struct globuf_error_info* error); 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /src/appkit/appkit_vulkan.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_APPKIT_VULKAN 2 | #define H_GLOBUF_INTERNAL_APPKIT_VULKAN 3 | 4 | #include "include/globuf.h" 5 | #include 6 | 7 | // # main API (globuf.h) 8 | void globuf_appkit_vulkan_init( 9 | struct globuf* context, 10 | struct globuf_error_info* error); 11 | 12 | void globuf_appkit_vulkan_clean( 13 | struct globuf* context, 14 | struct globuf_error_info* error); 15 | 16 | void globuf_appkit_vulkan_window_create( 17 | struct globuf* context, 18 | struct globuf_config_request* configs, 19 | size_t count, 20 | void (*callback)(struct globuf_config_reply* replies, size_t count, void* data), 21 | void* data, 22 | struct globuf_error_info* error); 23 | 24 | void globuf_appkit_vulkan_window_destroy( 25 | struct globuf* context, 26 | struct globuf_error_info* error); 27 | 28 | void globuf_appkit_vulkan_window_confirm( 29 | struct globuf* context, 30 | struct globuf_error_info* error); 31 | 32 | void globuf_appkit_vulkan_window_start( 33 | struct globuf* context, 34 | struct globuf_error_info* error); 35 | 36 | void globuf_appkit_vulkan_window_block( 37 | struct globuf* context, 38 | struct globuf_error_info* error); 39 | 40 | void globuf_appkit_vulkan_window_stop( 41 | struct globuf* context, 42 | struct globuf_error_info* error); 43 | 44 | 45 | void globuf_appkit_vulkan_init_render( 46 | struct globuf* context, 47 | struct globuf_config_render* config, 48 | struct globuf_error_info* error); 49 | 50 | void globuf_appkit_vulkan_init_events( 51 | struct globuf* context, 52 | struct globuf_config_events* config, 53 | struct globuf_error_info* error); 54 | 55 | enum globuf_event globuf_appkit_vulkan_handle_events( 56 | struct globuf* context, 57 | void* event, 58 | struct globuf_error_info* error); 59 | 60 | 61 | struct globuf_config_features* globuf_appkit_vulkan_init_features( 62 | struct globuf* context, 63 | struct globuf_error_info* error); 64 | 65 | void globuf_appkit_vulkan_feature_set_interaction( 66 | struct globuf* context, 67 | struct globuf_feature_interaction* config, 68 | struct globuf_error_info* error); 69 | 70 | void globuf_appkit_vulkan_feature_set_state( 71 | struct globuf* context, 72 | struct globuf_feature_state* config, 73 | struct globuf_error_info* error); 74 | 75 | void globuf_appkit_vulkan_feature_set_title( 76 | struct globuf* context, 77 | struct globuf_feature_title* config, 78 | struct globuf_error_info* error); 79 | 80 | void globuf_appkit_vulkan_feature_set_icon( 81 | struct globuf* context, 82 | struct globuf_feature_icon* config, 83 | struct globuf_error_info* error); 84 | 85 | 86 | unsigned globuf_appkit_vulkan_get_width( 87 | struct globuf* context, 88 | struct globuf_error_info* error); 89 | 90 | unsigned globuf_appkit_vulkan_get_height( 91 | struct globuf* context, 92 | struct globuf_error_info* error); 93 | 94 | struct globuf_rect globuf_appkit_vulkan_get_expose( 95 | struct globuf* context, 96 | struct globuf_error_info* error); 97 | 98 | 99 | // for this backend, `data` is of type `struct globuf_update_vulkan*` 100 | void globuf_appkit_vulkan_update_content( 101 | struct globuf* context, 102 | void* data, 103 | struct globuf_error_info* error); 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /src/appkit/appkit_software.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_APPKIT_SOFTWARE 2 | #define H_GLOBUF_INTERNAL_APPKIT_SOFTWARE 3 | 4 | #include "include/globuf.h" 5 | #include 6 | 7 | // # main API (globuf.h) 8 | void globuf_appkit_software_init( 9 | struct globuf* context, 10 | struct globuf_error_info* error); 11 | 12 | void globuf_appkit_software_clean( 13 | struct globuf* context, 14 | struct globuf_error_info* error); 15 | 16 | void globuf_appkit_software_window_create( 17 | struct globuf* context, 18 | struct globuf_config_request* configs, 19 | size_t count, 20 | void (*callback)(struct globuf_config_reply* replies, size_t count, void* data), 21 | void* data, 22 | struct globuf_error_info* error); 23 | 24 | void globuf_appkit_software_window_destroy( 25 | struct globuf* context, 26 | struct globuf_error_info* error); 27 | 28 | void globuf_appkit_software_window_confirm( 29 | struct globuf* context, 30 | struct globuf_error_info* error); 31 | 32 | void globuf_appkit_software_window_start( 33 | struct globuf* context, 34 | struct globuf_error_info* error); 35 | 36 | void globuf_appkit_software_window_block( 37 | struct globuf* context, 38 | struct globuf_error_info* error); 39 | 40 | void globuf_appkit_software_window_stop( 41 | struct globuf* context, 42 | struct globuf_error_info* error); 43 | 44 | 45 | void globuf_appkit_software_init_render( 46 | struct globuf* context, 47 | struct globuf_config_render* config, 48 | struct globuf_error_info* error); 49 | 50 | void globuf_appkit_software_init_events( 51 | struct globuf* context, 52 | struct globuf_config_events* config, 53 | struct globuf_error_info* error); 54 | 55 | enum globuf_event globuf_appkit_software_handle_events( 56 | struct globuf* context, 57 | void* event, 58 | struct globuf_error_info* error); 59 | 60 | 61 | struct globuf_config_features* globuf_appkit_software_init_features( 62 | struct globuf* context, 63 | struct globuf_error_info* error); 64 | 65 | void globuf_appkit_software_feature_set_interaction( 66 | struct globuf* context, 67 | struct globuf_feature_interaction* config, 68 | struct globuf_error_info* error); 69 | 70 | void globuf_appkit_software_feature_set_state( 71 | struct globuf* context, 72 | struct globuf_feature_state* config, 73 | struct globuf_error_info* error); 74 | 75 | void globuf_appkit_software_feature_set_title( 76 | struct globuf* context, 77 | struct globuf_feature_title* config, 78 | struct globuf_error_info* error); 79 | 80 | void globuf_appkit_software_feature_set_icon( 81 | struct globuf* context, 82 | struct globuf_feature_icon* config, 83 | struct globuf_error_info* error); 84 | 85 | 86 | unsigned globuf_appkit_software_get_width( 87 | struct globuf* context, 88 | struct globuf_error_info* error); 89 | 90 | unsigned globuf_appkit_software_get_height( 91 | struct globuf* context, 92 | struct globuf_error_info* error); 93 | 94 | struct globuf_rect globuf_appkit_software_get_expose( 95 | struct globuf* context, 96 | struct globuf_error_info* error); 97 | 98 | 99 | // for this backend, `data` is of type `struct globuf_update_software*` 100 | void globuf_appkit_software_update_content( 101 | struct globuf* context, 102 | void* data, 103 | struct globuf_error_info* error); 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /src/wayland/wayland_software.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_WAYLAND_SOFTWARE 2 | #define H_GLOBUF_INTERNAL_WAYLAND_SOFTWARE 3 | 4 | #include "include/globuf.h" 5 | #include 6 | 7 | // # main API (globuf.h) 8 | void globuf_wayland_software_init( 9 | struct globuf* context, 10 | struct globuf_error_info* error); 11 | 12 | void globuf_wayland_software_clean( 13 | struct globuf* context, 14 | struct globuf_error_info* error); 15 | 16 | void globuf_wayland_software_window_create( 17 | struct globuf* context, 18 | struct globuf_config_request* configs, 19 | size_t count, 20 | void (*callback)(struct globuf_config_reply* replies, size_t count, void* data), 21 | void* data, 22 | struct globuf_error_info* error); 23 | 24 | void globuf_wayland_software_window_destroy( 25 | struct globuf* context, 26 | struct globuf_error_info* error); 27 | 28 | void globuf_wayland_software_window_confirm( 29 | struct globuf* context, 30 | struct globuf_error_info* error); 31 | 32 | void globuf_wayland_software_window_start( 33 | struct globuf* context, 34 | struct globuf_error_info* error); 35 | 36 | void globuf_wayland_software_window_block( 37 | struct globuf* context, 38 | struct globuf_error_info* error); 39 | 40 | void globuf_wayland_software_window_stop( 41 | struct globuf* context, 42 | struct globuf_error_info* error); 43 | 44 | 45 | void globuf_wayland_software_init_render( 46 | struct globuf* context, 47 | struct globuf_config_render* config, 48 | struct globuf_error_info* error); 49 | 50 | void globuf_wayland_software_init_events( 51 | struct globuf* context, 52 | struct globuf_config_events* config, 53 | struct globuf_error_info* error); 54 | 55 | enum globuf_event globuf_wayland_software_handle_events( 56 | struct globuf* context, 57 | void* event, 58 | struct globuf_error_info* error); 59 | 60 | 61 | struct globuf_config_features* globuf_wayland_software_init_features( 62 | struct globuf* context, 63 | struct globuf_error_info* error); 64 | 65 | void globuf_wayland_software_feature_set_interaction( 66 | struct globuf* context, 67 | struct globuf_feature_interaction* config, 68 | struct globuf_error_info* error); 69 | 70 | void globuf_wayland_software_feature_set_state( 71 | struct globuf* context, 72 | struct globuf_feature_state* config, 73 | struct globuf_error_info* error); 74 | 75 | void globuf_wayland_software_feature_set_title( 76 | struct globuf* context, 77 | struct globuf_feature_title* config, 78 | struct globuf_error_info* error); 79 | 80 | void globuf_wayland_software_feature_set_icon( 81 | struct globuf* context, 82 | struct globuf_feature_icon* config, 83 | struct globuf_error_info* error); 84 | 85 | 86 | unsigned globuf_wayland_software_get_width( 87 | struct globuf* context, 88 | struct globuf_error_info* error); 89 | 90 | unsigned globuf_wayland_software_get_height( 91 | struct globuf* context, 92 | struct globuf_error_info* error); 93 | 94 | struct globuf_rect globuf_wayland_software_get_expose( 95 | struct globuf* context, 96 | struct globuf_error_info* error); 97 | 98 | 99 | // for this backend, `data` is of type `struct globuf_update_software*` 100 | void globuf_wayland_software_update_content( 101 | struct globuf* context, 102 | void* data, 103 | struct globuf_error_info* error); 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /src/wayland/wayland_common_registry.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_WAYLAND_COMMON_REGISTRY 2 | #define H_GLOBUF_INTERNAL_WAYLAND_COMMON_REGISTRY 3 | 4 | #include "include/globuf.h" 5 | #include "wayland/wayland_common.h" 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | // registry callbacks 13 | void wayland_helpers_callback_registry( 14 | void* data, 15 | struct wl_registry* registry, 16 | uint32_t name, 17 | const char* interface, 18 | uint32_t version); 19 | 20 | void wayland_helpers_callback_registry_remove( 21 | void* data, 22 | struct wl_registry* registry, 23 | uint32_t name); 24 | 25 | // seat listener 26 | void wayland_helpers_seat_capabilities( 27 | void* data, 28 | struct wl_seat* seat, 29 | uint32_t capabilities); 30 | 31 | void wayland_helpers_seat_name( 32 | void* data, 33 | struct wl_seat* seat, 34 | const char* name); 35 | 36 | // pointer listener 37 | void wayland_helpers_pointer_enter( 38 | void* data, 39 | struct wl_pointer* wl_pointer, 40 | uint32_t serial, 41 | struct wl_surface* surface, 42 | wl_fixed_t surface_x, 43 | wl_fixed_t surface_y); 44 | 45 | void wayland_helpers_pointer_leave( 46 | void* data, 47 | struct wl_pointer* wl_pointer, 48 | uint32_t serial, 49 | struct wl_surface* surface); 50 | 51 | void wayland_helpers_pointer_motion( 52 | void* data, 53 | struct wl_pointer* wl_pointer, 54 | uint32_t time, 55 | wl_fixed_t surface_x, 56 | wl_fixed_t surface_y); 57 | 58 | void wayland_helpers_pointer_button( 59 | void* data, 60 | struct wl_pointer* wl_pointer, 61 | uint32_t serial, 62 | uint32_t time, 63 | uint32_t button, 64 | uint32_t state); 65 | 66 | void wayland_helpers_pointer_axis( 67 | void* data, 68 | struct wl_pointer* wl_pointer, 69 | uint32_t time, 70 | uint32_t axis, 71 | wl_fixed_t value); 72 | 73 | void wayland_helpers_pointer_frame( 74 | void* data, 75 | struct wl_pointer* wl_pointer); 76 | 77 | void wayland_helpers_pointer_axis_source( 78 | void* data, 79 | struct wl_pointer* wl_pointer, 80 | uint32_t axis_source); 81 | 82 | void wayland_helpers_pointer_axis_stop( 83 | void* data, 84 | struct wl_pointer* wl_pointer, 85 | uint32_t time, 86 | uint32_t axis); 87 | 88 | void wayland_helpers_pointer_axis_discrete( 89 | void* data, 90 | struct wl_pointer* wl_pointer, 91 | uint32_t axis, 92 | int32_t discrete); 93 | 94 | // frame callback listener 95 | void wayland_helpers_surface_frame_done( 96 | void* data, 97 | struct wl_callback* callback, 98 | uint32_t time); 99 | 100 | // XDG WM base listener 101 | void wayland_helpers_xdg_wm_base_ping( 102 | void* data, 103 | struct xdg_wm_base* xdg_wm_base, 104 | uint32_t serial); 105 | 106 | // XDG surface listener 107 | void wayland_helpers_xdg_surface_configure( 108 | void* data, 109 | struct xdg_surface* xdg_surface, 110 | uint32_t serial); 111 | 112 | // XDG toplevel listener 113 | void wayland_helpers_xdg_toplevel_configure( 114 | void* data, 115 | struct xdg_toplevel* xdg_toplevel, 116 | int32_t width, 117 | int32_t height, 118 | struct wl_array* states); 119 | 120 | void wayland_helpers_xdg_toplevel_close( 121 | void* data, 122 | struct xdg_toplevel* xdg_toplevel); 123 | 124 | // XDG decoration listener 125 | void wayland_helpers_xdg_decoration_configure( 126 | void* data, 127 | struct zxdg_toplevel_decoration_v1* xdg_decoration, 128 | uint32_t mode); 129 | 130 | #endif 131 | -------------------------------------------------------------------------------- /example/helpers/appkit.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | // Because of a series of design mistakes made a long time ago, it is not 4 | // possible to handle window events or render window content on anything 5 | // other than the main thread when using AppKit. 6 | // While it is possible to handle events in a non-blocking way, this requires 7 | // extensive tinkering and creates other issues, so it is not worth the risk 8 | // given Apple has a record of changing the way Apps must be initialized. 9 | // This means on top of having to interface with AppKit on the main thread only, 10 | // we also have to let it steal the thread so it can spin its internal loops, 11 | // leaving us with having to use a second one for actual work. 12 | // Another side-effect of that is the rendering and event handling are probably 13 | // never truly parallel on macOS apps, while they can be on other platforms 14 | // (something to keep in mind when writing your program). 15 | 16 | // run the example main() on a secondary thread (symbol renamed) 17 | extern int real_main(int argc, char** argv); 18 | 19 | @interface GlobufThread: NSThread 20 | @end 21 | 22 | @implementation GlobufThread 23 | - (void) main 24 | { 25 | real_main(0, NULL); 26 | } 27 | @end 28 | 29 | // sacrifice the main thread to AppKit 30 | int main(int argc, char** argv) 31 | { 32 | // create a pool to track Apple resources 33 | NSAutoreleasePool* pool = [NSAutoreleasePool new]; 34 | 35 | 36 | // create the app's bar menu 37 | id menubar = [[NSMenu new] autorelease]; 38 | id appMenuItem = [[NSMenuItem new] autorelease]; 39 | id appMenu = [[NSMenu new] autorelease]; 40 | 41 | // add items to the menu (non-localized in this example) 42 | NSMenuItem* menuItem; 43 | 44 | // add the "Hide" item 45 | menuItem = [appMenu addItemWithTitle:@"Hide" action:@selector(hide:) keyEquivalent:@"h"]; 46 | [menuItem setTarget:NSApp]; 47 | 48 | // add the "Hide Others" item 49 | menuItem = [appMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"]; 50 | [menuItem setKeyEquivalentModifierMask:NSEventModifierFlagCommand | NSEventModifierFlagOption]; 51 | [menuItem setTarget:NSApp]; 52 | 53 | // add the "Show All" item 54 | menuItem = [appMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""]; 55 | [menuItem setTarget:NSApp]; 56 | 57 | // add a separator item 58 | [appMenu addItem:[NSMenuItem separatorItem]]; 59 | 60 | // add the "Quit" item 61 | menuItem = [appMenu addItemWithTitle:@"Quit" action:@selector(terminate:) keyEquivalent:@"q"]; 62 | [menuItem setTarget:NSApp]; 63 | 64 | // set the app's bar menu 65 | [appMenuItem setSubmenu:appMenu]; 66 | [menubar addItem:appMenuItem]; 67 | 68 | 69 | // create the app 70 | [NSApplication sharedApplication]; 71 | 72 | // set the app's menu 73 | [NSApp setMainMenu:menubar]; 74 | 75 | // set the app's activation policy 76 | [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; 77 | 78 | 79 | // start the app 80 | dispatch_async(dispatch_get_main_queue(), ^{ 81 | [NSApp activateIgnoringOtherApps:YES]; 82 | }); 83 | 84 | [NSApp finishLaunching]; 85 | 86 | 87 | // start globuf 88 | // we *have* to use a NSThread for this, posix threads are not guaranteed to 89 | // play well with AppKit (here we use GlobufThread which inherits NSThread) 90 | GlobufThread* thread = [GlobufThread new]; 91 | [thread start]; 92 | 93 | 94 | // handle window events 95 | [NSApp run]; 96 | 97 | 98 | // release Apple resources 99 | [pool release]; 100 | 101 | return 0; 102 | } 103 | -------------------------------------------------------------------------------- /src/win/win_common.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_WIN_COMMON 2 | #define H_GLOBUF_INTERNAL_WIN_COMMON 3 | 4 | #include "include/globuf.h" 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // # private helpers 11 | enum win_user_msg 12 | { 13 | WIN_USER_MSG_FULLSCREEN = WM_USER, 14 | WIN_USER_MSG_MAXIMIZE, 15 | WIN_USER_MSG_MINIMIZE, 16 | WIN_USER_MSG_REGULAR, 17 | }; 18 | 19 | enum win_dpi_api 20 | { 21 | WIN_DPI_API_NONE = 0, 22 | WIN_DPI_API_VISTA, 23 | WIN_DPI_API_8, 24 | WIN_DPI_API_10_V1, 25 | WIN_DPI_API_10_V2, 26 | }; 27 | 28 | struct win_thread_render_loop_data 29 | { 30 | struct globuf* globuf; 31 | struct win_platform* platform; 32 | struct globuf_error_info* error; 33 | }; 34 | 35 | struct win_thread_event_loop_data 36 | { 37 | struct globuf* globuf; 38 | struct win_platform* platform; 39 | struct globuf_error_info* error; 40 | }; 41 | 42 | struct win_platform 43 | { 44 | HANDLE mutex_main; 45 | CONDITION_VARIABLE cond_block; 46 | CONDITION_VARIABLE cond_window; 47 | CONDITION_VARIABLE cond_render; 48 | SRWLOCK lock_block; 49 | SRWLOCK lock_window; 50 | SRWLOCK lock_render; 51 | bool block; 52 | bool window; 53 | bool render; 54 | 55 | // connection 56 | bool closed; 57 | HWND event_handle; 58 | 59 | // win 60 | HICON icon_32; 61 | HICON icon_64; 62 | enum win_dpi_api dpi; 63 | 64 | // window 65 | HMODULE win_module; 66 | WNDCLASSEX win_class; 67 | LPWSTR win_name; 68 | HCURSOR default_cursor; 69 | WINDOWPLACEMENT win_placement; 70 | bool sizemove; 71 | 72 | // render handling 73 | HANDLE thread_render; 74 | struct win_thread_render_loop_data thread_render_loop_data; 75 | void (*render_init_callback)(struct win_thread_render_loop_data* data); 76 | 77 | // event handling 78 | HANDLE thread_event; 79 | struct win_thread_event_loop_data thread_event_loop_data; 80 | void (*event_init_callback)(struct win_thread_render_loop_data* data); 81 | }; 82 | 83 | void globuf_win_common_init( 84 | struct globuf* context, 85 | struct win_platform* platform, 86 | struct globuf_error_info* error); 87 | 88 | void globuf_win_common_clean( 89 | struct globuf* context, 90 | struct win_platform* platform, 91 | struct globuf_error_info* error); 92 | 93 | void globuf_win_common_window_create( 94 | struct globuf* context, 95 | struct win_platform* platform, 96 | struct globuf_config_request* configs, 97 | size_t count, 98 | void (*callback)(struct globuf_config_reply* replies, size_t count, void* data), 99 | void* data, 100 | struct globuf_error_info* error); 101 | 102 | void globuf_win_common_window_destroy( 103 | struct globuf* context, 104 | struct win_platform* platform, 105 | struct globuf_error_info* error); 106 | 107 | void globuf_win_common_window_confirm( 108 | struct globuf* context, 109 | struct win_platform* platform, 110 | struct globuf_error_info* error); 111 | 112 | void globuf_win_common_window_start( 113 | struct globuf* context, 114 | struct win_platform* platform, 115 | struct globuf_error_info* error); 116 | 117 | void globuf_win_common_window_block( 118 | struct globuf* context, 119 | struct win_platform* platform, 120 | struct globuf_error_info* error); 121 | 122 | void globuf_win_common_window_stop( 123 | struct globuf* context, 124 | struct win_platform* platform, 125 | struct globuf_error_info* error); 126 | 127 | 128 | void globuf_win_common_init_render( 129 | struct globuf* context, 130 | struct win_platform* platform, 131 | struct globuf_config_render* config, 132 | struct globuf_error_info* error); 133 | 134 | void globuf_win_common_init_events( 135 | struct globuf* context, 136 | struct win_platform* platform, 137 | struct globuf_config_events* config, 138 | struct globuf_error_info* error); 139 | 140 | enum globuf_event globuf_win_common_handle_events( 141 | struct globuf* context, 142 | struct win_platform* platform, 143 | void* event, 144 | struct globuf_error_info* error); 145 | 146 | 147 | struct globuf_config_features* globuf_win_common_init_features( 148 | struct globuf* context, 149 | struct win_platform* platform, 150 | struct globuf_error_info* error); 151 | 152 | void globuf_win_common_feature_set_interaction( 153 | struct globuf* context, 154 | struct win_platform* platform, 155 | struct globuf_feature_interaction* config, 156 | struct globuf_error_info* error); 157 | 158 | void globuf_win_common_feature_set_state( 159 | struct globuf* context, 160 | struct win_platform* platform, 161 | struct globuf_feature_state* config, 162 | struct globuf_error_info* error); 163 | 164 | void globuf_win_common_feature_set_title( 165 | struct globuf* context, 166 | struct win_platform* platform, 167 | struct globuf_feature_title* config, 168 | struct globuf_error_info* error); 169 | 170 | void globuf_win_common_feature_set_icon( 171 | struct globuf* context, 172 | struct win_platform* platform, 173 | struct globuf_feature_icon* config, 174 | struct globuf_error_info* error); 175 | 176 | 177 | unsigned globuf_win_common_get_width( 178 | struct globuf* context, 179 | struct win_platform* platform, 180 | struct globuf_error_info* error); 181 | 182 | unsigned globuf_win_common_get_height( 183 | struct globuf* context, 184 | struct win_platform* platform, 185 | struct globuf_error_info* error); 186 | 187 | struct globuf_rect globuf_win_common_get_expose( 188 | struct globuf* context, 189 | struct win_platform* platform, 190 | struct globuf_error_info* error); 191 | 192 | #endif 193 | -------------------------------------------------------------------------------- /src/appkit/appkit_common.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_APPKIT_COMMON 2 | #define H_GLOBUF_INTERNAL_APPKIT_COMMON 3 | 4 | #include "include/globuf.h" 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | // # private helpers 13 | struct appkit_thread_render_loop_data 14 | { 15 | struct globuf* globuf; 16 | struct appkit_platform* platform; 17 | struct globuf_error_info* error; 18 | }; 19 | 20 | struct appkit_thread_event_loop_data 21 | { 22 | struct globuf* globuf; 23 | struct appkit_platform* platform; 24 | struct globuf_error_info* error; 25 | }; 26 | 27 | struct appkit_window_delegate_data 28 | { 29 | struct globuf* globuf; 30 | struct appkit_platform* platform; 31 | struct globuf_error_info* error; 32 | }; 33 | 34 | struct appkit_layer_delegate_data 35 | { 36 | struct globuf* globuf; 37 | struct appkit_platform* platform; 38 | struct globuf_error_info* error; 39 | }; 40 | 41 | struct appkit_platform 42 | { 43 | pthread_mutex_t mutex_main; 44 | pthread_mutex_t mutex_block; 45 | pthread_cond_t cond_main; 46 | 47 | bool closed; 48 | id win_delegate; 49 | id win; 50 | NSView* view_master; 51 | NSVisualEffectView* view_blur; 52 | NSView* view; 53 | id layer_delegate; 54 | id layer; 55 | 56 | // saved action for globuf mouse action 57 | int32_t old_mouse_pos_x; 58 | int32_t old_mouse_pos_y; 59 | int32_t saved_mouse_pos_x; 60 | int32_t saved_mouse_pos_y; 61 | bool saved_window; 62 | NSRect saved_window_geometry; 63 | 64 | // render handling 65 | pthread_t thread_render_loop; 66 | struct appkit_thread_render_loop_data thread_render_loop_data; 67 | struct appkit_thread_event_loop_data thread_event_loop_data; 68 | struct appkit_window_delegate_data window_delegate_data; 69 | struct appkit_layer_delegate_data layer_delegate_data; 70 | void (*render_init_callback)(struct globuf*, struct globuf_error_info*); 71 | }; 72 | 73 | void globuf_appkit_common_init( 74 | struct globuf* context, 75 | struct appkit_platform* platform, 76 | struct globuf_error_info* error); 77 | 78 | void globuf_appkit_common_clean( 79 | struct globuf* context, 80 | struct appkit_platform* platform, 81 | struct globuf_error_info* error); 82 | 83 | void globuf_appkit_common_window_create( 84 | struct globuf* context, 85 | struct appkit_platform* platform, 86 | struct globuf_config_request* configs, 87 | size_t count, 88 | void (*callback)(struct globuf_config_reply* replies, size_t count, void* data), 89 | void* data, 90 | struct globuf_error_info* error); 91 | 92 | void globuf_appkit_common_window_destroy( 93 | struct globuf* context, 94 | struct appkit_platform* platform, 95 | struct globuf_error_info* error); 96 | 97 | void globuf_appkit_common_window_confirm( 98 | struct globuf* context, 99 | struct appkit_platform* platform, 100 | struct globuf_error_info* error); 101 | 102 | void globuf_appkit_common_window_start( 103 | struct globuf* context, 104 | struct appkit_platform* platform, 105 | struct globuf_error_info* error); 106 | 107 | void globuf_appkit_common_window_block( 108 | struct globuf* context, 109 | struct appkit_platform* platform, 110 | struct globuf_error_info* error); 111 | 112 | void globuf_appkit_common_window_stop( 113 | struct globuf* context, 114 | struct appkit_platform* platform, 115 | struct globuf_error_info* error); 116 | 117 | 118 | void globuf_appkit_common_init_render( 119 | struct globuf* context, 120 | struct appkit_platform* platform, 121 | struct globuf_config_render* config, 122 | struct globuf_error_info* error); 123 | 124 | void globuf_appkit_common_init_events( 125 | struct globuf* context, 126 | struct appkit_platform* platform, 127 | struct globuf_config_events* config, 128 | struct globuf_error_info* error); 129 | 130 | enum globuf_event globuf_appkit_common_handle_events( 131 | struct globuf* context, 132 | struct appkit_platform* platform, 133 | void* event, 134 | struct globuf_error_info* error); 135 | 136 | 137 | struct globuf_config_features* globuf_appkit_common_init_features( 138 | struct globuf* context, 139 | struct appkit_platform* platform, 140 | struct globuf_error_info* error); 141 | 142 | void globuf_appkit_common_feature_set_interaction( 143 | struct globuf* context, 144 | struct appkit_platform* platform, 145 | struct globuf_feature_interaction* config, 146 | struct globuf_error_info* error); 147 | 148 | void globuf_appkit_common_feature_set_state( 149 | struct globuf* context, 150 | struct appkit_platform* platform, 151 | struct globuf_feature_state* config, 152 | struct globuf_error_info* error); 153 | 154 | void globuf_appkit_common_feature_set_title( 155 | struct globuf* context, 156 | struct appkit_platform* platform, 157 | struct globuf_feature_title* config, 158 | struct globuf_error_info* error); 159 | 160 | void globuf_appkit_common_feature_set_icon( 161 | struct globuf* context, 162 | struct appkit_platform* platform, 163 | struct globuf_feature_icon* config, 164 | struct globuf_error_info* error); 165 | 166 | 167 | unsigned globuf_appkit_common_get_width( 168 | struct globuf* context, 169 | struct appkit_platform* platform, 170 | struct globuf_error_info* error); 171 | 172 | unsigned globuf_appkit_common_get_height( 173 | struct globuf* context, 174 | struct appkit_platform* platform, 175 | struct globuf_error_info* error); 176 | 177 | struct globuf_rect globuf_appkit_common_get_expose( 178 | struct globuf* context, 179 | struct appkit_platform* platform, 180 | struct globuf_error_info* error); 181 | 182 | #endif 183 | -------------------------------------------------------------------------------- /example/helpers/dynamic_loader.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_LOADER_X11_SOFTWARE 2 | #define H_GLOBUF_LOADER_X11_SOFTWARE 3 | #if defined(GLOBUF_SHARED) 4 | 5 | #include "globuf.h" 6 | #include "cursoryx.h" 7 | #include "dpishit.h" 8 | #include "willis.h" 9 | 10 | #include 11 | 12 | #if defined(GLOBUF_EXAMPLE_X11) 13 | #include 14 | #elif defined(GLOBUF_EXAMPLE_APPKIT) 15 | #elif defined(GLOBUF_EXAMPLE_WIN) 16 | #elif defined(GLOBUF_EXAMPLE_WAYLAND) 17 | #endif 18 | 19 | // pointers declaration 20 | #if defined(GLOBUF_EXAMPLE_X11) 21 | extern xcb_connection_t* (*globuf_get_x11_conn)(struct globuf* context); 22 | extern xcb_window_t (*globuf_get_x11_window)(struct globuf* context); 23 | extern xcb_window_t (*globuf_get_x11_root)(struct globuf* context); 24 | extern xcb_screen_t* (*globuf_get_x11_screen)(struct globuf* context); 25 | extern void (*cursoryx_prepare_init_x11)(struct cursoryx_config_backend* config); 26 | extern void (*willis_prepare_init_x11)(struct willis_config_backend* config); 27 | extern void (*dpishit_prepare_init_x11)(struct dpishit_config_backend* config); 28 | #if defined(GLOBUF_EXAMPLE_SOFTWARE) 29 | extern void (*globuf_prepare_init_x11_software)( 30 | struct globuf_config_backend* config, 31 | struct globuf_error_info* error); 32 | #elif defined(GLOBUF_EXAMPLE_GLX) 33 | extern void (*globuf_prepare_init_x11_glx)( 34 | struct globuf_config_backend* config, 35 | struct globuf_error_info* error); 36 | #elif defined(GLOBUF_EXAMPLE_EGL) 37 | extern void (*globuf_prepare_init_x11_egl)( 38 | struct globuf_config_backend* config, 39 | struct globuf_error_info* error); 40 | #elif defined(GLOBUF_EXAMPLE_VULKAN) 41 | extern void (*globuf_prepare_init_x11_vulkan)( 42 | struct globuf_config_backend* config, 43 | struct globuf_error_info* error); 44 | #endif 45 | #elif defined(GLOBUF_EXAMPLE_APPKIT) 46 | extern void (*cursoryx_prepare_init_appkit)(struct cursoryx_config_backend* config); 47 | extern void (*willis_prepare_init_appkit)(struct willis_config_backend* config); 48 | extern void (*dpishit_prepare_init_appkit)(struct dpishit_config_backend* config); 49 | #if defined(GLOBUF_EXAMPLE_SOFTWARE) 50 | extern void (*globuf_prepare_init_appkit_software)( 51 | struct globuf_config_backend* config, 52 | struct globuf_error_info* error); 53 | #elif defined(GLOBUF_EXAMPLE_EGL) 54 | extern double (*globuf_appkit_egl_get_scale)( 55 | struct globuf* context, 56 | struct globuf_error_info* error); 57 | extern void (*globuf_prepare_init_appkit_egl)( 58 | struct globuf_config_backend* config, 59 | struct globuf_error_info* error); 60 | #elif defined(GLOBUF_EXAMPLE_VULKAN) 61 | extern void (*globuf_prepare_init_appkit_vulkan)( 62 | struct globuf_config_backend* config, 63 | struct globuf_error_info* error); 64 | #endif 65 | #elif defined(GLOBUF_EXAMPLE_WIN) 66 | extern void* (*globuf_get_win_surface)(struct globuf* context); 67 | extern void (*cursoryx_prepare_init_win)(struct cursoryx_config_backend* config); 68 | extern void (*willis_prepare_init_win)(struct willis_config_backend* config); 69 | extern void (*dpishit_prepare_init_win)(struct dpishit_config_backend* config); 70 | #if defined(GLOBUF_EXAMPLE_SOFTWARE) 71 | extern void (*globuf_prepare_init_win_software)( 72 | struct globuf_config_backend* config, 73 | struct globuf_error_info* error); 74 | #elif defined(GLOBUF_EXAMPLE_WGL) 75 | extern void (*globuf_prepare_init_win_wgl)( 76 | struct globuf_config_backend* config, 77 | struct globuf_error_info* error); 78 | #elif defined(GLOBUF_EXAMPLE_VULKAN) 79 | extern void (*globuf_prepare_init_win_vulkan)( 80 | struct globuf_config_backend* config, 81 | struct globuf_error_info* error); 82 | #endif 83 | #elif defined(GLOBUF_EXAMPLE_WAYLAND) 84 | extern bool (*globuf_add_wayland_capabilities_handler)( 85 | void* data, 86 | void (*capabilities_handler)( 87 | void* data, 88 | void* seat, 89 | uint32_t capabilities), 90 | void* capabilities_handler_data); 91 | extern bool (*globuf_add_wayland_registry_handler)( 92 | void* data, 93 | void (*registry_handler)( 94 | void* data, 95 | void* registry, 96 | uint32_t name, 97 | const char* interface, 98 | uint32_t version), 99 | void* registry_handler_data); 100 | extern bool (*globuf_add_wayland_registry_remover)( 101 | void* data, 102 | void (*registry_remover)( 103 | void* data, 104 | void* registry, 105 | uint32_t name), 106 | void* registry_remover_data); 107 | extern void* (*globuf_get_wayland_surface)( 108 | struct globuf* context); 109 | extern void (*cursoryx_prepare_init_wayland)(struct cursoryx_config_backend* config); 110 | extern void (*willis_prepare_init_wayland)(struct willis_config_backend* config); 111 | extern void (*dpishit_prepare_init_wayland)(struct dpishit_config_backend* config); 112 | extern void (*dpishit_set_wayland_surface)( 113 | struct dpishit* context, 114 | void* surface, 115 | struct dpishit_error_info* error); 116 | #if defined(GLOBUF_EXAMPLE_SOFTWARE) 117 | extern void (*globuf_prepare_init_wayland_software)( 118 | struct globuf_config_backend* config, 119 | struct globuf_error_info* error); 120 | #elif defined(GLOBUF_EXAMPLE_EGL) 121 | extern void (*globuf_prepare_init_wayland_egl)( 122 | struct globuf_config_backend* config, 123 | struct globuf_error_info* error); 124 | #elif defined(GLOBUF_EXAMPLE_VULKAN) 125 | extern void (*globuf_prepare_init_wayland_vulkan)( 126 | struct globuf_config_backend* config, 127 | struct globuf_error_info* error); 128 | #endif 129 | #endif 130 | 131 | // loader declaration 132 | bool dynamic_loader_globuf(char* path); 133 | bool dynamic_loader_cursoryx(char* path); 134 | bool dynamic_loader_willis(char* path); 135 | bool dynamic_loader_dpishit(char* path); 136 | 137 | #endif 138 | #endif 139 | -------------------------------------------------------------------------------- /make/scripts/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # get in the right folder 4 | path="$(pwd)/$0" 5 | folder=$(dirname "$path") 6 | cd "$folder"/../.. || exit 7 | 8 | # get params 9 | build_type=$1 10 | build_platform=$2 11 | build_backend=$3 12 | build_example=$4 13 | build_toolchain=$5 14 | 15 | # set params default values if needed 16 | if [ -z "$build_type" ]; then 17 | build_type=development 18 | fi 19 | 20 | if [ -z "$build_platform" ]; then 21 | build_platform=x11 22 | fi 23 | 24 | if [ -z "$build_backend" ]; then 25 | build_backend=software 26 | fi 27 | 28 | if [ -z "$build_example" ]; then 29 | build_example=simple 30 | fi 31 | 32 | if [ -z "$build_toolchain" ]; then 33 | build_toolchain=native 34 | fi 35 | 36 | # generate ninja files 37 | case $build_platform in 38 | x11) 39 | rm -rf build make/output 40 | ./make/lib/elf.sh $build_type common 41 | ./make/lib/x11.sh $build_type common 42 | ./make/lib/x11.sh $build_type $build_backend 43 | 44 | case $build_backend in 45 | software|vulkan) 46 | ./make/lib/elf.sh $build_type $build_backend 47 | ;; 48 | 49 | egl|glx) 50 | ./make/lib/elf.sh $build_type opengl 51 | ;; 52 | esac 53 | 54 | if [ "$build_example" != "none" ]; then 55 | ./make/example/$build_example/x11.sh $build_type $build_backend 56 | fi 57 | ;; 58 | 59 | appkit) 60 | rm -rf build make/output 61 | ./make/lib/macho.sh $build_type common $build_toolchain 62 | ./make/lib/appkit.sh $build_type common $build_toolchain 63 | ./make/lib/appkit.sh $build_type $build_backend $build_toolchain 64 | 65 | case $build_backend in 66 | software|vulkan) 67 | ./make/lib/macho.sh $build_type $build_backend $build_toolchain 68 | ;; 69 | 70 | egl) 71 | ./make/lib/macho.sh $build_type opengl $build_toolchain 72 | ;; 73 | esac 74 | 75 | if [ "$build_example" != "none" ]; then 76 | ./make/example/$build_example/appkit.sh $build_type $build_backend $build_toolchain 77 | fi 78 | ;; 79 | 80 | win) 81 | rm -rf build make/output 82 | ./make/lib/pe.sh $build_type common 83 | ./make/lib/win.sh $build_type common 84 | ./make/lib/win.sh $build_type $build_backend 85 | 86 | case $build_backend in 87 | software|vulkan) 88 | ./make/lib/pe.sh $build_type $build_backend 89 | ;; 90 | 91 | wgl) 92 | ./make/lib/pe.sh $build_type opengl 93 | ;; 94 | esac 95 | 96 | if [ "$build_example" != "none" ]; then 97 | ./make/example/$build_example/win.sh $build_type $build_backend 98 | fi 99 | ;; 100 | 101 | wayland) 102 | rm -rf build make/output 103 | ./make/lib/elf.sh $build_type common 104 | ./make/lib/wayland.sh $build_type common 105 | ./make/lib/wayland.sh $build_type $build_backend 106 | 107 | case $build_backend in 108 | software|vulkan) 109 | ./make/lib/elf.sh $build_type $build_backend 110 | ;; 111 | 112 | egl) 113 | ./make/lib/elf.sh $build_type opengl 114 | ;; 115 | esac 116 | 117 | if [ "$build_example" != "none" ]; then 118 | ./make/example/$build_example/wayland.sh $build_type $build_backend 119 | fi 120 | ;; 121 | 122 | *) 123 | echo "invalid platform: $build_platform" 124 | exit 1 125 | ;; 126 | esac 127 | 128 | # build 129 | case $build_platform in 130 | x11) 131 | samu -f ./make/output/lib_elf.ninja 132 | samu -f ./make/output/lib_x11_common.ninja 133 | samu -f ./make/output/lib_x11_"$build_backend".ninja 134 | 135 | samu -f ./make/output/lib_elf.ninja headers 136 | samu -f ./make/output/lib_x11_"$build_backend".ninja headers 137 | 138 | case $build_backend in 139 | software|vulkan) 140 | samu -f ./make/output/lib_elf_"$build_backend".ninja 141 | ;; 142 | 143 | egl|glx) 144 | samu -f ./make/output/lib_elf_opengl.ninja 145 | ;; 146 | esac 147 | 148 | if [ "$build_example" != "none" ]; then 149 | samu -f ./make/output/example_"$build_example"_x11_"$build_backend".ninja 150 | fi 151 | ;; 152 | 153 | appkit) 154 | samu -f ./make/output/lib_macho.ninja 155 | samu -f ./make/output/lib_appkit_common.ninja 156 | samu -f ./make/output/lib_appkit_"$build_backend".ninja 157 | 158 | samu -f ./make/output/lib_macho.ninja headers 159 | samu -f ./make/output/lib_appkit_"$build_backend".ninja headers 160 | 161 | case $build_backend in 162 | software|vulkan) 163 | samu -f ./make/output/lib_macho_"$build_backend".ninja 164 | ;; 165 | 166 | egl) 167 | samu -f ./make/output/lib_macho_opengl.ninja 168 | ;; 169 | esac 170 | 171 | if [ "$build_example" != "none" ]; then 172 | samu -f ./make/output/example_"$build_example"_appkit_"$build_backend".ninja 173 | fi 174 | ;; 175 | 176 | win) 177 | ninja -f ./make/output/lib_pe.ninja 178 | ninja -f ./make/output/lib_win_common.ninja 179 | ninja -f ./make/output/lib_win_"$build_backend".ninja 180 | 181 | ninja -f ./make/output/lib_pe.ninja headers 182 | ninja -f ./make/output/lib_win_"$build_backend".ninja headers 183 | 184 | case $build_backend in 185 | software|vulkan) 186 | ninja -f ./make/output/lib_pe_"$build_backend".ninja 187 | ;; 188 | 189 | wgl) 190 | ninja -f ./make/output/lib_pe_opengl.ninja 191 | ;; 192 | esac 193 | 194 | if [ "$build_example" != "none" ]; then 195 | ninja -f ./make/output/example_"$build_example"_win_"$build_backend".ninja 196 | fi 197 | ;; 198 | 199 | wayland) 200 | samu -f ./make/output/lib_elf.ninja 201 | samu -f ./make/output/lib_wayland_common.ninja 202 | samu -f ./make/output/lib_wayland_"$build_backend".ninja 203 | 204 | samu -f ./make/output/lib_elf.ninja headers 205 | samu -f ./make/output/lib_wayland_"$build_backend".ninja headers 206 | 207 | case $build_backend in 208 | software|vulkan) 209 | samu -f ./make/output/lib_elf_"$build_backend".ninja 210 | ;; 211 | 212 | egl) 213 | samu -f ./make/output/lib_elf_opengl.ninja 214 | ;; 215 | esac 216 | 217 | if [ "$build_example" != "none" ]; then 218 | samu -f ./make/output/example_"$build_example"_wayland_"$build_backend".ninja 219 | fi 220 | ;; 221 | 222 | *) 223 | echo "invalid platform: $build_platform" 224 | exit 1 225 | ;; 226 | esac 227 | -------------------------------------------------------------------------------- /src/x11/x11_common.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_X11_COMMON 2 | #define H_GLOBUF_INTERNAL_X11_COMMON 3 | 4 | #include "include/globuf.h" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | // # private helpers 13 | enum x11_atoms 14 | { 15 | X11_ATOM_STATE_MAXIMIZED_HORIZONTAL = 0, 16 | X11_ATOM_STATE_MAXIMIZED_VERTICAL, 17 | X11_ATOM_STATE_FULLSCREEN, 18 | X11_ATOM_STATE_HIDDEN, 19 | X11_ATOM_STATE, 20 | X11_ATOM_ICON, 21 | X11_ATOM_HINTS_MOTIF, 22 | X11_ATOM_BLUR_KDE, 23 | X11_ATOM_BLUR_DEEPIN, 24 | X11_ATOM_PROTOCOLS, 25 | X11_ATOM_DELETE_WINDOW, 26 | X11_ATOM_SYNC_REQUEST, 27 | X11_ATOM_SYNC_REQUEST_COUNTER, 28 | X11_ATOM_FRAME_DRAWN, 29 | X11_ATOM_CHANGE_STATE, 30 | X11_ATOM_NET_SUPPORTED, 31 | X11_ATOM_NET_FRAME_EXTENTS, 32 | X11_ATOM_COUNT, 33 | }; 34 | 35 | enum globuf_xsync_status 36 | { 37 | GLOBUF_XSYNC_WAITING = 0, 38 | GLOBUF_XSYNC_CONFIGURED, 39 | GLOBUF_XSYNC_ACKNOWLEDGED, 40 | GLOBUF_XSYNC_FINISHED, 41 | }; 42 | 43 | struct x11_thread_render_loop_data 44 | { 45 | struct globuf* globuf; 46 | struct x11_platform* platform; 47 | struct globuf_error_info* error; 48 | }; 49 | 50 | struct x11_thread_event_loop_data 51 | { 52 | struct globuf* globuf; 53 | struct x11_platform* platform; 54 | struct globuf_error_info* error; 55 | }; 56 | 57 | struct x11_platform 58 | { 59 | pthread_mutex_t mutex_main; 60 | pthread_mutex_t mutex_block; 61 | pthread_mutex_t mutex_xsync; 62 | pthread_cond_t cond_main; 63 | 64 | // connection 65 | bool closed; 66 | xcb_connection_t* conn; 67 | 68 | // x11 69 | int screen_id; 70 | xcb_screen_t* screen_obj; 71 | xcb_window_t root_win; 72 | xcb_atom_t atoms[X11_ATOM_COUNT]; 73 | 74 | // window 75 | uint32_t attr_mask; 76 | uint32_t attr_val[3]; 77 | xcb_window_t win; 78 | int visual_depth; 79 | xcb_visualid_t visual_id; 80 | 81 | // xsync 82 | enum globuf_xsync_status xsync_status; 83 | xcb_sync_counter_t xsync_counter; 84 | xcb_sync_int64_t xsync_value; 85 | unsigned xsync_width; 86 | unsigned xsync_height; 87 | 88 | // saved action for globuf mouse action 89 | int32_t old_mouse_pos_x; 90 | int32_t old_mouse_pos_y; 91 | int32_t saved_mouse_pos_x; 92 | int32_t saved_mouse_pos_y; 93 | bool saved_window; 94 | int32_t saved_window_geometry[4]; 95 | bool sizemove; 96 | 97 | // render handling 98 | pthread_t thread_render_loop; 99 | struct x11_thread_render_loop_data thread_render_loop_data; 100 | void (*render_init_callback)(struct globuf*, struct globuf_error_info*); 101 | 102 | // event handling 103 | pthread_t thread_event_loop; 104 | struct x11_thread_event_loop_data thread_event_loop_data; 105 | void (*event_init_callback)(struct globuf*, struct globuf_error_info*); 106 | }; 107 | 108 | void globuf_x11_common_init( 109 | struct globuf* context, 110 | struct x11_platform* platform, 111 | struct globuf_error_info* error); 112 | 113 | void globuf_x11_common_clean( 114 | struct globuf* context, 115 | struct x11_platform* platform, 116 | struct globuf_error_info* error); 117 | 118 | void globuf_x11_common_window_create( 119 | struct globuf* context, 120 | struct x11_platform* platform, 121 | struct globuf_config_request* configs, 122 | size_t count, 123 | void (*callback)(struct globuf_config_reply* replies, size_t count, void* data), 124 | void* data, 125 | struct globuf_error_info* error); 126 | 127 | void globuf_x11_common_window_destroy( 128 | struct globuf* context, 129 | struct x11_platform* platform, 130 | struct globuf_error_info* error); 131 | 132 | void globuf_x11_common_window_confirm( 133 | struct globuf* context, 134 | struct x11_platform* platform, 135 | struct globuf_error_info* error); 136 | 137 | void globuf_x11_common_window_start( 138 | struct globuf* context, 139 | struct x11_platform* platform, 140 | struct globuf_error_info* error); 141 | 142 | void globuf_x11_common_window_block( 143 | struct globuf* context, 144 | struct x11_platform* platform, 145 | struct globuf_error_info* error); 146 | 147 | void globuf_x11_common_window_stop( 148 | struct globuf* context, 149 | struct x11_platform* platform, 150 | struct globuf_error_info* error); 151 | 152 | 153 | void globuf_x11_common_init_render( 154 | struct globuf* context, 155 | struct x11_platform* platform, 156 | struct globuf_config_render* config, 157 | struct globuf_error_info* error); 158 | 159 | void globuf_x11_common_init_events( 160 | struct globuf* context, 161 | struct x11_platform* platform, 162 | struct globuf_config_events* config, 163 | struct globuf_error_info* error); 164 | 165 | enum globuf_event globuf_x11_common_handle_events( 166 | struct globuf* context, 167 | struct x11_platform* platform, 168 | void* event, 169 | struct globuf_error_info* error); 170 | 171 | 172 | struct globuf_config_features* globuf_x11_common_init_features( 173 | struct globuf* context, 174 | struct x11_platform* platform, 175 | struct globuf_error_info* error); 176 | 177 | void globuf_x11_common_feature_set_interaction( 178 | struct globuf* context, 179 | struct x11_platform* platform, 180 | struct globuf_feature_interaction* config, 181 | struct globuf_error_info* error); 182 | 183 | void globuf_x11_common_feature_set_state( 184 | struct globuf* context, 185 | struct x11_platform* platform, 186 | struct globuf_feature_state* config, 187 | struct globuf_error_info* error); 188 | 189 | void globuf_x11_common_feature_set_title( 190 | struct globuf* context, 191 | struct x11_platform* platform, 192 | struct globuf_feature_title* config, 193 | struct globuf_error_info* error); 194 | 195 | void globuf_x11_common_feature_set_icon( 196 | struct globuf* context, 197 | struct x11_platform* platform, 198 | struct globuf_feature_icon* config, 199 | struct globuf_error_info* error); 200 | 201 | 202 | unsigned globuf_x11_common_get_width( 203 | struct globuf* context, 204 | struct x11_platform* platform, 205 | struct globuf_error_info* error); 206 | 207 | unsigned globuf_x11_common_get_height( 208 | struct globuf* context, 209 | struct x11_platform* platform, 210 | struct globuf_error_info* error); 211 | 212 | struct globuf_rect globuf_x11_common_get_expose( 213 | struct globuf* context, 214 | struct x11_platform* platform, 215 | struct globuf_error_info* error); 216 | 217 | #endif 218 | -------------------------------------------------------------------------------- /src/common/globuf.c: -------------------------------------------------------------------------------- 1 | #include "include/globuf.h" 2 | #include "common/globuf_private.h" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | struct globuf* globuf_init( 10 | struct globuf_config_backend* config, 11 | struct globuf_error_info* error) 12 | { 13 | // We allocate the context here and on the heap to avoid having to implement 14 | // a complex synchronization system just to reset a user-supplied structure 15 | // (this way this function is naturally thread-safe and reentrant). 16 | struct globuf* context = malloc(sizeof (struct globuf)); 17 | 18 | // If the context allocation failed, we can't initialize the error system 19 | // and must therefore return NULL to communicate something went wrong. 20 | if (context == NULL) 21 | { 22 | return NULL; 23 | } 24 | 25 | // zero-initialize the context (don't worry, this is optimized by compilers) 26 | struct globuf zero = {0}; 27 | *context = zero; 28 | 29 | struct globuf_config_features features = 30 | { 31 | .list = NULL, 32 | .count = 0, 33 | }; 34 | context->features = features; 35 | 36 | context->backend_data = NULL; 37 | 38 | struct globuf_config_render render_callback = 39 | { 40 | .data = NULL, 41 | .callback = NULL, 42 | }; 43 | context->render_callback = render_callback; 44 | 45 | struct globuf_config_events event_callbacks = 46 | { 47 | .data = NULL, 48 | .handler = NULL, 49 | }; 50 | context->event_callbacks = event_callbacks; 51 | 52 | context->backend_callbacks = *config; 53 | 54 | struct globuf_rect expose = 55 | { 56 | .x = 0, 57 | .y = 0, 58 | .width = 0, 59 | .height = 0, 60 | }; 61 | context->expose = expose; 62 | 63 | // initialize the error system 64 | globuf_error_init(context); 65 | 66 | // initialize the feature pointers 67 | context->feature_interaction = NULL; 68 | context->feature_state = NULL; 69 | context->feature_title = NULL; 70 | context->feature_icon = NULL; 71 | context->feature_size = NULL; 72 | context->feature_pos = NULL; 73 | context->feature_frame = NULL; 74 | context->feature_background = NULL; 75 | context->feature_vsync = NULL; 76 | 77 | // call the backend's init function 78 | context->backend_callbacks.init(context, error); 79 | 80 | // error always set 81 | return context; 82 | } 83 | 84 | void globuf_clean( 85 | struct globuf* context, 86 | struct globuf_error_info* error) 87 | { 88 | context->backend_callbacks.clean(context, error); 89 | free(context); 90 | 91 | // error always set 92 | } 93 | 94 | void globuf_window_create( 95 | struct globuf* context, 96 | struct globuf_config_request* configs, 97 | size_t count, 98 | void (*callback)(struct globuf_config_reply* replies, size_t count, void* data), 99 | void* data, 100 | struct globuf_error_info* error) 101 | { 102 | context->backend_callbacks.window_create(context, configs, count, callback, data, error); 103 | 104 | // error always set 105 | } 106 | 107 | void globuf_window_destroy( 108 | struct globuf* context, 109 | struct globuf_error_info* error) 110 | { 111 | context->backend_callbacks.window_destroy(context, error); 112 | 113 | // error always set 114 | } 115 | 116 | void globuf_window_confirm( 117 | struct globuf* context, 118 | struct globuf_error_info* error) 119 | { 120 | context->backend_callbacks.window_confirm(context, error); 121 | 122 | // error always set 123 | } 124 | 125 | void globuf_window_start( 126 | struct globuf* context, 127 | struct globuf_error_info* error) 128 | { 129 | context->backend_callbacks.window_start(context, error); 130 | 131 | // error always set 132 | } 133 | 134 | void globuf_window_block( 135 | struct globuf* context, 136 | struct globuf_error_info* error) 137 | { 138 | context->backend_callbacks.window_block(context, error); 139 | 140 | // error always set 141 | } 142 | 143 | void globuf_window_stop( 144 | struct globuf* context, 145 | struct globuf_error_info* error) 146 | { 147 | context->backend_callbacks.window_stop(context, error); 148 | 149 | // error always set 150 | } 151 | 152 | 153 | void globuf_init_render( 154 | struct globuf* context, 155 | struct globuf_config_render* config, 156 | struct globuf_error_info* error) 157 | { 158 | context->backend_callbacks.init_render(context, config, error); 159 | 160 | // error always set 161 | } 162 | 163 | void globuf_init_events( 164 | struct globuf* context, 165 | struct globuf_config_events* config, 166 | struct globuf_error_info* error) 167 | { 168 | context->backend_callbacks.init_events(context, config, error); 169 | 170 | // error always set 171 | } 172 | 173 | enum globuf_event globuf_handle_events( 174 | struct globuf* context, 175 | void* event, 176 | struct globuf_error_info* error) 177 | { 178 | // error always set 179 | return context->backend_callbacks.handle_events(context, event, error); 180 | } 181 | 182 | 183 | struct globuf_config_features* globuf_init_features( 184 | struct globuf* context, 185 | struct globuf_error_info* error) 186 | { 187 | // error always set 188 | return context->backend_callbacks.init_features(context, error); 189 | } 190 | 191 | void globuf_feature_set_interaction( 192 | struct globuf* context, 193 | struct globuf_feature_interaction* config, 194 | struct globuf_error_info* error) 195 | { 196 | context->backend_callbacks.feature_set_interaction(context, config, error); 197 | 198 | // error always set 199 | } 200 | 201 | void globuf_feature_set_state( 202 | struct globuf* context, 203 | struct globuf_feature_state* config, 204 | struct globuf_error_info* error) 205 | { 206 | context->backend_callbacks.feature_set_state(context, config, error); 207 | 208 | // error always set 209 | } 210 | 211 | void globuf_feature_set_title( 212 | struct globuf* context, 213 | struct globuf_feature_title* config, 214 | struct globuf_error_info* error) 215 | { 216 | context->backend_callbacks.feature_set_title(context, config, error); 217 | 218 | // error always set 219 | } 220 | 221 | void globuf_feature_set_icon( 222 | struct globuf* context, 223 | struct globuf_feature_icon* config, 224 | struct globuf_error_info* error) 225 | { 226 | context->backend_callbacks.feature_set_icon(context, config, error); 227 | 228 | // error always set 229 | } 230 | 231 | 232 | // always available 233 | unsigned globuf_get_width( 234 | struct globuf* context, 235 | struct globuf_error_info* error) 236 | { 237 | // error always set 238 | return context->backend_callbacks.get_width(context, error); 239 | } 240 | 241 | // always available 242 | unsigned globuf_get_height( 243 | struct globuf* context, 244 | struct globuf_error_info* error) 245 | { 246 | // error always set 247 | return context->backend_callbacks.get_height(context, error); 248 | } 249 | 250 | // always available 251 | struct globuf_rect globuf_get_expose( 252 | struct globuf* context, 253 | struct globuf_error_info* error) 254 | { 255 | // error always set 256 | return context->backend_callbacks.get_expose(context, error); 257 | } 258 | 259 | 260 | void globuf_update_content( 261 | struct globuf* context, 262 | void* data, 263 | struct globuf_error_info* error) 264 | { 265 | context->backend_callbacks.update_content(context, data, error); 266 | 267 | // error always set 268 | } 269 | -------------------------------------------------------------------------------- /src/x11/x11_vulkan_helpers.c: -------------------------------------------------------------------------------- 1 | #define _XOPEN_SOURCE 700 2 | 3 | #include "include/globuf.h" 4 | #include "common/globuf_private.h" 5 | #include "x11/x11_vulkan_helpers.h" 6 | #include "x11/x11_vulkan.h" 7 | #include "x11/x11_common.h" 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | size_t x11_helpers_vulkan_add_extensions( 17 | struct globuf* context, 18 | const char*** ext_needed, 19 | bool** ext_found, 20 | struct globuf_error_info* error) 21 | { 22 | // list vulkan extensions here to make the code cleaner 23 | const char* extensions_names[] = 24 | { 25 | VK_EXT_DEBUG_REPORT_EXTENSION_NAME, 26 | VK_KHR_SURFACE_EXTENSION_NAME, 27 | VK_KHR_XCB_SURFACE_EXTENSION_NAME, 28 | }; 29 | 30 | size_t extensions_count = 31 | (sizeof (extensions_names)) / (sizeof (const char*)); 32 | 33 | // allocate required extensions list 34 | *ext_needed = malloc(extensions_count * sizeof (char*)); 35 | 36 | if (*ext_needed == NULL) 37 | { 38 | globuf_error_throw(context, error, GLOBUF_ERROR_ALLOC); 39 | return 0; 40 | } 41 | 42 | // allocate found required extensions list 43 | *ext_found = malloc(extensions_count * sizeof (bool)); 44 | 45 | if (*ext_found == NULL) 46 | { 47 | globuf_error_throw(context, error, GLOBUF_ERROR_ALLOC); 48 | return 0; 49 | } 50 | 51 | // initialize values 52 | for (size_t i = 0; i < extensions_count; ++i) 53 | { 54 | (*ext_needed)[i] = extensions_names[i]; 55 | (*ext_found)[i] = false; 56 | } 57 | 58 | globuf_error_ok(error); 59 | 60 | return extensions_count; 61 | } 62 | 63 | void x11_helpers_vulkan_visual_transparent( 64 | struct globuf* context, 65 | struct globuf_error_info* error) 66 | { 67 | struct x11_vulkan_backend* backend = context->backend_data; 68 | struct x11_platform* platform = &(backend->platform); 69 | 70 | xcb_render_query_pict_formats_cookie_t cookie_pict; 71 | xcb_render_query_pict_formats_reply_t* reply_pict; 72 | xcb_generic_error_t* error_pict; 73 | 74 | cookie_pict = 75 | xcb_render_query_pict_formats( 76 | platform->conn); 77 | 78 | reply_pict = 79 | xcb_render_query_pict_formats_reply( 80 | platform->conn, 81 | cookie_pict, 82 | &error_pict); 83 | 84 | if (error_pict != NULL) 85 | { 86 | globuf_error_throw( 87 | context, 88 | error, 89 | GLOBUF_ERROR_X11_VISUAL_INCOMPATIBLE); 90 | 91 | return; 92 | } 93 | 94 | // loop over all buffer formats to find ARGB8888 95 | xcb_render_pictforminfo_iterator_t iter_pict; 96 | xcb_render_pictforminfo_t* pictforminfo; 97 | xcb_render_pictformat_t pictformat; 98 | bool found_format; 99 | 100 | iter_pict = 101 | xcb_render_query_pict_formats_formats_iterator( 102 | reply_pict); 103 | 104 | found_format = false; 105 | 106 | while (iter_pict.rem != 0) 107 | { 108 | pictforminfo = iter_pict.data; 109 | 110 | if ((pictforminfo->direct.alpha_mask == 255) 111 | && (pictforminfo->direct.red_mask == 255) 112 | && (pictforminfo->direct.green_mask == 255) 113 | && (pictforminfo->direct.blue_mask == 255) 114 | && (pictforminfo->direct.alpha_shift == 24) 115 | && (pictforminfo->direct.red_shift == 16) 116 | && (pictforminfo->direct.green_shift == 8) 117 | && (pictforminfo->direct.blue_shift == 0) 118 | && (pictforminfo->depth == 32)) 119 | { 120 | platform->visual_depth = 32; 121 | pictformat = pictforminfo->id; 122 | found_format = true; 123 | break; 124 | } 125 | 126 | xcb_render_pictforminfo_next( 127 | &iter_pict); 128 | } 129 | 130 | if (found_format == false) 131 | { 132 | free(reply_pict); 133 | 134 | globuf_error_throw( 135 | context, 136 | error, 137 | GLOBUF_ERROR_X11_VISUAL_INCOMPATIBLE); 138 | 139 | return; 140 | } 141 | 142 | // match the buffer format with a visual id 143 | xcb_render_pictscreen_iterator_t iter_screens; 144 | xcb_render_pictdepth_iterator_t iter_depths; 145 | xcb_render_pictvisual_iterator_t iter_visuals; 146 | xcb_colormap_t colormap; 147 | bool found_visual; 148 | 149 | iter_screens = 150 | xcb_render_query_pict_formats_screens_iterator( 151 | reply_pict); 152 | 153 | found_visual = false; 154 | 155 | while ((iter_screens.rem != 0) && (found_visual == false)) 156 | { 157 | iter_depths = 158 | xcb_render_pictscreen_depths_iterator( 159 | iter_screens.data); 160 | 161 | while ((iter_depths.rem != 0) && (found_visual == false)) 162 | { 163 | iter_visuals = 164 | xcb_render_pictdepth_visuals_iterator( 165 | iter_depths.data); 166 | 167 | while ((iter_visuals.rem != 0) && (found_visual == false)) 168 | { 169 | // infer false-positive 170 | if ((iter_visuals.data != NULL) 171 | && (iter_visuals.data->format == pictformat)) 172 | { 173 | platform->visual_id = iter_visuals.data->visual; 174 | found_visual = true; 175 | break; 176 | } 177 | 178 | xcb_render_pictvisual_next( 179 | &iter_visuals); 180 | } 181 | 182 | xcb_render_pictdepth_next( 183 | &iter_depths); 184 | } 185 | 186 | xcb_render_pictscreen_next( 187 | &iter_screens); 188 | } 189 | 190 | if (found_visual == false) 191 | { 192 | free(reply_pict); 193 | 194 | globuf_error_throw( 195 | context, 196 | error, 197 | GLOBUF_ERROR_X11_VISUAL_INCOMPATIBLE); 198 | 199 | return; 200 | } 201 | 202 | // generate a compatible colormap for the chosen visual id 203 | colormap = 204 | xcb_generate_id( 205 | platform->conn); 206 | 207 | xcb_create_colormap( 208 | platform->conn, 209 | XCB_COLORMAP_ALLOC_NONE, 210 | colormap, 211 | platform->screen_obj->root, 212 | platform->visual_id); 213 | 214 | platform->attr_val[2] = colormap; 215 | 216 | free(reply_pict); 217 | 218 | globuf_error_ok(error); 219 | return; 220 | } 221 | 222 | void x11_helpers_vulkan_visual_opaque( 223 | struct globuf* context, 224 | struct globuf_error_info* error) 225 | { 226 | struct x11_vulkan_backend* backend = context->backend_data; 227 | struct x11_platform* platform = &(backend->platform); 228 | 229 | platform->visual_id = platform->screen_obj->root_visual; 230 | xcb_visualtype_t* visual = NULL; 231 | 232 | xcb_depth_iterator_t depth_iter = 233 | xcb_screen_allowed_depths_iterator( 234 | platform->screen_obj); 235 | 236 | xcb_visualtype_iterator_t visual_iter; 237 | 238 | while (depth_iter.rem != 0) 239 | { 240 | visual_iter = xcb_depth_visuals_iterator(depth_iter.data); 241 | 242 | while (visual_iter.rem != 0) 243 | { 244 | if (platform->visual_id == visual_iter.data->visual_id) 245 | { 246 | visual = visual_iter.data; 247 | break; 248 | } 249 | 250 | xcb_visualtype_next(&visual_iter); 251 | } 252 | 253 | if (visual != NULL) 254 | { 255 | if ((visual->_class != XCB_VISUAL_CLASS_TRUE_COLOR) 256 | && (visual->_class != XCB_VISUAL_CLASS_DIRECT_COLOR)) 257 | { 258 | globuf_error_throw( 259 | context, 260 | error, 261 | GLOBUF_ERROR_X11_VISUAL_INCOMPATIBLE); 262 | 263 | return; 264 | } 265 | else 266 | { 267 | break; 268 | } 269 | } 270 | 271 | xcb_depth_next(&depth_iter); 272 | } 273 | 274 | if (depth_iter.rem == 0) 275 | { 276 | globuf_error_throw( 277 | context, 278 | error, 279 | GLOBUF_ERROR_X11_VISUAL_MISSING); 280 | 281 | return; 282 | } 283 | 284 | platform->visual_depth = depth_iter.data->depth; 285 | 286 | globuf_error_ok(error); 287 | } 288 | -------------------------------------------------------------------------------- /src/wayland/wayland_common.h: -------------------------------------------------------------------------------- 1 | #ifndef H_GLOBUF_INTERNAL_WAYLAND_COMMON 2 | #define H_GLOBUF_INTERNAL_WAYLAND_COMMON 3 | 4 | #include "include/globuf.h" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "xdg-shell-client-protocol.h" 12 | #include "xdg-decoration-client-protocol.h" 13 | #include "kde-blur-client-protocol.h" 14 | 15 | // # private helpers 16 | struct wayland_thread_render_loop_data 17 | { 18 | struct globuf* globuf; 19 | struct wayland_platform* platform; 20 | struct globuf_error_info* error; 21 | }; 22 | 23 | struct wayland_thread_event_loop_data 24 | { 25 | struct globuf* globuf; 26 | struct wayland_platform* platform; 27 | struct globuf_error_info* error; 28 | }; 29 | 30 | struct wayland_capabilities_handler_node 31 | { 32 | void (*capabilities_handler)( 33 | void* data, 34 | void* seat, 35 | uint32_t capabilities); 36 | void* capabilities_handler_data; 37 | struct wayland_capabilities_handler_node* next; 38 | }; 39 | 40 | struct wayland_registry_handler_node 41 | { 42 | void (*registry_handler)( 43 | void* data, 44 | void* registry, 45 | uint32_t name, 46 | const char* interface, 47 | uint32_t version); 48 | void* registry_handler_data; 49 | struct wayland_registry_handler_node* next; 50 | }; 51 | 52 | struct wayland_registry_remover_node 53 | { 54 | void (*registry_remover)( 55 | void* data, 56 | void* registry, 57 | uint32_t name); 58 | void* registry_remover_data; 59 | struct wayland_registry_remover_node* next; 60 | }; 61 | 62 | struct wayland_platform 63 | { 64 | pthread_mutex_t mutex_main; 65 | pthread_mutex_t mutex_block; 66 | pthread_mutex_t mutex_xsync; 67 | pthread_cond_t cond_main; 68 | 69 | // globuf 70 | bool init; 71 | bool closed; 72 | struct globuf* globuf; 73 | 74 | // core structures 75 | struct wl_display* display; 76 | struct wl_registry* registry; 77 | struct wl_seat* seat; 78 | struct wl_pointer* pointer; 79 | struct wl_surface* surface; 80 | 81 | // base interfaces 82 | struct wl_compositor* compositor; 83 | struct xdg_wm_base* xdg_wm_base; 84 | 85 | // desktop structures 86 | struct xdg_surface* xdg_surface; 87 | struct xdg_toplevel* xdg_toplevel; 88 | 89 | // desktop decorations interface 90 | struct zxdg_decoration_manager_v1* xdg_decoration_manager; 91 | struct zxdg_toplevel_decoration_v1* xdg_decoration; 92 | 93 | // kde blur interface 94 | struct org_kde_kwin_blur_manager* kde_blur_manager; 95 | struct org_kde_kwin_blur* kde_blur; 96 | 97 | // wayland window status info 98 | uint32_t decoration_mode; 99 | uint32_t sizing_edge; 100 | 101 | // wayland listeners 102 | struct wl_registry_listener listener_registry; 103 | struct wl_seat_listener listener_seat; 104 | struct wl_pointer_listener listener_pointer; 105 | struct wl_callback_listener listener_surface_frame; 106 | 107 | struct xdg_wm_base_listener listener_xdg_wm_base; 108 | struct xdg_surface_listener listener_xdg_surface; 109 | struct xdg_toplevel_listener listener_xdg_toplevel; 110 | struct zxdg_toplevel_decoration_v1_listener listener_xdg_decoration; 111 | 112 | // external wayland negociation callbacks handling 113 | struct wayland_capabilities_handler_node* capabilities_handlers; 114 | struct wayland_registry_handler_node* registry_handlers; 115 | struct wayland_registry_remover_node* registry_removers; 116 | 117 | // globuf feature negociation 118 | void (*feature_callback)( 119 | struct globuf_config_reply* replies, 120 | size_t count, 121 | void* data); 122 | void* feature_callback_data; 123 | struct globuf_config_request* feature_configs; 124 | size_t feature_count; 125 | 126 | // render handling 127 | pthread_t thread_render_loop; 128 | struct wayland_thread_render_loop_data thread_render_loop_data; 129 | void (*render_init_callback)(struct globuf*, struct globuf_error_info*); 130 | 131 | // event handling 132 | pthread_t thread_event_loop; 133 | struct wayland_thread_event_loop_data thread_event_loop_data; 134 | void (*event_init_callback)(struct globuf*, struct globuf_error_info*); 135 | }; 136 | 137 | void globuf_wayland_common_init( 138 | struct globuf* context, 139 | struct wayland_platform* platform, 140 | struct globuf_error_info* error); 141 | 142 | void globuf_wayland_common_clean( 143 | struct globuf* context, 144 | struct wayland_platform* platform, 145 | struct globuf_error_info* error); 146 | 147 | void globuf_wayland_common_window_create( 148 | struct globuf* context, 149 | struct wayland_platform* platform, 150 | struct globuf_config_request* configs, 151 | size_t count, 152 | void (*callback)(struct globuf_config_reply* replies, size_t count, void* data), 153 | void* data, 154 | struct globuf_error_info* error); 155 | 156 | void globuf_wayland_common_window_destroy( 157 | struct globuf* context, 158 | struct wayland_platform* platform, 159 | struct globuf_error_info* error); 160 | 161 | void globuf_wayland_common_window_confirm( 162 | struct globuf* context, 163 | struct wayland_platform* platform, 164 | struct globuf_error_info* error); 165 | 166 | void globuf_wayland_common_window_start( 167 | struct globuf* context, 168 | struct wayland_platform* platform, 169 | struct globuf_error_info* error); 170 | 171 | void globuf_wayland_common_window_block( 172 | struct globuf* context, 173 | struct wayland_platform* platform, 174 | struct globuf_error_info* error); 175 | 176 | void globuf_wayland_common_window_stop( 177 | struct globuf* context, 178 | struct wayland_platform* platform, 179 | struct globuf_error_info* error); 180 | 181 | 182 | void globuf_wayland_common_init_render( 183 | struct globuf* context, 184 | struct wayland_platform* platform, 185 | struct globuf_config_render* config, 186 | struct globuf_error_info* error); 187 | 188 | void globuf_wayland_common_init_events( 189 | struct globuf* context, 190 | struct wayland_platform* platform, 191 | struct globuf_config_events* config, 192 | struct globuf_error_info* error); 193 | 194 | enum globuf_event globuf_wayland_common_handle_events( 195 | struct globuf* context, 196 | struct wayland_platform* platform, 197 | void* event, 198 | struct globuf_error_info* error); 199 | 200 | 201 | struct globuf_config_features* globuf_wayland_common_init_features( 202 | struct globuf* context, 203 | struct wayland_platform* platform, 204 | struct globuf_error_info* error); 205 | 206 | void globuf_wayland_common_feature_set_interaction( 207 | struct globuf* context, 208 | struct wayland_platform* platform, 209 | struct globuf_feature_interaction* config, 210 | struct globuf_error_info* error); 211 | 212 | void globuf_wayland_common_feature_set_state( 213 | struct globuf* context, 214 | struct wayland_platform* platform, 215 | struct globuf_feature_state* config, 216 | struct globuf_error_info* error); 217 | 218 | void globuf_wayland_common_feature_set_title( 219 | struct globuf* context, 220 | struct wayland_platform* platform, 221 | struct globuf_feature_title* config, 222 | struct globuf_error_info* error); 223 | 224 | void globuf_wayland_common_feature_set_icon( 225 | struct globuf* context, 226 | struct wayland_platform* platform, 227 | struct globuf_feature_icon* config, 228 | struct globuf_error_info* error); 229 | 230 | 231 | unsigned globuf_wayland_common_get_width( 232 | struct globuf* context, 233 | struct wayland_platform* platform, 234 | struct globuf_error_info* error); 235 | 236 | unsigned globuf_wayland_common_get_height( 237 | struct globuf* context, 238 | struct wayland_platform* platform, 239 | struct globuf_error_info* error); 240 | 241 | struct globuf_rect globuf_wayland_common_get_expose( 242 | struct globuf* context, 243 | struct wayland_platform* platform, 244 | struct globuf_error_info* error); 245 | 246 | #endif 247 | --------------------------------------------------------------------------------