Elaztek Developer Hub
Blamite Game Engine - blam!  00398.09.22.23.2015.blamite
The core library for the Blamite Game Engine.
imgui_impl_sdl.h
Go to the documentation of this file.
1 // dear imgui: Platform Backend for SDL2
2 // This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
3 // (Info: SDL2 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.)
4 
5 // Implemented features:
6 // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
7 // [X] Platform: Clipboard support.
8 // [X] Platform: Keyboard arrays indexed using SDL_SCANCODE_* codes, e.g. ImGui::IsKeyPressed(SDL_SCANCODE_SPACE).
9 // [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
10 // Missing features:
11 // [ ] Platform: SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME.
12 
13 // You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
14 // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
15 // Read online: https://github.com/ocornut/imgui/tree/master/docs
16 
17 #pragma once
18 #include "../imgui.h" // IMGUI_IMPL_API
19 
20 struct SDL_Window;
21 typedef union SDL_Event SDL_Event;
22 
23 IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context);
24 IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window);
25 IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window);
26 IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForMetal(SDL_Window* window);
28 IMGUI_IMPL_API void ImGui_ImplSDL2_NewFrame(SDL_Window* window);
30 
ImGuiIO::KeyAlt
bool KeyAlt
Definition: imgui.h:1415
ImGuiIO::KeySuper
bool KeySuper
Definition: imgui.h:1416
ImGuiNavInput_FocusPrev
@ ImGuiNavInput_FocusPrev
Definition: imgui.h:981
ImGuiMouseCursor_Hand
@ ImGuiMouseCursor_Hand
Definition: imgui.h:1181
SDL_SCANCODE_UP
@ SDL_SCANCODE_UP
Definition: SdlEmulationLayer.h:158
ImGuiNavInput_DpadLeft
@ ImGuiNavInput_DpadLeft
Definition: imgui.h:973
SDL_SCANCODE_C
@ SDL_SCANCODE_C
Definition: SdlEmulationLayer.h:35
ImGuiIO::MouseDown
bool MouseDown[5]
Definition: imgui.h:1410
SDL_SCANCODE_Z
@ SDL_SCANCODE_Z
Definition: SdlEmulationLayer.h:58
ImGuiBackendFlags_HasGamepad
@ ImGuiBackendFlags_HasGamepad
Definition: imgui.h:1018
ImGuiKey_Home
@ ImGuiKey_Home
Definition: imgui.h:944
ImGui_ImplSDL2_Shutdown
IMGUI_IMPL_API void ImGui_ImplSDL2_Shutdown()
Definition: imgui_impl_sdl.cpp:225
SDL_Event::button
SDL_MouseButtonEvent button
Mouse button event data.
Definition: SdlEmulationLayer.h:740
SDL_SCANCODE_PAGEUP
@ SDL_SCANCODE_PAGEUP
Definition: SdlEmulationLayer.h:151
SDL_SCANCODE_INSERT
@ SDL_SCANCODE_INSERT
insert on PC, help on some Mac keyboards (but does send code 73, not 117)
Definition: SdlEmulationLayer.h:148
ImGuiIO::ClipboardUserData
void * ClipboardUserData
Definition: imgui.h:1389
ImGuiKey_PageDown
@ ImGuiKey_PageDown
Definition: imgui.h:943
imgui_impl_sdl.h
SDL_SCANCODE_TAB
@ SDL_SCANCODE_TAB
Definition: SdlEmulationLayer.h:74
MAP_BUTTON
#define MAP_BUTTON(NAV_NO, BUTTON_NO)
ImGuiMouseCursor_ResizeNS
@ ImGuiMouseCursor_ResizeNS
Definition: imgui.h:1177
ImGuiBackendFlags_HasSetMousePos
@ ImGuiBackendFlags_HasSetMousePos
Definition: imgui.h:1020
ImGuiBackendFlags_HasMouseCursors
@ ImGuiBackendFlags_HasMouseCursors
Definition: imgui.h:1019
ImGuiNavInput_Menu
@ ImGuiNavInput_Menu
Definition: imgui.h:972
ImGuiIO::MousePos
ImVec2 MousePos
Definition: imgui.h:1409
ImGuiIO::AddInputCharactersUTF8
IMGUI_API void AddInputCharactersUTF8(const char *str)
Definition: imgui.cpp:1265
ImGuiMouseCursor_Arrow
@ ImGuiMouseCursor_Arrow
Definition: imgui.h:1174
ImGuiNavInput_Cancel
@ ImGuiNavInput_Cancel
Definition: imgui.h:970
ImGuiNavInput_LStickRight
@ ImGuiNavInput_LStickRight
Definition: imgui.h:978
ImGui_ImplSDL2_ProcessEvent
IMGUI_IMPL_API bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event *event)
Definition: imgui_impl_sdl.cpp:89
ImGui_ImplSDL2_ProcessEvent
bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event *event)
Definition: imgui_impl_sdl.cpp:89
ImGuiMouseCursor
int ImGuiMouseCursor
Definition: imgui.h:138
ImGui_ImplSDL2_InitForD3D
bool ImGui_ImplSDL2_InitForD3D(SDL_Window *window)
Definition: imgui_impl_sdl.cpp:212
SDL_MouseWheelEvent::y
Ogre::int32 y
The amount scrolled vertically, positive away from the user and negative toward the user.
Definition: SdlEmulationLayer.h:731
ImGuiIO::ImeWindowHandle
void * ImeWindowHandle
Definition: imgui.h:1394
ImGuiNavInput_FocusNext
@ ImGuiNavInput_FocusNext
Definition: imgui.h:982
ImGuiIO::BackendFlags
ImGuiBackendFlags BackendFlags
Definition: imgui.h:1345
MAP_ANALOG
#define MAP_ANALOG(NAV_NO, AXIS_NO, V0, V1)
ImGuiIO
Definition: imgui.h:1338
ImGui_ImplSDL2_SetActiveWindowOverride
IMGUI_IMPL_API void ImGui_ImplSDL2_SetActiveWindowOverride(bool override_state)
Special function used to override active window checks.
Definition: imgui_impl_sdl.cpp:375
SDL_SCANCODE_BACKSPACE
@ SDL_SCANCODE_BACKSPACE
Definition: SdlEmulationLayer.h:73
SDL_SCANCODE_KP_ENTER
@ SDL_SCANCODE_KP_ENTER
Definition: SdlEmulationLayer.h:166
ImGui_ImplSDL2_NewFrame
void ImGui_ImplSDL2_NewFrame(SDL_Window *window)
Definition: imgui_impl_sdl.cpp:346
ImGui_ImplSDL2_InitForOpenGL
bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window *window, void *sdl_gl_context)
Definition: imgui_impl_sdl.cpp:198
SDL_SCANCODE_Y
@ SDL_SCANCODE_Y
Definition: SdlEmulationLayer.h:57
ImGuiKey_UpArrow
@ ImGuiKey_UpArrow
Definition: imgui.h:940
SDL_MouseWheelEvent::x
Ogre::int32 x
The amount scrolled horizontally, positive to the right and negative to the left.
Definition: SdlEmulationLayer.h:730
ImVec2::x
float x
Definition: imgui.h:181
ImGuiIO::KeysDown
bool KeysDown[512]
Definition: imgui.h:1417
ImGuiIO::MouseDrawCursor
bool MouseDrawCursor
Definition: imgui.h:1366
ImFontAtlas::IsBuilt
bool IsBuilt()
Definition: imgui.h:2113
ImGuiIO::NavInputs
float NavInputs[ImGuiNavInput_COUNT]
Definition: imgui.h:1418
SDL_SCANCODE_DOWN
@ SDL_SCANCODE_DOWN
Definition: SdlEmulationLayer.h:157
ImVec2
Definition: imgui.h:179
NULL
Add a fourth parameter to bake specific font ranges NULL
Definition: README.txt:57
ImGuiIO::WantSetMousePos
bool WantSetMousePos
Definition: imgui.h:1432
ImGuiNavInput_TweakFast
@ ImGuiNavInput_TweakFast
Definition: imgui.h:984
ImGuiMouseCursor_None
@ ImGuiMouseCursor_None
Definition: imgui.h:1173
ImGuiIO::Fonts
ImFontAtlas * Fonts
Definition: imgui.h:1359
ImGuiKey_V
@ ImGuiKey_V
Definition: imgui.h:955
SDL_SCANCODE_V
@ SDL_SCANCODE_V
Definition: SdlEmulationLayer.h:54
ImGuiIO::DisplayFramebufferScale
ImVec2 DisplayFramebufferScale
Definition: imgui.h:1363
ImGuiIO::KeyCtrl
bool KeyCtrl
Definition: imgui.h:1413
ImGuiKey_LeftArrow
@ ImGuiKey_LeftArrow
Definition: imgui.h:938
ImGuiIO::KeyShift
bool KeyShift
Definition: imgui.h:1414
ImGui_ImplSDL2_InitForOpenGL
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window *window, void *sdl_gl_context)
Definition: imgui_impl_sdl.cpp:198
ImGuiConfigFlags_NavEnableGamepad
@ ImGuiConfigFlags_NavEnableGamepad
Definition: imgui.h:1003
ImGuiConfigFlags_NoMouseCursorChange
@ ImGuiConfigFlags_NoMouseCursorChange
Definition: imgui.h:1007
ImGuiMouseCursor_TextInput
@ ImGuiMouseCursor_TextInput
Definition: imgui.h:1175
ImGuiMouseCursor_COUNT
@ ImGuiMouseCursor_COUNT
Definition: imgui.h:1182
ImGui::GetIO
IMGUI_API ImGuiIO & GetIO()
Definition: imgui.cpp:3300
ImGuiIO::ConfigFlags
ImGuiConfigFlags ConfigFlags
Definition: imgui.h:1344
ImGui_ImplSDL2_SetActiveWindowOverride
void ImGui_ImplSDL2_SetActiveWindowOverride(bool override_state)
Special function used to override active window checks.
Definition: imgui_impl_sdl.cpp:375
ImGui_ImplSDL2_NewFrame
IMGUI_IMPL_API void ImGui_ImplSDL2_NewFrame(SDL_Window *window)
Definition: imgui_impl_sdl.cpp:346
SDL_SCANCODE_DELETE
@ SDL_SCANCODE_DELETE
Definition: SdlEmulationLayer.h:152
ImGuiMouseCursor_ResizeEW
@ ImGuiMouseCursor_ResizeEW
Definition: imgui.h:1178
ImGuiKey_End
@ ImGuiKey_End
Definition: imgui.h:945
ImGui_ImplSDL2_Shutdown
void ImGui_ImplSDL2_Shutdown()
Definition: imgui_impl_sdl.cpp:225
ImGuiIO::GetClipboardTextFn
const char *(* GetClipboardTextFn)(void *user_data)
Definition: imgui.h:1387
SDL_SCANCODE_HOME
@ SDL_SCANCODE_HOME
Definition: SdlEmulationLayer.h:150
IM_ARRAYSIZE
#define IM_ARRAYSIZE(_ARR)
Definition: imgui.h:75
ImGuiIO::SetClipboardTextFn
void(* SetClipboardTextFn)(void *user_data, const char *text)
Definition: imgui.h:1388
ImGuiKey_Enter
@ ImGuiKey_Enter
Definition: imgui.h:950
SDL_SCANCODE_PAGEDOWN
@ SDL_SCANCODE_PAGEDOWN
Definition: SdlEmulationLayer.h:154
ImGuiKey_Backspace
@ ImGuiKey_Backspace
Definition: imgui.h:948
ImGuiKey_C
@ ImGuiKey_C
Definition: imgui.h:954
ImGuiKey_RightArrow
@ ImGuiKey_RightArrow
Definition: imgui.h:939
SDL_MouseButtonEvent::button
Ogre::uint8 button
The mouse button index.
Definition: SdlEmulationLayer.h:713
ImGuiIO::MouseWheelH
float MouseWheelH
Definition: imgui.h:1412
ImGuiKey_A
@ ImGuiKey_A
Definition: imgui.h:953
ImGuiIO::BackendPlatformName
const char * BackendPlatformName
Definition: imgui.h:1379
ImGuiNavInput_DpadDown
@ ImGuiNavInput_DpadDown
Definition: imgui.h:976
ImGui_ImplSDL2_InitForMetal
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForMetal(SDL_Window *window)
Definition: imgui_impl_sdl.cpp:220
ImGuiIO::DeltaTime
float DeltaTime
Definition: imgui.h:1347
ImGuiKey_Z
@ ImGuiKey_Z
Definition: imgui.h:958
SDL_SCANCODE_END
@ SDL_SCANCODE_END
Definition: SdlEmulationLayer.h:153
ImGui_ImplSDL2_InitForMetal
bool ImGui_ImplSDL2_InitForMetal(SDL_Window *window)
Definition: imgui_impl_sdl.cpp:220
ImGui_ImplSDL2_InitForVulkan
bool ImGui_ImplSDL2_InitForVulkan(SDL_Window *window)
Definition: imgui_impl_sdl.cpp:204
ImGuiNavInput_DpadUp
@ ImGuiNavInput_DpadUp
Definition: imgui.h:975
ImVec2::y
float y
Definition: imgui.h:181
ImGuiKey_Space
@ ImGuiKey_Space
Definition: imgui.h:949
ImGuiNavInput_LStickUp
@ ImGuiNavInput_LStickUp
Definition: imgui.h:979
ImGuiKey_PageUp
@ ImGuiKey_PageUp
Definition: imgui.h:942
IMGUI_IMPL_API
#define IMGUI_IMPL_API
Definition: imgui.h:60
SDL_SCANCODE_ESCAPE
@ SDL_SCANCODE_ESCAPE
Definition: SdlEmulationLayer.h:72
ImGuiKey_Delete
@ ImGuiKey_Delete
Definition: imgui.h:947
ImGuiNavInput_Input
@ ImGuiNavInput_Input
Definition: imgui.h:971
ImGuiKey_X
@ ImGuiKey_X
Definition: imgui.h:956
ImGuiKey_DownArrow
@ ImGuiKey_DownArrow
Definition: imgui.h:941
ImGuiKey_Insert
@ ImGuiKey_Insert
Definition: imgui.h:946
ImGuiNavInput_Activate
@ ImGuiNavInput_Activate
Definition: imgui.h:969
SDL_SCANCODE_X
@ SDL_SCANCODE_X
Definition: SdlEmulationLayer.h:56
SDL_Event::type
Ogre::uint32 type
Event type, shared with all events.
Definition: SdlEmulationLayer.h:737
SDL_SCANCODE_SPACE
@ SDL_SCANCODE_SPACE
Definition: SdlEmulationLayer.h:75
ImGui::IsAnyMouseDown
IMGUI_API bool IsAnyMouseDown()
Definition: imgui.cpp:4448
ImGuiMouseCursor_ResizeNESW
@ ImGuiMouseCursor_ResizeNESW
Definition: imgui.h:1179
SDL_Event
Definition: SdlEmulationLayer.h:735
SDL_SCANCODE_RETURN
@ SDL_SCANCODE_RETURN
Definition: SdlEmulationLayer.h:71
ImGuiNavInput_TweakSlow
@ ImGuiNavInput_TweakSlow
Definition: imgui.h:983
ImGui::GetMouseCursor
IMGUI_API ImGuiMouseCursor GetMouseCursor()
Definition: imgui.cpp:4558
ImGuiMouseCursor_ResizeNWSE
@ ImGuiMouseCursor_ResizeNWSE
Definition: imgui.h:1180
ImGuiIO::KeyMap
int KeyMap[ImGuiKey_COUNT]
Definition: imgui.h:1354
SDL_SCANCODE_LEFT
@ SDL_SCANCODE_LEFT
Definition: SdlEmulationLayer.h:156
ImGuiNavInput_LStickLeft
@ ImGuiNavInput_LStickLeft
Definition: imgui.h:977
ImGui_ImplSDL2_InitForVulkan
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForVulkan(SDL_Window *window)
Definition: imgui_impl_sdl.cpp:204
ImGuiKey_Y
@ ImGuiKey_Y
Definition: imgui.h:957
IM_ASSERT
#define IM_ASSERT(_EXPR)
Definition: imgui.h:66
ImGuiMouseCursor_ResizeAll
@ ImGuiMouseCursor_ResizeAll
Definition: imgui.h:1176
ImGui_ImplSDL2_InitForD3D
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForD3D(SDL_Window *window)
Definition: imgui_impl_sdl.cpp:212
ImGuiIO::MouseWheel
float MouseWheel
Definition: imgui.h:1411
SDL_SCANCODE_RIGHT
@ SDL_SCANCODE_RIGHT
Definition: SdlEmulationLayer.h:155
ImGuiKey_Tab
@ ImGuiKey_Tab
Definition: imgui.h:937
ImGuiKey_Escape
@ ImGuiKey_Escape
Definition: imgui.h:951
ImGuiIO::DisplaySize
ImVec2 DisplaySize
Definition: imgui.h:1346
ImGuiKey_KeyPadEnter
@ ImGuiKey_KeyPadEnter
Definition: imgui.h:952
SDL_SCANCODE_A
@ SDL_SCANCODE_A
Definition: SdlEmulationLayer.h:33
SDL_Event::wheel
SDL_MouseWheelEvent wheel
Mouse wheel event data.
Definition: SdlEmulationLayer.h:741
ImGuiNavInput_LStickDown
@ ImGuiNavInput_LStickDown
Definition: imgui.h:980
ImGuiNavInput_DpadRight
@ ImGuiNavInput_DpadRight
Definition: imgui.h:974