Skip to content

Commit

Permalink
NetImgui 1.8 update (#35)
Browse files Browse the repository at this point in the history
* Fixed a few issues

-Prevent client crash when Dear Imgui has 0 draws
-Fixed 32bits Client rendering issues
-Added Dear ImGui 1.87 compatibility test

* Make sure new client connection RT is cleared

Prevents seeing previous client content until 1st DrawCommand is received

* Skip preamble when parsing command line host;port (#25)

* Bug fix for command line parsing including the executable location.

* Add some safety to command line parsing.

* Coverity warning fixes

Fixes some issues found by Coverity static analyser

* Fix to null check & change vertex UV range

* * Fix data race between reading and writing pending textures (#26) (#28)

Signed-off-by: Kostiantyn <kos.chernenok@gmail.com>

* VS2022 warning fixes

* Fix accept thread not getting properly signalled to stop on certain platforms (#33)

* Version update

* *Update DearImGui lib to 1.88 WIP version (#31)

* *Update DearImGui lib to 1.88 WIP version

Remove direct access to obsolete key arrays for version starts from 1.87
Replace ImGui opengl loader by glad

Signed-off-by: Kostiantyn <kos.chernenok@gmail.com>

* *Add back compatibility for keyboard keys transfer between server and client

Signed-off-by: Kostiantyn <k.chernenok@frontpictures.com>

* * Update DearImgui lib to 1879 version

Signed-off-by: Kostiantyn <kos.chernenok@gmail.com>

* * Add debug libs for glfw

- Fix CmdInput for compatibility tests
- Add linking for glfw debug lib
- Update glfw to version 3.3

Signed-off-by: Kostiantyn <k.chernenok@frontpictures.com>

* Some OpenGl build fixes

Also reimported NetImguiServer_App_win32dx11.cpp from latest dear imgui sample main.cpp, makign sure it fits the current backend

* Added NoBackend sample

New Sample demonstrating use of Dear Imgui without any Backend.
-Useful for hardward without display/input.
Refactored the Dear Imgui compatibility test to now be console application trying to connect to NetImguiServer (using NoBackend sample code)
-This allows making sure older Dear ImGui works with current NetImgui (instead of only testing that it compiles)

* Support of the new Dear ImGui in put api

Fixed compatibility with older Dear ImGui version

* Added Gamepad support

* Updated to Dear ImGui 1.88 (docking branch)

* Visual Studio 2022 LLVM build fix

Runtime library switched to DLL

* Center server popup

Center server popup on parent Window when they first appear
Bug fix that prevent server asset copy in post build step

* readme update

Co-authored-by: Jeff <96199164+rtjeffk@users.noreply.github.com>
Co-authored-by: Kostiantyn Chernenok <44094399+lemantisee@users.noreply.github.com>
Co-authored-by: Víctor Popovici <557049+TheAnswer@users.noreply.github.com>
  • Loading branch information
4 people committed Jul 18, 2022
1 parent 8883df5 commit 0f3fc7d
Show file tree
Hide file tree
Showing 61 changed files with 8,540 additions and 3,729 deletions.
10 changes: 5 additions & 5 deletions Build/GenerateCompatibilityTest.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cls
:: SETTINGS
::-----------------------------------------------------------------------------------
:: List of offical Dear ImGui (from official depot)
set VERSIONS=(v1.70 v1.71 v1.72 v1.73 v1.74 v1.75 v1.76 v1.77 v1.78 v1.79, v1.80, v1.81, v1.82, v1.83, v1.84, v1.85, v1.86)
set VERSIONS=(v1.71 v1.72 v1.73 v1.74 v1.75 v1.76 v1.77 v1.78 v1.79, v1.80, v1.81, v1.82, v1.83, v1.84, v1.85, v1.86, v1.87, v1.88)

:: List of custom Dear ImGui releases (from own depot)
set EXTRA_VERSIONS=(dock-1-76, dock-1-80)
Expand Down Expand Up @@ -49,7 +49,7 @@ for %%v in %VERSIONS% do (
echo !IMGUI_FILEPATH!
curl -LJ !IMGUI_FILEPATH! --output !IMGUI_FILE!
tar -xzf !IMGUI_FILE!
del !IMGUI_FILE!
::del !IMGUI_FILE!
echo.
)
for %%v in %EXTRA_VERSIONS% do (
Expand All @@ -71,7 +71,7 @@ type compatibility.sharpmake.cs.1 > %COMPAT_FILE%
:: Declare each compatibility project (1 per Imgui version)
for /D %%d IN (%IMGUI_DIR%\*) DO (
call :GenerateProjectName %%d
echo [Sharpmake.Generate] public class !NetImguiName! : ProjectNetImgui { public !NetImguiName!^(^): base^(@"%%d"^){} } >> %COMPAT_FILE%
echo [Sharpmake.Generate] public class !NetImguiName! : ProjectNoBackend { public !NetImguiName!^(^): base^("!NetImguiName!", @"%%d"^){} } >> %COMPAT_FILE%
)

type compatibility.sharpmake.cs.2 >> %COMPAT_FILE%
Expand All @@ -92,10 +92,10 @@ pause
exit /b %errorlevel%

:: Take a Imgui install path, and make it into a NetImgui project name
:: By keeping only the last direcotory name and removing '-' and '.'
:: By keeping only the last directory name and removing '-' and '.'
:GenerateProjectName
set NetImguiName=%~nx1
set NetImguiName=%NetImguiName:-=_%
set NetImguiName=%NetImguiName:.=_%
set NetImguiName=ProjectNetImgui_%NetImguiName%
set NetImguiName=ProjectCompatibility_%NetImguiName%
exit /b 0
86 changes: 77 additions & 9 deletions Build/netImgui.sharpmake.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ public ProjectNetImguiServer()

//---------------------------------------------
// For the OpenGL Server build
AdditionalSourceRootPaths.Add(NetImguiTarget.GetPath(@"\Code\ThirdParty\gl3w"));
AdditionalSourceRootPaths.Add(NetImguiTarget.GetPath(@"\Code\ThirdParty\glfw\include"));
SourceFilesBuildExcludeRegex.Add(@"ThirdParty\\gl3w\\");
AdditionalSourceRootPaths.Add(NetImguiTarget.GetPath(@"\Code\ThirdParty\glfw\include"));
AdditionalSourceRootPaths.Add(NetImguiTarget.GetPath(@"\Code\ThirdParty\glad30core\include"));
AdditionalSourceRootPaths.Add(NetImguiTarget.GetPath(@"\Code\ThirdParty\glad30core\src"));
SourceFilesBuildExcludeRegex.Add(@"ThirdParty\\glfw\\");
//---------------------------------------------
}
Expand All @@ -72,22 +72,44 @@ public override void ConfigureAll(Configuration conf, NetImguiTarget target)
{
base.ConfigureAll(conf, target);

AddDependencyImguiIndex32(conf, target);
AddDependencyImguiServer(conf, target);
conf.AddPublicDependency<ProjectNetImgui32_Default>(target);

conf.Defines.Add("IS_NETIMGUISERVER=1"); //
conf.Defines.Add("ImTextureID=ImU64"); // Server must absolutly use at minimum 64bits texture id, even when compiled in 32 bits

conf.IncludePaths.Add(SourceRootPath + @"\Source");
conf.IncludePaths.Add(NetImguiTarget.GetPath(ProjectImgui.sDefaultPath));
conf.IncludePaths.Add(NetImguiTarget.GetPath(@"\Code\Client"));

//---------------------------------------------
// For the OpenGL Server build
conf.IncludePaths.Add(NetImguiTarget.GetPath(@"\Code\ThirdParty\gl3w"));
conf.IncludePaths.Add(NetImguiTarget.GetPath(@"\Code\ThirdParty\glfw\include"));
if( target.DevEnv == DevEnv.vs2019 ) conf.LibraryPaths.Add(NetImguiTarget.GetPath(@"\Code\ThirdParty\glfw\lib-vc2019-64"));
else if( target.DevEnv == DevEnv.vs2017 ) conf.LibraryPaths.Add(NetImguiTarget.GetPath(@"\Code\ThirdParty\glfw\lib-vc2017-64"));
conf.LibraryPaths.Add(NetImguiTarget.GetPath(@"\Code\ThirdParty\glfw\" + getGlfwLibName(target.Platform, target.DevEnv)));
conf.Options.Add(new Options.Vc.Linker.DisableSpecificWarnings("4099")); //Prevents: warning LNK4099: PDB '' was not found with 'glfw3_mtd.lib(context.c.obj)' or at ''; linking object as if no debug info
//---------------------------------------------

conf.EventPostBuild.Add(@"xcopy " + NetImguiTarget.GetPath(@"\Code\ServerApp\Background.png") + " " + conf.TargetPath + " /D /Y");
conf.EventPostBuild.Add("xcopy \"" + NetImguiTarget.GetPath(@"\Code\ServerApp\Background.png") + "\" \"" + conf.TargetPath + "\" /D /Y");
}

private string getGlfwLibName(Platform platform, DevEnv developerEnv)
{
string libName = "lib";
if( developerEnv == DevEnv.vs2022 ){
libName += "-vc2022";
} else if( developerEnv == DevEnv.vs2019 ) {
libName += "-vc2019";
} else if( developerEnv == DevEnv.vs2017 ) {
libName += "-vc2017";
}

if (platform == Platform.win64) {
libName += "-64";
} else if (platform == Platform.win32) {
libName += "-32";
}

return libName;
}
}

Expand Down Expand Up @@ -152,6 +174,23 @@ public override void ConfigureAll(Configuration conf, NetImguiTarget target)
}
}

//-------------------------------------------------------------------------
// This sample does not have a UI Window, only show a console and wait
// for a connection to NetImguiServer. when connected, Display its
// Dear ImGui content normally, on the remote server.
// Usefull to demonstrate being able to use NetImgui without even needing to
// implement a Backend support (windows / renderer / input) on the client.
// It also compiles the Dear ImGui/NetImgui sources directly
//-------------------------------------------------------------------------
[Sharpmake.Generate]
public class ProjectSample_NoBackend : ProjectNoBackend
{
public ProjectSample_NoBackend()
: base("SampleNoBackend","")
{
}
}

//
[Sharpmake.Generate]
public class ProjectSample_Compression : ProjectBase
Expand Down Expand Up @@ -183,6 +222,33 @@ public override void ConfigureAll(Configuration conf, NetImguiTarget target)
}
}

//
[Sharpmake.Generate]
public class ProjectSample_SampleCompatibility : ProjectBase
{
// This sample does not includes the Dear Imgui or NetImgui Library included.
// They are instead compiled inside this project. This allows to test various
// older version of Dear ImGui against our NetImgui Server compiled
// with latest version
public ProjectSample_SampleCompatibility()
: base(true)
{
Name = "Compatibility";
SourceRootPath = NetImguiTarget.GetPath(@"\Code\Sample\SampleCompatibility");
SourceFiles.Add(@"C:\GitHub\NetImguiDev\Build\..\_generated\imgui\imgui-1.88\*.cpp");
SourceFiles.Add(@"C:\GitHub\NetImguiDev\Build\..\_generated\imgui\imgui-1.88\*.h");
}

public override void ConfigureAll(Configuration conf, NetImguiTarget target)
{
base.ConfigureAll(conf, target);
conf.IncludePaths.Add(@"C:\GitHub\NetImguiDev\Build\..\_generated\imgui\imgui-1.88\");
conf.IncludePaths.Add(NetImguiTarget.GetPath(@"\Code\Client"));

conf.Options.Add(Options.Vc.Linker.SubSystem.Console);

}
}

//=============================================================================================
// SOLUTIONS
Expand Down Expand Up @@ -211,7 +277,9 @@ public static void AddSampleProjects(Configuration conf, NetImguiTarget target)
conf.AddProject<ProjectSample_Index32Bits>(target, false, SolutionFolder);
conf.AddProject<ProjectSample_Disabled>(target, false, SolutionFolder);
conf.AddProject<ProjectSample_SingleInclude>(target, false, SolutionFolder);
// Adding an already auto included dependcy, so it can be moved to more appropriate folder
conf.AddProject<ProjectSample_NoBackend>(target, false, SolutionFolder);

// Adding an already auto included dependency, so it can be moved to more appropriate folder
conf.AddProject<ProjectNetImgui_Disabled>(target, false, "CompatibilityTest");
}
}
Expand Down
88 changes: 81 additions & 7 deletions Build/shared.sharpmake.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ public class NetImguiTarget : ITarget
public NetImguiTarget()
{
DevEnv = DevEnv.vs2019;
Platform = Platform.win64;
Platform = Platform.win64 | Platform.win32;
Optimization = Optimization.Debug | Optimization.Release;
Compiler = Compiler.MSBuild | Compiler.Clang;
}

// Generates a solution for each Visual Studio version found
// Note: Add a Clang target when detected isntalled for that Visual Studio version
// Note: Add a Clang target when detected installed for that Visual Studio version
static public NetImguiTarget[] CreateTargets()
{
List<NetImguiTarget> targets = new List<NetImguiTarget>();
Expand Down Expand Up @@ -175,6 +175,11 @@ public virtual void ConfigureAll(Configuration conf, NetImguiTarget target)
conf.Defines.Add("_HAS_EXCEPTIONS=0"); // Prevents error in VisualStudio c++ library with NoExcept, like xlocale
conf.Defines.Add("IMGUI_DISABLE_OBSOLETE_FUNCTIONS"); // Enforce using up to date Dear ImGui Api (In Server, Compatibility tests and Samples)

if (target.Optimization == Optimization.Debug)
conf.Options.Add(Options.Vc.Compiler.RuntimeLibrary.MultiThreadedDebugDLL);
else
conf.Options.Add(Options.Vc.Compiler.RuntimeLibrary.MultiThreadedDLL);

if( target.Compiler == Compiler.MSBuild ){
conf.Options.Add(new Options.Vc.Compiler.DisableSpecificWarnings(""));
conf.Options.Add(Options.Vc.Librarian.TreatLibWarningAsErrors.Enable); //Note: Clang VS2019 doesn't support this option properly
Expand Down Expand Up @@ -202,6 +207,12 @@ public void AddDependencyImguiIndex32(Configuration conf, NetImguiTarget target)
EnabledImguiIndex32Bits(conf);
}

public void AddDependencyImguiServer(Configuration conf, NetImguiTarget target)
{
conf.AddPublicDependency<ProjectImguiServer>(target);
EnabledImguiIndex32Bits(conf);
}

public void EnabledImguiIndex16Bits(Configuration conf)
{
}
Expand Down Expand Up @@ -256,6 +267,20 @@ public override void ConfigureAll(Configuration conf, NetImguiTarget target)
}
}

