Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Integrate ImGui with SFML 2.6.x on Linux?  (Read 302 times)

0 Members and 1 Guest are viewing this topic.

thanhdz167

  • Newbie
  • *
  • Posts: 2
    • View Profile
Integrate ImGui with SFML 2.6.x on Linux?
« on: November 24, 2023, 05:13:17 pm »
The first time I posted here. I followed tutorial from https://edw.is/using-imgui-with-sfml-pt1 and https://www.youtube.com/watch?v=2YS5WJTeKpI.

But I'm getting this error:

/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp: In lambda function:
/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp:272:55: error:const class sf::Window’ has no member named ‘getSystemHandle’
  272 |                             return ctx->window->getSystemHandle() == window.getSystemHandle();
      |                                                 ^~~~~~~~~~~~~~~

/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp:272:83: error:const class sf::Window’ has no member named ‘getSystemHandle’
  272 | return ctx->window->getSystemHandle() == window.getSystemHandle();
      |                                                 ^~~~~~~~~~~~~~~

/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp: In function ‘void ImGui::SFML::Shutdown(const sf::Window&):
/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp:490:35: error:const class sf::Window’ has no member named ‘getSystemHandle’
  490 |         (s_currWindowCtx->window->getSystemHandle() == window.getSystemHandle());
      |                                   ^~~~~~~~~~~~~~~
/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp:490:63: error:const class sf::Window’ has no member named ‘getSystemHandle’
  490 | rWindowCtx->window->getSystemHandle() == window.getSystemHandle());
      |                                                 ^~~~~~~~~~~~~~~

/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp: In lambda function:
/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp:495:55: error:const class sf::Window’ has no member named ‘getSystemHandle’
  495 |                             return ctx->window->getSystemHandle() == window.getSystemHandle();
      |                                                 ^~~~~~~~~~~~~~~

/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp:495:83: error:const class sf::Window’ has no member named ‘getSystemHandle’
  495 | return ctx->window->getSystemHandle() == window.getSystemHandle();
      |                                                 ^~~~~~~~~~~~~~~

/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp: In function ‘bool ImGui::SFML::UpdateFontTexture():
/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp:534:24: error: no matching function for call to ‘sf::Texture::create(unsigned int, unsigned int)
  534 |     if (!texture.create(static_cast<unsigned>(width), static_cast<unsigned>(height))) {
      |          ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /mnt/Linux/cyberchess/3rdparty/SFML/include/SFML/Graphics/RenderTexture.hpp:33,
                 from /mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp:7:
/mnt/Linux/cyberchess/3rdparty/SFML/include/SFML/Graphics/Texture.hpp:115:24: note: candidate:bool sf::Texture::create(const sf::Vector2u&)
  115 |     [[nodiscard]] bool create(const Vector2u& size);
      |                        ^~~~~~
/mnt/Linux/cyberchess/3rdparty/SFML/include/SFML/Graphics/Texture.hpp:115:24: note:   candidate expects 1 argument, 2 provided
/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp: In function ‘void ImGui::Image(const sf::Sprite&, const sf::Vector2f&, const sf::Color&, const sf::Color&):
/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp:709:54: error: cannot convert ‘const sf::Texture’ to ‘const sf::Texture*’ in initialization
  709 |     const sf::Texture* texturePtr = sprite.getTexture();
      |                                     ~~~~~~~~~~~~~~~~~^~
      |                                                      |
      |                                                      const sf::Texture
/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp: In function ‘bool ImGui::ImageButton(const sf::Sprite&, const sf::Vector2f&, int, const sf::Color&, const sf::Color&):
/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp:771:54: error: cannot convert ‘const sf::Texture’ to ‘const sf::Texture*’ in initialization
  771 |     const sf::Texture* texturePtr = sprite.getTexture();
      |                                     ~~~~~~~~~~~~~~~~~^~
      |                                                      |
      |                                                      const sf::Texture
/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp: In function ‘ImGuiKey {anonymous}::keycodeToImGuiKey(sf::Keyboard::Key):
/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp:1178:24: error: ‘Quote’ is not a member of ‘sf::Keyboard
 1178 |     case sf::Keyboard::Quote:
      |                        ^~~~~
/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp:1198:24: error: ‘Tilde’ is not a member of ‘sf::Keyboard
 1198 |     case sf::Keyboard::Tilde:
      |                        ^~~~~
make: *** [Makefile:30: /mnt/Linux/cyberchess/build/cyberchess] Error 1

Here is my Makefile:

CC=g++ # GNU g++
ROOT_DIR=$(PWD)
SRC_DIR=$(ROOT_DIR)/src
SFML_DIR=$(ROOT_DIR)/3rdparty/SFML
IMGUI_SFML_DIR=$(ROOT_DIR)/3rdparty/SFML/imgui
SFML_BUILD_DIR=$(SFML_DIR)/build

SRC_FILE=$(SRC_DIR)/main.cpp

BUILD_DIR=$(ROOT_DIR)/build
BUILD_EXEC=$(BUILD_DIR)/cyberchess

INCLUDE_DIR=$(ROOT_DIR)/include

CXXFLAGS=-std=c++17
LDFLAGS= -fpermissive -static-libgcc -static-libstdc++ -lsfml-audio-s -lsfml-network-s -lsfml-graphics-s -lsfml-window-s -lsfml-system-s -lX11 -lXrandr -lXi -lXcursor -ludev -lopengl32

.PHONY: all always clean sfml

always:
        @chmod +x $(ROOT_DIR)/prepare.sh && $(ROOT_DIR)/prepare.sh
        @rm -rf $(BUILD_EXEC)
        @mkdir -p $(BUILD_DIR)
        @mkdir -p $(SFML_BUILD_DIR)

all: always sfml $(BUILD_EXEC)

$(BUILD_EXEC): $(IMGUI_SFML_DIR)/imgui_draw.cpp $(IMGUI_SFML_DIR)/imgui_tables.cpp $(IMGUI_SFML_DIR)/imgui_widgets.cpp $(IMGUI_SFML_DIR)/imgui.cpp $(IMGUI_SFML_DIR)/imgui-SFML.cpp $(SRC_FILE)
        @rm -rf $(BUILD_EXEC)
        @$(CC) $(CXXFLAGS) -I$(INCLUDE_DIR) -I$(SFML_DIR)/include -I$(IMGUI_SFML_DIR) -I$(SFML_BUILD_DIR)/include $^ -L$(SFML_BUILD_DIR)/lib -Wl,-rpath,$(SFML_BUILD_DIR) -o $@ $(LDFLAGS)

sfml:
        cd $(SFML_DIR) && cmake . -DCMAKE_INSTALL_PREFIX=$(SFML_BUILD_DIR) && make && sudo make install && cd ..

clean:
        @rm -rf $(BUILD_DIR)
        @cd $(SFML_DIR) && make clean

I'm not sure what I wrong. But both of tutorials for Windows, so ImGui for SFML only for Windows?

Here is my machine:

« Last Edit: November 24, 2023, 05:22:20 pm by thanhdz167 »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10782
    • View Profile
    • development blog
    • Email
Re: Integrate ImGui with SFML 2.6.x on Linux?
« Reply #1 on: January 07, 2024, 10:32:59 pm »
The topic is a bit older, but I think the issue here is, that we renamed the function in SFML from getSystemHandle to getNativeHandle

You can use the 2.6.x branch on imgui & SFML if you want to stick to SFML 2, or remain on the master branch for both repos.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/