Init
This commit is contained in:
commit
7a66ef5269
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
.DS_Store
|
||||||
|
**/*.obj
|
||||||
|
examples_macos_exec/
|
||||||
|
examples_windows_exec/
|
||||||
|
examples_linux_exec/
|
||||||
|
imgui.ini
|
6
.gitmodules
vendored
Normal file
6
.gitmodules
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[submodule "imgui"]
|
||||||
|
path = imgui
|
||||||
|
url = https://github.com/ocornut/imgui
|
||||||
|
[submodule "dear_bindings"]
|
||||||
|
path = dear_bindings
|
||||||
|
url = https://github.com/dearimgui/dear_bindings
|
75
README.md
Normal file
75
README.md
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
# Dear ImGui Bindings for Odin
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Copy the repo as a directory to your project and import it like you typically would in Odin. See examples for real code examples.
|
||||||
|
|
||||||
|
There is no need to run the build scripts unless you want to build the static libraries for yourself or if you want to build all the examples.
|
||||||
|
|
||||||
|
Note that Vulkan (if you use the Vulkan renderer) and C++ Standard Library\* must be linked when you use this library on macOS and Linux where it is preferred to link libraries dynamically.
|
||||||
|
|
||||||
|
\*for thread safety; if not needed, you must recompile with it `-fno-threadsafe-statics`
|
||||||
|
|
||||||
|
## Supported Backends
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
|
||||||
|
| Windows | OpenGL | Vulkan | D3D11 |
|
||||||
|
|---------|--------|--------|-------|
|
||||||
|
| SDL2 | X | X | - |
|
||||||
|
| GLFW | X | X | - |
|
||||||
|
|
||||||
|
### macOS
|
||||||
|
|
||||||
|
| macOS | OpenGL | Vulkan | Metal |
|
||||||
|
|-------|--------|--------|-------|
|
||||||
|
| SDL2 | X | X | X |
|
||||||
|
| GLFW | X | X | X |
|
||||||
|
|
||||||
|
### Linux
|
||||||
|
|
||||||
|
| Linux | OpenGL | Vulkan |
|
||||||
|
|---------|--------|--------|
|
||||||
|
| SDL2 | X | X |
|
||||||
|
| GLFW | X | X |
|
||||||
|
|
||||||
|
SDL3 will be supported once the package is available in its vendor library.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
You can run an example like so:
|
||||||
|
(replace `{backend}` and `{renderer}` with the one you want)
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
```batch
|
||||||
|
odin run examples/impl_{backend}_{renderer}.odin -file
|
||||||
|
```
|
||||||
|
|
||||||
|
### macOS/Linux:
|
||||||
|
```sh
|
||||||
|
odin run examples/impl_{backend}_{renderer}.odin -file -extra-linker-flags:"-lstdc++"
|
||||||
|
```
|
||||||
|
|
||||||
|
If you use Vulkan as a renderer on macOS or Linux, don't forget to link Vulkan as mentioned before: `-extra-linker-flags:"-lstdc++ -lvulkan"`.
|
||||||
|
|
||||||
|
## Building
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
|
||||||
|
```batch
|
||||||
|
./build.bat
|
||||||
|
```
|
||||||
|
|
||||||
|
### Linux
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./build_linux.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
### macOS
|
||||||
|
|
||||||
|
For Metal renderer, you must provide the path to the Metal Cpp header files in the `METAL_CPP_DIR` environment variable like so:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
METAL_CPP_DIR="replace this with the metal cpp path" ./build_mac.sh
|
||||||
|
```
|
161
build.bat
Executable file
161
build.bat
Executable file
@ -0,0 +1,161 @@
|
|||||||
|
@echo off
|
||||||
|
setlocal EnableDelayedExpansion
|
||||||
|
set SDL2_DIR=C:\tools\SDL2-2.30.11\
|
||||||
|
set GLFW_DIR=C:\tools\glfw-3.4.bin.WIN64\
|
||||||
|
set SDL3_DIR="C:\tools\SDL3\"
|
||||||
|
|
||||||
|
where /Q cl.exe || (
|
||||||
|
set __VSCMD_ARG_NO_LOGO=1
|
||||||
|
for /f "tokens=*" %%i in ('"%PROGRAMFILES(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -requires Microsoft.VisualStudio.Workload.NativeDesktop -property installationPath') do set VS=%%i
|
||||||
|
if "!VS!" equ "" (
|
||||||
|
echo Cannot find VS
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
call "!VS!\VC\Auxiliary\Build\vcvarsall.bat" amd64 || exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
pushd %~dp0
|
||||||
|
|
||||||
|
cl /nologo /Oi /GF /MP /MT /utf-8 /O2 /c ^
|
||||||
|
/I imgui\ ^
|
||||||
|
imgui\imgui.cpp ^
|
||||||
|
imgui\imgui_draw.cpp ^
|
||||||
|
imgui\imgui_tables.cpp ^
|
||||||
|
imgui\imgui_widgets.cpp ^
|
||||||
|
imgui\imgui_demo.cpp ^
|
||||||
|
dcimgui.cpp
|
||||||
|
|
||||||
|
lib /nologo /out:"lib\dcimgui.lib" ^
|
||||||
|
imgui.obj ^
|
||||||
|
imgui_draw.obj ^
|
||||||
|
imgui_tables.obj ^
|
||||||
|
imgui_widgets.obj ^
|
||||||
|
imgui_demo.obj ^
|
||||||
|
dcimgui.obj
|
||||||
|
|
||||||
|
del imgui.obj ^
|
||||||
|
imgui_draw.obj ^
|
||||||
|
imgui_tables.obj ^
|
||||||
|
imgui_widgets.obj ^
|
||||||
|
imgui_demo.obj ^
|
||||||
|
dcimgui.obj
|
||||||
|
|
||||||
|
if exist %SDL2_DIR% (
|
||||||
|
echo Building SDL2 Backend
|
||||||
|
cl /nologo /Oi /GF /MP /MT /utf-8 /O2 /c ^
|
||||||
|
imgui\backends/imgui_impl_sdl2.cpp ^
|
||||||
|
sdl2\impl_sdl2.cpp ^
|
||||||
|
/I imgui\ ^
|
||||||
|
/I imgui/backends\ ^
|
||||||
|
/I %SDL2_DIR%\include
|
||||||
|
|
||||||
|
lib /nologo /out:"lib\dcimgui_impl_sdl2.lib" ^
|
||||||
|
%SDL2_DIR%\lib\x64\SDL2.lib ^
|
||||||
|
%SDL2_DIR%\lib\x64\SDL2main.lib ^
|
||||||
|
impl_sdl2.obj ^
|
||||||
|
imgui_impl_sdl2.obj
|
||||||
|
|
||||||
|
del imgui_impl_sdl2.obj ^
|
||||||
|
impl_sdl2.obj
|
||||||
|
)
|
||||||
|
|
||||||
|
if exist %GLFW_DIR% (
|
||||||
|
echo Building GLFW Backend
|
||||||
|
cl /nologo /Oi /GF /MP /MT /utf-8 /O2 /c ^
|
||||||
|
imgui\backends/imgui_impl_glfw.cpp ^
|
||||||
|
glfw\impl_glfw.cpp ^
|
||||||
|
/I imgui\ ^
|
||||||
|
/I imgui/backends\ ^
|
||||||
|
/I %GLFW_DIR%\include\
|
||||||
|
|
||||||
|
lib /nologo /out:"lib\dcimgui_impl_glfw.lib" ^
|
||||||
|
%GLFW_DIR%\lib-vc2022\glfw3_mt.lib ^
|
||||||
|
impl_glfw.obj ^
|
||||||
|
imgui_impl_glfw.obj
|
||||||
|
|
||||||
|
del imgui_impl_glfw.obj ^
|
||||||
|
impl_glfw.obj
|
||||||
|
)
|
||||||
|
|
||||||
|
if exist %SDL3_DIR% (
|
||||||
|
echo Building SDL3 Backend
|
||||||
|
cl /nologo /Oi /GF /MP /MT /utf-8 /O2 /c ^
|
||||||
|
imgui\backends/imgui_impl_sdl3.cpp ^
|
||||||
|
sdl3\impl_sdl3.cpp ^
|
||||||
|
/I imgui\ ^
|
||||||
|
/I imgui/backends\ ^
|
||||||
|
/I %SDL3_DIR%\include ^
|
||||||
|
/link %SDL3_DIR%\lib\x64\SDL3.lib %SDL3_DIR%\lib\x64\SDL3main.lib
|
||||||
|
|
||||||
|
lib /nologo /out:"lib\dcimgui_impl_sdl3.lib" ^
|
||||||
|
impl_sdl3.obj ^
|
||||||
|
imgui_impl_sdl3.obj
|
||||||
|
|
||||||
|
del imgui_impl_sdl3.obj ^
|
||||||
|
impl_sdl3.obj
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
echo Building OpenGL3 Backend
|
||||||
|
|
||||||
|
cl /nologo /Oi /GF /MP /MT /utf-8 /O2 /c ^
|
||||||
|
imgui/backends/imgui_impl_opengl3.cpp ^
|
||||||
|
opengl3/impl_opengl3.cpp ^
|
||||||
|
/I imgui\ ^
|
||||||
|
/I imgui\backends\
|
||||||
|
|
||||||
|
lib /nologo /out:".\lib\dcimgui_impl_opengl3.lib" ^
|
||||||
|
impl_opengl3.obj ^
|
||||||
|
imgui_impl_opengl3.obj ^
|
||||||
|
Opengl32.lib
|
||||||
|
|
||||||
|
del imgui_impl_opengl3.obj ^
|
||||||
|
impl_opengl3.obj
|
||||||
|
|
||||||
|
|
||||||
|
if exist %VULKAN_SDK% (
|
||||||
|
echo Building Vulkan Backend
|
||||||
|
cl /nologo /Oi /GF /MP /MT /utf-8 /O2 /c ^
|
||||||
|
imgui/backends/imgui_impl_vulkan.cpp ^
|
||||||
|
vulkan/impl_vulkan.cpp ^
|
||||||
|
/I imgui\ ^
|
||||||
|
/I imgui\backends\ ^
|
||||||
|
/I %VULKAN_SDK%\Include\
|
||||||
|
|
||||||
|
lib /nologo /out:".\lib\dcimgui_impl_vulkan.lib" ^
|
||||||
|
impl_vulkan.obj ^
|
||||||
|
imgui_impl_vulkan.obj ^
|
||||||
|
%VULKAN_SDK%\Lib\vulkan-1.lib
|
||||||
|
|
||||||
|
del imgui_impl_vulkan.obj ^
|
||||||
|
impl_vulkan.obj
|
||||||
|
)
|
||||||
|
|
||||||
|
popd
|
||||||
|
|
||||||
|
rem @echo off
|
||||||
|
rem setlocal
|
||||||
|
|
||||||
|
rem REM Define the file to check
|
||||||
|
rem set "fileToCheck="
|
||||||
|
|
||||||
|
rem REM Get the last modified date of the file
|
||||||
|
rem forfiles /p "%fileToCheck%" /c "cmd /c echo @fdate" > lastModifiedDate.txt
|
||||||
|
|
||||||
|
rem REM Read the last modified date
|
||||||
|
rem set /p lastModified=<lastModifiedDate.txt
|
||||||
|
|
||||||
|
rem REM Define the stored date (you can store this in a file or a variable)
|
||||||
|
rem set storedDate=2024-01-01
|
||||||
|
|
||||||
|
rem REM Compare dates
|
||||||
|
rem if "%lastModified%" neq "%storedDate%" (
|
||||||
|
rem REM File has been modified, execute build command
|
||||||
|
rem echo Building...
|
||||||
|
rem REM Add your build command here
|
||||||
|
rem REM Example: call build.bat
|
||||||
|
rem ) else (
|
||||||
|
rem echo No changes detected.
|
||||||
|
rem )
|
||||||
|
|
||||||
|
rem endlocal
|
77
build_linux.sh
Executable file
77
build_linux.sh
Executable file
@ -0,0 +1,77 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -xue
|
||||||
|
|
||||||
|
mkdir -p lib/linux/
|
||||||
|
|
||||||
|
clang++ \
|
||||||
|
-c \
|
||||||
|
-O2 -fno-exceptions -fno-rtti \
|
||||||
|
-I./imgui \
|
||||||
|
./imgui/imgui.cpp \
|
||||||
|
./imgui/imgui_draw.cpp \
|
||||||
|
./imgui/imgui_tables.cpp \
|
||||||
|
./imgui/imgui_widgets.cpp \
|
||||||
|
./imgui/imgui_demo.cpp \
|
||||||
|
dcimgui.cpp
|
||||||
|
|
||||||
|
ar rcs ./lib/linux/libdcimgui.a imgui.o imgui_draw.o imgui_tables.o imgui_widgets.o imgui_demo.o dcimgui.o
|
||||||
|
rm imgui.o imgui_draw.o imgui_tables.o imgui_widgets.o imgui_demo.o dcimgui.o
|
||||||
|
|
||||||
|
# clang++ -c \
|
||||||
|
# -O2 -fno-exceptions -fno-rtti \
|
||||||
|
# -I./imgui/ \
|
||||||
|
# -I./imgui/backends/ \
|
||||||
|
# # -I/usr/include/SDL3 \
|
||||||
|
# ./imgui/backends/imgui_impl_sdl3.cpp \
|
||||||
|
# ./sdl3/impl_sdl3.cpp
|
||||||
|
|
||||||
|
clang++ \
|
||||||
|
-c \
|
||||||
|
-O2 -fno-exceptions -fno-rtti \
|
||||||
|
-I./imgui/ \
|
||||||
|
-I./imgui/backends/ \
|
||||||
|
$(sdl2-config --cflags) \
|
||||||
|
./imgui/backends/imgui_impl_sdl2.cpp \
|
||||||
|
./sdl2/impl_sdl2.cpp
|
||||||
|
|
||||||
|
ar rcs ./lib/linux/libdcimgui_impl_sdl2.a imgui_impl_sdl2.o impl_sdl2.o
|
||||||
|
rm imgui_impl_sdl2.o impl_sdl2.o
|
||||||
|
|
||||||
|
clang++ \
|
||||||
|
-c \
|
||||||
|
-O2 -fno-exceptions -fno-rtti \
|
||||||
|
-I./imgui/ \
|
||||||
|
-I./imgui/backends/ \
|
||||||
|
./imgui/backends/imgui_impl_glfw.cpp \
|
||||||
|
./glfw/impl_glfw.cpp
|
||||||
|
|
||||||
|
ar rcs ./lib/linux/libdcimgui_impl_glfw.a imgui_impl_glfw.o impl_glfw.o
|
||||||
|
rm imgui_impl_glfw.o impl_glfw.o
|
||||||
|
|
||||||
|
clang++ -c \
|
||||||
|
-O2 -fno-exceptions -fno-rtti \
|
||||||
|
-I./imgui/ \
|
||||||
|
-I./imgui/backends/ \
|
||||||
|
./imgui/backends/imgui_impl_vulkan.cpp \
|
||||||
|
./vulkan/impl_vulkan.cpp
|
||||||
|
|
||||||
|
ar rcs ./lib/linux/libdcimgui_impl_vulkan.a imgui_impl_vulkan.o impl_vulkan.o
|
||||||
|
rm imgui_impl_vulkan.o impl_vulkan.o
|
||||||
|
|
||||||
|
clang++ -c \
|
||||||
|
-O2 -fno-exceptions -fno-rtti \
|
||||||
|
-I./imgui/ \
|
||||||
|
-I./imgui/backends/ \
|
||||||
|
./imgui/backends/imgui_impl_opengl3.cpp \
|
||||||
|
./opengl3/impl_opengl3.cpp
|
||||||
|
|
||||||
|
ar rcs ./lib/linux/libdcimgui_impl_opengl3.a imgui_impl_opengl3.o impl_opengl3.o
|
||||||
|
rm imgui_impl_opengl3.o impl_opengl3.o
|
||||||
|
|
||||||
|
|
||||||
|
mkdir -p examples_linux_exec
|
||||||
|
|
||||||
|
odin build examples/impl_glfw_opengl3.odin -file -out:examples_linux_exec/glfw_opengl3 -extra-linker-flags:-lstdc++
|
||||||
|
odin build examples/impl_glfw_vulkan.odin -file -out:examples_linux_exec/glfw_vulkan -extra-linker-flags:"-lstdc++ -lvulkan"
|
||||||
|
odin build examples/impl_sdl2_opengl3.odin -file -out:examples_linux_exec/sdl2_opengl3 -extra-linker-flags:-lstdc++
|
||||||
|
odin build examples/impl_sdl2_vulkan.odin -file -out:examples_linux_exec/sdl2_vulkan -extra-linker-flags:"-lstdc++ -lvulkan"
|
131
build_mac.sh
Executable file
131
build_mac.sh
Executable file
@ -0,0 +1,131 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -xu
|
||||||
|
|
||||||
|
mkdir -p lib/darwin/
|
||||||
|
|
||||||
|
clang++ -std=c++17 \
|
||||||
|
-c \
|
||||||
|
-O2 -fno-exceptions -fno-rtti \
|
||||||
|
-I./imgui \
|
||||||
|
./imgui/imgui.cpp \
|
||||||
|
./imgui/imgui_draw.cpp \
|
||||||
|
./imgui/imgui_tables.cpp \
|
||||||
|
./imgui/imgui_widgets.cpp \
|
||||||
|
./imgui/imgui_demo.cpp \
|
||||||
|
dcimgui.cpp
|
||||||
|
|
||||||
|
libtool -static -o ./lib/darwin/libdcimgui_arm64.a imgui.o imgui_draw.o imgui_tables.o imgui_widgets.o imgui_demo.o dcimgui.o
|
||||||
|
rm imgui.o imgui_draw.o imgui_tables.o imgui_widgets.o imgui_demo.o dcimgui.o
|
||||||
|
|
||||||
|
# clang++ -c \
|
||||||
|
# -O2 -fno-exceptions -fno-rtti \
|
||||||
|
# -I./imgui/ \
|
||||||
|
# -I./imgui/backends/ \
|
||||||
|
# # -I/usr/include/SDL3 \
|
||||||
|
# ./imgui/backends/imgui_impl_sdl3.cpp \
|
||||||
|
# ./sdl3/impl_sdl3.cpp
|
||||||
|
|
||||||
|
clang++ -std=c++17 \
|
||||||
|
-c \
|
||||||
|
-O2 -fno-exceptions -fno-rtti \
|
||||||
|
-I./imgui/ \
|
||||||
|
-I./imgui/backends/ \
|
||||||
|
$(sdl2-config --cflags) \
|
||||||
|
./imgui/backends/imgui_impl_sdl2.cpp \
|
||||||
|
./sdl2/impl_sdl2.cpp
|
||||||
|
|
||||||
|
libtool -static -o ./lib/darwin/libdcimgui_impl_sdl2_arm64.a imgui_impl_sdl2.o impl_sdl2.o
|
||||||
|
rm imgui_impl_sdl2.o impl_sdl2.o
|
||||||
|
|
||||||
|
clang++ -std=c++17 \
|
||||||
|
-c \
|
||||||
|
-O2 -fno-exceptions -fno-rtti \
|
||||||
|
-I./imgui/ \
|
||||||
|
-I./imgui/backends/ \
|
||||||
|
$(pkg-config --cflags glfw3) \
|
||||||
|
./imgui/backends/imgui_impl_glfw.cpp \
|
||||||
|
./glfw/impl_glfw.cpp
|
||||||
|
|
||||||
|
libtool -static -o ./lib/darwin/libdcimgui_impl_glfw_arm64.a imgui_impl_glfw.o impl_glfw.o
|
||||||
|
rm imgui_impl_glfw.o impl_glfw.o
|
||||||
|
|
||||||
|
clang++ -std=c++17 \
|
||||||
|
-c \
|
||||||
|
-O2 -fno-exceptions -fno-rtti \
|
||||||
|
-I./imgui/ \
|
||||||
|
-I./imgui/backends/ \
|
||||||
|
$(pkg-config --cflags vulkan) \
|
||||||
|
./imgui/backends/imgui_impl_vulkan.cpp \
|
||||||
|
./vulkan/impl_vulkan.cpp
|
||||||
|
|
||||||
|
libtool -static -o ./lib/darwin/libdcimgui_impl_vulkan_arm64.a imgui_impl_vulkan.o impl_vulkan.o
|
||||||
|
rm imgui_impl_vulkan.o impl_vulkan.o
|
||||||
|
|
||||||
|
clang++ -std=c++17 \
|
||||||
|
-c \
|
||||||
|
-O2 -fno-exceptions -fno-rtti \
|
||||||
|
-I./imgui/ \
|
||||||
|
-I./imgui/backends/ \
|
||||||
|
./imgui/backends/imgui_impl_opengl3.cpp \
|
||||||
|
./opengl3/impl_opengl3.cpp
|
||||||
|
|
||||||
|
libtool -static -o ./lib/darwin/libdcimgui_impl_opengl3_arm64.a imgui_impl_opengl3.o impl_opengl3.o
|
||||||
|
rm imgui_impl_opengl3.o impl_opengl3.o
|
||||||
|
|
||||||
|
clang++ -c \
|
||||||
|
-ObjC++ \
|
||||||
|
-O2 -fno-exceptions -fno-rtti \
|
||||||
|
-std=c++17 \
|
||||||
|
-arch arm64 \
|
||||||
|
-DIMGUI_IMPL_METAL_CPP=1\
|
||||||
|
-I"$METAL_CPP_DIR" \
|
||||||
|
-I./imgui/ \
|
||||||
|
-I./imgui/backends/ \
|
||||||
|
imgui/backends/imgui_impl_metal.mm
|
||||||
|
|
||||||
|
clang++ -c -std=c++17 \
|
||||||
|
-O2 -fno-exceptions -fno-rtti \
|
||||||
|
-arch arm64 \
|
||||||
|
-I"$METAL_CPP_DIR" \
|
||||||
|
-DIMGUI_IMPL_METAL_CPP=1\
|
||||||
|
-I./imgui/ \
|
||||||
|
-I./imgui/backends/ \
|
||||||
|
./metal/impl_metal.cpp
|
||||||
|
|
||||||
|
libtool -static -o ./lib/darwin/libdcimgui_impl_metal_arm64.a imgui_impl_metal.o impl_metal.o
|
||||||
|
rm imgui_impl_metal.o impl_metal.o
|
||||||
|
|
||||||
|
# clang++
|
||||||
|
# -framework CoreGraphics -framework CoreVideo -framework Metal -framework MetalKit -framework Cocoa \
|
||||||
|
# -std=c++17 -I ../../Downloads/metal-cpp/ impl_metal.o -DIMGUI_IMPL_METAL_CPP^C
|
||||||
|
|
||||||
|
mkdir -p examples_macos_exec
|
||||||
|
|
||||||
|
odin build examples/impl_glfw_opengl3.odin -file -out:examples_macos_exec/glfw_opengl3 -extra-linker-flags:-lstdc++
|
||||||
|
odin build examples/impl_glfw_vulkan.odin -file -out:examples_macos_exec/glfw_vulkan -extra-linker-flags:"-lstdc++ -lvulkan"
|
||||||
|
odin build examples/impl_glfw_metal.odin -file -out:examples_macos_exec/glfw_metal -extra-linker-flags:"-lstdc++"
|
||||||
|
|
||||||
|
odin build examples/impl_sdl2_opengl3.odin -file -out:examples_macos_exec/sdl2_opengl3 -extra-linker-flags:-lstdc++
|
||||||
|
odin build examples/impl_sdl2_vulkan.odin -file -out:examples_macos_exec/sdl2_vulkan -extra-linker-flags:"-lstdc++ -lvulkan"
|
||||||
|
odin build examples/impl_sdl2_metal.odin -file -out:examples_macos_exec/sdl2_metal -extra-linker-flags:"-lstdc++" # -print-linker-flags
|
||||||
|
|
||||||
|
|
||||||
|
# clang++ -std=c++17 -undefined dynamic_lookup -fPIC \
|
||||||
|
# -o ./lib/libdcimgui_impl_sdl2.dylib \
|
||||||
|
# -I./imgui/ \
|
||||||
|
# -I./imgui/backends/ \
|
||||||
|
# -I/opt/homebrew/Cellar/sdl2/2.30.10/include/SDL2 \
|
||||||
|
# -L/opt/homebrew/Cellar/sdl2/2.30.10/lib/ \
|
||||||
|
# -lSDL2 \
|
||||||
|
# ./imgui/backends/imgui_impl_sdl2.cpp \
|
||||||
|
# ./sdl2/impl_sdl2.cpp
|
||||||
|
|
||||||
|
# clang++ -std=c++17 -undefined dynamic_lookup -fPIC \
|
||||||
|
# -o ./lib/libdcimgui_impl_glfw_arm64.dylib \
|
||||||
|
# -I./imgui/ \
|
||||||
|
# -I./imgui/backends/ \
|
||||||
|
# -I/opt/homebrew/Cellar/glfw/3.4/include/ \
|
||||||
|
# ./imgui/backends/imgui_impl_glfw.cpp \
|
||||||
|
# ./glfw/impl_glfw.cpp
|
||||||
|
|
3756
dcimgui.cpp
Normal file
3756
dcimgui.cpp
Normal file
File diff suppressed because it is too large
Load Diff
2089
dcimgui.odin
Normal file
2089
dcimgui.odin
Normal file
File diff suppressed because it is too large
Load Diff
1
dear_bindings
Submodule
1
dear_bindings
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 139b5b88b49946b817b7f9737d88c5c01b0ce1c8
|
120
examples/impl_glfw_metal.odin
Normal file
120
examples/impl_glfw_metal.odin
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
package impl_sdl2_metal
|
||||||
|
import "base:runtime"
|
||||||
|
import "core:os"
|
||||||
|
import "core:fmt"
|
||||||
|
import mtl "vendor:darwin/Metal"
|
||||||
|
import ns "core:sys/darwin/Foundation"
|
||||||
|
import ca "vendor:darwin/QuartzCore"
|
||||||
|
import glfw "vendor:glfw"
|
||||||
|
import imgui ".."
|
||||||
|
import imgui_glfw "../glfw"
|
||||||
|
import imgui_mtl "../metal"
|
||||||
|
|
||||||
|
main :: proc() {
|
||||||
|
run()
|
||||||
|
}
|
||||||
|
|
||||||
|
glfw_error_cb :: proc "c" (error: i32, desc: cstring) {
|
||||||
|
context = runtime.default_context()
|
||||||
|
fmt.eprintln("[GLFW Error]", error, desc)
|
||||||
|
}
|
||||||
|
|
||||||
|
run :: proc() -> b32 {
|
||||||
|
imgui.CreateContext(nil)
|
||||||
|
io := imgui.GetIO()
|
||||||
|
io.ConfigFlags |= imgui.ConfigFlags.NavEnableKeyboard
|
||||||
|
io.ConfigFlags |= imgui.ConfigFlags.NavEnableGamepad
|
||||||
|
imgui.StyleColorsDark(nil)
|
||||||
|
|
||||||
|
glfw.SetErrorCallback(glfw_error_cb)
|
||||||
|
glfw.Init() or_return
|
||||||
|
glfw.WindowHint(glfw.CLIENT_API, glfw.NO_API)
|
||||||
|
|
||||||
|
window := glfw.CreateWindow(1280, 720, "Test", nil, nil)
|
||||||
|
if window == nil do return false
|
||||||
|
|
||||||
|
device := mtl.CreateSystemDefaultDevice()
|
||||||
|
defer device->release()
|
||||||
|
|
||||||
|
command_queue := device->newCommandQueue()
|
||||||
|
defer command_queue->release()
|
||||||
|
|
||||||
|
imgui_glfw.InitForOpenGL(window, true)
|
||||||
|
imgui_mtl.Init(device)
|
||||||
|
|
||||||
|
ns_win := glfw.GetCocoaWindow(window)
|
||||||
|
ns_view := glfw.GetCocoaView(window)
|
||||||
|
|
||||||
|
layer := ca.MetalLayer.layer()
|
||||||
|
|
||||||
|
layer->setDevice(device)
|
||||||
|
layer->setPixelFormat(.BGRA8Unorm)
|
||||||
|
|
||||||
|
ns_view->setLayer(layer)
|
||||||
|
ns_view->setWantsLayer(true)
|
||||||
|
|
||||||
|
render_pass_desc := mtl.RenderPassDescriptor.renderPassDescriptor()
|
||||||
|
defer render_pass_desc->release()
|
||||||
|
|
||||||
|
clear_color: [4]f32 = {0.45, 0.55, 0.60, 1.00}
|
||||||
|
_cc := clear_color.xyz
|
||||||
|
show_demo: b8 = true
|
||||||
|
|
||||||
|
for !glfw.WindowShouldClose(window) {
|
||||||
|
glfw.PollEvents()
|
||||||
|
|
||||||
|
w, h: i32 = glfw.GetFramebufferSize(window)
|
||||||
|
layer->setDrawableSize({width=ns.Float(w), height=ns.Float(h)})
|
||||||
|
|
||||||
|
drawable := layer->nextDrawable()
|
||||||
|
defer drawable->release()
|
||||||
|
|
||||||
|
col_attachment := render_pass_desc->colorAttachments()->object(0)
|
||||||
|
col_attachment->setClearColor(mtl.ClearColor{
|
||||||
|
f64(clear_color[0] * clear_color[3]),
|
||||||
|
f64(clear_color[1] * clear_color[3]),
|
||||||
|
f64(clear_color[2] * clear_color[3]),
|
||||||
|
f64(clear_color[3])})
|
||||||
|
col_attachment->setTexture(drawable->texture())
|
||||||
|
col_attachment->setLoadAction(.Clear)
|
||||||
|
col_attachment->setStoreAction(.Store)
|
||||||
|
|
||||||
|
command_buffer := command_queue->commandBuffer()
|
||||||
|
defer command_buffer->release()
|
||||||
|
|
||||||
|
render_encoder := command_buffer->renderCommandEncoderWithDescriptor(render_pass_desc)
|
||||||
|
defer render_encoder->release()
|
||||||
|
render_encoder->pushDebugGroup(ns.MakeConstantString("test"))
|
||||||
|
|
||||||
|
imgui_mtl.NewFrame(render_pass_desc)
|
||||||
|
imgui_glfw.NewFrame()
|
||||||
|
imgui.NewFrame()
|
||||||
|
|
||||||
|
if imgui.Button("Toggle DearImgui Demo") do show_demo = !show_demo
|
||||||
|
if show_demo do imgui.ShowDemoWindow(&show_demo)
|
||||||
|
|
||||||
|
_cc = clear_color.xyz
|
||||||
|
imgui.ColorEdit3("clear color", &_cc, .None)
|
||||||
|
imgui.SliderFloat3("clear color", &_cc, 0, 1)
|
||||||
|
clear_color.xyz = _cc
|
||||||
|
imgui.Render()
|
||||||
|
|
||||||
|
|
||||||
|
imgui_mtl.RenderDrawData(imgui.GetDrawData(), command_buffer, render_encoder);
|
||||||
|
|
||||||
|
render_encoder->popDebugGroup()
|
||||||
|
render_encoder->endEncoding()
|
||||||
|
|
||||||
|
command_buffer->presentDrawable(drawable)
|
||||||
|
command_buffer->commit()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
imgui_mtl.Shutdown()
|
||||||
|
imgui_glfw.Shutdown()
|
||||||
|
imgui.DestroyContext(nil)
|
||||||
|
|
||||||
|
glfw.DestroyWindow(window)
|
||||||
|
glfw.Terminate()
|
||||||
|
return true
|
||||||
|
}
|
88
examples/impl_glfw_opengl3.odin
Normal file
88
examples/impl_glfw_opengl3.odin
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
package impl_glfw_opengl3
|
||||||
|
import "base:runtime"
|
||||||
|
import "core:os"
|
||||||
|
import "core:fmt"
|
||||||
|
import "vendor:glfw"
|
||||||
|
import gl "vendor:OpenGL"
|
||||||
|
import imgui ".."
|
||||||
|
import imgui_glfw "../glfw"
|
||||||
|
import imgui_gl3 "../opengl3"
|
||||||
|
|
||||||
|
main :: proc() {
|
||||||
|
run()
|
||||||
|
}
|
||||||
|
|
||||||
|
glfw_error_cb :: proc "c" (error: i32, desc: cstring) {
|
||||||
|
context = runtime.default_context()
|
||||||
|
fmt.eprintln("[GLFW Error]", error, desc)
|
||||||
|
}
|
||||||
|
|
||||||
|
run :: proc() -> b32 {
|
||||||
|
glfw.SetErrorCallback(glfw_error_cb)
|
||||||
|
glfw.Init() or_return
|
||||||
|
|
||||||
|
glsl_version: cstring = "#version 330"
|
||||||
|
// glsl_version: cstring = "#version 130"
|
||||||
|
glfw.WindowHint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)
|
||||||
|
glfw.WindowHint(glfw.CONTEXT_VERSION_MAJOR, 3)
|
||||||
|
glfw.WindowHint(glfw.CONTEXT_VERSION_MINOR, 2)
|
||||||
|
glfw.WindowHint(glfw.OPENGL_FORWARD_COMPAT, true)
|
||||||
|
|
||||||
|
window := glfw.CreateWindow(1280, 720, "Test", nil, nil)
|
||||||
|
if window == nil do return false
|
||||||
|
glfw.MakeContextCurrent(window)
|
||||||
|
glfw.SwapInterval(1)
|
||||||
|
|
||||||
|
gl.load_up_to(3, 3, glfw.gl_set_proc_address)
|
||||||
|
|
||||||
|
|
||||||
|
imgui.CreateContext(nil)
|
||||||
|
io := imgui.GetIO()
|
||||||
|
io.ConfigFlags |= imgui.ConfigFlags.NavEnableKeyboard
|
||||||
|
io.ConfigFlags |= imgui.ConfigFlags.NavEnableGamepad
|
||||||
|
imgui.StyleColorsDark(nil)
|
||||||
|
|
||||||
|
imgui_glfw.InitForOpenGL(window, true)
|
||||||
|
imgui_gl3.InitEx(glsl_version)
|
||||||
|
clear_color: [4]f32 = {0.45, 0.55, 0.60, 1.00}
|
||||||
|
_cc := clear_color.xyz
|
||||||
|
show_demo: b8 = true
|
||||||
|
|
||||||
|
for !glfw.WindowShouldClose(window) {
|
||||||
|
glfw.PollEvents()
|
||||||
|
if glfw.GetWindowAttrib(window, glfw.ICONIFIED) != 0 {
|
||||||
|
imgui_glfw.Sleep(10)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
imgui_gl3.NewFrame()
|
||||||
|
imgui_glfw.NewFrame()
|
||||||
|
imgui.NewFrame()
|
||||||
|
|
||||||
|
if imgui.Button("Toggle DearImgui Demo") do show_demo = !show_demo
|
||||||
|
if show_demo do imgui.ShowDemoWindow(&show_demo)
|
||||||
|
|
||||||
|
_cc = clear_color.xyz
|
||||||
|
imgui.ColorEdit3("clear color", &_cc, .None)
|
||||||
|
imgui.SliderFloat3("clear color", &_cc, 0, 1)
|
||||||
|
clear_color.xyz = _cc
|
||||||
|
imgui.Render()
|
||||||
|
|
||||||
|
dw, dh:= glfw.GetFramebufferSize(window)
|
||||||
|
gl.Viewport(0, 0, dw, dh)
|
||||||
|
gl.ClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w);
|
||||||
|
gl.Clear(gl.COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
imgui_gl3.RenderDrawData(imgui.GetDrawData());
|
||||||
|
glfw.SwapBuffers(window);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
imgui_gl3.Shutdown()
|
||||||
|
imgui_glfw.Shutdown()
|
||||||
|
imgui.DestroyContext(nil)
|
||||||
|
|
||||||
|
glfw.DestroyWindow(window)
|
||||||
|
glfw.Terminate()
|
||||||
|
return true
|
||||||
|
}
|
410
examples/impl_glfw_vulkan.odin
Normal file
410
examples/impl_glfw_vulkan.odin
Normal file
@ -0,0 +1,410 @@
|
|||||||
|
package impl_glfw_vulkan
|
||||||
|
import "core:fmt"
|
||||||
|
import "core:strings"
|
||||||
|
import "core:bytes"
|
||||||
|
import "base:runtime"
|
||||||
|
import "vendor:glfw"
|
||||||
|
import vk "vendor:vulkan"
|
||||||
|
|
||||||
|
import imgui ".."
|
||||||
|
import imgui_glfw "../glfw"
|
||||||
|
import imgui_vk "../vulkan"
|
||||||
|
|
||||||
|
vk_allocator: ^vk.AllocationCallbacks = nil
|
||||||
|
vk_instance: vk.Instance = nil
|
||||||
|
vk_physical_device: vk.PhysicalDevice = nil
|
||||||
|
vk_device: vk.Device = nil
|
||||||
|
vk_queue_family: u32 = max(u32)
|
||||||
|
vk_queue: vk.Queue = nil
|
||||||
|
vk_pipeline_cache: vk.PipelineCache = 0
|
||||||
|
vk_descriptor_pool: vk.DescriptorPool = 0
|
||||||
|
|
||||||
|
imgui_vk_main_window_data: imgui_vk.Window
|
||||||
|
imgui_vk_min_image_count: u32 = 2
|
||||||
|
imgui_vk_swap_chain_rebuild: b32 = false
|
||||||
|
|
||||||
|
main :: proc() { run() }
|
||||||
|
|
||||||
|
vk_select_physical_device :: proc() -> vk.PhysicalDevice {
|
||||||
|
vk_res: vk.Result
|
||||||
|
gpu_count: u32 = 0
|
||||||
|
|
||||||
|
vk_res = vk.EnumeratePhysicalDevices(vk_instance, &gpu_count, nil)
|
||||||
|
if !vk_res_ok(vk_res) do return nil
|
||||||
|
|
||||||
|
if gpu_count <= 0 {
|
||||||
|
fmt.eprintln("no gpus found")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
gpus := make([dynamic]vk.PhysicalDevice, gpu_count)
|
||||||
|
vk_res = vk.EnumeratePhysicalDevices(vk_instance, &gpu_count, raw_data(gpus))
|
||||||
|
if !vk_res_ok(vk_res) do return nil
|
||||||
|
|
||||||
|
for gpu, i in gpus {
|
||||||
|
properties: vk.PhysicalDeviceProperties = {}
|
||||||
|
vk.GetPhysicalDeviceProperties(gpu, &properties)
|
||||||
|
if properties.deviceType == .DISCRETE_GPU do return gpu
|
||||||
|
}
|
||||||
|
|
||||||
|
return gpus[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
is_ext_available :: proc(properties: [] vk.ExtensionProperties, extension: cstring)-> b32 {
|
||||||
|
for &property in properties {
|
||||||
|
if cstring(&property.extensionName[0]) == extension do return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
vk_res_ok :: proc(res: vk.Result) -> b32 {
|
||||||
|
if res >= .SUCCESS {
|
||||||
|
if res != .SUCCESS do fmt.eprintln("[VULKAN Info]", res)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.eprintln("[VULKAN Error]", res)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
glfw_error_cb :: proc "c" (error: i32, desc: cstring) {
|
||||||
|
context = runtime.default_context()
|
||||||
|
fmt.eprintln("[GLFW Error]", error, desc)
|
||||||
|
}
|
||||||
|
|
||||||
|
run :: proc() -> b32 {
|
||||||
|
glfw.SetErrorCallback(glfw_error_cb)
|
||||||
|
glfw.Init() or_return
|
||||||
|
glfw.WindowHint(glfw.CLIENT_API, glfw.NO_API)
|
||||||
|
|
||||||
|
window := glfw.CreateWindow(
|
||||||
|
1280,
|
||||||
|
720,
|
||||||
|
"Test",
|
||||||
|
nil,
|
||||||
|
nil
|
||||||
|
)
|
||||||
|
|
||||||
|
glfw.VulkanSupported() or_return
|
||||||
|
vk.load_proc_addresses(glfw.GetInstanceProcAddress(nil, "vkGetInstanceProcAddr"))
|
||||||
|
vk_res: vk.Result
|
||||||
|
extensions := make([dynamic]cstring)
|
||||||
|
defer delete(extensions)
|
||||||
|
for ext in glfw.GetRequiredInstanceExtensions() do append(&extensions, ext)
|
||||||
|
|
||||||
|
{
|
||||||
|
create_info: vk.InstanceCreateInfo = {}
|
||||||
|
create_info.sType = .INSTANCE_CREATE_INFO
|
||||||
|
|
||||||
|
properties_count: u32
|
||||||
|
vk_res = vk.EnumerateInstanceExtensionProperties(nil, &properties_count, nil)
|
||||||
|
vk_res_ok(vk_res) or_return
|
||||||
|
|
||||||
|
properties := make([dynamic]vk.ExtensionProperties, properties_count)
|
||||||
|
defer delete(properties)
|
||||||
|
vk_res = vk.EnumerateInstanceExtensionProperties(nil, &properties_count, raw_data(properties))
|
||||||
|
vk_res_ok(vk_res) or_return
|
||||||
|
|
||||||
|
ext: cstring
|
||||||
|
ext = vk.KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME
|
||||||
|
if is_ext_available(properties[:], ext) do append(&extensions, ext)
|
||||||
|
ext = vk.KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME
|
||||||
|
if is_ext_available(properties[:], ext) {
|
||||||
|
append(&extensions, ext)
|
||||||
|
create_info.flags = create_info.flags + {.ENUMERATE_PORTABILITY_KHR}
|
||||||
|
}
|
||||||
|
|
||||||
|
create_info.enabledExtensionCount = cast(u32)len(extensions)
|
||||||
|
create_info.ppEnabledExtensionNames = raw_data(extensions)
|
||||||
|
|
||||||
|
vk_res = vk.CreateInstance(&create_info, vk_allocator, &vk_instance)
|
||||||
|
vk_res_ok(vk_res) or_return
|
||||||
|
}
|
||||||
|
|
||||||
|
vk.load_proc_addresses(vk_instance)
|
||||||
|
vk_physical_device = vk_select_physical_device()
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
count: u32
|
||||||
|
vk.GetPhysicalDeviceQueueFamilyProperties(vk_physical_device, &count, nil)
|
||||||
|
queues: [dynamic]vk.QueueFamilyProperties = make([dynamic]vk.QueueFamilyProperties, count)
|
||||||
|
defer delete(queues)
|
||||||
|
vk.GetPhysicalDeviceQueueFamilyProperties(vk_physical_device, &count, raw_data(queues))
|
||||||
|
for q_item, i in queues {
|
||||||
|
if .GRAPHICS in q_item.queueFlags {
|
||||||
|
vk_queue_family = u32(i)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if vk_queue_family == max(u32) do return false
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
device_extensions:= make([dynamic] cstring)
|
||||||
|
defer delete(device_extensions)
|
||||||
|
append(&device_extensions, "VK_KHR_swapchain")
|
||||||
|
properties_count: u32
|
||||||
|
vk.EnumerateDeviceExtensionProperties(vk_physical_device, nil, &properties_count, nil)
|
||||||
|
properties := make([dynamic]vk.ExtensionProperties, properties_count)
|
||||||
|
defer delete(properties)
|
||||||
|
vk.EnumerateDeviceExtensionProperties(vk_physical_device, nil, &properties_count, raw_data(properties))
|
||||||
|
|
||||||
|
queue_priority: []f32 = { 1.0 }
|
||||||
|
queue_info: [1]vk.DeviceQueueCreateInfo = {}
|
||||||
|
queue_info[0].sType = .DEVICE_QUEUE_CREATE_INFO
|
||||||
|
queue_info[0].queueFamilyIndex = vk_queue_family
|
||||||
|
queue_info[0].queueCount = 1
|
||||||
|
queue_info[0].pQueuePriorities = raw_data(queue_priority)
|
||||||
|
create_info: vk.DeviceCreateInfo = {}
|
||||||
|
create_info.sType = .DEVICE_CREATE_INFO
|
||||||
|
create_info.queueCreateInfoCount = len(queue_info)
|
||||||
|
create_info.pQueueCreateInfos = raw_data(queue_info[:])
|
||||||
|
create_info.enabledExtensionCount = u32(len(device_extensions))
|
||||||
|
create_info.ppEnabledExtensionNames = raw_data(device_extensions)
|
||||||
|
vk_res = vk.CreateDevice(vk_physical_device, &create_info, vk_allocator, &vk_device)
|
||||||
|
vk_res_ok(vk_res) or_return
|
||||||
|
vk.GetDeviceQueue(vk_device, vk_queue_family, 0, &vk_queue)
|
||||||
|
}
|
||||||
|
vk.load_proc_addresses(vk_device)
|
||||||
|
{
|
||||||
|
pool_sizes: []vk.DescriptorPoolSize = {{.COMBINED_IMAGE_SAMPLER, 1}}
|
||||||
|
pool_info: vk.DescriptorPoolCreateInfo = {}
|
||||||
|
pool_info.sType = .DESCRIPTOR_POOL_CREATE_INFO
|
||||||
|
pool_info.flags = {.FREE_DESCRIPTOR_SET}
|
||||||
|
pool_info.maxSets = 1
|
||||||
|
pool_info.poolSizeCount = u32(len(pool_sizes))
|
||||||
|
pool_info.pPoolSizes = raw_data(pool_sizes)
|
||||||
|
vk_res = vk.CreateDescriptorPool(vk_device, &pool_info, vk_allocator, &vk_descriptor_pool)
|
||||||
|
vk_res_ok(vk_res) or_return
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
surface: vk.SurfaceKHR
|
||||||
|
vk_res = glfw.CreateWindowSurface(vk_instance, window, vk_allocator, &surface)
|
||||||
|
vk_res_ok(vk_res) or_return
|
||||||
|
|
||||||
|
imgui_window: ^imgui_vk.Window = &imgui_vk_main_window_data
|
||||||
|
imgui_window.Surface = surface
|
||||||
|
|
||||||
|
response: b32
|
||||||
|
vk_res = vk.GetPhysicalDeviceSurfaceSupportKHR(vk_physical_device, vk_queue_family, surface, &response)
|
||||||
|
vk_res_ok(vk_res) or_return
|
||||||
|
if !response {
|
||||||
|
fmt.eprintln("GetPhysicalDeviceSurfaceSupportKHR failed")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
req_surface_img_fmt: [] vk.Format = {.B8G8R8A8_UNORM, .R8G8B8A8_UNORM, .B8G8R8_UNORM, .R8G8B8_UNORM}
|
||||||
|
req_surface_color_space: vk.ColorSpaceKHR = .SRGB_NONLINEAR
|
||||||
|
imgui_window.SurfaceFormat = imgui_vk.SelectSurfaceFormat(vk_physical_device, surface, raw_data(req_surface_img_fmt), i32(len(req_surface_img_fmt)), req_surface_color_space)
|
||||||
|
|
||||||
|
present_modes: [] vk.PresentModeKHR = {.MAILBOX, .IMMEDIATE, .FIFO}
|
||||||
|
imgui_window.PresentMode = imgui_vk.SelectPresentMode(vk_physical_device, surface, raw_data(present_modes), i32(len(present_modes)))
|
||||||
|
assert(imgui_vk_min_image_count >= 2)
|
||||||
|
fb_w, fb_h := glfw.GetFramebufferSize(window)
|
||||||
|
imgui_window.ClearEnable = true // This is enabled by default in Cpp; required for the attachment to clear
|
||||||
|
imgui_vk.CreateOrResizeWindow(vk_instance, vk_physical_device, vk_device, imgui_window, vk_queue_family, vk_allocator, fb_w, fb_h, imgui_vk_min_image_count)
|
||||||
|
|
||||||
|
imgui.CreateContext(nil)
|
||||||
|
io := imgui.GetIO()
|
||||||
|
io.ConfigFlags |= imgui.ConfigFlags.NavEnableKeyboard
|
||||||
|
io.ConfigFlags |= imgui.ConfigFlags.NavEnableGamepad
|
||||||
|
imgui.StyleColorsDark(nil)
|
||||||
|
|
||||||
|
imgui_glfw.InitForVulkan(window, true)
|
||||||
|
init_info: imgui_vk.InitInfo = {}
|
||||||
|
init_info.Instance = vk_instance
|
||||||
|
init_info.PhysicalDevice = vk_physical_device
|
||||||
|
init_info.Device = vk_device
|
||||||
|
init_info.QueueFamily = vk_queue_family
|
||||||
|
init_info.Queue = vk_queue
|
||||||
|
init_info.PipelineCache = vk_pipeline_cache
|
||||||
|
init_info.DescriptorPool = vk_descriptor_pool
|
||||||
|
init_info.RenderPass = imgui_window.RenderPass
|
||||||
|
init_info.Subpass = 0
|
||||||
|
init_info.MinImageCount = imgui_vk_min_image_count
|
||||||
|
init_info.ImageCount = imgui_window.ImageCount
|
||||||
|
init_info.MSAASamples = {._1}
|
||||||
|
init_info.Allocator = vk_allocator
|
||||||
|
check_vk_res :: proc(res: vk.Result) { vk_res_ok(res) }
|
||||||
|
init_info.CheckVkResultFn = check_vk_res
|
||||||
|
imgui_vk.Init(&init_info)
|
||||||
|
|
||||||
|
clear_color: [4]f32 = {0.45, 0.55, 0.60, 1.00}
|
||||||
|
_cc := clear_color.xyz
|
||||||
|
show_demo_window: b8 = true
|
||||||
|
show_another_window: b8 = false
|
||||||
|
_f: f32 = 0
|
||||||
|
_counter: i32 = 0
|
||||||
|
|
||||||
|
|
||||||
|
for !glfw.WindowShouldClose(window) {
|
||||||
|
glfw.PollEvents()
|
||||||
|
|
||||||
|
|
||||||
|
fb_w, fb_h = glfw.GetFramebufferSize(window)
|
||||||
|
if fb_w > 0 && fb_h > 0 && (imgui_vk_swap_chain_rebuild || imgui_vk_main_window_data.Width != fb_w || imgui_vk_main_window_data.Height != fb_h) {
|
||||||
|
imgui_vk.SetMinImageCount(imgui_vk_min_image_count)
|
||||||
|
imgui_vk.CreateOrResizeWindow(vk_instance, vk_physical_device, vk_device, &imgui_vk_main_window_data, vk_queue_family, vk_allocator, fb_w, fb_h, imgui_vk_min_image_count)
|
||||||
|
imgui_vk_main_window_data.FrameIndex = 0
|
||||||
|
imgui_vk_swap_chain_rebuild = false
|
||||||
|
}
|
||||||
|
|
||||||
|
if glfw.GetWindowAttrib(window, glfw.ICONIFIED) != 0 {
|
||||||
|
imgui_glfw.Sleep(10)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
imgui_vk.NewFrame()
|
||||||
|
imgui_glfw.NewFrame()
|
||||||
|
imgui.NewFrame()
|
||||||
|
|
||||||
|
|
||||||
|
if show_demo_window do imgui.ShowDemoWindow(&show_demo_window)
|
||||||
|
{
|
||||||
|
|
||||||
|
imgui.Begin("Hello, world!") // Create a window called "Hello, world!" and append into it.
|
||||||
|
|
||||||
|
imgui.Text("This is some useful text.") // Display some text (you can use a format strings too)
|
||||||
|
imgui.Checkbox("Demo Window", &show_demo_window) // Edit bools storing our window open/close state
|
||||||
|
imgui.Checkbox("Another Window", &show_another_window)
|
||||||
|
|
||||||
|
imgui.SliderFloat("float", &_f, 0.0, 1.0) // Edit 1 float using a slider from 0.0f to 1.0f
|
||||||
|
_cc = clear_color.xyz
|
||||||
|
imgui.ColorEdit3("clear color", &_cc, {}) // Edit 3 floats representing a color
|
||||||
|
imgui.SliderFloat3("clear color", &_cc, 0, 1)
|
||||||
|
clear_color.xyz = _cc
|
||||||
|
|
||||||
|
|
||||||
|
if imgui.Button("Button") do _counter += 1 // Buttons return true when clicked (most widgets return true when edited/activated)
|
||||||
|
|
||||||
|
imgui.SameLine()
|
||||||
|
imgui.Text("counter = %d", _counter)
|
||||||
|
|
||||||
|
imgui.Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0 / io.Framerate, io.Framerate)
|
||||||
|
imgui.End()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Show another simple window.
|
||||||
|
if show_another_window {
|
||||||
|
imgui.Begin("Another Window", &show_another_window) // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
|
||||||
|
imgui.Text("Hello from another window!")
|
||||||
|
if imgui.Button("Close Me") do show_another_window = false
|
||||||
|
imgui.End()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
imgui.Render()
|
||||||
|
|
||||||
|
draw_data: ^imgui.ImDrawData = imgui.GetDrawData()
|
||||||
|
is_minimized := draw_data.DisplaySize.x <= 0 || draw_data.DisplaySize.y <= 0
|
||||||
|
if !is_minimized {
|
||||||
|
imgui_window.ClearValue.color.float32.r = clear_color.r * clear_color.a
|
||||||
|
imgui_window.ClearValue.color.float32.g = clear_color.g * clear_color.a
|
||||||
|
imgui_window.ClearValue.color.float32.b = clear_color.b * clear_color.a
|
||||||
|
imgui_window.ClearValue.color.float32.a = clear_color.a
|
||||||
|
frame_render(imgui_window, draw_data)
|
||||||
|
frame_present(imgui_window)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vk_res = vk.DeviceWaitIdle(vk_device)
|
||||||
|
vk_res_ok(vk_res) or_return
|
||||||
|
imgui_vk.Shutdown()
|
||||||
|
imgui_glfw.Shutdown()
|
||||||
|
imgui.DestroyContext(nil)
|
||||||
|
|
||||||
|
imgui_vk.DestroyWindow(vk_instance, vk_device, &imgui_vk_main_window_data, vk_allocator)
|
||||||
|
vk.DestroyDescriptorPool(vk_device, vk_descriptor_pool, vk_allocator)
|
||||||
|
vk.DestroyDevice(vk_device, vk_allocator)
|
||||||
|
vk.DestroyInstance(vk_instance, vk_allocator)
|
||||||
|
|
||||||
|
glfw.DestroyWindow(window)
|
||||||
|
glfw.Terminate()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
frame_render:: proc(imgui_vk_window: ^imgui_vk.Window, draw_data: ^imgui.ImDrawData) {
|
||||||
|
vk_res: vk.Result
|
||||||
|
|
||||||
|
img_acquired_semaphore: vk.Semaphore = imgui_vk_window.FrameSemaphores[imgui_vk_window.SemaphoreIndex].ImageAcquiredSemaphore
|
||||||
|
render_complete_semaphore: vk.Semaphore = imgui_vk_window.FrameSemaphores[imgui_vk_window.SemaphoreIndex].RenderCompleteSemaphore
|
||||||
|
vk_res = vk.AcquireNextImageKHR(vk_device, imgui_vk_window.Swapchain, max(u64), img_acquired_semaphore, 0, &imgui_vk_window.FrameIndex)
|
||||||
|
|
||||||
|
if vk_res == .TIMEOUT do return
|
||||||
|
if vk_res == .ERROR_OUT_OF_DATE_KHR || vk_res == .SUBOPTIMAL_KHR {
|
||||||
|
imgui_vk_swap_chain_rebuild = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !vk_res_ok(vk_res) do return
|
||||||
|
|
||||||
|
fd: imgui_vk.Frame = imgui_vk_window.Frames[imgui_vk_window.FrameIndex]
|
||||||
|
{
|
||||||
|
|
||||||
|
vk_res = vk.WaitForFences(vk_device, 1, &fd.Fence, true, max(u64))
|
||||||
|
if !vk_res_ok(vk_res) do return
|
||||||
|
|
||||||
|
vk_res = vk.ResetFences(vk_device, 1, &fd.Fence)
|
||||||
|
if !vk_res_ok(vk_res) do return
|
||||||
|
}
|
||||||
|
{
|
||||||
|
vk_res = vk.ResetCommandPool(vk_device, fd.CommandPool, {})
|
||||||
|
if !vk_res_ok(vk_res) do return
|
||||||
|
|
||||||
|
info: vk.CommandBufferBeginInfo = {}
|
||||||
|
info.sType = .COMMAND_BUFFER_BEGIN_INFO
|
||||||
|
info.flags = {.ONE_TIME_SUBMIT}
|
||||||
|
vk_res = vk.BeginCommandBuffer(fd.CommandBuffer, &info)
|
||||||
|
if !vk_res_ok(vk_res) do return
|
||||||
|
}
|
||||||
|
{
|
||||||
|
info: vk.RenderPassBeginInfo = {}
|
||||||
|
info.sType = .RENDER_PASS_BEGIN_INFO
|
||||||
|
info.renderPass = imgui_vk_window.RenderPass
|
||||||
|
info.framebuffer = fd.Framebuffer
|
||||||
|
info.renderArea.extent.width = u32(imgui_vk_window.Width)
|
||||||
|
info.renderArea.extent.height = u32(imgui_vk_window.Height)
|
||||||
|
info.clearValueCount = 1
|
||||||
|
info.pClearValues = &imgui_vk_window.ClearValue
|
||||||
|
vk.CmdBeginRenderPass(fd.CommandBuffer, &info, .INLINE)
|
||||||
|
}
|
||||||
|
imgui_vk.RenderDrawData(draw_data, fd.CommandBuffer)
|
||||||
|
vk.CmdEndRenderPass(fd.CommandBuffer)
|
||||||
|
{
|
||||||
|
wait_stage: vk.PipelineStageFlags = {.COLOR_ATTACHMENT_OUTPUT}
|
||||||
|
info: vk.SubmitInfo = {}
|
||||||
|
info.sType = .SUBMIT_INFO
|
||||||
|
info.waitSemaphoreCount = 1
|
||||||
|
info.pWaitSemaphores = &img_acquired_semaphore
|
||||||
|
info.pWaitDstStageMask = &wait_stage
|
||||||
|
info.commandBufferCount = 1
|
||||||
|
info.pCommandBuffers = &fd.CommandBuffer
|
||||||
|
info.signalSemaphoreCount = 1
|
||||||
|
info.pSignalSemaphores = &render_complete_semaphore
|
||||||
|
|
||||||
|
vk_res = vk.EndCommandBuffer(fd.CommandBuffer)
|
||||||
|
if !vk_res_ok(vk_res) do return
|
||||||
|
vk_res = vk.QueueSubmit(vk_queue, 1, &info, fd.Fence)
|
||||||
|
if !vk_res_ok(vk_res) do return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
frame_present:: proc(igvk_window: ^imgui_vk.Window) {
|
||||||
|
vk_res: vk.Result
|
||||||
|
if imgui_vk_swap_chain_rebuild do return
|
||||||
|
render_complete_semaphore := igvk_window.FrameSemaphores[igvk_window.SemaphoreIndex].RenderCompleteSemaphore
|
||||||
|
info: vk.PresentInfoKHR = {}
|
||||||
|
info.sType = .PRESENT_INFO_KHR
|
||||||
|
info.waitSemaphoreCount = 1
|
||||||
|
info.pWaitSemaphores = &render_complete_semaphore
|
||||||
|
info.swapchainCount = 1
|
||||||
|
info.pSwapchains = &igvk_window.Swapchain
|
||||||
|
info.pImageIndices = &igvk_window.FrameIndex
|
||||||
|
vk_res = vk.QueuePresentKHR(vk_queue, &info)
|
||||||
|
if vk_res == .ERROR_OUT_OF_DATE_KHR || vk_res == .SUBOPTIMAL_KHR {
|
||||||
|
imgui_vk_swap_chain_rebuild = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !vk_res_ok(vk_res) do return
|
||||||
|
igvk_window.SemaphoreIndex = (igvk_window.SemaphoreIndex + 1) % igvk_window.SemaphoreCount
|
||||||
|
}
|
31
examples/impl_null.odin
Normal file
31
examples/impl_null.odin
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package impl_null
|
||||||
|
import "core:fmt"
|
||||||
|
import imgui ".."
|
||||||
|
|
||||||
|
main :: proc() {
|
||||||
|
fmt.println("CreateContext()")
|
||||||
|
imgui.CreateContext()
|
||||||
|
io := imgui.GetIO()
|
||||||
|
|
||||||
|
tex_pixels: cstring
|
||||||
|
tex_w, tex_h: i32
|
||||||
|
imgui.ImFontAtlas_GetTexDataAsRGBA32(io.Fonts, &tex_pixels, &tex_w, &tex_h, nil)
|
||||||
|
for n: i32 = 0; n < 20; n += 1 {
|
||||||
|
fmt.println("NewFrame()", n)
|
||||||
|
io.DisplaySize.x = 1920
|
||||||
|
io.DisplaySize.y = 1920
|
||||||
|
io.DeltaTime = 1.0 / 60.0
|
||||||
|
imgui.NewFrame()
|
||||||
|
|
||||||
|
f: f32 = 0.0
|
||||||
|
imgui.Text("Hello, world!")
|
||||||
|
imgui.SliderFloat("float", &f, 0.0, 1.0)
|
||||||
|
imgui.Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0 / io.Framerate, io.Framerate)
|
||||||
|
imgui.ShowDemoWindow()
|
||||||
|
|
||||||
|
imgui.Render()
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.println("DestroyContext()")
|
||||||
|
imgui.DestroyContext()
|
||||||
|
}
|
125
examples/impl_sdl2_metal.odin
Normal file
125
examples/impl_sdl2_metal.odin
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
package impl_sdl2_metal
|
||||||
|
import "core:os"
|
||||||
|
import "core:fmt"
|
||||||
|
import mtl "vendor:darwin/Metal"
|
||||||
|
import ns "core:sys/darwin/Foundation"
|
||||||
|
import ca "vendor:darwin/QuartzCore"
|
||||||
|
import sdl "vendor:sdl2"
|
||||||
|
import imgui ".."
|
||||||
|
import imgui_sdl2 "../sdl2"
|
||||||
|
import imgui_mtl "../metal"
|
||||||
|
|
||||||
|
main :: proc() {
|
||||||
|
run()
|
||||||
|
}
|
||||||
|
|
||||||
|
run :: proc() -> b32 {
|
||||||
|
imgui.CreateContext(nil)
|
||||||
|
io := imgui.GetIO()
|
||||||
|
io.ConfigFlags |= imgui.ConfigFlags.NavEnableKeyboard
|
||||||
|
io.ConfigFlags |= imgui.ConfigFlags.NavEnableGamepad
|
||||||
|
imgui.StyleColorsDark(nil)
|
||||||
|
|
||||||
|
if sdl.Init({.VIDEO, .GAMECONTROLLER, .TIMER}) != 0 {
|
||||||
|
fmt.eprintln(sdl.GetError())
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
sdl.SetHint(sdl.HINT_RENDER_DRIVER, "metal")
|
||||||
|
window := sdl.CreateWindow("Test", sdl.WINDOWPOS_CENTERED, sdl.WINDOWPOS_CENTERED, 1280, 720, {.METAL, .RESIZABLE, .ALLOW_HIGHDPI})
|
||||||
|
if window == nil {
|
||||||
|
fmt.eprintln(sdl.GetError())
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
renderer := sdl.CreateRenderer(window, -1, {.ACCELERATED, .PRESENTVSYNC})
|
||||||
|
if renderer == nil {
|
||||||
|
fmt.eprintln(sdl.GetError())
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
layer: ^ca.MetalLayer = cast(^ca.MetalLayer)sdl.RenderGetMetalLayer(renderer)
|
||||||
|
layer->setPixelFormat(.BGRA8Unorm)
|
||||||
|
device := layer->device()
|
||||||
|
defer device->release()
|
||||||
|
imgui_mtl.Init(device)
|
||||||
|
imgui_sdl2.InitForMetal(window)
|
||||||
|
|
||||||
|
command_queue := layer->device()->newCommandQueue()
|
||||||
|
defer command_queue->release()
|
||||||
|
|
||||||
|
render_pass_desc := mtl.RenderPassDescriptor.renderPassDescriptor()
|
||||||
|
defer render_pass_desc->release()
|
||||||
|
|
||||||
|
clear_color: [4]f32 = {0.45, 0.55, 0.60, 1.00}
|
||||||
|
_cc := clear_color.xyz
|
||||||
|
done: b32 = false
|
||||||
|
show_demo: b8 = true
|
||||||
|
|
||||||
|
for !done {
|
||||||
|
|
||||||
|
event: sdl.Event
|
||||||
|
for sdl.PollEvent(&event) {
|
||||||
|
imgui_sdl2.ProcessEvent(&event)
|
||||||
|
|
||||||
|
if event.type == .QUIT do done = true
|
||||||
|
if event.type == .WINDOWEVENT && event.window.event == .CLOSE do done = true
|
||||||
|
}
|
||||||
|
|
||||||
|
w, h: i32
|
||||||
|
sdl.GetRendererOutputSize(renderer, &w, &h)
|
||||||
|
layer->setDrawableSize({width=ns.Float(w), height=ns.Float(h)})
|
||||||
|
|
||||||
|
drawable := layer->nextDrawable()
|
||||||
|
defer drawable->release()
|
||||||
|
|
||||||
|
col_attachment := render_pass_desc->colorAttachments()->object(0)
|
||||||
|
col_attachment->setClearColor(mtl.ClearColor{
|
||||||
|
f64(clear_color[0] * clear_color[3]),
|
||||||
|
f64(clear_color[1] * clear_color[3]),
|
||||||
|
f64(clear_color[2] * clear_color[3]),
|
||||||
|
f64(clear_color[3])})
|
||||||
|
col_attachment->setTexture(drawable->texture())
|
||||||
|
col_attachment->setLoadAction(.Clear)
|
||||||
|
col_attachment->setStoreAction(.Store)
|
||||||
|
|
||||||
|
command_buffer := command_queue->commandBuffer()
|
||||||
|
defer command_buffer->release()
|
||||||
|
|
||||||
|
render_encoder := command_buffer->renderCommandEncoderWithDescriptor(render_pass_desc)
|
||||||
|
defer render_encoder->release()
|
||||||
|
render_encoder->pushDebugGroup(ns.MakeConstantString("test"))
|
||||||
|
|
||||||
|
imgui_mtl.NewFrame(render_pass_desc)
|
||||||
|
imgui_sdl2.NewFrame()
|
||||||
|
imgui.NewFrame()
|
||||||
|
|
||||||
|
if imgui.Button("Toggle DearImgui Demo") do show_demo = !show_demo
|
||||||
|
if show_demo do imgui.ShowDemoWindow(&show_demo)
|
||||||
|
|
||||||
|
_cc = clear_color.xyz
|
||||||
|
imgui.ColorEdit3("clear color", &_cc, .None)
|
||||||
|
imgui.SliderFloat3("clear color", &_cc, 0, 1)
|
||||||
|
clear_color.xyz = _cc
|
||||||
|
imgui.Render()
|
||||||
|
|
||||||
|
|
||||||
|
imgui_mtl.RenderDrawData(imgui.GetDrawData(), command_buffer, render_encoder);
|
||||||
|
|
||||||
|
render_encoder->popDebugGroup()
|
||||||
|
render_encoder->endEncoding()
|
||||||
|
|
||||||
|
command_buffer->presentDrawable(drawable)
|
||||||
|
command_buffer->commit()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
imgui_mtl.Shutdown()
|
||||||
|
imgui_sdl2.Shutdown()
|
||||||
|
imgui.DestroyContext(nil)
|
||||||
|
|
||||||
|
sdl.DestroyRenderer(renderer)
|
||||||
|
sdl.DestroyWindow(window)
|
||||||
|
sdl.Quit()
|
||||||
|
return true
|
||||||
|
}
|
100
examples/impl_sdl2_opengl3.odin
Normal file
100
examples/impl_sdl2_opengl3.odin
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
package impl_sdl2_opengl3
|
||||||
|
import os "core:os"
|
||||||
|
import fmt "core:fmt"
|
||||||
|
import sdl "vendor:sdl2"
|
||||||
|
import gl "vendor:OpenGL"
|
||||||
|
import imgui ".."
|
||||||
|
import imgui_sdl2 "../sdl2"
|
||||||
|
import imgui_gl3 "../opengl3"
|
||||||
|
|
||||||
|
main :: proc() {
|
||||||
|
run()
|
||||||
|
}
|
||||||
|
|
||||||
|
run :: proc() -> b32 {
|
||||||
|
if sdl.Init({.VIDEO, .GAMECONTROLLER, .TIMER}) != 0 {
|
||||||
|
fmt.eprintln(sdl.GetError())
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
glsl_version: cstring = "#version 330"
|
||||||
|
sdl.GL_SetAttribute(.CONTEXT_FLAGS, 0)
|
||||||
|
sdl.GL_SetAttribute(.CONTEXT_PROFILE_MASK, i32(sdl.GLprofile.CORE))
|
||||||
|
sdl.GL_SetAttribute(.CONTEXT_MAJOR_VERSION, 3)
|
||||||
|
sdl.GL_SetAttribute(.CONTEXT_MINOR_VERSION, 0)
|
||||||
|
|
||||||
|
sdl.GL_SetAttribute(.DOUBLEBUFFER, 1)
|
||||||
|
sdl.GL_SetAttribute(.DEPTH_SIZE, 24)
|
||||||
|
sdl.GL_SetAttribute(.STENCIL_SIZE, 8)
|
||||||
|
|
||||||
|
window_flags: sdl.WindowFlags = {.OPENGL, .RESIZABLE, .HIDDEN, .ALLOW_HIGHDPI}
|
||||||
|
window := sdl.CreateWindow("Test", sdl.WINDOWPOS_CENTERED, sdl.WINDOWPOS_CENTERED, 1280, 720, window_flags)
|
||||||
|
if window == nil {
|
||||||
|
fmt.eprintln(sdl.GetError())
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
gl_ctx := sdl.GL_CreateContext(window)
|
||||||
|
if gl_ctx == nil {
|
||||||
|
fmt.eprintln(sdl.GetError())
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
sdl.GL_MakeCurrent(window, gl_ctx)
|
||||||
|
gl.load_up_to(3, 3, sdl.gl_set_proc_address)
|
||||||
|
|
||||||
|
sdl.GL_SetSwapInterval(1)
|
||||||
|
sdl.ShowWindow(window)
|
||||||
|
|
||||||
|
imgui.CreateContext(nil)
|
||||||
|
io := imgui.GetIO()
|
||||||
|
io.ConfigFlags |= imgui.ConfigFlags.NavEnableKeyboard
|
||||||
|
io.ConfigFlags |= imgui.ConfigFlags.NavEnableGamepad
|
||||||
|
imgui.StyleColorsDark(nil)
|
||||||
|
|
||||||
|
imgui_sdl2.InitForOpenGL(window, gl_ctx)
|
||||||
|
imgui_gl3.InitEx(glsl_version)
|
||||||
|
clear_color: [4]f32 = {0.45, 0.55, 0.60, 1.00}
|
||||||
|
_cc := clear_color.xyz
|
||||||
|
done: b32 = false
|
||||||
|
show_demo: b8 = true
|
||||||
|
|
||||||
|
for !done {
|
||||||
|
event: sdl.Event
|
||||||
|
for sdl.PollEvent(&event) {
|
||||||
|
imgui_sdl2.ProcessEvent(&event)
|
||||||
|
if event.type == .QUIT do done = true
|
||||||
|
if event.type == .WINDOWEVENT && event.window.event == .CLOSE do done = true
|
||||||
|
}
|
||||||
|
|
||||||
|
imgui_gl3.NewFrame()
|
||||||
|
imgui_sdl2.NewFrame()
|
||||||
|
imgui.NewFrame()
|
||||||
|
|
||||||
|
if imgui.Button("Toggle DearImgui Demo") do show_demo = !show_demo
|
||||||
|
if show_demo do imgui.ShowDemoWindow(&show_demo)
|
||||||
|
|
||||||
|
_cc = clear_color.xyz
|
||||||
|
imgui.ColorEdit3("clear color", &_cc, .None)
|
||||||
|
imgui.SliderFloat3("clear color", &_cc, 0, 1)
|
||||||
|
clear_color.xyz = _cc
|
||||||
|
imgui.Render()
|
||||||
|
|
||||||
|
gl.Viewport(0, 0, i32(io.DisplaySize.x), i32(io.DisplaySize.y))
|
||||||
|
gl.ClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w);
|
||||||
|
gl.Clear(gl.COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
imgui_gl3.RenderDrawData(imgui.GetDrawData());
|
||||||
|
sdl.GL_SwapWindow(window);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
imgui_gl3.Shutdown()
|
||||||
|
imgui_sdl2.Shutdown()
|
||||||
|
imgui.DestroyContext(nil)
|
||||||
|
|
||||||
|
sdl.GL_DeleteContext(gl_ctx)
|
||||||
|
sdl.DestroyWindow(window)
|
||||||
|
sdl.Quit()
|
||||||
|
return true
|
||||||
|
}
|
403
examples/impl_sdl2_vulkan.odin
Normal file
403
examples/impl_sdl2_vulkan.odin
Normal file
@ -0,0 +1,403 @@
|
|||||||
|
package impl_sdl2_vulkan
|
||||||
|
import "core:fmt"
|
||||||
|
import "core:strings"
|
||||||
|
import "core:bytes"
|
||||||
|
|
||||||
|
import imgui ".."
|
||||||
|
import imgui_vk "../vulkan"
|
||||||
|
import imgui_sdl2 "../sdl2"
|
||||||
|
import sdl "vendor:sdl2"
|
||||||
|
import vk "vendor:vulkan"
|
||||||
|
|
||||||
|
vk_allocator: ^vk.AllocationCallbacks = nil
|
||||||
|
vk_instance: vk.Instance = nil
|
||||||
|
vk_physical_device: vk.PhysicalDevice = nil
|
||||||
|
vk_device: vk.Device = nil
|
||||||
|
vk_queue_family: u32 = max(u32)
|
||||||
|
vk_queue: vk.Queue = nil
|
||||||
|
vk_debugreport: vk.DebugReportCallbackEXT = 0
|
||||||
|
vk_pipeline_cache: vk.PipelineCache = 0
|
||||||
|
vk_descriptor_pool: vk.DescriptorPool = 0
|
||||||
|
|
||||||
|
imgui_vk_main_window_data: imgui_vk.Window
|
||||||
|
imgui_vk_min_image_count: u32 = 2
|
||||||
|
imgui_vk_swap_chain_rebuild: b32 = false
|
||||||
|
|
||||||
|
main :: proc() { run() }
|
||||||
|
|
||||||
|
vk_select_physical_device :: proc() -> vk.PhysicalDevice {
|
||||||
|
vk_res: vk.Result
|
||||||
|
gpu_count: u32 = 0
|
||||||
|
|
||||||
|
vk_res = vk.EnumeratePhysicalDevices(vk_instance, &gpu_count, nil)
|
||||||
|
if !vk_res_ok(vk_res) do return nil
|
||||||
|
|
||||||
|
if gpu_count <= 0 {
|
||||||
|
fmt.eprintln("no gpus found")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
gpus := make([dynamic]vk.PhysicalDevice, gpu_count)
|
||||||
|
vk_res = vk.EnumeratePhysicalDevices(vk_instance, &gpu_count, raw_data(gpus))
|
||||||
|
if !vk_res_ok(vk_res) do return nil
|
||||||
|
|
||||||
|
for gpu, i in gpus {
|
||||||
|
properties: vk.PhysicalDeviceProperties = {}
|
||||||
|
vk.GetPhysicalDeviceProperties(gpu, &properties)
|
||||||
|
if properties.deviceType == .DISCRETE_GPU do return gpu
|
||||||
|
}
|
||||||
|
|
||||||
|
return gpus[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
is_ext_available :: proc(properties: [] vk.ExtensionProperties, extension: cstring)-> b32 {
|
||||||
|
for &property in properties {
|
||||||
|
if cstring(&property.extensionName[0]) == extension do return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
vk_res_ok :: proc(res: vk.Result) -> b32 {
|
||||||
|
if res >= .SUCCESS {
|
||||||
|
if res != .SUCCESS do fmt.eprintln("[VULKAN Info]", res)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.eprintln("[VULKAN Error]", res)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
run :: proc() -> b32 {
|
||||||
|
window := sdl.CreateWindow(
|
||||||
|
"Test",
|
||||||
|
sdl.WINDOWPOS_CENTERED,
|
||||||
|
sdl.WINDOWPOS_CENTERED,
|
||||||
|
1280,
|
||||||
|
720,
|
||||||
|
{.VULKAN, .RESIZABLE, .ALLOW_HIGHDPI}
|
||||||
|
)
|
||||||
|
defer sdl.DestroyWindow(window)
|
||||||
|
|
||||||
|
vk.load_proc_addresses(sdl.Vulkan_GetVkGetInstanceProcAddr())
|
||||||
|
|
||||||
|
vk_res: vk.Result
|
||||||
|
sdl_res: sdl.bool
|
||||||
|
|
||||||
|
extensions_count: u32
|
||||||
|
sdl_res = sdl.Vulkan_GetInstanceExtensions(window, &extensions_count, nil)
|
||||||
|
|
||||||
|
extensions := make([dynamic]cstring, extensions_count)
|
||||||
|
defer delete(extensions)
|
||||||
|
sdl_res = sdl.Vulkan_GetInstanceExtensions(window, &extensions_count, raw_data(extensions))
|
||||||
|
|
||||||
|
{
|
||||||
|
create_info: vk.InstanceCreateInfo = {}
|
||||||
|
create_info.sType = .INSTANCE_CREATE_INFO
|
||||||
|
|
||||||
|
properties_count: u32
|
||||||
|
vk_res = vk.EnumerateInstanceExtensionProperties(nil, &properties_count, nil)
|
||||||
|
vk_res_ok(vk_res) or_return
|
||||||
|
|
||||||
|
properties := make([dynamic]vk.ExtensionProperties, properties_count)
|
||||||
|
defer delete(properties)
|
||||||
|
vk_res = vk.EnumerateInstanceExtensionProperties(nil, &properties_count, raw_data(properties))
|
||||||
|
vk_res_ok(vk_res) or_return
|
||||||
|
|
||||||
|
ext: cstring
|
||||||
|
ext = vk.KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME
|
||||||
|
if is_ext_available(properties[:], ext) do append(&extensions, ext)
|
||||||
|
ext = vk.KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME
|
||||||
|
if is_ext_available(properties[:], ext) {
|
||||||
|
append(&extensions, ext)
|
||||||
|
create_info.flags = create_info.flags + {.ENUMERATE_PORTABILITY_KHR}
|
||||||
|
}
|
||||||
|
|
||||||
|
create_info.enabledExtensionCount = cast(u32)len(extensions)
|
||||||
|
create_info.ppEnabledExtensionNames = raw_data(extensions)
|
||||||
|
|
||||||
|
vk_res = vk.CreateInstance(&create_info, vk_allocator, &vk_instance);
|
||||||
|
vk_res_ok(vk_res) or_return
|
||||||
|
}
|
||||||
|
|
||||||
|
vk.load_proc_addresses(vk_instance)
|
||||||
|
vk_physical_device = vk_select_physical_device()
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
count: u32
|
||||||
|
vk.GetPhysicalDeviceQueueFamilyProperties(vk_physical_device, &count, nil)
|
||||||
|
queues: [dynamic]vk.QueueFamilyProperties = make([dynamic]vk.QueueFamilyProperties, count)
|
||||||
|
defer delete(queues)
|
||||||
|
vk.GetPhysicalDeviceQueueFamilyProperties(vk_physical_device, &count, raw_data(queues))
|
||||||
|
for q_item, i in queues {
|
||||||
|
if .GRAPHICS in q_item.queueFlags {
|
||||||
|
vk_queue_family = u32(i)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if vk_queue_family == max(u32) do return false
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
device_extensions:= make([dynamic] cstring)
|
||||||
|
defer delete(device_extensions)
|
||||||
|
append(&device_extensions, "VK_KHR_swapchain")
|
||||||
|
properties_count: u32
|
||||||
|
vk.EnumerateDeviceExtensionProperties(vk_physical_device, nil, &properties_count, nil)
|
||||||
|
properties := make([dynamic]vk.ExtensionProperties, properties_count)
|
||||||
|
defer delete(properties)
|
||||||
|
vk.EnumerateDeviceExtensionProperties(vk_physical_device, nil, &properties_count, raw_data(properties))
|
||||||
|
|
||||||
|
queue_priority: []f32 = { 1.0 }
|
||||||
|
queue_info: [1]vk.DeviceQueueCreateInfo = {}
|
||||||
|
queue_info[0].sType = .DEVICE_QUEUE_CREATE_INFO
|
||||||
|
queue_info[0].queueFamilyIndex = vk_queue_family
|
||||||
|
queue_info[0].queueCount = 1
|
||||||
|
queue_info[0].pQueuePriorities = raw_data(queue_priority)
|
||||||
|
create_info: vk.DeviceCreateInfo = {}
|
||||||
|
create_info.sType = .DEVICE_CREATE_INFO
|
||||||
|
create_info.queueCreateInfoCount = len(queue_info)
|
||||||
|
create_info.pQueueCreateInfos = raw_data(queue_info[:])
|
||||||
|
create_info.enabledExtensionCount = u32(len(device_extensions))
|
||||||
|
create_info.ppEnabledExtensionNames = raw_data(device_extensions)
|
||||||
|
vk_res = vk.CreateDevice(vk_physical_device, &create_info, vk_allocator, &vk_device)
|
||||||
|
vk_res_ok(vk_res) or_return
|
||||||
|
vk.GetDeviceQueue(vk_device, vk_queue_family, 0, &vk_queue)
|
||||||
|
}
|
||||||
|
vk.load_proc_addresses(vk_device)
|
||||||
|
{
|
||||||
|
pool_sizes: []vk.DescriptorPoolSize = {{.COMBINED_IMAGE_SAMPLER, 1}}
|
||||||
|
pool_info: vk.DescriptorPoolCreateInfo = {}
|
||||||
|
pool_info.sType = .DESCRIPTOR_POOL_CREATE_INFO
|
||||||
|
pool_info.flags = {.FREE_DESCRIPTOR_SET}
|
||||||
|
pool_info.maxSets = 1
|
||||||
|
pool_info.poolSizeCount = u32(len(pool_sizes))
|
||||||
|
pool_info.pPoolSizes = raw_data(pool_sizes)
|
||||||
|
vk_res = vk.CreateDescriptorPool(vk_device, &pool_info, vk_allocator, &vk_descriptor_pool)
|
||||||
|
vk_res_ok(vk_res) or_return
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
surface: vk.SurfaceKHR
|
||||||
|
sdl.Vulkan_CreateSurface(window, vk_instance, &surface) or_return
|
||||||
|
|
||||||
|
imgui_window: ^imgui_vk.Window = &imgui_vk_main_window_data
|
||||||
|
imgui_window.Surface = surface
|
||||||
|
|
||||||
|
response: b32
|
||||||
|
vk_res = vk.GetPhysicalDeviceSurfaceSupportKHR(vk_physical_device, vk_queue_family, surface, &response)
|
||||||
|
vk_res_ok(vk_res) or_return
|
||||||
|
if !response {
|
||||||
|
fmt.eprintln("GetPhysicalDeviceSurfaceSupportKHR failed")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
req_surface_img_fmt: [] vk.Format = {.B8G8R8A8_UNORM, .R8G8B8A8_UNORM, .B8G8R8_UNORM, .R8G8B8_UNORM}
|
||||||
|
req_surface_color_space: vk.ColorSpaceKHR = .SRGB_NONLINEAR
|
||||||
|
imgui_window.SurfaceFormat = imgui_vk.SelectSurfaceFormat(vk_physical_device, surface, raw_data(req_surface_img_fmt), i32(len(req_surface_img_fmt)), req_surface_color_space);
|
||||||
|
|
||||||
|
present_modes: [] vk.PresentModeKHR = {.MAILBOX, .IMMEDIATE, .FIFO}
|
||||||
|
imgui_window.PresentMode = imgui_vk.SelectPresentMode(vk_physical_device, surface, &present_modes[0], i32(len(present_modes)))
|
||||||
|
assert(imgui_vk_min_image_count >= 2)
|
||||||
|
w,h: i32
|
||||||
|
sdl.GetWindowSize(window, &w, &h)
|
||||||
|
imgui_window.ClearEnable = true // This is enabled by default in Cpp; required for the attachment to clear
|
||||||
|
imgui_vk.CreateOrResizeWindow(vk_instance, vk_physical_device, vk_device, imgui_window, vk_queue_family, vk_allocator, w, h, imgui_vk_min_image_count)
|
||||||
|
|
||||||
|
imgui.CreateContext(nil)
|
||||||
|
io := imgui.GetIO()
|
||||||
|
io.ConfigFlags |= imgui.ConfigFlags.NavEnableKeyboard
|
||||||
|
io.ConfigFlags |= imgui.ConfigFlags.NavEnableGamepad
|
||||||
|
imgui.StyleColorsDark(nil)
|
||||||
|
|
||||||
|
imgui_sdl2.InitForVulkan(window)
|
||||||
|
init_info: imgui_vk.InitInfo = {}
|
||||||
|
init_info.Allocator = vk_allocator
|
||||||
|
check_vk_res :: proc(res: vk.Result) { vk_res_ok(res) }
|
||||||
|
init_info.CheckVkResultFn = check_vk_res
|
||||||
|
init_info.DescriptorPool = vk_descriptor_pool
|
||||||
|
init_info.Device = vk_device
|
||||||
|
init_info.ImageCount = imgui_window.ImageCount
|
||||||
|
init_info.Instance = vk_instance
|
||||||
|
init_info.MSAASamples = {._1}
|
||||||
|
init_info.MinImageCount = imgui_vk_min_image_count
|
||||||
|
init_info.PhysicalDevice = vk_physical_device
|
||||||
|
init_info.PipelineCache = vk_pipeline_cache
|
||||||
|
init_info.Queue = vk_queue
|
||||||
|
init_info.QueueFamily = vk_queue_family
|
||||||
|
init_info.RenderPass = imgui_window.RenderPass
|
||||||
|
init_info.Subpass = 0
|
||||||
|
imgui_vk.Init(&init_info)
|
||||||
|
|
||||||
|
clear_color: [4]f32 = {0.45, 0.55, 0.60, 1.00}
|
||||||
|
_cc := clear_color.xyz
|
||||||
|
show_demo_window: b8 = true
|
||||||
|
show_another_window: b8 = false
|
||||||
|
_f: f32 = 0
|
||||||
|
_counter: i32 = 0
|
||||||
|
|
||||||
|
done: b32 = false
|
||||||
|
for !done {
|
||||||
|
event: sdl.Event
|
||||||
|
for sdl.PollEvent(&event) {
|
||||||
|
imgui_sdl2.ProcessEvent(&event)
|
||||||
|
if event.type == .QUIT do done = true
|
||||||
|
if event.type == .WINDOWEVENT && event.window.event == .CLOSE do done = true
|
||||||
|
}
|
||||||
|
|
||||||
|
fb_w, fb_h: i32
|
||||||
|
sdl.GetWindowSize(window, &fb_w, &fb_h)
|
||||||
|
if fb_w > 0 && fb_h > 0 && (imgui_vk_swap_chain_rebuild || imgui_vk_main_window_data.Width != fb_w || imgui_vk_main_window_data.Height != fb_h) {
|
||||||
|
imgui_vk.SetMinImageCount(imgui_vk_min_image_count)
|
||||||
|
imgui_vk.CreateOrResizeWindow(vk_instance, vk_physical_device, vk_device, &imgui_vk_main_window_data, vk_queue_family, vk_allocator, fb_w, fb_h, imgui_vk_min_image_count)
|
||||||
|
imgui_vk_main_window_data.FrameIndex = 0
|
||||||
|
imgui_vk_swap_chain_rebuild = false
|
||||||
|
}
|
||||||
|
|
||||||
|
imgui_sdl2.NewFrame()
|
||||||
|
imgui_vk.NewFrame()
|
||||||
|
imgui.NewFrame()
|
||||||
|
|
||||||
|
if show_demo_window do imgui.ShowDemoWindow(&show_demo_window)
|
||||||
|
{
|
||||||
|
|
||||||
|
imgui.Begin("Hello, world!") // Create a window called "Hello, world!" and append into it.
|
||||||
|
|
||||||
|
imgui.Text("This is some useful text.") // Display some text (you can use a format strings too)
|
||||||
|
imgui.Checkbox("Demo Window", &show_demo_window) // Edit bools storing our window open/close state
|
||||||
|
imgui.Checkbox("Another Window", &show_another_window)
|
||||||
|
|
||||||
|
imgui.SliderFloat("float", &_f, 0.0, 1.0) // Edit 1 float using a slider from 0.0f to 1.0f
|
||||||
|
_cc = clear_color.xyz
|
||||||
|
imgui.ColorEdit3("clear color", &_cc, {}) // Edit 3 floats representing a color
|
||||||
|
imgui.SliderFloat3("clear color", &_cc, 0, 1)
|
||||||
|
clear_color.xyz = _cc
|
||||||
|
|
||||||
|
|
||||||
|
if imgui.Button("Button") do _counter += 1 // Buttons return true when clicked (most widgets return true when edited/activated)
|
||||||
|
|
||||||
|
imgui.SameLine()
|
||||||
|
imgui.Text("counter = %d", _counter)
|
||||||
|
|
||||||
|
imgui.Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0 / io.Framerate, io.Framerate)
|
||||||
|
imgui.End()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Show another simple window.
|
||||||
|
if show_another_window {
|
||||||
|
imgui.Begin("Another Window", &show_another_window) // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
|
||||||
|
imgui.Text("Hello from another window!")
|
||||||
|
if imgui.Button("Close Me") do show_another_window = false
|
||||||
|
imgui.End()
|
||||||
|
}
|
||||||
|
|
||||||
|
imgui.Render()
|
||||||
|
|
||||||
|
draw_data: ^imgui.ImDrawData = imgui.GetDrawData()
|
||||||
|
|
||||||
|
imgui_window.ClearValue.color.float32[0] = clear_color.x * clear_color.w;
|
||||||
|
imgui_window.ClearValue.color.float32[1] = clear_color.y * clear_color.w;
|
||||||
|
imgui_window.ClearValue.color.float32[2] = clear_color.z * clear_color.w;
|
||||||
|
imgui_window.ClearValue.color.float32[3] = clear_color.w;
|
||||||
|
frame_render(imgui_window, draw_data)
|
||||||
|
frame_present(imgui_window)
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
imgui_vk.DestroyWindow(vk_instance, vk_device, &imgui_vk_main_window_data, vk_allocator);
|
||||||
|
|
||||||
|
vk.DestroyDescriptorPool(vk_device, vk_descriptor_pool, vk_allocator)
|
||||||
|
vk.DestroyDevice(vk_device, vk_allocator)
|
||||||
|
vk.DestroyInstance(vk_instance, vk_allocator)
|
||||||
|
|
||||||
|
sdl.DestroyWindow(window)
|
||||||
|
sdl.Quit()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
frame_render:: proc(igvk_window: ^imgui_vk.Window, draw_data: ^imgui.ImDrawData) {
|
||||||
|
vk_res: vk.Result
|
||||||
|
|
||||||
|
img_acquired_semaphore: vk.Semaphore = igvk_window.FrameSemaphores[igvk_window.SemaphoreIndex].ImageAcquiredSemaphore
|
||||||
|
render_complete_semaphore: vk.Semaphore = igvk_window.FrameSemaphores[igvk_window.SemaphoreIndex].RenderCompleteSemaphore
|
||||||
|
vk_res = vk.AcquireNextImageKHR(vk_device, igvk_window.Swapchain, max(u64), img_acquired_semaphore, 0, &igvk_window.FrameIndex)
|
||||||
|
|
||||||
|
if vk_res == .ERROR_OUT_OF_DATE_KHR || vk_res == .SUBOPTIMAL_KHR {
|
||||||
|
imgui_vk_swap_chain_rebuild = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if vk_res == .TIMEOUT do return
|
||||||
|
if !vk_res_ok(vk_res) do return
|
||||||
|
|
||||||
|
fd: imgui_vk.Frame = igvk_window.Frames[igvk_window.FrameIndex]
|
||||||
|
{
|
||||||
|
|
||||||
|
vk_res = vk.WaitForFences(vk_device, 1, &fd.Fence, true, max(u64))
|
||||||
|
if !vk_res_ok(vk_res) do return
|
||||||
|
|
||||||
|
vk_res = vk.ResetFences(vk_device, 1, &fd.Fence)
|
||||||
|
if !vk_res_ok(vk_res) do return
|
||||||
|
}
|
||||||
|
{
|
||||||
|
vk_res = vk.ResetCommandPool(vk_device, fd.CommandPool, {})
|
||||||
|
if !vk_res_ok(vk_res) do return
|
||||||
|
|
||||||
|
info: vk.CommandBufferBeginInfo = {}
|
||||||
|
info.sType = .COMMAND_BUFFER_BEGIN_INFO
|
||||||
|
info.flags = {.ONE_TIME_SUBMIT}
|
||||||
|
vk_res = vk.BeginCommandBuffer(fd.CommandBuffer, &info)
|
||||||
|
if !vk_res_ok(vk_res) do return
|
||||||
|
}
|
||||||
|
{
|
||||||
|
info: vk.RenderPassBeginInfo = {}
|
||||||
|
info.sType = .RENDER_PASS_BEGIN_INFO
|
||||||
|
info.renderPass = igvk_window.RenderPass
|
||||||
|
info.framebuffer = fd.Framebuffer
|
||||||
|
info.renderArea.extent.width = u32(igvk_window.Width)
|
||||||
|
info.renderArea.extent.height = u32(igvk_window.Height)
|
||||||
|
info.clearValueCount = 1
|
||||||
|
info.pClearValues = &igvk_window.ClearValue
|
||||||
|
vk.CmdBeginRenderPass(fd.CommandBuffer, &info, .INLINE)
|
||||||
|
}
|
||||||
|
|
||||||
|
imgui_vk.RenderDrawData(draw_data, fd.CommandBuffer)
|
||||||
|
vk.CmdEndRenderPass(fd.CommandBuffer)
|
||||||
|
|
||||||
|
{
|
||||||
|
wait_stage: vk.PipelineStageFlags = {.COLOR_ATTACHMENT_OUTPUT}
|
||||||
|
info: vk.SubmitInfo = {}
|
||||||
|
info.sType = .SUBMIT_INFO
|
||||||
|
info.waitSemaphoreCount = 1
|
||||||
|
info.pWaitSemaphores = &img_acquired_semaphore
|
||||||
|
info.pWaitDstStageMask = &wait_stage
|
||||||
|
info.commandBufferCount = 1
|
||||||
|
info.pCommandBuffers = &fd.CommandBuffer
|
||||||
|
info.signalSemaphoreCount = 1
|
||||||
|
info.pSignalSemaphores = &render_complete_semaphore
|
||||||
|
vk_res = vk.EndCommandBuffer(fd.CommandBuffer)
|
||||||
|
if !vk_res_ok(vk_res) do return
|
||||||
|
vk_res = vk.QueueSubmit(vk_queue, 1, &info, fd.Fence)
|
||||||
|
if !vk_res_ok(vk_res) do return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
frame_present:: proc(igvk_window: ^imgui_vk.Window) {
|
||||||
|
vk_res: vk.Result
|
||||||
|
if imgui_vk_swap_chain_rebuild do return
|
||||||
|
render_complete_semaphore := igvk_window.FrameSemaphores[igvk_window.SemaphoreIndex].RenderCompleteSemaphore
|
||||||
|
info: vk.PresentInfoKHR = {}
|
||||||
|
info.sType = .PRESENT_INFO_KHR
|
||||||
|
info.waitSemaphoreCount = 1
|
||||||
|
info.pWaitSemaphores = &render_complete_semaphore
|
||||||
|
info.swapchainCount = 1
|
||||||
|
info.pSwapchains = &igvk_window.Swapchain
|
||||||
|
info.pImageIndices = &igvk_window.FrameIndex
|
||||||
|
vk_res = vk.QueuePresentKHR(vk_queue, &info)
|
||||||
|
if vk_res == .ERROR_OUT_OF_DATE_KHR || vk_res == .SUBOPTIMAL_KHR {
|
||||||
|
imgui_vk_swap_chain_rebuild = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !vk_res_ok(vk_res) do return
|
||||||
|
igvk_window.SemaphoreIndex = (igvk_window.SemaphoreIndex + 1) % igvk_window.SemaphoreCount
|
||||||
|
}
|
91
examples/impl_win32_opengl3.odin
Normal file
91
examples/impl_win32_opengl3.odin
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
package impl_wini32_opengl3
|
||||||
|
import "base:runtime"
|
||||||
|
import "core:os"
|
||||||
|
import "core:fmt"
|
||||||
|
import win32 "core:sys/windows"
|
||||||
|
import gl "vendor:OpenGL"
|
||||||
|
import imgui ".."
|
||||||
|
import imgui_win32 "../win32"
|
||||||
|
import imgui_gl3 "../opengl3"
|
||||||
|
|
||||||
|
main :: proc() {
|
||||||
|
run()
|
||||||
|
}
|
||||||
|
|
||||||
|
win32_hrc: win32.HGLRC
|
||||||
|
win32_main_window: win32.HDC
|
||||||
|
win32_width: i32
|
||||||
|
win32_height: i32
|
||||||
|
|
||||||
|
win32_gl_create :: proc(hwnd: win32.HWND, data: win32.HDC) -> b8
|
||||||
|
{
|
||||||
|
hdc: win32.HDC = win32.GetDC(hwnd)
|
||||||
|
pfd: win32.PIXELFORMATDESCRIPTOR = {}
|
||||||
|
pfd.nSize = size_of(pfd)
|
||||||
|
pfd.nVersion = 1
|
||||||
|
pfd.dwFlags = 0 // TODO flags
|
||||||
|
pfd.iPixelType = 0 // more flags
|
||||||
|
pfd.cColorBits = 32
|
||||||
|
|
||||||
|
pf: i32 = win32.ChoosePixelFormat(hdc, &pfd)
|
||||||
|
if pf == 0 do return false
|
||||||
|
if !win32.SetPixelFormat(hdc, pf, &pfd) do return false
|
||||||
|
win32.ReleaseDC(hwnd, hdc)
|
||||||
|
data = win32.GetDC(hwnd)
|
||||||
|
if win32_hrc == 0 do win32_hrc = win32.wglCreateContext(data)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
run :: proc() -> b32 {
|
||||||
|
wc: win32.WNDCLASSEXW = {}
|
||||||
|
|
||||||
|
imgui.CreateContext(nil)
|
||||||
|
io := imgui.GetIO()
|
||||||
|
io.ConfigFlags |= imgui.ConfigFlags.NavEnableKeyboard
|
||||||
|
io.ConfigFlags |= imgui.ConfigFlags.NavEnableGamepad
|
||||||
|
imgui.StyleColorsDark(nil)
|
||||||
|
|
||||||
|
imgui_glfw.InitForOpenGL(window, true)
|
||||||
|
imgui_gl3.InitEx(glsl_version)
|
||||||
|
clear_color: [4]f32 = {0.45, 0.55, 0.60, 1.00}
|
||||||
|
_cc := clear_color.xyz
|
||||||
|
show_demo: b8 = true
|
||||||
|
|
||||||
|
for !glfw.WindowShouldClose(window) {
|
||||||
|
glfw.PollEvents()
|
||||||
|
if glfw.GetWindowAttrib(window, glfw.ICONIFIED) != 0 {
|
||||||
|
imgui_glfw.Sleep(10)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
imgui_gl3.NewFrame()
|
||||||
|
imgui_glfw.NewFrame()
|
||||||
|
imgui.NewFrame()
|
||||||
|
|
||||||
|
if imgui.Button("Toggle DearImgui Demo") do show_demo = !show_demo
|
||||||
|
if show_demo do imgui.ShowDemoWindow(&show_demo)
|
||||||
|
|
||||||
|
_cc = clear_color.xyz
|
||||||
|
imgui.ColorEdit3("clear color", &_cc, .None)
|
||||||
|
imgui.SliderFloat3("clear color", &_cc, 0, 1)
|
||||||
|
clear_color.xyz = _cc
|
||||||
|
imgui.Render()
|
||||||
|
|
||||||
|
dw, dh:= glfw.GetFramebufferSize(window)
|
||||||
|
gl.Viewport(0, 0, dw, dh)
|
||||||
|
gl.ClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w);
|
||||||
|
gl.Clear(gl.COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
imgui_gl3.RenderDrawData(imgui.GetDrawData());
|
||||||
|
glfw.SwapBuffers(window);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
imgui_gl3.Shutdown()
|
||||||
|
imgui_glfw.Shutdown()
|
||||||
|
imgui.DestroyContext(nil)
|
||||||
|
|
||||||
|
glfw.DestroyWindow(window)
|
||||||
|
glfw.Terminate()
|
||||||
|
return true
|
||||||
|
}
|
342
generator.js
Executable file
342
generator.js
Executable file
@ -0,0 +1,342 @@
|
|||||||
|
// a crappy dear_binding -> odin generator
|
||||||
|
const file = await Bun.file('glfw/impl_glfw.json').json()
|
||||||
|
|
||||||
|
const keywords =['asm','auto_cast','bit_set','break','case','cast','context','continue',
|
||||||
|
'defer','distinct','do','dynamic','else','enum','fallthrough','for','foreign','if',
|
||||||
|
'import','in','map','not_in','or_else','or_return','package','proc','return','struct',
|
||||||
|
'switch','transmute','typeid','union','using','when','where'];
|
||||||
|
const namespace = {} // [c-name]: odin-name
|
||||||
|
|
||||||
|
console.log(`package imgui\n
|
||||||
|
foreign import imgui "!!!!!!!!!!!!!"
|
||||||
|
`)
|
||||||
|
|
||||||
|
for (const en of file.enums) {
|
||||||
|
let name = en.name;
|
||||||
|
if (name.startsWith('ImGui'))
|
||||||
|
name = name.substring(5)
|
||||||
|
if (name.endsWith('_'))
|
||||||
|
name = name.substring(0, name.length - 1)
|
||||||
|
|
||||||
|
let out = `${name} :: enum {`
|
||||||
|
for (const el of en.elements) {
|
||||||
|
let el_name = el.name
|
||||||
|
if (el_name.startsWith(en.name)) el_name = el_name.substring(en.name.length)
|
||||||
|
if (el_name.startsWith('_')) el_name = el_name.substring(1)
|
||||||
|
if (el_name.match(/^\d/)) el_name = 'Num' + el_name
|
||||||
|
out += `\n\t${el_name}`;
|
||||||
|
if (el.value !== undefined) {
|
||||||
|
let v = el.value
|
||||||
|
// if (el.value_expression.startsWith(en.name)) ve = el_name.substring(en.name.length)
|
||||||
|
out += ` = ${v}`
|
||||||
|
}
|
||||||
|
out += ','
|
||||||
|
}
|
||||||
|
out += '\n}'
|
||||||
|
console.log(out)
|
||||||
|
if (en.name.endsWith('_')) namespace[en.name.substring(0, en.name.length - 1)] = name
|
||||||
|
else namespace[en.name] = name
|
||||||
|
}
|
||||||
|
|
||||||
|
// see odin core:c
|
||||||
|
const cToOdinTypes = {
|
||||||
|
'int': 'i32',
|
||||||
|
'signed char': 'i8',
|
||||||
|
'unsigned char': 'u8',
|
||||||
|
'short': 'i16',
|
||||||
|
'signed short': 'i16',
|
||||||
|
'unsigned short': 'u16',
|
||||||
|
'signed int': 'i32',
|
||||||
|
'unsigned int': 'u32',
|
||||||
|
'long long': 'i64',
|
||||||
|
'signed long long': 'i64',
|
||||||
|
'unsigned long long': 'u64',
|
||||||
|
'void*': 'rawptr',
|
||||||
|
'const void*': 'rawptr',
|
||||||
|
'size_t': 'u32',
|
||||||
|
'ssize_t': 'i32',
|
||||||
|
'const char*': 'cstring',
|
||||||
|
'char*': 'cstring',
|
||||||
|
'unsigned char*': 'cstring',
|
||||||
|
'bool': 'b8',
|
||||||
|
'float': 'f32',
|
||||||
|
'double': 'f64',
|
||||||
|
}
|
||||||
|
|
||||||
|
const fp_typedef = []
|
||||||
|
for (const td of file.typedefs) {
|
||||||
|
if (namespace[td.name]) continue
|
||||||
|
let name = td.name;
|
||||||
|
if (name.startsWith('ImGui'))
|
||||||
|
name = name.substring(5)
|
||||||
|
|
||||||
|
let decl = td.type.declaration;
|
||||||
|
if (decl in cToOdinTypes)
|
||||||
|
decl = cToOdinTypes[decl];
|
||||||
|
|
||||||
|
if (td.type.type_details?.flavour === 'function_pointer') {
|
||||||
|
const fp_return_type = td.type.type_details.return_type.declaration
|
||||||
|
const args = []
|
||||||
|
for (const arg of td.type.type_details.arguments) {
|
||||||
|
let type = '';
|
||||||
|
if (arg.type.declaration in cToOdinTypes)
|
||||||
|
type = cToOdinTypes[arg.type.declaration]
|
||||||
|
else {
|
||||||
|
let innerType = arg.type.description
|
||||||
|
while (innerType.kind === 'Pointer') {
|
||||||
|
type += '^'
|
||||||
|
innerType = innerType.inner_type
|
||||||
|
}
|
||||||
|
if (innerType.name in namespace)
|
||||||
|
type += namespace[innerType.name]
|
||||||
|
else
|
||||||
|
{
|
||||||
|
type += innerType.name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// args.push(`${arg.name}: ${type}`)
|
||||||
|
args.push({
|
||||||
|
name: arg.name,
|
||||||
|
type: type,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
let return_type = null
|
||||||
|
if (fp_return_type !== 'void'){
|
||||||
|
if (fp_return_type in cToOdinTypes)
|
||||||
|
return_type = cToOdinTypes[fp_return_type]
|
||||||
|
else {
|
||||||
|
let innerType = td.type.type_details.return_type
|
||||||
|
while (innerType.kind === 'Pointer') {
|
||||||
|
return_type += '^'
|
||||||
|
innerType = innerType.inner_type
|
||||||
|
}
|
||||||
|
// return_type += innerType.name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fp_typedef.push({
|
||||||
|
name: name,
|
||||||
|
args: args,
|
||||||
|
return_type: return_type,
|
||||||
|
})
|
||||||
|
|
||||||
|
} else {
|
||||||
|
console.log(`${name} :: ${decl}`)
|
||||||
|
}
|
||||||
|
namespace[td.name] = name
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (const fptd of fp_typedef) {
|
||||||
|
let sep = ''
|
||||||
|
let out = fptd.name
|
||||||
|
out += ` :: proc(`
|
||||||
|
for (const arg of fptd.args) {
|
||||||
|
let type = arg.type
|
||||||
|
if (arg.type in namespace) type = namespace[arg.type]
|
||||||
|
out += `${sep}${arg.name}: ${type}`
|
||||||
|
sep = ', '
|
||||||
|
}
|
||||||
|
out += `)`
|
||||||
|
if (fptd.return_type !== null) out += ` -> ${fptd.return_type}`
|
||||||
|
console.log(out)
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`@(default_calling_convention = "cdecl", link_prefix = "ImGui_")
|
||||||
|
foreign imgui {`)
|
||||||
|
|
||||||
|
for (const fn of file.functions) {
|
||||||
|
let name = fn.name;
|
||||||
|
if (name.startsWith('ImGui_')) name = name.substring(6)
|
||||||
|
|
||||||
|
const args = []
|
||||||
|
for (const arg of fn.arguments) {
|
||||||
|
let type = '';
|
||||||
|
let name = (keywords.includes(arg.name))? '_' + arg.name: arg.name
|
||||||
|
if (arg.is_varargs){
|
||||||
|
name = '#c_vararg ' + name
|
||||||
|
type = '..any'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (arg.type.declaration in cToOdinTypes)
|
||||||
|
type = cToOdinTypes[arg.type.declaration]
|
||||||
|
else if (arg.type.declaration in namespace) {
|
||||||
|
if (namespace[arg.type.declaration].startsWith('ImGui'))
|
||||||
|
type = namespace[arg.type.declaration].substring('ImGui'.length)
|
||||||
|
else
|
||||||
|
type = namespace[arg.type.declaration]
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
let innerType = arg.type.description
|
||||||
|
if (arg.is_array) {
|
||||||
|
type += `[${innerType.bounds ?? ''}]`
|
||||||
|
innerType = innerType.inner_type
|
||||||
|
}
|
||||||
|
let ptr = 0
|
||||||
|
let ptr_chr = '^'
|
||||||
|
while (innerType.kind === 'Pointer') {
|
||||||
|
ptr++
|
||||||
|
innerType = innerType.inner_type
|
||||||
|
}
|
||||||
|
if (ptr && innerType.builtin_type == 'void' || innerType.builtin_type?.endsWith('char')) {
|
||||||
|
ptr--
|
||||||
|
ptr_chr = '[^]'
|
||||||
|
}
|
||||||
|
for (let i = 0; i < ptr; i++) {
|
||||||
|
type += ptr_chr
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ptr_chr === '[^]') {
|
||||||
|
if (innerType.builtin_type == 'void') type += 'rawptr'
|
||||||
|
else if (innerType.builtin_type.endsWith('char')) type += 'cstring'
|
||||||
|
}
|
||||||
|
else if (innerType.name in namespace) type += namespace[innerType.name]
|
||||||
|
else if (innerType.name in cToOdinTypes) type += cToOdinTypes[innerType.name]
|
||||||
|
else if (innerType.builtin_type in cToOdinTypes) type += cToOdinTypes[innerType.builtin_type]
|
||||||
|
else if (innerType.builtin_type?.replace('_',' ') in cToOdinTypes) type += cToOdinTypes[innerType.builtin_type.replace('_',' ')]
|
||||||
|
else if (innerType.name) {
|
||||||
|
if (innerType.name.startsWith('ImGui'))
|
||||||
|
type += innerType.name.substring('ImGui'.length)
|
||||||
|
else
|
||||||
|
type += innerType.name
|
||||||
|
}
|
||||||
|
else type = '[!!!]'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// args.push(`${arg.name}: ${type}`)
|
||||||
|
args.push({
|
||||||
|
name: name, // do a keyword check instead
|
||||||
|
type: type,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
let sep = ''
|
||||||
|
let out = name
|
||||||
|
out += ` :: proc(`
|
||||||
|
for (const arg of args) {
|
||||||
|
let type = arg.type
|
||||||
|
if (arg.type in namespace) type = namespace[arg.type]
|
||||||
|
out += `${sep}${arg.name}: ${type}`
|
||||||
|
sep = ', '
|
||||||
|
}
|
||||||
|
out += `)`
|
||||||
|
|
||||||
|
if (fn.return_type.declaration !== 'void'){
|
||||||
|
let return_type = ''
|
||||||
|
if (fn.return_type in cToOdinTypes)
|
||||||
|
return_type = cToOdinTypes[fp_return_type]
|
||||||
|
else if (fn.return_type in namespace) {
|
||||||
|
if (namespace[fn.return_type].startsWith('ImGui'))
|
||||||
|
return_type = namespace[fn.return_type].substring('ImGui'.length)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let innerType = fn.return_type.description
|
||||||
|
let ptr = 0
|
||||||
|
let ptr_chr = '^'
|
||||||
|
while (innerType.kind === 'Pointer') {
|
||||||
|
ptr++
|
||||||
|
innerType = innerType.inner_type
|
||||||
|
}
|
||||||
|
if (ptr && innerType.builtin_type == 'void' || innerType.builtin_type == 'char') {
|
||||||
|
ptr--
|
||||||
|
ptr_chr = '[^]'
|
||||||
|
}
|
||||||
|
for (let i = 0; i < ptr; i++) {
|
||||||
|
return_type += ptr_chr
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ptr_chr === '[^]') {
|
||||||
|
if (innerType.builtin_type == 'void') return_type += 'rawptr'
|
||||||
|
else if (innerType.builtin_type == 'char') return_type += 'cstring'
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (innerType.name in namespace) {
|
||||||
|
if (namespace[innerType.name].startsWith('ImGui'))
|
||||||
|
return_type += namespace[innerType.name].substring('ImGui'.length)
|
||||||
|
else
|
||||||
|
return_type += namespace[innerType.name]
|
||||||
|
}
|
||||||
|
else if (innerType.name in cToOdinTypes) return_type += cToOdinTypes[innerType.name]
|
||||||
|
else if (innerType.builtin_type in cToOdinTypes) return_type += cToOdinTypes[innerType.builtin_type]
|
||||||
|
else if (innerType.builtin_type?.replace('_',' ') in cToOdinTypes) return_type += cToOdinTypes[innerType.builtin_type.replace('_',' ')]
|
||||||
|
else if (innerType.name) {
|
||||||
|
if (innerType.name.startsWith('ImGui'))
|
||||||
|
return_type += innerType.name.substring('ImGui'.length)
|
||||||
|
else
|
||||||
|
return_type += innerType.name
|
||||||
|
}
|
||||||
|
else return_type = '[!!!]'
|
||||||
|
}
|
||||||
|
|
||||||
|
out += ` -> ${return_type}`
|
||||||
|
}
|
||||||
|
out += ` ---`
|
||||||
|
console.log('\t'+out)
|
||||||
|
namespace[fn.name] = name
|
||||||
|
|
||||||
|
}
|
||||||
|
console.log('}')
|
||||||
|
|
||||||
|
for (const struct of file.structs) {
|
||||||
|
let name = struct.name;
|
||||||
|
if (name.startsWith('ImGui'))
|
||||||
|
name = name.substring(5)
|
||||||
|
|
||||||
|
namespace[struct.name] = name
|
||||||
|
|
||||||
|
let out = `${name} :: struct {\n`;
|
||||||
|
for (const field of struct.fields) {
|
||||||
|
out += '\t'
|
||||||
|
out += field.name
|
||||||
|
out += ': '
|
||||||
|
let innerType = field.type.description
|
||||||
|
if (field.is_array) {
|
||||||
|
let bound = innerType.bounds
|
||||||
|
// bleh
|
||||||
|
if (innerType.bounds.startsWith('ImGui')) {
|
||||||
|
bound = bound.substring('ImGui'.length)
|
||||||
|
if (bound.split('_')[0] in namespace)
|
||||||
|
bound = bound.split('_')[1]
|
||||||
|
else
|
||||||
|
bound = innerType.bounds
|
||||||
|
}
|
||||||
|
out += `[${bound ?? ''}]`
|
||||||
|
innerType = innerType.inner_type
|
||||||
|
}
|
||||||
|
let ptr = 0
|
||||||
|
let ptr_chr = '^'
|
||||||
|
while (innerType.kind === 'Pointer') {
|
||||||
|
ptr++
|
||||||
|
innerType = innerType.inner_type
|
||||||
|
}
|
||||||
|
if (ptr && innerType.builtin_type == 'void' || innerType.builtin_type?.endsWith('char')) {
|
||||||
|
ptr--
|
||||||
|
ptr_chr = '[^]'
|
||||||
|
}
|
||||||
|
for (let i = 0; i < ptr; i++) {
|
||||||
|
out += ptr_chr
|
||||||
|
}
|
||||||
|
if (ptr_chr === '[^]') {
|
||||||
|
if (innerType.builtin_type == 'void') out += 'rawptr'
|
||||||
|
else if (innerType.builtin_type.endsWith('char')) out += 'cstring'
|
||||||
|
}
|
||||||
|
else if (innerType.name in namespace) out += namespace[innerType.name]
|
||||||
|
else if (innerType.name in cToOdinTypes) out += cToOdinTypes[innerType.name]
|
||||||
|
else if (innerType.builtin_type in cToOdinTypes) out += cToOdinTypes[innerType.builtin_type]
|
||||||
|
else if (innerType.builtin_type?.replace('_',' ') in cToOdinTypes) out += cToOdinTypes[innerType.builtin_type.replace('_',' ')]
|
||||||
|
else if (innerType.name) {
|
||||||
|
if (innerType.name.startsWith('ImGui'))
|
||||||
|
out += innerType.name.substring('ImGui'.length)
|
||||||
|
else
|
||||||
|
out += innerType.name
|
||||||
|
}
|
||||||
|
|
||||||
|
out += ',\n'
|
||||||
|
}
|
||||||
|
out += '}'
|
||||||
|
console.log(out)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
116
glfw/impl_glfw.cpp
Normal file
116
glfw/impl_glfw.cpp
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
// THIS FILE HAS BEEN AUTO-GENERATED BY THE 'DEAR BINDINGS' GENERATOR.
|
||||||
|
// **DO NOT EDIT DIRECTLY**
|
||||||
|
// https://github.com/dearimgui/dear_bindings
|
||||||
|
|
||||||
|
#include "imgui.h"
|
||||||
|
#include "imgui_impl_glfw.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
// Wrap this in a namespace to keep it separate from the C++ API
|
||||||
|
namespace cimgui
|
||||||
|
{
|
||||||
|
#include "impl_glfw.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
// By-value struct conversions
|
||||||
|
|
||||||
|
// Function stubs
|
||||||
|
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API bool cimgui::cImGui_ImplGlfw_InitForOpenGL(cimgui::GLFWwindow* window, bool install_callbacks)
|
||||||
|
{
|
||||||
|
return ::ImGui_ImplGlfw_InitForOpenGL(reinterpret_cast<::GLFWwindow*>(window), install_callbacks);
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API bool cimgui::cImGui_ImplGlfw_InitForVulkan(cimgui::GLFWwindow* window, bool install_callbacks)
|
||||||
|
{
|
||||||
|
return ::ImGui_ImplGlfw_InitForVulkan(reinterpret_cast<::GLFWwindow*>(window), install_callbacks);
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API bool cimgui::cImGui_ImplGlfw_InitForOther(cimgui::GLFWwindow* window, bool install_callbacks)
|
||||||
|
{
|
||||||
|
return ::ImGui_ImplGlfw_InitForOther(reinterpret_cast<::GLFWwindow*>(window), install_callbacks);
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplGlfw_Shutdown(void)
|
||||||
|
{
|
||||||
|
::ImGui_ImplGlfw_Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplGlfw_NewFrame(void)
|
||||||
|
{
|
||||||
|
::ImGui_ImplGlfw_NewFrame();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplGlfw_InstallEmscriptenCallbacks(cimgui::GLFWwindow* window, const char* canvas_selector)
|
||||||
|
{
|
||||||
|
::ImGui_ImplGlfw_InstallEmscriptenCallbacks(reinterpret_cast<::GLFWwindow*>(window), canvas_selector);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // #ifdef __EMSCRIPTEN__
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplGlfw_InstallCallbacks(cimgui::GLFWwindow* window)
|
||||||
|
{
|
||||||
|
::ImGui_ImplGlfw_InstallCallbacks(reinterpret_cast<::GLFWwindow*>(window));
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplGlfw_RestoreCallbacks(cimgui::GLFWwindow* window)
|
||||||
|
{
|
||||||
|
::ImGui_ImplGlfw_RestoreCallbacks(reinterpret_cast<::GLFWwindow*>(window));
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplGlfw_SetCallbacksChainForAllWindows(bool chain_for_all_windows)
|
||||||
|
{
|
||||||
|
::ImGui_ImplGlfw_SetCallbacksChainForAllWindows(chain_for_all_windows);
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplGlfw_WindowFocusCallback(cimgui::GLFWwindow* window, int focused)
|
||||||
|
{
|
||||||
|
::ImGui_ImplGlfw_WindowFocusCallback(reinterpret_cast<::GLFWwindow*>(window), focused);
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplGlfw_CursorEnterCallback(cimgui::GLFWwindow* window, int entered)
|
||||||
|
{
|
||||||
|
::ImGui_ImplGlfw_CursorEnterCallback(reinterpret_cast<::GLFWwindow*>(window), entered);
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplGlfw_CursorPosCallback(cimgui::GLFWwindow* window, double x, double y)
|
||||||
|
{
|
||||||
|
::ImGui_ImplGlfw_CursorPosCallback(reinterpret_cast<::GLFWwindow*>(window), x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplGlfw_MouseButtonCallback(cimgui::GLFWwindow* window, int button, int action, int mods)
|
||||||
|
{
|
||||||
|
::ImGui_ImplGlfw_MouseButtonCallback(reinterpret_cast<::GLFWwindow*>(window), button, action, mods);
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplGlfw_ScrollCallback(cimgui::GLFWwindow* window, double xoffset, double yoffset)
|
||||||
|
{
|
||||||
|
::ImGui_ImplGlfw_ScrollCallback(reinterpret_cast<::GLFWwindow*>(window), xoffset, yoffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplGlfw_KeyCallback(cimgui::GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||||
|
{
|
||||||
|
::ImGui_ImplGlfw_KeyCallback(reinterpret_cast<::GLFWwindow*>(window), key, scancode, action, mods);
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplGlfw_CharCallback(cimgui::GLFWwindow* window, unsigned int c)
|
||||||
|
{
|
||||||
|
::ImGui_ImplGlfw_CharCallback(reinterpret_cast<::GLFWwindow*>(window), c);
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplGlfw_MonitorCallback(cimgui::GLFWmonitor* monitor, int event)
|
||||||
|
{
|
||||||
|
::ImGui_ImplGlfw_MonitorCallback(reinterpret_cast<::GLFWmonitor*>(monitor), event);
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplGlfw_Sleep(int milliseconds)
|
||||||
|
{
|
||||||
|
::ImGui_ImplGlfw_Sleep(milliseconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
73
glfw/impl_glfw.h
Normal file
73
glfw/impl_glfw.h
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
// THIS FILE HAS BEEN AUTO-GENERATED BY THE 'DEAR BINDINGS' GENERATOR.
|
||||||
|
// **DO NOT EDIT DIRECTLY**
|
||||||
|
// https://github.com/dearimgui/dear_bindings
|
||||||
|
|
||||||
|
// dear imgui: Platform Backend for GLFW
|
||||||
|
// This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan, WebGPU..)
|
||||||
|
// (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
|
||||||
|
|
||||||
|
// Implemented features:
|
||||||
|
// [X] Platform: Clipboard support.
|
||||||
|
// [X] Platform: Mouse support. Can discriminate Mouse/TouchScreen/Pen (Windows only).
|
||||||
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLFW_KEY_* values are obsolete since 1.87 and not supported since 1.91.5]
|
||||||
|
// [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
|
// [X] Platform: Mouse cursor shape and visibility (ImGuiBackendFlags_HasMouseCursors). Resizing cursors requires GLFW 3.4+! Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
|
|
||||||
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
|
// Learn about Dear ImGui:
|
||||||
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
#include "../dcimgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
typedef struct GLFWwindow GLFWwindow;
|
||||||
|
typedef struct GLFWmonitor GLFWmonitor;
|
||||||
|
|
||||||
|
typedef struct ImDrawData_t ImDrawData;
|
||||||
|
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
|
||||||
|
CIMGUI_IMPL_API bool cImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, bool install_callbacks);
|
||||||
|
CIMGUI_IMPL_API bool cImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks);
|
||||||
|
CIMGUI_IMPL_API bool cImGui_ImplGlfw_InitForOther(GLFWwindow* window, bool install_callbacks);
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplGlfw_Shutdown(void);
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplGlfw_NewFrame(void);
|
||||||
|
|
||||||
|
// Emscripten related initialization phase methods (call after ImGui_ImplGlfw_InitForOpenGL)
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplGlfw_InstallEmscriptenCallbacks(GLFWwindow* window, const char* canvas_selector);
|
||||||
|
//static inline void ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback(const char* canvas_selector) { ImGui_ImplGlfw_InstallEmscriptenCallbacks(nullptr, canvas_selector); } } // Renamed in 1.91.0
|
||||||
|
#endif // #ifdef __EMSCRIPTEN__
|
||||||
|
// GLFW callbacks install
|
||||||
|
// - When calling Init with 'install_callbacks=true': ImGui_ImplGlfw_InstallCallbacks() is called. GLFW callbacks will be installed for you. They will chain-call user's previously installed callbacks, if any.
|
||||||
|
// - When calling Init with 'install_callbacks=false': GLFW callbacks won't be installed. You will need to call individual function yourself from your own GLFW callbacks.
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplGlfw_InstallCallbacks(GLFWwindow* window);
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplGlfw_RestoreCallbacks(GLFWwindow* window);
|
||||||
|
|
||||||
|
// GFLW callbacks options:
|
||||||
|
// - Set 'chain_for_all_windows=true' to enable chaining callbacks for all windows (including secondary viewports created by backends or by user)
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplGlfw_SetCallbacksChainForAllWindows(bool chain_for_all_windows);
|
||||||
|
|
||||||
|
// GLFW callbacks (individual callbacks to call yourself if you didn't install callbacks)
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplGlfw_WindowFocusCallback(GLFWwindow* window, int focused); // Since 1.84
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplGlfw_CursorEnterCallback(GLFWwindow* window, int entered); // Since 1.84
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplGlfw_CursorPosCallback(GLFWwindow* window, double x, double y); // Since 1.87
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplGlfw_MonitorCallback(GLFWmonitor* monitor, int event);
|
||||||
|
|
||||||
|
// GLFW helpers
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplGlfw_Sleep(int milliseconds);
|
||||||
|
#endif// #ifndef IMGUI_DISABLE
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // End of extern "C" block
|
||||||
|
#endif
|
36
glfw/impl_glfw.odin
Normal file
36
glfw/impl_glfw.odin
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
package imgui_glfw
|
||||||
|
|
||||||
|
|
||||||
|
when ODIN_OS == .Windows {
|
||||||
|
foreign import imgui_glfw "../lib/dcimgui_impl_glfw.lib"
|
||||||
|
}
|
||||||
|
else when ODIN_OS == .Linux {
|
||||||
|
foreign import imgui_glfw "../lib/linux/libdcimgui_impl_glfw.a"
|
||||||
|
}
|
||||||
|
else when ODIN_OS == .Darwin {
|
||||||
|
foreign import imgui_glfw "../lib/darwin/libdcimgui_impl_glfw_arm64.a"
|
||||||
|
}
|
||||||
|
|
||||||
|
import glfw "vendor:glfw"
|
||||||
|
|
||||||
|
@(default_calling_convention = "cdecl", link_prefix = "cImGui_ImplGlfw_")
|
||||||
|
foreign imgui_glfw {
|
||||||
|
InitForOpenGL :: proc(window: glfw.WindowHandle, install_callbacks: b32) -> b32 ---
|
||||||
|
InitForVulkan :: proc(window: glfw.WindowHandle, install_callbacks: b32) -> b32 ---
|
||||||
|
InitForOther :: proc(window: glfw.WindowHandle, install_callbacks: b32) -> b32 ---
|
||||||
|
Shutdown :: proc() ---
|
||||||
|
NewFrame :: proc() ---
|
||||||
|
InstallEmscriptenCallbacks :: proc(window: glfw.WindowHandle, canvas_selector: cstring) ---
|
||||||
|
InstallCallbacks :: proc(window: glfw.WindowHandle) ---
|
||||||
|
RestoreCallbacks :: proc(window: glfw.WindowHandle) ---
|
||||||
|
SetCallbacksChainForAllWindows :: proc(chain_for_all_windows: b32) ---
|
||||||
|
WindowFocusCallback :: proc(window: glfw.WindowHandle, focused: i32) ---
|
||||||
|
CursorEnterCallback :: proc(window: glfw.WindowHandle, entered: i32) ---
|
||||||
|
CursorPosCallback :: proc(window: glfw.WindowHandle, x: f64, y: f64) ---
|
||||||
|
MouseButtonCallback :: proc(window: glfw.WindowHandle, button: i32, action: i32, mods: i32) ---
|
||||||
|
ScrollCallback :: proc(window: glfw.WindowHandle, xoffset: f64, yoffset: f64) ---
|
||||||
|
KeyCallback :: proc(window: glfw.WindowHandle, key: i32, scancode: i32, action: i32, mods: i32) ---
|
||||||
|
CharCallback :: proc(window: glfw.WindowHandle, c: u32) ---
|
||||||
|
MonitorCallback :: proc(monitor: glfw.MonitorHandle, event: i32) ---
|
||||||
|
Sleep :: proc(milliseconds: i32) ---
|
||||||
|
}
|
1
imgui
Submodule
1
imgui
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 1d962820d8b972d93a4627afc3cb4c09837c298c
|
BIN
lib/darwin/libdcimgui_arm64.a
Normal file
BIN
lib/darwin/libdcimgui_arm64.a
Normal file
Binary file not shown.
BIN
lib/darwin/libdcimgui_impl_glfw_arm64.a
Normal file
BIN
lib/darwin/libdcimgui_impl_glfw_arm64.a
Normal file
Binary file not shown.
BIN
lib/darwin/libdcimgui_impl_metal_arm64.a
Normal file
BIN
lib/darwin/libdcimgui_impl_metal_arm64.a
Normal file
Binary file not shown.
BIN
lib/darwin/libdcimgui_impl_opengl3_arm64.a
Normal file
BIN
lib/darwin/libdcimgui_impl_opengl3_arm64.a
Normal file
Binary file not shown.
BIN
lib/darwin/libdcimgui_impl_sdl2_arm64.a
Normal file
BIN
lib/darwin/libdcimgui_impl_sdl2_arm64.a
Normal file
Binary file not shown.
BIN
lib/darwin/libdcimgui_impl_vulkan_arm64.a
Normal file
BIN
lib/darwin/libdcimgui_impl_vulkan_arm64.a
Normal file
Binary file not shown.
BIN
lib/dcimgui.lib
Normal file
BIN
lib/dcimgui.lib
Normal file
Binary file not shown.
BIN
lib/dcimgui_impl_glfw.lib
Normal file
BIN
lib/dcimgui_impl_glfw.lib
Normal file
Binary file not shown.
BIN
lib/dcimgui_impl_opengl3.lib
Normal file
BIN
lib/dcimgui_impl_opengl3.lib
Normal file
Binary file not shown.
BIN
lib/dcimgui_impl_sdl2.lib
Normal file
BIN
lib/dcimgui_impl_sdl2.lib
Normal file
Binary file not shown.
BIN
lib/dcimgui_impl_vulkan.lib
Normal file
BIN
lib/dcimgui_impl_vulkan.lib
Normal file
Binary file not shown.
BIN
lib/linux/libdcimgui.a
Normal file
BIN
lib/linux/libdcimgui.a
Normal file
Binary file not shown.
BIN
lib/linux/libdcimgui_impl_glfw.a
Normal file
BIN
lib/linux/libdcimgui_impl_glfw.a
Normal file
Binary file not shown.
BIN
lib/linux/libdcimgui_impl_opengl3.a
Normal file
BIN
lib/linux/libdcimgui_impl_opengl3.a
Normal file
Binary file not shown.
BIN
lib/linux/libdcimgui_impl_sdl2.a
Normal file
BIN
lib/linux/libdcimgui_impl_sdl2.a
Normal file
Binary file not shown.
BIN
lib/linux/libdcimgui_impl_vulkan.a
Normal file
BIN
lib/linux/libdcimgui_impl_vulkan.a
Normal file
Binary file not shown.
53
metal/impl_metal.cpp
Normal file
53
metal/impl_metal.cpp
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
|
||||||
|
#include "imgui.h"
|
||||||
|
#include "imgui_impl_metal.h"
|
||||||
|
|
||||||
|
namespace cimgui
|
||||||
|
{
|
||||||
|
#include "impl_metal.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API bool cimgui::cImGui_ImplMetal_Init(MtlDevice* device)
|
||||||
|
{
|
||||||
|
return ::ImGui_ImplMetal_Init(reinterpret_cast<MTL::Device*>(device));
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplMetal_Shutdown(void)
|
||||||
|
{
|
||||||
|
::ImGui_ImplMetal_Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplMetal_NewFrame(MtlRenderPassDescriptor* renderPassDescriptor)
|
||||||
|
{
|
||||||
|
::ImGui_ImplMetal_NewFrame(reinterpret_cast<MTL::RenderPassDescriptor*>(renderPassDescriptor));
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplMetal_RenderDrawData(cimgui::ImDrawData* draw_data, MtlCommandBuffer* commandBuffer, MtlRenderCommandEncoder* commandEncoder)
|
||||||
|
{
|
||||||
|
::ImGui_ImplMetal_RenderDrawData(reinterpret_cast<::ImDrawData*>(draw_data), reinterpret_cast<MTL::CommandBuffer*>(commandBuffer), reinterpret_cast<MTL::RenderCommandEncoder*>(commandEncoder));
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API bool cimgui::cImGui_ImplMetal_CreateFontsTexture(MtlDevice* device)
|
||||||
|
{
|
||||||
|
return ::ImGui_ImplMetal_CreateFontsTexture(reinterpret_cast<MTL::Device*>(device));
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplMetal_DestroyFontsTexture(void)
|
||||||
|
{
|
||||||
|
::ImGui_ImplMetal_DestroyFontsTexture();
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API bool cimgui::cImGui_ImplMetal_CreateDeviceObjects(MtlDevice* device)
|
||||||
|
{
|
||||||
|
return ::ImGui_ImplMetal_CreateDeviceObjects(reinterpret_cast<MTL::Device*>(device));
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplMetal_DestroyDeviceObjects(void)
|
||||||
|
{
|
||||||
|
::ImGui_ImplMetal_DestroyDeviceObjects();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
29
metal/impl_metal.h
Normal file
29
metal/impl_metal.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
|
||||||
|
typedef void MtlDevice;
|
||||||
|
typedef void MtlRenderPassDescriptor;
|
||||||
|
typedef void MtlCommandBuffer;
|
||||||
|
typedef void MtlRenderCommandEncoder;
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
#include "../dcimgui.h"
|
||||||
|
|
||||||
|
typedef struct ImDrawData_t ImDrawData;
|
||||||
|
CIMGUI_IMPL_API bool cImGui_ImplMetal_Init(MtlDevice* device);
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplMetal_Shutdown(void);
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplMetal_NewFrame(MtlRenderPassDescriptor* renderPassDescriptor);
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data, MtlCommandBuffer* commandBuffer, MtlRenderCommandEncoder* commandEncoder);
|
||||||
|
CIMGUI_IMPL_API bool cImGui_ImplMetal_CreateFontsTexture(MtlDevice* device);
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplMetal_DestroyFontsTexture(void);
|
||||||
|
CIMGUI_IMPL_API bool cImGui_ImplMetal_CreateDeviceObjects(MtlDevice* device);
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplMetal_DestroyDeviceObjects(void);
|
||||||
|
|
||||||
|
#endif// #ifndef IMGUI_DISABLE
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // End of extern "C" block
|
||||||
|
#endif
|
19
metal/impl_metal.odin
Normal file
19
metal/impl_metal.odin
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#+build darwin
|
||||||
|
package impl_metal
|
||||||
|
|
||||||
|
import imgui "../"
|
||||||
|
import mtl "vendor:darwin/Metal"
|
||||||
|
|
||||||
|
foreign import impl_metal "../lib/darwin/libdcimgui_impl_metal_arm64.a"
|
||||||
|
|
||||||
|
@(default_calling_convention = "cdecl", link_prefix = "cImGui_ImplMetal_")
|
||||||
|
foreign impl_metal {
|
||||||
|
Init :: proc(device: ^mtl.Device) -> b8 ---
|
||||||
|
Shutdown :: proc() ---
|
||||||
|
NewFrame :: proc( renderPassDescriptor: ^mtl.RenderPassDescriptor) ---
|
||||||
|
RenderDrawData :: proc(drawData: ^imgui.ImDrawData, commandBuffer: ^mtl.CommandBuffer, commandEncoder: ^mtl.CommandEncoder) ---
|
||||||
|
CreateFontsTexture :: proc(device: ^mtl.Device) -> b8 ---
|
||||||
|
DestroyFontsTexture :: proc () ---
|
||||||
|
CreateDeviceObjects :: proc(device: ^mtl.Device) -> b8 ---
|
||||||
|
DestroyDeviceObjects :: proc () ---
|
||||||
|
}
|
67
opengl3/impl_opengl3.cpp
Normal file
67
opengl3/impl_opengl3.cpp
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
// THIS FILE HAS BEEN AUTO-GENERATED BY THE 'DEAR BINDINGS' GENERATOR.
|
||||||
|
// **DO NOT EDIT DIRECTLY**
|
||||||
|
// https://github.com/dearimgui/dear_bindings
|
||||||
|
|
||||||
|
#include "imgui.h"
|
||||||
|
#include "imgui_impl_opengl3.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
// Wrap this in a namespace to keep it separate from the C++ API
|
||||||
|
namespace cimgui
|
||||||
|
{
|
||||||
|
#include "impl_opengl3.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
// By-value struct conversions
|
||||||
|
|
||||||
|
// Function stubs
|
||||||
|
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API bool cimgui::cImGui_ImplOpenGL3_Init(void)
|
||||||
|
{
|
||||||
|
return ::ImGui_ImplOpenGL3_Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API bool cimgui::cImGui_ImplOpenGL3_InitEx(const char* glsl_version)
|
||||||
|
{
|
||||||
|
return ::ImGui_ImplOpenGL3_Init(glsl_version);
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplOpenGL3_Shutdown(void)
|
||||||
|
{
|
||||||
|
::ImGui_ImplOpenGL3_Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplOpenGL3_NewFrame(void)
|
||||||
|
{
|
||||||
|
::ImGui_ImplOpenGL3_NewFrame();
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplOpenGL3_RenderDrawData(cimgui::ImDrawData* draw_data)
|
||||||
|
{
|
||||||
|
::ImGui_ImplOpenGL3_RenderDrawData(reinterpret_cast<::ImDrawData*>(draw_data));
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API bool cimgui::cImGui_ImplOpenGL3_CreateFontsTexture(void)
|
||||||
|
{
|
||||||
|
return ::ImGui_ImplOpenGL3_CreateFontsTexture();
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplOpenGL3_DestroyFontsTexture(void)
|
||||||
|
{
|
||||||
|
::ImGui_ImplOpenGL3_DestroyFontsTexture();
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API bool cimgui::cImGui_ImplOpenGL3_CreateDeviceObjects(void)
|
||||||
|
{
|
||||||
|
return ::ImGui_ImplOpenGL3_CreateDeviceObjects();
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplOpenGL3_DestroyDeviceObjects(void)
|
||||||
|
{
|
||||||
|
::ImGui_ImplOpenGL3_DestroyDeviceObjects();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
78
opengl3/impl_opengl3.h
Normal file
78
opengl3/impl_opengl3.h
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
// THIS FILE HAS BEEN AUTO-GENERATED BY THE 'DEAR BINDINGS' GENERATOR.
|
||||||
|
// **DO NOT EDIT DIRECTLY**
|
||||||
|
// https://github.com/dearimgui/dear_bindings
|
||||||
|
|
||||||
|
// dear imgui: Renderer Backend for modern OpenGL with shaders / programmatic pipeline
|
||||||
|
// - Desktop GL: 2.x 3.x 4.x
|
||||||
|
// - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0)
|
||||||
|
// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..)
|
||||||
|
|
||||||
|
// Implemented features:
|
||||||
|
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
|
||||||
|
// [x] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset) [Desktop OpenGL only!]
|
||||||
|
|
||||||
|
// About WebGL/ES:
|
||||||
|
// - You need to '#define IMGUI_IMPL_OPENGL_ES2' or '#define IMGUI_IMPL_OPENGL_ES3' to use WebGL or OpenGL ES.
|
||||||
|
// - This is done automatically on iOS, Android and Emscripten targets.
|
||||||
|
// - For other targets, the define needs to be visible from the imgui_impl_opengl3.cpp compilation unit. If unsure, define globally or in imconfig.h.
|
||||||
|
|
||||||
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
|
// Learn about Dear ImGui:
|
||||||
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
|
// About GLSL version:
|
||||||
|
// The 'glsl_version' initialization parameter should be nullptr (default) or a "#version XXX" string.
|
||||||
|
// On computer platform the GLSL version default to "#version 130". On OpenGL ES 3 platform it defaults to "#version 300 es"
|
||||||
|
// Only override if your GL version doesn't handle this GLSL version. See GLSL version table at the top of imgui_impl_opengl3.cpp.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
#include "../dcimgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
typedef struct ImDrawData_t ImDrawData;
|
||||||
|
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
|
||||||
|
CIMGUI_IMPL_API bool cImGui_ImplOpenGL3_Init(void); // Implied glsl_version = nullptr
|
||||||
|
CIMGUI_IMPL_API bool cImGui_ImplOpenGL3_InitEx(const char* glsl_version /* = nullptr */);
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplOpenGL3_Shutdown(void);
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplOpenGL3_NewFrame(void);
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data);
|
||||||
|
|
||||||
|
// (Optional) Called by Init/NewFrame/Shutdown
|
||||||
|
CIMGUI_IMPL_API bool cImGui_ImplOpenGL3_CreateFontsTexture(void);
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplOpenGL3_DestroyFontsTexture(void);
|
||||||
|
CIMGUI_IMPL_API bool cImGui_ImplOpenGL3_CreateDeviceObjects(void);
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplOpenGL3_DestroyDeviceObjects(void);
|
||||||
|
|
||||||
|
// Configuration flags to add in your imconfig file:
|
||||||
|
//#define IMGUI_IMPL_OPENGL_ES2 // Enable ES 2 (Auto-detected on Emscripten)
|
||||||
|
//#define IMGUI_IMPL_OPENGL_ES3 // Enable ES 3 (Auto-detected on iOS/Android)
|
||||||
|
|
||||||
|
// You can explicitly select GLES2 or GLES3 API by using one of the '#define IMGUI_IMPL_OPENGL_LOADER_XXX' in imconfig.h or compiler command-line.
|
||||||
|
#if !defined(IMGUI_IMPL_OPENGL_ES2)\
|
||||||
|
&&!defined(IMGUI_IMPL_OPENGL_ES3)
|
||||||
|
// Try to detect GLES on matching platforms
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
#include <TargetConditionals.h>
|
||||||
|
#endif // #if defined(__APPLE__)
|
||||||
|
#if (defined(__APPLE__)&&(TARGET_OS_IOS || TARGET_OS_TV))||(defined(__ANDROID__))
|
||||||
|
#define IMGUI_IMPL_OPENGL_ES3 // iOS, Android -> GL ES 3, "#version 300 es"
|
||||||
|
#else
|
||||||
|
#if defined(__EMSCRIPTEN__)|| defined(__amigaos4__)
|
||||||
|
#define IMGUI_IMPL_OPENGL_ES2 // Emscripten -> GL ES 2, "#version 100"
|
||||||
|
#else
|
||||||
|
// Otherwise imgui_impl_opengl3_loader.h will be used.
|
||||||
|
#endif // #if defined(__EMSCRIPTEN__)|| defined(__amigaos4__)
|
||||||
|
#endif // #if (defined(__APPLE__)&&(TARGET_OS_IOS || TARGET_OS_TV))||(defined(__ANDROID__))
|
||||||
|
#endif // #if !defined(IMGUI_IMPL_OPENGL_ES2) &&!defined(IMGUI_IMPL_OPENGL_ES3)
|
||||||
|
#endif// #ifndef IMGUI_DISABLE
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // End of extern "C" block
|
||||||
|
#endif
|
27
opengl3/impl_opengl3.odin
Normal file
27
opengl3/impl_opengl3.odin
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package impl_opengl3
|
||||||
|
|
||||||
|
import imgui "../"
|
||||||
|
import vk "vendor:vulkan"
|
||||||
|
|
||||||
|
when ODIN_OS == .Windows {
|
||||||
|
foreign import impl_opengl3 "../lib/dcimgui_impl_opengl3.lib"
|
||||||
|
}
|
||||||
|
else when ODIN_OS == .Linux {
|
||||||
|
foreign import impl_opengl3 "../lib/linux/libdcimgui_impl_opengl3.a"
|
||||||
|
}
|
||||||
|
else when ODIN_OS == .Darwin {
|
||||||
|
foreign import impl_opengl3 "../lib/darwin/libdcimgui_impl_opengl3_arm64.a"
|
||||||
|
}
|
||||||
|
|
||||||
|
@(default_calling_convention = "cdecl", link_prefix = "cImGui_ImplOpenGL3_")
|
||||||
|
foreign impl_opengl3 {
|
||||||
|
Init :: proc() -> b32 ---
|
||||||
|
InitEx :: proc(glsl_version: cstring) -> b32 ---
|
||||||
|
Shutdown :: proc() ---
|
||||||
|
NewFrame :: proc() ---
|
||||||
|
RenderDrawData :: proc(draw_data: ^imgui.ImDrawData) ---
|
||||||
|
CreateFontsTexture :: proc() -> b32 ---
|
||||||
|
DestroyFontsTexture :: proc() ---
|
||||||
|
CreateDeviceObjects :: proc() -> b32 ---
|
||||||
|
DestroyDeviceObjects :: proc() ---
|
||||||
|
}
|
77
sdl2/impl_sdl2.cpp
Normal file
77
sdl2/impl_sdl2.cpp
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
// THIS FILE HAS BEEN AUTO-GENERATED BY THE 'DEAR BINDINGS' GENERATOR.
|
||||||
|
// **DO NOT EDIT DIRECTLY**
|
||||||
|
// https://github.com/dearimgui/dear_bindings
|
||||||
|
|
||||||
|
#include "imgui.h"
|
||||||
|
#include "imgui_impl_sdl2.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
// Wrap this in a namespace to keep it separate from the C++ API
|
||||||
|
namespace cimgui
|
||||||
|
{
|
||||||
|
#include "impl_sdl2.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
// By-value struct conversions
|
||||||
|
|
||||||
|
// Function stubs
|
||||||
|
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API bool cimgui::cImGui_ImplSDL2_InitForOpenGL(cimgui::SDL_Window* window, void* sdl_gl_context)
|
||||||
|
{
|
||||||
|
return ::ImGui_ImplSDL2_InitForOpenGL(reinterpret_cast<::SDL_Window*>(window), sdl_gl_context);
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API bool cimgui::cImGui_ImplSDL2_InitForVulkan(cimgui::SDL_Window* window)
|
||||||
|
{
|
||||||
|
return ::ImGui_ImplSDL2_InitForVulkan(reinterpret_cast<::SDL_Window*>(window));
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API bool cimgui::cImGui_ImplSDL2_InitForD3D(cimgui::SDL_Window* window)
|
||||||
|
{
|
||||||
|
return ::ImGui_ImplSDL2_InitForD3D(reinterpret_cast<::SDL_Window*>(window));
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API bool cimgui::cImGui_ImplSDL2_InitForMetal(cimgui::SDL_Window* window)
|
||||||
|
{
|
||||||
|
return ::ImGui_ImplSDL2_InitForMetal(reinterpret_cast<::SDL_Window*>(window));
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API bool cimgui::cImGui_ImplSDL2_InitForSDLRenderer(cimgui::SDL_Window* window, cimgui::SDL_Renderer* renderer)
|
||||||
|
{
|
||||||
|
return ::ImGui_ImplSDL2_InitForSDLRenderer(reinterpret_cast<::SDL_Window*>(window), reinterpret_cast<::SDL_Renderer*>(renderer));
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API bool cimgui::cImGui_ImplSDL2_InitForOther(cimgui::SDL_Window* window)
|
||||||
|
{
|
||||||
|
return ::ImGui_ImplSDL2_InitForOther(reinterpret_cast<::SDL_Window*>(window));
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplSDL2_Shutdown(void)
|
||||||
|
{
|
||||||
|
::ImGui_ImplSDL2_Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplSDL2_NewFrame(void)
|
||||||
|
{
|
||||||
|
::ImGui_ImplSDL2_NewFrame();
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API bool cimgui::cImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
|
||||||
|
{
|
||||||
|
return ::ImGui_ImplSDL2_ProcessEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplSDL2_SetGamepadMode(cimgui::ImGui_ImplSDL2_GamepadMode mode)
|
||||||
|
{
|
||||||
|
::ImGui_ImplSDL2_SetGamepadMode(static_cast<::ImGui_ImplSDL2_GamepadMode>(mode));
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplSDL2_SetGamepadModeEx(cimgui::ImGui_ImplSDL2_GamepadMode mode, cimgui::_SDL_GameController** manual_gamepads_array, int manual_gamepads_count)
|
||||||
|
{
|
||||||
|
::ImGui_ImplSDL2_SetGamepadMode(static_cast<::ImGui_ImplSDL2_GamepadMode>(mode), reinterpret_cast<struct ::_SDL_GameController**>(manual_gamepads_array), manual_gamepads_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
63
sdl2/impl_sdl2.h
Normal file
63
sdl2/impl_sdl2.h
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
// THIS FILE HAS BEEN AUTO-GENERATED BY THE 'DEAR BINDINGS' GENERATOR.
|
||||||
|
// **DO NOT EDIT DIRECTLY**
|
||||||
|
// https://github.com/dearimgui/dear_bindings
|
||||||
|
|
||||||
|
// dear imgui: Platform Backend for SDL2
|
||||||
|
// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
|
||||||
|
// (Info: SDL2 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.)
|
||||||
|
|
||||||
|
// Implemented features:
|
||||||
|
// [X] Platform: Clipboard support.
|
||||||
|
// [X] Platform: Mouse support. Can discriminate Mouse/TouchScreen.
|
||||||
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values are obsolete since 1.87 and not supported since 1.91.5]
|
||||||
|
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
|
// [X] Platform: Mouse cursor shape and visibility (ImGuiBackendFlags_HasMouseCursors). Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
|
// [X] Platform: Basic IME support. App needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.
|
||||||
|
|
||||||
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
|
// Learn about Dear ImGui:
|
||||||
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
#include "../dcimgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
typedef struct SDL_Window SDL_Window;
|
||||||
|
typedef struct SDL_Renderer SDL_Renderer;
|
||||||
|
typedef struct _SDL_GameController _SDL_GameController;
|
||||||
|
typedef union SDL_Event SDL_Event;
|
||||||
|
|
||||||
|
typedef struct ImDrawData_t ImDrawData;
|
||||||
|
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
|
||||||
|
CIMGUI_IMPL_API bool cImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context);
|
||||||
|
CIMGUI_IMPL_API bool cImGui_ImplSDL2_InitForVulkan(SDL_Window* window);
|
||||||
|
CIMGUI_IMPL_API bool cImGui_ImplSDL2_InitForD3D(SDL_Window* window);
|
||||||
|
CIMGUI_IMPL_API bool cImGui_ImplSDL2_InitForMetal(SDL_Window* window);
|
||||||
|
CIMGUI_IMPL_API bool cImGui_ImplSDL2_InitForSDLRenderer(SDL_Window* window, SDL_Renderer* renderer);
|
||||||
|
CIMGUI_IMPL_API bool cImGui_ImplSDL2_InitForOther(SDL_Window* window);
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplSDL2_Shutdown(void);
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplSDL2_NewFrame(void);
|
||||||
|
CIMGUI_IMPL_API bool cImGui_ImplSDL2_ProcessEvent(const SDL_Event* event);
|
||||||
|
|
||||||
|
// Gamepad selection automatically starts in AutoFirst mode, picking first available SDL_Gamepad. You may override this.
|
||||||
|
// When using manual mode, caller is responsible for opening/closing gamepad.
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_GamepadMode_AutoFirst,
|
||||||
|
ImGui_ImplSDL2_GamepadMode_AutoAll,
|
||||||
|
ImGui_ImplSDL2_GamepadMode_Manual,
|
||||||
|
} ImGui_ImplSDL2_GamepadMode;
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplSDL2_SetGamepadMode(ImGui_ImplSDL2_GamepadMode mode); // Implied manual_gamepads_array = nullptr, manual_gamepads_count = -1
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplSDL2_SetGamepadModeEx(ImGui_ImplSDL2_GamepadMode mode, _SDL_GameController** manual_gamepads_array /* = nullptr */, int manual_gamepads_count /* = -1 */);
|
||||||
|
#endif// #ifndef IMGUI_DISABLE
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // End of extern "C" block
|
||||||
|
#endif
|
34
sdl2/impl_sdl2.odin
Normal file
34
sdl2/impl_sdl2.odin
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package imgui_sdl2
|
||||||
|
|
||||||
|
when ODIN_OS == .Windows {
|
||||||
|
foreign import imgui_sdl2 "../lib/dcimgui_impl_sdl2.lib"
|
||||||
|
}
|
||||||
|
else when ODIN_OS == .Linux {
|
||||||
|
foreign import imgui_sdl2 "../lib/linux/libdcimgui_impl_sdl2.a"
|
||||||
|
}
|
||||||
|
else when ODIN_OS == .Darwin {
|
||||||
|
foreign import imgui_sdl2 "../lib/darwin/libdcimgui_impl_sdl2_arm64.a"
|
||||||
|
}
|
||||||
|
|
||||||
|
import sdl "vendor:sdl2"
|
||||||
|
|
||||||
|
GamepadMode :: enum {
|
||||||
|
AutoFirst = 0,
|
||||||
|
AutoAll = 1,
|
||||||
|
Manual = 2,
|
||||||
|
}
|
||||||
|
|
||||||
|
@(default_calling_convention = "cdecl", link_prefix = "cImGui_ImplSDL2_")
|
||||||
|
foreign imgui_sdl2 {
|
||||||
|
InitForOpenGL :: proc(window: ^sdl.Window, sdl_gl_context: rawptr) -> b8 ---
|
||||||
|
InitForVulkan :: proc(window: ^sdl.Window) -> b8 ---
|
||||||
|
InitForD3D :: proc(window: ^sdl.Window) -> b8 ---
|
||||||
|
InitForMetal :: proc(window: ^sdl.Window) -> b8 ---
|
||||||
|
InitForSDLRenderer :: proc(window: ^sdl.Window, renderer: ^sdl.Renderer) -> b8 ---
|
||||||
|
InitForOther :: proc(window: ^sdl.Window) -> b8 ---
|
||||||
|
Shutdown :: proc() ---
|
||||||
|
NewFrame :: proc() ---
|
||||||
|
ProcessEvent :: proc(event: ^sdl.Event) -> b8 ---
|
||||||
|
SetGamepadMode :: proc(mode: GamepadMode) ---
|
||||||
|
SetGamepadModeEx :: proc(mode: GamepadMode, manual_gamepads_array: ^^sdl.GameController, manual_gamepads_count: i32) ---
|
||||||
|
}
|
77
sdl3/impl_sdl3.cpp
Normal file
77
sdl3/impl_sdl3.cpp
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
// THIS FILE HAS BEEN AUTO-GENERATED BY THE 'DEAR BINDINGS' GENERATOR.
|
||||||
|
// **DO NOT EDIT DIRECTLY**
|
||||||
|
// https://github.com/dearimgui/dear_bindings
|
||||||
|
|
||||||
|
#include "imgui.h"
|
||||||
|
#include "imgui_impl_sdl3.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
// Wrap this in a namespace to keep it separate from the C++ API
|
||||||
|
namespace cimgui
|
||||||
|
{
|
||||||
|
#include "impl_sdl3.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
// By-value struct conversions
|
||||||
|
|
||||||
|
// Function stubs
|
||||||
|
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API bool cimgui::cImGui_ImplSDL3_InitForOpenGL(cimgui::SDL_Window* window, void* sdl_gl_context)
|
||||||
|
{
|
||||||
|
return ::ImGui_ImplSDL3_InitForOpenGL(reinterpret_cast<::SDL_Window*>(window), sdl_gl_context);
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API bool cimgui::cImGui_ImplSDL3_InitForVulkan(cimgui::SDL_Window* window)
|
||||||
|
{
|
||||||
|
return ::ImGui_ImplSDL3_InitForVulkan(reinterpret_cast<::SDL_Window*>(window));
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API bool cimgui::cImGui_ImplSDL3_InitForD3D(cimgui::SDL_Window* window)
|
||||||
|
{
|
||||||
|
return ::ImGui_ImplSDL3_InitForD3D(reinterpret_cast<::SDL_Window*>(window));
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API bool cimgui::cImGui_ImplSDL3_InitForMetal(cimgui::SDL_Window* window)
|
||||||
|
{
|
||||||
|
return ::ImGui_ImplSDL3_InitForMetal(reinterpret_cast<::SDL_Window*>(window));
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API bool cimgui::cImGui_ImplSDL3_InitForSDLRenderer(cimgui::SDL_Window* window, cimgui::SDL_Renderer* renderer)
|
||||||
|
{
|
||||||
|
return ::ImGui_ImplSDL3_InitForSDLRenderer(reinterpret_cast<::SDL_Window*>(window), reinterpret_cast<::SDL_Renderer*>(renderer));
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API bool cimgui::cImGui_ImplSDL3_InitForOther(cimgui::SDL_Window* window)
|
||||||
|
{
|
||||||
|
return ::ImGui_ImplSDL3_InitForOther(reinterpret_cast<::SDL_Window*>(window));
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplSDL3_Shutdown(void)
|
||||||
|
{
|
||||||
|
::ImGui_ImplSDL3_Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplSDL3_NewFrame(void)
|
||||||
|
{
|
||||||
|
::ImGui_ImplSDL3_NewFrame();
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API bool cimgui::cImGui_ImplSDL3_ProcessEvent(const SDL_Event* event)
|
||||||
|
{
|
||||||
|
return ::ImGui_ImplSDL3_ProcessEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplSDL3_SetGamepadMode(cimgui::ImGui_ImplSDL3_GamepadMode mode)
|
||||||
|
{
|
||||||
|
::ImGui_ImplSDL3_SetGamepadMode(static_cast<::ImGui_ImplSDL3_GamepadMode>(mode));
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplSDL3_SetGamepadModeEx(cimgui::ImGui_ImplSDL3_GamepadMode mode, cimgui::SDL_Gamepad** manual_gamepads_array, int manual_gamepads_count)
|
||||||
|
{
|
||||||
|
::ImGui_ImplSDL3_SetGamepadMode(static_cast<::ImGui_ImplSDL3_GamepadMode>(mode), reinterpret_cast<::SDL_Gamepad**>(manual_gamepads_array), manual_gamepads_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
65
sdl3/impl_sdl3.h
Normal file
65
sdl3/impl_sdl3.h
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
// THIS FILE HAS BEEN AUTO-GENERATED BY THE 'DEAR BINDINGS' GENERATOR.
|
||||||
|
// **DO NOT EDIT DIRECTLY**
|
||||||
|
// https://github.com/dearimgui/dear_bindings
|
||||||
|
|
||||||
|
// dear imgui: Platform Backend for SDL3 (*EXPERIMENTAL*)
|
||||||
|
// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
|
||||||
|
// (Info: SDL3 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.)
|
||||||
|
|
||||||
|
// (**IMPORTANT: SDL 3.0.0 is NOT YET RELEASED AND CURRENTLY HAS A FAST CHANGING API. THIS CODE BREAKS OFTEN AS SDL3 CHANGES.**)
|
||||||
|
|
||||||
|
// Implemented features:
|
||||||
|
// [X] Platform: Clipboard support.
|
||||||
|
// [X] Platform: Mouse support. Can discriminate Mouse/TouchScreen.
|
||||||
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values are obsolete since 1.87 and not supported since 1.91.5]
|
||||||
|
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
|
// [X] Platform: Mouse cursor shape and visibility (ImGuiBackendFlags_HasMouseCursors). Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
|
// [X] Platform: IME support.
|
||||||
|
|
||||||
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
|
// Learn about Dear ImGui:
|
||||||
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
#include "../dcimgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
typedef struct SDL_Window SDL_Window;
|
||||||
|
typedef struct SDL_Renderer SDL_Renderer;
|
||||||
|
typedef struct SDL_Gamepad SDL_Gamepad;
|
||||||
|
typedef union SDL_Event SDL_Event;
|
||||||
|
|
||||||
|
typedef struct ImDrawData_t ImDrawData;
|
||||||
|
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
|
||||||
|
CIMGUI_IMPL_API bool cImGui_ImplSDL3_InitForOpenGL(SDL_Window* window, void* sdl_gl_context);
|
||||||
|
CIMGUI_IMPL_API bool cImGui_ImplSDL3_InitForVulkan(SDL_Window* window);
|
||||||
|
CIMGUI_IMPL_API bool cImGui_ImplSDL3_InitForD3D(SDL_Window* window);
|
||||||
|
CIMGUI_IMPL_API bool cImGui_ImplSDL3_InitForMetal(SDL_Window* window);
|
||||||
|
CIMGUI_IMPL_API bool cImGui_ImplSDL3_InitForSDLRenderer(SDL_Window* window, SDL_Renderer* renderer);
|
||||||
|
CIMGUI_IMPL_API bool cImGui_ImplSDL3_InitForOther(SDL_Window* window);
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplSDL3_Shutdown(void);
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplSDL3_NewFrame(void);
|
||||||
|
CIMGUI_IMPL_API bool cImGui_ImplSDL3_ProcessEvent(const SDL_Event* event);
|
||||||
|
|
||||||
|
// Gamepad selection automatically starts in AutoFirst mode, picking first available SDL_Gamepad. You may override this.
|
||||||
|
// When using manual mode, caller is responsible for opening/closing gamepad.
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_GamepadMode_AutoFirst,
|
||||||
|
ImGui_ImplSDL3_GamepadMode_AutoAll,
|
||||||
|
ImGui_ImplSDL3_GamepadMode_Manual,
|
||||||
|
} ImGui_ImplSDL3_GamepadMode;
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplSDL3_SetGamepadMode(ImGui_ImplSDL3_GamepadMode mode); // Implied manual_gamepads_array = nullptr, manual_gamepads_count = -1
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplSDL3_SetGamepadModeEx(ImGui_ImplSDL3_GamepadMode mode, SDL_Gamepad** manual_gamepads_array /* = nullptr */, int manual_gamepads_count /* = -1 */);
|
||||||
|
#endif// #ifndef IMGUI_DISABLE
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // End of extern "C" block
|
||||||
|
#endif
|
26
sdl3/impl_sdl3.odin
Normal file
26
sdl3/impl_sdl3.odin
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package imgui_sdl3
|
||||||
|
#panic(`SDL3 will be supported once it is stable and available in Odin`)
|
||||||
|
import sdl "vendor:sdl3"
|
||||||
|
|
||||||
|
foreign import imgui_sdl3 "libdcimgui.so"
|
||||||
|
|
||||||
|
GamepadMode :: enum {
|
||||||
|
AutoFirst = 0,
|
||||||
|
AutoAll = 1,
|
||||||
|
Manual = 2,
|
||||||
|
}
|
||||||
|
|
||||||
|
@(default_calling_convention = "cdecl", link_prefix = "cImGui_")
|
||||||
|
foreign imgui {
|
||||||
|
InitForOpenGL :: proc(window: ^sdl.Window, sdl_gl_context: rawptr) -> b32 ---
|
||||||
|
InitForVulkan :: proc(window: ^sdl.Window) -> b32 ---
|
||||||
|
InitForD3D :: proc(window: ^sdl.Window) -> b32 ---
|
||||||
|
InitForMetal :: proc(window: ^sdl.Window) -> b32 ---
|
||||||
|
InitForSDLRenderer :: proc(window: ^sdl.Window, renderer: ^sdl.Renderer) -> b32 ---
|
||||||
|
InitForOther :: proc(window: ^sdl.Window) -> b32 ---
|
||||||
|
Shutdown :: proc() ---
|
||||||
|
NewFrame :: proc() ---
|
||||||
|
ProcessEvent :: proc(event: ^sdl.Event) -> b32 ---
|
||||||
|
SetGamepadMode :: proc(mode: GamepadMode) ---
|
||||||
|
SetGamepadModeEx :: proc(mode: GamepadMode, manual_gamepads_array: ^^sdl.Gamepad, manual_gamepads_count: i32) ---
|
||||||
|
}
|
97
vulkan/impl_vulkan.cpp
Normal file
97
vulkan/impl_vulkan.cpp
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
// THIS FILE HAS BEEN AUTO-GENERATED BY THE 'DEAR BINDINGS' GENERATOR.
|
||||||
|
// **DO NOT EDIT DIRECTLY**
|
||||||
|
// https://github.com/dearimgui/dear_bindings
|
||||||
|
|
||||||
|
#include "imgui.h"
|
||||||
|
#include "imgui_impl_vulkan.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
// Wrap this in a namespace to keep it separate from the C++ API
|
||||||
|
namespace cimgui
|
||||||
|
{
|
||||||
|
#include "impl_vulkan.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
// By-value struct conversions
|
||||||
|
|
||||||
|
// Function stubs
|
||||||
|
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API bool cimgui::cImGui_ImplVulkan_Init(cimgui::ImGui_ImplVulkan_InitInfo* info)
|
||||||
|
{
|
||||||
|
return ::ImGui_ImplVulkan_Init(reinterpret_cast<::ImGui_ImplVulkan_InitInfo*>(info));
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplVulkan_Shutdown(void)
|
||||||
|
{
|
||||||
|
::ImGui_ImplVulkan_Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplVulkan_NewFrame(void)
|
||||||
|
{
|
||||||
|
::ImGui_ImplVulkan_NewFrame();
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplVulkan_RenderDrawData(cimgui::ImDrawData* draw_data, VkCommandBuffer command_buffer, VkPipeline pipeline)
|
||||||
|
{
|
||||||
|
::ImGui_ImplVulkan_RenderDrawData(reinterpret_cast<::ImDrawData*>(draw_data), command_buffer, pipeline);
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API bool cimgui::cImGui_ImplVulkan_CreateFontsTexture(void)
|
||||||
|
{
|
||||||
|
return ::ImGui_ImplVulkan_CreateFontsTexture();
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplVulkan_DestroyFontsTexture(void)
|
||||||
|
{
|
||||||
|
::ImGui_ImplVulkan_DestroyFontsTexture();
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplVulkan_SetMinImageCount(uint32_t min_image_count)
|
||||||
|
{
|
||||||
|
::ImGui_ImplVulkan_SetMinImageCount(min_image_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API VkDescriptorSet cimgui::cImGui_ImplVulkan_AddTexture(VkSampler sampler, VkImageView image_view, VkImageLayout image_layout)
|
||||||
|
{
|
||||||
|
return ::ImGui_ImplVulkan_AddTexture(sampler, image_view, image_layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplVulkan_RemoveTexture(VkDescriptorSet descriptor_set)
|
||||||
|
{
|
||||||
|
::ImGui_ImplVulkan_RemoveTexture(descriptor_set);
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API bool cimgui::cImGui_ImplVulkan_LoadFunctions(PFN_vkVoidFunction (*loader_func)(const char* function_name, void* user_data), void* user_data)
|
||||||
|
{
|
||||||
|
return ::ImGui_ImplVulkan_LoadFunctions(loader_func, user_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplVulkanH_CreateOrResizeWindow(VkInstance instance, VkPhysicalDevice physical_device, VkDevice device, cimgui::ImGui_ImplVulkanH_Window* wnd, uint32_t queue_family, const VkAllocationCallbacks* allocator, int w, int h, uint32_t min_image_count)
|
||||||
|
{
|
||||||
|
::ImGui_ImplVulkanH_CreateOrResizeWindow(instance, physical_device, device, reinterpret_cast<::ImGui_ImplVulkanH_Window*>(wnd), queue_family, allocator, w, h, min_image_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API void cimgui::cImGui_ImplVulkanH_DestroyWindow(VkInstance instance, VkDevice device, cimgui::ImGui_ImplVulkanH_Window* wnd, const VkAllocationCallbacks* allocator)
|
||||||
|
{
|
||||||
|
::ImGui_ImplVulkanH_DestroyWindow(instance, device, reinterpret_cast<::ImGui_ImplVulkanH_Window*>(wnd), allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API VkSurfaceFormatKHR cimgui::cImGui_ImplVulkanH_SelectSurfaceFormat(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkFormat* request_formats, int request_formats_count, VkColorSpaceKHR request_color_space)
|
||||||
|
{
|
||||||
|
return ::ImGui_ImplVulkanH_SelectSurfaceFormat(physical_device, surface, request_formats, request_formats_count, request_color_space);
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API VkPresentModeKHR cimgui::cImGui_ImplVulkanH_SelectPresentMode(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkPresentModeKHR* request_modes, int request_modes_count)
|
||||||
|
{
|
||||||
|
return ::ImGui_ImplVulkanH_SelectPresentMode(physical_device, surface, request_modes, request_modes_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
CIMGUI_IMPL_API int cimgui::cImGui_ImplVulkanH_GetMinImageCountFromPresentMode(VkPresentModeKHR present_mode)
|
||||||
|
{
|
||||||
|
return ::ImGui_ImplVulkanH_GetMinImageCountFromPresentMode(present_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
216
vulkan/impl_vulkan.h
Normal file
216
vulkan/impl_vulkan.h
Normal file
@ -0,0 +1,216 @@
|
|||||||
|
// THIS FILE HAS BEEN AUTO-GENERATED BY THE 'DEAR BINDINGS' GENERATOR.
|
||||||
|
// **DO NOT EDIT DIRECTLY**
|
||||||
|
// https://github.com/dearimgui/dear_bindings
|
||||||
|
|
||||||
|
// dear imgui: Renderer Backend for Vulkan
|
||||||
|
// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..)
|
||||||
|
|
||||||
|
// Implemented features:
|
||||||
|
// [!] Renderer: User texture binding. Use 'VkDescriptorSet' as ImTextureID. Call ImGui_ImplVulkan_AddTexture() to register one. Read the FAQ about ImTextureID! See https://github.com/ocornut/imgui/pull/914 for discussions.
|
||||||
|
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
||||||
|
// [X] Renderer: Expose selected render state for draw callbacks to use. Access in '(ImGui_ImplXXXX_RenderState*)GetPlatformIO().Renderer_RenderState'.
|
||||||
|
|
||||||
|
// The aim of imgui_impl_vulkan.h/.cpp is to be usable in your engine without any modification.
|
||||||
|
// IF YOU FEEL YOU NEED TO MAKE ANY CHANGE TO THIS CODE, please share them and your feedback at https://github.com/ocornut/imgui/
|
||||||
|
|
||||||
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
|
// Learn about Dear ImGui:
|
||||||
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
|
// Important note to the reader who wish to integrate imgui_impl_vulkan.cpp/.h in their own engine/app.
|
||||||
|
// - Common ImGui_ImplVulkan_XXX functions and structures are used to interface with imgui_impl_vulkan.cpp/.h.
|
||||||
|
// You will use those if you want to use this rendering backend in your engine/app.
|
||||||
|
// - Helper ImGui_ImplVulkanH_XXX functions and structures are only used by this example (main.cpp) and by
|
||||||
|
// the backend itself (imgui_impl_vulkan.cpp), but should PROBABLY NOT be used by your own engine/app code.
|
||||||
|
// Read comments in imgui_impl_vulkan.h.
|
||||||
|
|
||||||
|
// Auto-generated forward declarations for C header
|
||||||
|
typedef struct ImGui_ImplVulkan_InitInfo_t ImGui_ImplVulkan_InitInfo;
|
||||||
|
typedef struct ImGui_ImplVulkan_RenderState_t ImGui_ImplVulkan_RenderState;
|
||||||
|
typedef struct ImGui_ImplVulkanH_FrameSemaphores_t ImGui_ImplVulkanH_FrameSemaphores;
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
#include "../dcimgui.h"
|
||||||
|
// [Configuration] in order to use a custom Vulkan function loader:
|
||||||
|
// (1) You'll need to disable default Vulkan function prototypes.
|
||||||
|
// We provide a '#define IMGUI_IMPL_VULKAN_NO_PROTOTYPES' convenience configuration flag.
|
||||||
|
// In order to make sure this is visible from the imgui_impl_vulkan.cpp compilation unit:
|
||||||
|
// - Add '#define IMGUI_IMPL_VULKAN_NO_PROTOTYPES' in your imconfig.h file
|
||||||
|
// - Or as a compilation flag in your build system
|
||||||
|
// - Or uncomment here (not recommended because you'd be modifying imgui sources!)
|
||||||
|
// - Do not simply add it in a .cpp file!
|
||||||
|
// (2) Call ImGui_ImplVulkan_LoadFunctions() before ImGui_ImplVulkan_Init() with your custom function.
|
||||||
|
// If you have no idea what this is, leave it alone!
|
||||||
|
//#define IMGUI_IMPL_VULKAN_NO_PROTOTYPES
|
||||||
|
|
||||||
|
// Convenience support for Volk
|
||||||
|
// (you can also technically use IMGUI_IMPL_VULKAN_NO_PROTOTYPES + wrap Volk via ImGui_ImplVulkan_LoadFunctions().)
|
||||||
|
//#define IMGUI_IMPL_VULKAN_USE_VOLK
|
||||||
|
|
||||||
|
#if defined(IMGUI_IMPL_VULKAN_NO_PROTOTYPES)&&!defined(VK_NO_PROTOTYPES)
|
||||||
|
#define VK_NO_PROTOTYPES
|
||||||
|
#endif // #if defined(IMGUI_IMPL_VULKAN_NO_PROTOTYPES)&&!defined(VK_NO_PROTOTYPES)
|
||||||
|
#if defined(VK_USE_PLATFORM_WIN32_KHR)&&!defined(NOMINMAX)
|
||||||
|
#define NOMINMAX
|
||||||
|
#endif // #if defined(VK_USE_PLATFORM_WIN32_KHR)&&!defined(NOMINMAX)
|
||||||
|
// Vulkan includes
|
||||||
|
#ifdef IMGUI_IMPL_VULKAN_USE_VOLK
|
||||||
|
#include <volk.h>
|
||||||
|
#else
|
||||||
|
#include <vulkan/vulkan.h>
|
||||||
|
#endif // #ifdef IMGUI_IMPL_VULKAN_USE_VOLK
|
||||||
|
#if defined(VK_VERSION_1_3)|| defined(VK_KHR_dynamic_rendering)
|
||||||
|
#define IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
|
#endif // #if defined(VK_VERSION_1_3)|| defined(VK_KHR_dynamic_rendering)
|
||||||
|
// Initialization data, for ImGui_ImplVulkan_Init()
|
||||||
|
// [Please zero-clear before use!]
|
||||||
|
// - About descriptor pool:
|
||||||
|
// - A VkDescriptorPool should be created with VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT,
|
||||||
|
// and must contain a pool size large enough to hold a small number of VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER descriptors.
|
||||||
|
// - As an convenience, by setting DescriptorPoolSize > 0 the backend will create one for you.
|
||||||
|
// - Current version of the backend use 1 descriptor for the font atlas + as many as additional calls done to ImGui_ImplVulkan_AddTexture().
|
||||||
|
// - It is expected that as early as Q1 2025 the backend will use a few more descriptors, so aim at 10 + number of desierd calls to ImGui_ImplVulkan_AddTexture().
|
||||||
|
// - About dynamic rendering:
|
||||||
|
// - When using dynamic rendering, set UseDynamicRendering=true and fill PipelineRenderingCreateInfo structure.
|
||||||
|
struct ImGui_ImplVulkan_InitInfo_t
|
||||||
|
{
|
||||||
|
VkInstance Instance;
|
||||||
|
VkPhysicalDevice PhysicalDevice;
|
||||||
|
VkDevice Device;
|
||||||
|
uint32_t QueueFamily;
|
||||||
|
VkQueue Queue;
|
||||||
|
VkDescriptorPool DescriptorPool; // See requirements in note above; ignored if using DescriptorPoolSize > 0
|
||||||
|
VkRenderPass RenderPass; // Ignored if using dynamic rendering
|
||||||
|
uint32_t MinImageCount; // >= 2
|
||||||
|
uint32_t ImageCount; // >= MinImageCount
|
||||||
|
VkSampleCountFlagBits MSAASamples; // 0 defaults to VK_SAMPLE_COUNT_1_BIT
|
||||||
|
|
||||||
|
// (Optional)
|
||||||
|
VkPipelineCache PipelineCache;
|
||||||
|
uint32_t Subpass;
|
||||||
|
|
||||||
|
// (Optional) Set to create internal descriptor pool instead of using DescriptorPool
|
||||||
|
uint32_t DescriptorPoolSize;
|
||||||
|
|
||||||
|
// (Optional) Dynamic Rendering
|
||||||
|
// Need to explicitly enable VK_KHR_dynamic_rendering extension to use this, even for Vulkan 1.3.
|
||||||
|
bool UseDynamicRendering;
|
||||||
|
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
|
VkPipelineRenderingCreateInfoKHR PipelineRenderingCreateInfo;
|
||||||
|
#endif // #ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
|
// (Optional) Allocation, Debugging
|
||||||
|
const VkAllocationCallbacks* Allocator;
|
||||||
|
void (*CheckVkResultFn)(VkResult err);
|
||||||
|
VkDeviceSize MinAllocationSize; // Minimum allocation size. Set to 1024*1024 to satisfy zealous best practices validation layer and waste a little memory.
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct ImDrawData_t ImDrawData;
|
||||||
|
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
|
||||||
|
CIMGUI_IMPL_API bool cImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info);
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplVulkan_Shutdown(void);
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplVulkan_NewFrame(void);
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer command_buffer, VkPipeline pipeline /* = VK_NULL_HANDLE */);
|
||||||
|
CIMGUI_IMPL_API bool cImGui_ImplVulkan_CreateFontsTexture(void);
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplVulkan_DestroyFontsTexture(void);
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplVulkan_SetMinImageCount(uint32_t min_image_count); // To override MinImageCount after initialization (e.g. if swap chain is recreated)
|
||||||
|
|
||||||
|
// Register a texture (VkDescriptorSet == ImTextureID)
|
||||||
|
// FIXME: This is experimental in the sense that we are unsure how to best design/tackle this problem
|
||||||
|
// Please post to https://github.com/ocornut/imgui/pull/914 if you have suggestions.
|
||||||
|
CIMGUI_IMPL_API VkDescriptorSet cImGui_ImplVulkan_AddTexture(VkSampler sampler, VkImageView image_view, VkImageLayout image_layout);
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplVulkan_RemoveTexture(VkDescriptorSet descriptor_set);
|
||||||
|
|
||||||
|
// Optional: load Vulkan functions with a custom function loader
|
||||||
|
// This is only useful with IMGUI_IMPL_VULKAN_NO_PROTOTYPES / VK_NO_PROTOTYPES
|
||||||
|
CIMGUI_IMPL_API bool cImGui_ImplVulkan_LoadFunctions(PFN_vkVoidFunction (*loader_func)(const char* function_name, void* user_data), void* user_data /* = nullptr */);
|
||||||
|
|
||||||
|
// [BETA] Selected render state data shared with callbacks.
|
||||||
|
// This is temporarily stored in GetPlatformIO().Renderer_RenderState during the ImGui_ImplVulkan_RenderDrawData() call.
|
||||||
|
// (Please open an issue if you feel you need access to more data)
|
||||||
|
struct ImGui_ImplVulkan_RenderState_t
|
||||||
|
{
|
||||||
|
VkCommandBuffer CommandBuffer;
|
||||||
|
VkPipeline Pipeline;
|
||||||
|
VkPipelineLayout PipelineLayout;
|
||||||
|
};
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
// Internal / Miscellaneous Vulkan Helpers
|
||||||
|
// (Used by example's main.cpp. Used by multi-viewport features. PROBABLY NOT used by your own engine/app.)
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
// You probably do NOT need to use or care about those functions.
|
||||||
|
// Those functions only exist because:
|
||||||
|
// 1) they facilitate the readability and maintenance of the multiple main.cpp examples files.
|
||||||
|
// 2) the multi-viewport / platform window implementation needs them internally.
|
||||||
|
// Generally we avoid exposing any kind of superfluous high-level helpers in the bindings,
|
||||||
|
// but it is too much code to duplicate everywhere so we exceptionally expose them.
|
||||||
|
//
|
||||||
|
// Your engine/app will likely _already_ have code to setup all that stuff (swap chain, render pass, frame buffers, etc.).
|
||||||
|
// You may read this code to learn about Vulkan, but it is recommended you use you own custom tailored code to do equivalent work.
|
||||||
|
// (The ImGui_ImplVulkanH_XXX functions do not interact with any of the state used by the regular ImGui_ImplVulkan_XXX functions)
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
typedef struct ImGui_ImplVulkanH_Frame_t ImGui_ImplVulkanH_Frame;
|
||||||
|
typedef struct ImGui_ImplVulkanH_Window_t ImGui_ImplVulkanH_Window;
|
||||||
|
|
||||||
|
// Helpers
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplVulkanH_CreateOrResizeWindow(VkInstance instance, VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wnd, uint32_t queue_family, const VkAllocationCallbacks* allocator, int w, int h, uint32_t min_image_count);
|
||||||
|
CIMGUI_IMPL_API void cImGui_ImplVulkanH_DestroyWindow(VkInstance instance, VkDevice device, ImGui_ImplVulkanH_Window* wnd, const VkAllocationCallbacks* allocator);
|
||||||
|
CIMGUI_IMPL_API VkSurfaceFormatKHR cImGui_ImplVulkanH_SelectSurfaceFormat(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkFormat* request_formats, int request_formats_count, VkColorSpaceKHR request_color_space);
|
||||||
|
CIMGUI_IMPL_API VkPresentModeKHR cImGui_ImplVulkanH_SelectPresentMode(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkPresentModeKHR* request_modes, int request_modes_count);
|
||||||
|
CIMGUI_IMPL_API int cImGui_ImplVulkanH_GetMinImageCountFromPresentMode(VkPresentModeKHR present_mode);
|
||||||
|
|
||||||
|
// Helper structure to hold the data needed by one rendering frame
|
||||||
|
// (Used by example's main.cpp. Used by multi-viewport features. Probably NOT used by your own engine/app.)
|
||||||
|
// [Please zero-clear before use!]
|
||||||
|
struct ImGui_ImplVulkanH_Frame_t
|
||||||
|
{
|
||||||
|
VkCommandPool CommandPool;
|
||||||
|
VkCommandBuffer CommandBuffer;
|
||||||
|
VkFence Fence;
|
||||||
|
VkImage Backbuffer;
|
||||||
|
VkImageView BackbufferView;
|
||||||
|
VkFramebuffer Framebuffer;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ImGui_ImplVulkanH_FrameSemaphores_t
|
||||||
|
{
|
||||||
|
VkSemaphore ImageAcquiredSemaphore;
|
||||||
|
VkSemaphore RenderCompleteSemaphore;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Helper structure to hold the data needed by one rendering context into one OS window
|
||||||
|
// (Used by example's main.cpp. Used by multi-viewport features. Probably NOT used by your own engine/app.)
|
||||||
|
struct ImGui_ImplVulkanH_Window_t
|
||||||
|
{
|
||||||
|
int Width;
|
||||||
|
int Height;
|
||||||
|
VkSwapchainKHR Swapchain;
|
||||||
|
VkSurfaceKHR Surface;
|
||||||
|
VkSurfaceFormatKHR SurfaceFormat;
|
||||||
|
VkPresentModeKHR PresentMode;
|
||||||
|
VkRenderPass RenderPass;
|
||||||
|
VkPipeline Pipeline; // The window pipeline may uses a different VkRenderPass than the one passed in ImGui_ImplVulkan_InitInfo
|
||||||
|
bool UseDynamicRendering;
|
||||||
|
bool ClearEnable;
|
||||||
|
VkClearValue ClearValue;
|
||||||
|
uint32_t FrameIndex; // Current frame being rendered to (0 <= FrameIndex < FrameInFlightCount)
|
||||||
|
uint32_t ImageCount; // Number of simultaneous in-flight frames (returned by vkGetSwapchainImagesKHR, usually derived from min_image_count)
|
||||||
|
uint32_t SemaphoreCount; // Number of simultaneous in-flight frames + 1, to be able to use it in vkAcquireNextImageKHR
|
||||||
|
uint32_t SemaphoreIndex; // Current set of swapchain wait semaphores we're using (needs to be distinct from per frame data)
|
||||||
|
ImGui_ImplVulkanH_Frame* Frames;
|
||||||
|
ImGui_ImplVulkanH_FrameSemaphores* FrameSemaphores;
|
||||||
|
};
|
||||||
|
#endif// #ifndef IMGUI_DISABLE
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // End of extern "C" block
|
||||||
|
#endif
|
102
vulkan/impl_vulkan.odin
Normal file
102
vulkan/impl_vulkan.odin
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
package impl_vulkan
|
||||||
|
|
||||||
|
import imgui "../"
|
||||||
|
import vk "vendor:vulkan"
|
||||||
|
|
||||||
|
when ODIN_OS == .Windows {
|
||||||
|
foreign import impl_vulkan "../lib/dcimgui_impl_vulkan.lib"
|
||||||
|
} else when ODIN_OS == .Linux {
|
||||||
|
foreign import impl_vulkan "../lib/linux/libdcimgui_impl_vulkan.a"
|
||||||
|
} else when ODIN_OS == .Darwin {
|
||||||
|
foreign import impl_vulkan "../lib/darwin/libdcimgui_impl_vulkan_arm64.a"
|
||||||
|
// #panic(`Vulkan backend is not implemented yet for macOS; Consider using Metal instead`)
|
||||||
|
}
|
||||||
|
|
||||||
|
@(default_calling_convention = "cdecl", link_prefix = "cImGui_ImplVulkan_")
|
||||||
|
foreign impl_vulkan {
|
||||||
|
Init :: proc(info: ^InitInfo) -> b8 ---
|
||||||
|
Shutdown :: proc() ---
|
||||||
|
NewFrame :: proc() ---
|
||||||
|
RenderDrawData :: proc(draw_data: ^imgui.ImDrawData, command_buffer: vk.CommandBuffer, pipeline: vk.Pipeline = 0) ---
|
||||||
|
CreateFontsTexture :: proc() -> b8 ---
|
||||||
|
DestroyFontsTexture :: proc() ---
|
||||||
|
SetMinImageCount :: proc(min_image_count: u32) ---
|
||||||
|
AddTexture :: proc(sampler: vk.Sampler, image_view: vk.ImageView, image_layout: vk.ImageLayout) -> vk.DescriptorSet ---
|
||||||
|
RemoveTexture :: proc(descriptor_set: vk.DescriptorSet) ---
|
||||||
|
LoadFunctions :: proc(loader_func: proc(function_name: cstring, user_data: rawptr), user_data: rawptr = nil) -> b8 ---
|
||||||
|
}
|
||||||
|
|
||||||
|
@(default_calling_convention = "cdecl", link_prefix = "cImGui_ImplVulkanH_")
|
||||||
|
foreign impl_vulkan {
|
||||||
|
CreateOrResizeWindow :: proc(
|
||||||
|
instance: vk.Instance,
|
||||||
|
physical_device: vk.PhysicalDevice,
|
||||||
|
device: vk.Device,
|
||||||
|
wnd: ^Window,
|
||||||
|
queue_family: u32,
|
||||||
|
allocator: ^vk.AllocationCallbacks,
|
||||||
|
w: i32,
|
||||||
|
h: i32,
|
||||||
|
min_image_count: u32) ---
|
||||||
|
DestroyWindow :: proc(instance: vk.Instance, device: vk.Device, wnd: ^Window, allocator: ^vk.AllocationCallbacks) ---
|
||||||
|
SelectSurfaceFormat :: proc(physical_device: vk.PhysicalDevice, surface: vk.SurfaceKHR, request_formats: [^]vk.Format, request_formats_count: i32, request_color_space: vk.ColorSpaceKHR) -> vk.SurfaceFormatKHR ---
|
||||||
|
SelectPresentMode :: proc(physical_device: vk.PhysicalDevice, surface: vk.SurfaceKHR, request_modes: [^]vk.PresentModeKHR, request_modes_count: i32) -> vk.PresentModeKHR ---
|
||||||
|
GetMinImageCountFromPresentMode :: proc(present_mode: vk.PresentModeKHR) -> i32 ---
|
||||||
|
}
|
||||||
|
InitInfo :: struct {
|
||||||
|
Instance: vk.Instance,
|
||||||
|
PhysicalDevice: vk.PhysicalDevice,
|
||||||
|
Device: vk.Device,
|
||||||
|
QueueFamily: u32,
|
||||||
|
Queue: vk.Queue,
|
||||||
|
DescriptorPool: vk.DescriptorPool,
|
||||||
|
RenderPass: vk.RenderPass,
|
||||||
|
MinImageCount: u32,
|
||||||
|
ImageCount: u32,
|
||||||
|
MSAASamples: vk.SampleCountFlags,
|
||||||
|
PipelineCache: vk.PipelineCache,
|
||||||
|
Subpass: u32,
|
||||||
|
DescriptorPoolSize: u32,
|
||||||
|
UseDynamicRendering: b8,
|
||||||
|
PipelineRenderingCreateInfo: vk.PipelineRenderingCreateInfoKHR,
|
||||||
|
Allocator: ^vk.AllocationCallbacks,
|
||||||
|
CheckVkResultFn: proc(err: vk.Result),
|
||||||
|
MinAllocationSize: vk.DeviceSize,
|
||||||
|
}
|
||||||
|
|
||||||
|
RenderState :: struct {
|
||||||
|
CommandBuffer: vk.CommandBuffer,
|
||||||
|
Pipeline: vk.Pipeline,
|
||||||
|
PipelineLayout: vk.PipelineLayout,
|
||||||
|
}
|
||||||
|
Frame :: struct {
|
||||||
|
CommandPool: vk.CommandPool,
|
||||||
|
CommandBuffer: vk.CommandBuffer,
|
||||||
|
Fence: vk.Fence,
|
||||||
|
Backbuffer: vk.Image,
|
||||||
|
BackbufferView: vk.ImageView,
|
||||||
|
Framebuffer: vk.Framebuffer,
|
||||||
|
}
|
||||||
|
FrameSemaphores :: struct {
|
||||||
|
ImageAcquiredSemaphore: vk.Semaphore,
|
||||||
|
RenderCompleteSemaphore: vk.Semaphore,
|
||||||
|
}
|
||||||
|
Window :: struct {
|
||||||
|
Width: i32,
|
||||||
|
Height: i32,
|
||||||
|
Swapchain: vk.SwapchainKHR,
|
||||||
|
Surface: vk.SurfaceKHR,
|
||||||
|
SurfaceFormat: vk.SurfaceFormatKHR,
|
||||||
|
PresentMode: vk.PresentModeKHR,
|
||||||
|
RenderPass: vk.RenderPass,
|
||||||
|
Pipeline: vk.Pipeline,
|
||||||
|
UseDynamicRendering: b8,
|
||||||
|
ClearEnable: b8,
|
||||||
|
ClearValue: vk.ClearValue,
|
||||||
|
FrameIndex: u32,
|
||||||
|
ImageCount: u32,
|
||||||
|
SemaphoreCount: u32,
|
||||||
|
SemaphoreIndex: u32,
|
||||||
|
Frames: [^]Frame,
|
||||||
|
FrameSemaphores: [^]FrameSemaphores,
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user