// Dear ImGui Library, 32bits index & 64 bits textureID
[Sharpmake.Generate]
public class ProjectImguiServer : ProjectImgui
{
public ProjectImguiServer() { Name = "DearImguiServerLib"; }

public override void ConfigureAll(Configuration conf, NetImguiTarget target)
{
base.ConfigureAll(conf, target);
conf.Defines.Add("ImTextureID=ImU64"); // Server must absolutly use at minimum 64bits texture id, even when compiled in 32 bits
EnabledImguiIndex32Bits(conf);
}
}

//---------------------------------------------------------------------------------------------
// NETIMGUI Project
//---------------------------------------------------------------------------------------------
Expand All @@ -265,10 +290,10 @@ public class ProjectNetImgui : ProjectBase
public ProjectNetImgui(string imguiFullPath)
: base(false)
{
mVersion = Path.GetFileName(imguiFullPath);
mImguiPath = imguiFullPath;
Name = "NetImguiLib (" + mVersion + ")";
SourceRootPath = NetImguiTarget.GetPath(@"\Code\Client");
mVersion = Path.GetFileName(imguiFullPath);
mImguiPath = imguiFullPath;
Name = "NetImguiLib (" + mVersion + ")";
SourceRootPath = NetImguiTarget.GetPath(@"\Code\Client");
SourceFiles.Add(mImguiPath + @"\imgui.h");
}

