Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client and server on Linux #39

Closed
hinxx opened this issue Oct 27, 2022 · 6 comments
Closed

client and server on Linux #39

hinxx opened this issue Oct 27, 2022 · 6 comments

Comments

@hinxx
Copy link

hinxx commented Oct 27, 2022

My embedded system (no keyboard/screen) processes data and I'm considering using netImgui to move that data to the PC (keyboard/screen) and use ImGui to visualize it and interact with the embedded system. They would both be Linux based and have opengl3 and glfw.

I'm little confused on what part of netImgui runs where and how it is referred to in the docs / code / comments. Would the server run on the embedded system and the client on the PC in my case, or is it the other way around?

Which ImGui render/input backend should the embedded system use?

Reading through some older issues I get a feeling that Linux support is there but not complete. Has that changed?

Can you point me to an existing sample code that would best fit the use case outlined above, please?

Thank you in advance!

@sammyfreg
Copy link
Owner

sammyfreg commented Oct 27, 2022 via email

@hinxx
Copy link
Author

hinxx commented Oct 27, 2022

Thanks for clarifying!

I'm using g++ on Linux platform.
I've compiled the SampleNoBackend as the client with no issues.

Now I'm trying to compile the ServerApp as well and I'm facing this error:

g++ -std=c++11 -I../../ThirdParty/DearImgui -I../../ThirdParty/DearImgui/backends -g -Wall -Wformat -I. -I../../ -I../../Client `pkg-config --cflags glfw3` -c -o NetImguiServer_RemoteClient.o NetImguiServer_RemoteClient.cpp
NetImguiServer_RemoteClient.cpp: In member function ‘NetImguiServer::RemoteClient::NetImguiImDrawData* NetImguiServer::RemoteClient::Client::GetImguiDrawData(void*)’:
NetImguiServer_RemoteClient.cpp:241:83: error: invalid conversion from ‘uint64_t’ {aka ‘long unsigned int’} to ‘ImTextureID’ {aka ‘void*’} [-fpermissive]
  241 |     pCmdList->CmdBuffer[drawIdx].TextureId = NetImgui::Internal::TextureCastHelper(pEmtpyTextureHAL); // Default to empty texture
      |                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
      |                                                                                   |
      |                                                                                   uint64_t {aka long unsigned int}
NetImguiServer_RemoteClient.cpp:246:85: error: invalid conversion from ‘uint64_t’ {aka ‘long unsigned int’} to ‘ImTextureID’ {aka ‘void*’} [-fpermissive]
  246 |       pCmdList->CmdBuffer[drawIdx].TextureId = NetImgui::Internal::TextureCastHelper(mvTextures[texIdx].mpHAL_Texture);
      |                                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                                                     |
      |                                                                                     uint64_t {aka long unsigned int}

Should I just cast the return value to ImTextureID?

BTW, I had to comment out this line #include "backends/imgui_impl_win32.cpp" from NetImguiServer_App_GlfwGL3.cpp..

@hinxx
Copy link
Author

hinxx commented Oct 27, 2022

Should I just cast the return value to ImTextureID?

Did that and it compiled fine.

I managed to also run the server and client on the same Linux host!

Screenshot_2022-10-27_14-51-45

This looks very cool!

@sammyfreg
Copy link
Owner

sammyfreg commented Oct 27, 2022 via email

@hinxx
Copy link
Author

hinxx commented Oct 27, 2022

That code seems to be already using the TextureCastHelper. Looks like it is picking up the wrong one, though. If I explicitly cast the argument to (const void*) then the compiler is happy.

Here the little diff that sorts that out:

$ git diff NetImguiServer_RemoteClient.cpp
diff --git a/Code/ServerApp/Source/NetImguiServer_RemoteClient.cpp b/Code/ServerApp/Source/NetImguiServer_RemoteClient.cpp
index 2046ec9..7a08103 100644
--- a/Code/ServerApp/Source/NetImguiServer_RemoteClient.cpp
+++ b/Code/ServerApp/Source/NetImguiServer_RemoteClient.cpp
@@ -238,12 +238,12 @@ NetImguiImDrawData*       Client::GetImguiDrawData(void* pEmtpyTextureHAL)
                        for(int drawIdx(0), drawCount(pCmdList->CmdBuffer.size()); drawIdx<drawCount; ++drawIdx)
                        {
                                uint64_t wantedTexID                                    = NetImgui::Internal::TextureCastHelper(pCmdList->CmdBuffer[drawIdx].TextureId);
-                               pCmdList->CmdBuffer[drawIdx].TextureId  = NetImgui::Internal::TextureCastHelper(pEmtpyTextureHAL); // Default to empty texture
+                               pCmdList->CmdBuffer[drawIdx].TextureId  = NetImgui::Internal::TextureCastHelper((const void*)pEmtpyTextureHAL); // Default to empty texture
                                for(size_t texIdx=0; texIdx<clientTexCount; ++texIdx)
                                {
                                        if( mvTextures[texIdx].mImguiId == wantedTexID )
                                        {
-                                               pCmdList->CmdBuffer[drawIdx].TextureId  = NetImgui::Internal::TextureCastHelper(mvTextures[texIdx].mpHAL_Texture);
+                                               pCmdList->CmdBuffer[drawIdx].TextureId  = NetImgui::Internal::TextureCastHelper((const void*)mvTextures[texIdx].mpHAL_Texture);
                                                break;
                                        }
                                }

@sammyfreg
Copy link
Owner

Thank you for your investigations, c707101 should fixes them. Let me know if there's still some problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants