Skip to content

Commit

Permalink
deal with new ImTextureID type
Browse files Browse the repository at this point in the history
in ocornut/imgui@92b9498 `ImTextureID` was updated from `void*` to `ImU64`, which is defined as `unsigned long long` (which conflicts with some implementations of `uint64_t` that have it as `unsigned long`)
  • Loading branch information
briaguya-ai committed Jan 10, 2025
1 parent f226cf2 commit 9b6a91e
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/graphic/Fast3D/gfx_direct3d11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,7 @@ gfx_d3d11_get_pixel_depth(int fb_id, const std::set<std::pair<float, float>>& co

} // namespace

ImTextureID gfx_d3d11_get_texture_by_id(int id) {
ImTextureID gfx_d3d11_get_texture_by_id(unsigned long long id) {
return d3d.textures[id].resource_view.Get();
}

Expand Down
2 changes: 1 addition & 1 deletion src/graphic/Fast3D/gfx_direct3d11.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <imgui.h>

extern struct GfxRenderingAPI gfx_direct3d11_api;
ImTextureID gfx_d3d11_get_texture_by_id(int id);
ImTextureID gfx_d3d11_get_texture_by_id(unsigned long long id);

#endif

Expand Down
2 changes: 1 addition & 1 deletion src/graphic/Fast3D/gfx_metal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1295,7 +1295,7 @@ FilteringMode gfx_metal_get_texture_filter() {
return mctx.current_filter_mode;
}

ImTextureID gfx_metal_get_texture_by_id(int fb_id) {
ImTextureID gfx_metal_get_texture_by_id(unsigned long long fb_id) {
return (void*)mctx.textures[fb_id].texture;
}

Expand Down
2 changes: 1 addition & 1 deletion src/graphic/Fast3D/gfx_metal.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

extern struct GfxRenderingAPI gfx_metal_api;

ImTextureID gfx_metal_get_texture_by_id(int id);
ImTextureID gfx_metal_get_texture_by_id(unsigned long long id);

bool Metal_IsSupported();

Expand Down
8 changes: 4 additions & 4 deletions src/window/gui/Gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ void Gui::DrawGame() {
}
if (gfxFramebuffer) {
ImGui::SetCursorPos(pos);
ImGui::Image((ImTextureID)gfxFramebuffer, size);
ImGui::Image(gfxFramebuffer, size);
}

ImGui::End();
Expand Down Expand Up @@ -722,7 +722,7 @@ void Gui::SetupRendererFrame() {
}
}

ImTextureID Gui::GetTextureById(int32_t id) {
ImTextureID Gui::GetTextureById(unsigned long long id) {
#ifdef ENABLE_DX11
if (Context::GetInstance()->GetWindow()->GetWindowBackend() == WindowBackend::FAST3D_DXGI_DX11) {
return gfx_d3d11_get_texture_by_id(id);
Expand All @@ -734,7 +734,7 @@ ImTextureID Gui::GetTextureById(int32_t id) {
}
#endif

return (ImTextureID)id;
return id;
}

bool Gui::HasTextureByName(const std::string& name) {
Expand All @@ -743,7 +743,7 @@ bool Gui::HasTextureByName(const std::string& name) {

ImTextureID Gui::GetTextureByName(const std::string& name) {
if (!Gui::HasTextureByName(name)) {
return (ImTextureID)nullptr;
return 0;
}
return GetTextureById(mGuiTextures[name].RendererTextureId);
}
Expand Down
2 changes: 1 addition & 1 deletion src/window/gui/Gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class Gui {
void ImGuiBackendInit();
void ImGuiRenderDrawData(ImDrawData* data);

ImTextureID GetTextureById(int32_t id);
ImTextureID GetTextureById(unsigned long long id);
void ApplyResolutionChanges();
int16_t GetIntegerScaleFactor();
void CheckSaveCvars();
Expand Down
2 changes: 1 addition & 1 deletion src/window/gui/resource/GuiTexture.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Ship {
#define RESOURCE_TYPE_GUI_TEXTURE 0x47544558 // GTEX

struct GuiTextureMetadata {
uint32_t RendererTextureId;
unsigned long long RendererTextureId;
int32_t Width;
int32_t Height;
};
Expand Down

0 comments on commit 9b6a91e

Please sign in to comment.