Expand Down Expand Up @@ -308,12 +333,61 @@ public override void ConfigureAll(Configuration conf, NetImguiTarget target)
AddDependencyImguiIndex32(conf, target);
conf.AddPublicDependency<ProjectNetImgui32_Default>(target);
}
conf.IncludePaths.Add(ProjectImgui.sDefaultPath);
conf.IncludePaths.Add(NetImguiTarget.GetPath(ProjectImgui.sDefaultPath));
conf.IncludePaths.Add(NetImguiTarget.GetPath(@"\Code\Client"));
}
bool mUseIndex32;
}

// Compile a console program, with Dear ImGui and NetImgui sources
// included directly. The Dear ImGui code does not include any backend,
// only try connecting the the NetImgui Server to draw its content remotely.
[Sharpmake.Generate]
public class ProjectNoBackend : ProjectBase
{
public ProjectNoBackend(string inName, string inImguiFullPath)
: base(true)
{
mImguiFullPath = string.IsNullOrEmpty(inImguiFullPath) ? NetImguiTarget.GetPath(ProjectImgui.sDefaultPath) : inImguiFullPath;
Name = inName;
SourceRootPath = NetImguiTarget.GetPath(@"\Code\Sample\SampleNoBackend");

// Find the Dear Imgui Sources files
string[] sourceExtensions = new string[]{".h",".cpp"};
var files = Directory.EnumerateFiles(mImguiFullPath, "*.*", SearchOption.TopDirectoryOnly);
foreach (var file in files)
{
if (sourceExtensions.Contains(Path.GetExtension(file), StringComparer.OrdinalIgnoreCase)){
//Console.WriteLine("File Added: {0}", Path.GetFullPath(file));
SourceFiles.Add(Path.GetFullPath(file));
}
};
}

public override void ConfigureAll(Configuration conf, NetImguiTarget target)
{
base.ConfigureAll(conf, target);
conf.IncludePaths.Add(mImguiFullPath);
conf.IncludePaths.Add(NetImguiTarget.GetPath(@"\Code\Client"));
conf.Options.Add(Options.Vc.Linker.SubSystem.Console);
conf.LibraryFiles.Add("ws2_32.lib");

// Remove a some Dear ImGui sources compile warning
if( target.Compiler == Compiler.MSBuild ){
conf.Options.Add(new Options.Vc.Compiler.DisableSpecificWarnings("4100")); // warning C4100: xxx: unreferenced formal parameter
conf.Options.Add(new Options.Vc.Compiler.DisableSpecificWarnings("4189")); // warning C4189: xxx: unused local variable
}
else if ( target.Compiler == Compiler.Clang ){
conf.Options.Add(Options.Vc.General.PlatformToolset.ClangCL);
conf.AdditionalCompilerOptions.Add("-Wno-unknown-warning-option");
conf.AdditionalCompilerOptions.Add("-Wno-unused-parameter");
conf.AdditionalCompilerOptions.Add("-Wno-unused-variable");
conf.AdditionalCompilerOptions.Add("-Wno-unused-but-set-variable");
}
}
string mImguiFullPath;
}

