Skip to content

Commit 3e0bb70

Browse files
committed
Update ImGui to 1.92.5 (#9463)
1 parent e09c702 commit 3e0bb70

File tree

183 files changed

+33859
-11572
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

183 files changed

+33859
-11572
lines changed

libs/filagui/src/ImGuiHelper.cpp

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,47 @@ void ImGuiHelper::render(float timeStepInSeconds, Callback imguiCommands) {
190190
void ImGuiHelper::processImGuiCommands(ImDrawData* commands, const ImGuiIO& io) {
191191
ImGui::SetCurrentContext(mImGuiContext);
192192

193+
if (commands->Textures != nullptr) {
194+
for (ImTextureData* tex : *commands->Textures) {
195+
if (tex->Status == ImTextureStatus_OK) {
196+
continue;
197+
} else if (tex->Status == ImTextureStatus_WantCreate) {
198+
IM_ASSERT(tex->TexID == 0 && tex->BackendUserData == nullptr);
199+
Texture* ftex = Texture::Builder()
200+
.width(tex->Width)
201+
.height(tex->Height)
202+
.levels(1)
203+
.format(Texture::InternalFormat::RGBA8)
204+
.sampler(Texture::Sampler::SAMPLER_2D)
205+
.build(*mEngine);
206+
207+
IM_ASSERT(tex->Format == ImTextureFormat_RGBA32);
208+
const int size = tex->Width * tex->Height * 4;
209+
Texture::PixelBufferDescriptor pb(tex->GetPixels(), size,
210+
Texture::Format::RGBA,
211+
Texture::Type::UBYTE);
212+
ftex->setImage(*mEngine, 0, std::move(pb));
213+
214+
tex->SetTexID((ImTextureID)ftex);
215+
tex->SetStatus(ImTextureStatus_OK);
216+
} else if (tex->Status == ImTextureStatus_WantUpdates) {
217+
const int size = tex->Width * tex->Height * 4;
218+
Texture::PixelBufferDescriptor pb(tex->GetPixels(), size,
219+
Texture::Format::RGBA,
220+
Texture::Type::UBYTE);
221+
filament::Texture* ftex = (filament::Texture*)tex->TexID;
222+
ftex->setImage(*mEngine, 0, std::move(pb));
223+
tex->SetStatus(ImTextureStatus_OK);
224+
} else if (tex->Status == ImTextureStatus_WantDestroy &&
225+
tex->UnusedFrames > 0) {
226+
filament::Texture* ftex = (filament::Texture*)tex->TexID;
227+
mEngine->destroy(ftex);
228+
tex->SetTexID(ImTextureID_Invalid);
229+
tex->SetStatus(ImTextureStatus_Destroyed);
230+
}
231+
}
232+
}
233+
193234
mHasSynced = false;
194235
auto& rcm = mEngine->getRenderableManager();
195236

@@ -228,7 +269,7 @@ void ImGuiHelper::processImGuiCommands(ImDrawData* commands, const ImGuiIO& io)
228269
if (pcmd.UserCallback) {
229270
pcmd.UserCallback(cmds, &pcmd);
230271
} else {
231-
auto texture = (Texture const*)pcmd.TextureId;
272+
auto texture = (Texture const*)pcmd.GetTexID();
232273
MaterialInstance* materialInstance;
233274
#ifdef __ANDROID__
234275
if (texture && texture->getTarget() == Texture::Sampler::SAMPLER_EXTERNAL) {

libs/filamentapp/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ set(SRCS
3737
src/IcoSphere.cpp
3838
src/MeshAssimp.cpp
3939
src/Sphere.cpp
40+
src/KeyInputConversion.h
4041
)
4142

4243
if (FILAMENT_SUPPORTS_VULKAN)

libs/filamentapp/src/FilamentApp.cpp

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
#include <filamentapp/FilamentApp.h>
1818

19+
#include "KeyInputConversion.h"
20+
1921
#if defined(WIN32)
2022
# include <SDL_syswm.h>
2123
# include <utils/unwindows.h>
@@ -211,27 +213,6 @@ void FilamentApp::run(const Config& config, SetupCallback setupCallback,
211213
SDL_GetWindowWMInfo(window->getSDLWindow(), &wmInfo);
212214
ImGui::GetMainViewport()->PlatformHandleRaw = wmInfo.info.win.window;
213215
#endif
214-
io.KeyMap[ImGuiKey_Tab] = SDL_SCANCODE_TAB;
215-
io.KeyMap[ImGuiKey_LeftArrow] = SDL_SCANCODE_LEFT;
216-
io.KeyMap[ImGuiKey_RightArrow] = SDL_SCANCODE_RIGHT;
217-
io.KeyMap[ImGuiKey_UpArrow] = SDL_SCANCODE_UP;
218-
io.KeyMap[ImGuiKey_DownArrow] = SDL_SCANCODE_DOWN;
219-
io.KeyMap[ImGuiKey_PageUp] = SDL_SCANCODE_PAGEUP;
220-
io.KeyMap[ImGuiKey_PageDown] = SDL_SCANCODE_PAGEDOWN;
221-
io.KeyMap[ImGuiKey_Home] = SDL_SCANCODE_HOME;
222-
io.KeyMap[ImGuiKey_End] = SDL_SCANCODE_END;
223-
io.KeyMap[ImGuiKey_Insert] = SDL_SCANCODE_INSERT;
224-
io.KeyMap[ImGuiKey_Delete] = SDL_SCANCODE_DELETE;
225-
io.KeyMap[ImGuiKey_Backspace] = SDL_SCANCODE_BACKSPACE;
226-
io.KeyMap[ImGuiKey_Space] = SDL_SCANCODE_SPACE;
227-
io.KeyMap[ImGuiKey_Enter] = SDL_SCANCODE_RETURN;
228-
io.KeyMap[ImGuiKey_Escape] = SDL_SCANCODE_ESCAPE;
229-
io.KeyMap[ImGuiKey_A] = SDL_SCANCODE_A;
230-
io.KeyMap[ImGuiKey_C] = SDL_SCANCODE_C;
231-
io.KeyMap[ImGuiKey_V] = SDL_SCANCODE_V;
232-
io.KeyMap[ImGuiKey_X] = SDL_SCANCODE_X;
233-
io.KeyMap[ImGuiKey_Y] = SDL_SCANCODE_Y;
234-
io.KeyMap[ImGuiKey_Z] = SDL_SCANCODE_Z;
235216
io.SetClipboardTextFn = [](void*, const char* text) {
236217
SDL_SetClipboardText(text);
237218
};
@@ -305,15 +286,19 @@ void FilamentApp::run(const Config& config, SetupCallback setupCallback,
305286
io.AddInputCharactersUTF8(event->text.text);
306287
break;
307288
}
308-
case SDL_KEYDOWN:
309-
case SDL_KEYUP: {
310-
int key = event->key.keysym.scancode;
311-
IM_ASSERT(key >= 0 && key < IM_ARRAYSIZE(io.KeysDown));
312-
io.KeysDown[key] = (event->type == SDL_KEYDOWN);
313-
io.KeyShift = ((SDL_GetModState() & KMOD_SHIFT) != 0);
314-
io.KeyAlt = ((SDL_GetModState() & KMOD_ALT) != 0);
315-
io.KeyCtrl = ((SDL_GetModState() & KMOD_CTRL) != 0);
316-
io.KeySuper = ((SDL_GetModState() & KMOD_GUI) != 0);
289+
case SDL_KEYUP:
290+
case SDL_KEYDOWN: {
291+
SDL_Scancode const scancode = event->key.keysym.scancode;
292+
SDL_Keycode const keycode = event->key.keysym.sym;
293+
294+
auto modState = SDL_GetModState();
295+
io.AddKeyEvent(ImGuiMod_Ctrl, (modState & KMOD_CTRL) != 0);
296+
io.AddKeyEvent(ImGuiMod_Shift, (modState & KMOD_SHIFT) != 0);
297+
io.AddKeyEvent(ImGuiMod_Alt, (modState & KMOD_ALT) != 0);
298+
io.AddKeyEvent(ImGuiMod_Super, (modState & KMOD_GUI) != 0);
299+
io.AddKeyEvent(
300+
filamentapp_utils::ImGui_ImplSDL2_KeyEventToImGuiKey(keycode, scancode),
301+
event->type == SDL_KEYDOWN);
317302
break;
318303
}
319304
}

0 commit comments

Comments
 (0)