[go: up one dir, main page]

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

Node editor on GCC #1

Closed
francesco-cattoglio opened this issue Dec 13, 2017 · 6 comments
Closed

Node editor on GCC #1

francesco-cattoglio opened this issue Dec 13, 2017 · 6 comments

Comments

@francesco-cattoglio
Copy link

I finally had some time to start digging in the code, and as soon as I tried to compile it under Linux I noticed a couple things:

  1. Some member variables are named after their type (eg: Node* Node;) which does not play well with GCC/CLang.
  2. Usage of std::optional<>, which I love but requires C++17, which is not yet supported officially by most compiler versions (can be worked around by using std::experimental::optional<> instead).
  3. It seems like there's a decent chunk of platform-specific code in the imgui_impl_dx11.cpp file, which might be hard to port over Linux/OSX frameworks.
  4. itoa function, which is non-standard.
  5. Some template funkiness.

Point 1, 2 and 4 are easily fixed, but I would like to have your opinion about point 3. I got to the point where the simple test (application_simple.cpp) works, but got stuck after that. I was wondering if you had a rough idea of how much work it would be to change the main application code to run on glfw/SDL2, before I start banging my head at the wall 😄

@thedmd
Copy link
Owner
thedmd commented Dec 13, 2017

1, 2, 4 and 5 are on my todo list. Last two implicitly. I will work on that on weekend.

As for 3, imgui_impl_dx11.cpp is modified copy of example found in ImGui. You can easily pick different backend. From the user point of view these functions were added:

IMGUI_API ImTextureID ImGui_LoadTexture(const char* path);
IMGUI_API ImTextureID ImGui_CreateTexture(const void* data, int width, int height);
IMGUI_API void        ImGui_DestroyTexture(ImTextureID texture);
IMGUI_API int         ImGui_GetTextureWidth(ImTextureID texture);
IMGUI_API int         ImGui_GetTextureHeight(ImTextureID texture);

They can be replaced by stubs. I used them to load icons and background texture for node header. They're used only in example, Node Editor do not touch them.

Add these to imgui_impl_xxx.h of your choice and you should be able to run example.

// Stubs
inline ImTextureID ImGui_LoadTexture(const char* path) { return nullptr; }
inline ImTextureID ImGui_CreateTexture(const void* data, int width, int height) { return nullptr; }
inline void        ImGui_DestroyTexture(ImTextureID texture) {}
inline int         ImGui_GetTextureWidth(ImTextureID texture) { return 0; }
inline int         ImGui_GetTextureHeight(ImTextureID texture) { return 0; }

I will work towards portability not only in editor but in example application too.
Answering your question, I think switching to glfw/SDL2 should take about an hour. Most of that time will be consumed by thinkering with build systems. In case you use Windows libraries can be switched easily in solution.

Ask If I managed to miss something. : )

@francesco-cattoglio
Copy link
Author

TY for your quick reply!
I will try to add those stubs and see what happens. Right now I'm only tinkering with some shuffled files, and therefore I cannot make a pull request, but I will provide a diff patch containing all the changes I made to run the example under a Ubuntu 17.04, it might come handy to you.
And as soon as I have some time to spend on the project, I will help with that todo list!

@francesco-cattoglio
Copy link
Author

Here is a patch of all the changes I made to have it run under linux.
Some of those changes (like some "auto" keyword substitution) are due to me not realizing initially that C++14/C++17 was required to compile the project.

Most of it is "noise" due to point 1, but there are a couple interesting lines in there as well. I'm posting the whole diff anyway, you should be able to check it out very quickly anyway.

diff.zip

@thedmd
Copy link
Owner
thedmd commented Dec 16, 2017

I did some cleanup to project structure and replaced Visual Studio solution with CMake files. This should make project easier to hack.
Your changes cannot be directly integrated, I will treat them as a hint for future updates.

@thedmd
Copy link
Owner
thedmd commented Dec 18, 2017

@francesco-cattoglio master branch now builds on Windows, macOS and Linux.

@thedmd thedmd closed this as completed Dec 18, 2017
@francesco-cattoglio
Copy link
Author

This is super! I will check it as soon as possible. TY very much for your efforts, I'll keep you posted on any news!

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