//=============================================================================================
// SOLUTIONS
//=============================================================================================
Expand Down
28 changes: 17 additions & 11 deletions Code/Client/NetImgui_Api.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@
//! @Name : NetImgui
//=================================================================================================
//! @author : Sammy Fatnassi
//! @date : 2022/01/31
//! @version : v1.7.5
//! @date : 2022/06/19
//! @version : v1.7.7
//! @Details : For integration info : https://github.com/sammyfreg/netImgui/wiki
//=================================================================================================
#define NETIMGUI_VERSION "1.7.5"
#define NETIMGUI_VERSION_NUM 10705
#define NETIMGUI_VERSION "1.7.7"
#define NETIMGUI_VERSION_NUM 10707



#ifdef NETIMGUI_IMPLEMENTATION
#define NETIMGUI_INTERNAL_INCLUDE
#endif

//-------------------------------------------------------------------------------------------------
// Deactivate a few warnings to allow Imgui header include
Expand All @@ -23,7 +21,9 @@
#if defined (__clang__)
#pragma clang diagnostic push
// ImGui.h warnings(s)
#pragma clang diagnostic ignored "-Wunknown-warning-option"
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
#pragma clang diagnostic ignored "-Wreserved-identifier" // Enuma values using '__' or member starting with '_' in imgui.h
// NetImgui_Api.h Warning(s)
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" // Not using nullptr in case this file is used in pre C++11
#elif defined(_MSC_VER)
Expand All @@ -40,7 +40,14 @@
// 'imgui.h' : always
// 'imgui_internal.h' when 'NETIMGUI_INTERNAL_INCLUDE' is defined
//=================================================================================================
#include "NetImgui_Config.h"
#ifdef NETIMGUI_IMPLEMENTATION
#define NETIMGUI_INTERNAL_INCLUDE
#include "NetImgui_Config.h"
#undef NETIMGUI_INTERNAL_INCLUDE
#else
#include "NetImgui_Config.h"
#endif


