Skip to content

Commit

Permalink
added: SDL3 backend
Browse files Browse the repository at this point in the history
  • Loading branch information
dinau committed Jan 3, 2025
1 parent c94f3a8 commit 4892b74
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 11 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ This project is my experiment project to use ImGui, ImPlot, futhark and so on wi

- Notice
It may be better to use the **mainstream** project [nimgl/imgui](https://github.com/nimgl/imgui) (ImGui v1.85)
,updated project [nimgl-imgui](https://github.com/dinau/nimgl-imgui) (ImGui v1.89.9)
,sub project [nim_implot](https://github.com/dinau/nim_implot) and test project [nimgl_test](https://github.com/dinau/nimgl_test).
,updated project [nimgl-imgui](https://github.com/dinau/nimgl-imgui) (ImGui v1.89.9) ,sub project [nim_implot](https://github.com/dinau/nim_implot) and test project [nimgl_test](https://github.com/dinau/nimgl_test),
or [https://github.com/daniel-j/nimgl-imgui](https://github.com/daniel-j/nimgl-imgui) (ImGui v1.91.1)


#### Screen shot
Expand All @@ -43,7 +43,7 @@ See example project [ImGuin_examples](https://github.com/dinau/imguin_examples)
- [Nim-2.0.14](https://nim-lang.org) or later
- Windows10 or later
[MSys2/MinGW](https://www.msys2.org/) command line tools (Unix tools), make, cp, rm, git, ...etc
- Ubuntu / Debian families
- Linux: Ubuntu / Debian families

```sh
$ sudo apt install gcc g++ make git
Expand Down Expand Up @@ -83,7 +83,7 @@ nimble install https://github.com/dinau/imguin
| ------------------- | :----: | :---- | :----: | --- |
| OpenGL3<br>backend | v | v | v | Done. |
| SDL2<br>backend | - | v | - | Done. 2025 |
| SDL3<br>backend | - | - | WIP | |
| SDL3<br>backend | - | - | v | Done. 2025 |


#### Update / Downgrade Dear ImGui and CImGui
Expand Down
File renamed without changes
2 changes: 2 additions & 0 deletions src/imguin/impl_sdl3.nim
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type
ImGui_ImplSDL3_GamepadMode_Manual = 2
ImGui_ImplSDL3_GamepadMode* = enum_ImGui_ImplSDL3_GamepadMode

{.push discardable.}
proc ImGui_ImplSDL3_InitForOpenGL*(window: ptr SDL_Window; sdl_gl_context: pointer): bool {.cdecl, importc: "ImGui_ImplSDL3_InitForOpenGL".}
proc ImGui_ImplSDL3_InitForVulkan*(window: ptr SDL_Window): bool {.cdecl, importc: "ImGui_ImplSDL3_InitForVulkan".}
proc ImGui_ImplSDL3_InitForD3D*(window: ptr SDL_Window): bool {.cdecl, importc: "ImGui_ImplSDL3_InitForD3D".}
Expand All @@ -40,3 +41,4 @@ proc ImGui_ImplSDL3_Shutdown*(): void {.cdecl, importc: "ImGui_ImplSDL3_Shutdown
proc ImGui_ImplSDL3_NewFrame*(): void {.cdecl, importc: "ImGui_ImplSDL3_NewFrame".}
proc ImGui_ImplSDL3_ProcessEvent*(event: ptr SDL_Event): bool {.cdecl, importc: "ImGui_ImplSDL3_ProcessEvent".}
proc ImGui_ImplSDL3_SetGamepadMode*(mode: ImGui_ImplSDL3_GamepadMode; manual_gamepads_array: ptr ptr SDL_Gamepad; manual_gamepads_count: cint): void {.cdecl, importc: "ImGui_ImplSDL3_SetGamepadMode".}
{.pop.}
8 changes: 5 additions & 3 deletions src/imguin/impl_sdlrenderer3.nim
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ else:
const ImguiRootPath = joinPath(CImguiRootPath,"imgui").replace("\\", "/")
{.compile:joinPath(ImguiRootPath,"backends/imgui_impl_sdlrenderer3.cpp").replace("\\", "/").}
type
structsdlrenderer {.incompleteStruct.} = object
SDL_Renderer = structsdlrenderer
ImDrawData {.incompleteStruct.} = object
#struct_SDL_Renderer {.incompleteStruct.} = object
#SDL_Renderer = structsdlrenderer
ImDrawData* {.incompleteStruct.} = object

{.push discardable.}
proc ImGui_ImplSDLRenderer3_Init*(renderer: ptr SDL_Renderer): bool {.cdecl, importc: "ImGui_ImplSDLRenderer3_Init".}
proc ImGui_ImplSDLRenderer3_Shutdown*(): void {.cdecl, importc: "ImGui_ImplSDLRenderer3_Shutdown".}
proc ImGui_ImplSDLRenderer3_NewFrame*(): void {.cdecl, importc: "ImGui_ImplSDLRenderer3_NewFrame".}
Expand All @@ -35,3 +36,4 @@ proc ImGui_ImplSDLRenderer3_CreateFontsTexture*(): bool {.cdecl, importc: "ImGui
proc ImGui_ImplSDLRenderer3_DestroyFontsTexture*(): void {.cdecl, importc: "ImGui_ImplSDLRenderer3_DestroyFontsTexture".}
proc ImGui_ImplSDLRenderer3_CreateDeviceObjects*(): bool {.cdecl, importc: "ImGui_ImplSDLRenderer3_CreateDeviceObjects".}
proc ImGui_ImplSDLRenderer3_DestroyDeviceObjects*(): void {.cdecl, importc: "ImGui_ImplSDLRenderer3_DestroyDeviceObjects".}
{.pop.}
4 changes: 4 additions & 0 deletions src/imguin/sdl3_renderer.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This file exsists for only compatibility purpose.

import cimgui, impl_sdl3, impl_sdlrenderer3
export cimgui, impl_sdl3, impl_sdlrenderer3
8 changes: 4 additions & 4 deletions src/imguin/sdl_basetype.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ type
struct_SDL_Gamecontroller* {.incompleteStruct.} = object
internal_SDL_GameController* = structsdlgamecontroller ## Generated based on cimgui_impl.h:50:36
ImGui_ImplSDL2_Gamepadmode* = enum_ImGui_implSDL2_GamePadMode ## Generated based on cimgui_impl.h:55:125
unionSDLEvent* {.incompleteStruct.} = object
SDL_Window* = structsdlwindow ## Generated based on cimgui_impl.h:48:27
SDL_Event* = unionsdlevent ## Generated based on cimgui_impl.h:54:25
SDL_Renderer* = structsdlrenderer
union_SDL_Event* {.incompleteStruct.} = object
SDL_Window* = struct_SDL_Window ## Generated based on cimgui_impl.h:48:27
SDL_Event* = union_SDL_Event ## Generated based on cimgui_impl.h:54:25
SDL_Renderer* = struct_SDL_Renderer
ImDrawData* {.incompleteStruct.} = object

enum_ImGui_implSDL2_GamepadMode* {.size: sizeof(cuint).} = enum
Expand Down

0 comments on commit 4892b74

Please sign in to comment.