angeluriot / Dimension3D

A simple graphics library (2D, 3D and windows).
MIT License
44 stars 10 forks source link

Failed To Build On Linux With Unsafe Cast `int`/`GLuint` to `void*` #5

Open TheFloatingBrain opened 2 years ago

TheFloatingBrain commented 2 years ago

Wanted to say this seems like a library with some potential! I wish I had could have used something like this when I was younger, there was something called SF3D but I never got far with it.

GCC-12 on Ubuntu (in podman container) errors on a couple of casts in Scene.cpp

I created this patch file in the conan recipe I wrote in order to fix this problem (lines 449 and 451:

diff --git a/Dimension3D/sources/windows/Scene.cpp b/Dimension3D/sources/windows/Scene.cpp
index 62b5499..3fa36d8 100644
--- a/Dimension3D/sources/windows/Scene.cpp
+++ b/Dimension3D/sources/windows/Scene.cpp
@@ -446,9 +446,9 @@ namespace dim
        active = ImGui::IsWindowFocused();

        ImGui::SetCursorPos(ImVec2(8.f, 27.f));
-       ImGui::Image(frame_buffer.get_texture().get_id(), ImVec2(static_cast<float>(temp.x), static_cast<float>(temp.y)), ImVec2(0.f, 1.f), ImVec2(1.f, 0.f));
+       ImGui::Image((void*) frame_buffer.get_texture().get_id(), ImVec2(static_cast<float>(temp.x), static_cast<float>(temp.y)), ImVec2(0.f, 1.f), ImVec2(1.f, 0.f));
        ImGui::SetCursorPos(ImVec2(8.f, 27.f));
-       ImGui::Image(render_texture.getTexture().getNativeHandle(),
+       ImGui::Image((void*) render_texture.getTexture().getNativeHandle(),
            ImVec2(static_cast<float>(render_texture.getTexture().getSize().x),
            static_cast<float>(render_texture.getTexture().getSize().y)), ImVec2(0.f, 1.f), ImVec2(1.f, 0.f));

However it still throws a warning.

TheFloatingBrain commented 2 years ago

Casting with

(void*)(intptr_t)

Removes the errors + warnings