//-------------------------------------------------------------------------------------------------
// If 'NETIMGUI_ENABLED' hasn't been defined yet (in project settings or NetImgui_Config.h')
Expand Down Expand Up @@ -161,8 +168,8 @@ NETIMGUI_API bool IsDrawingRemote(void);
NETIMGUI_API void SendDataTexture(ImTextureID textureId, void* pData, uint16_t width, uint16_t height, eTexFormat format);

//=================================================================================================
// Start a new Imgui Frame and wait for Draws commands, using a ImGui created internally
// for remote drawing. Returns true if we are awaiting a new ImGui frame.
// Start a new Imgui Frame and wait for Draws commands, using ImContext that was active on connect.
// Returns true if we are awaiting a new ImGui frame.
//
// All ImGui drawing should be skipped when return is false.
//
Expand Down Expand Up @@ -223,7 +230,6 @@ NETIMGUI_API uint32_t GetTexture_BytePerImage (eTexFormat eFormat, uint32_t pi
#include "Private/NetImgui_NetworkPosix.cpp"
#include "Private/NetImgui_NetworkUE4.cpp"
#include "Private/NetImgui_NetworkWin32.cpp"
#undef NETIMGUI_INTERNAL_INCLUDE
#endif

#endif // NETIMGUI_ENABLED
Expand Down
Loading

0 comments on commit 0f3fc7d

Please sign in to comment.