Skip to content

Commit e986632

Browse files
committed
Added support for new Dear ImGui 1.92 textures (with its improved font atlas)
This is the cumulative work submitted to the 'Task_NewImguiFont' branch and adding support for the new Dear ImGui managed textures support as of 1.92. This is used by Dear ImGui to update the font atlas texture when blitting only the needed characters, but also supports user adding their own textures to it. 2 NetImgui samples have been removed (DualUI and DPI) since the first one isn't supported anymore, and the second one became mooth with improved font that now support remote and local DPI without needing user to code anything. Need to finish adapting the NetImguiServer OpenGL and Sokol backend to work with this. ------------------------------ commit 9523152 Author: Sammy Fatnassi <sammyfreg@gmail.com> Date: Tue Dec 30 20:07:56 2025 -0500 Fix for Server font resize crash commit c8220b6 Merge: 06b1704 d29d6a0 Author: Sammy Fatnassi <sammyfreg@gmail.com> Date: Tue Dec 30 17:35:16 2025 -0500 Merge branch 'Task_NewImguiFont' of https://github.com/sammyfreg/netImgui into Task_NewImguiFont commit 06b1704 Author: Sammy Fatnassi <sammyfreg@gmail.com> Date: Tue Dec 30 17:34:33 2025 -0500 Ongoing work on texture refactor Almost no issues left (need to fix server fotn resize crash). A lot of cleanup. commit d29d6a0 Author: Sammy Fatnassi <sammyfreg@gmail.com> Date: Tue Dec 30 17:34:33 2025 -0500 Ongoing work on texture refactor Almost no issues left (need to fix server fotn resize crash). A lot of cleanup. commit 7394136 Author: Sammy Fatnassi <sammyfreg@gmail.com> Date: Sat Dec 27 13:23:46 2025 -0500 Updated Sample Texture to test multiple partial updates on a texture in same frame commit ab52994 Author: Sammy Fatnassi <sammyfreg@gmail.com> Date: Fri Dec 26 20:19:58 2025 -0500 Fix for win32 sample crash commit ad1a253 Author: Sammy Fatnassi <sammyfreg@gmail.com> Date: Tue Dec 23 20:25:13 2025 -0500 Removed the FontDPI sample and fixed some compatibility errors With the new Dear ImGui font texture handling, there's no need anymore to regenerate the texture and use callbacks, everything is now seamless, so I removed the Sample. Also fixed some older Dear ImGui compatibilities errors. commit 15fb869 Author: Sammy Fatnassi <sammyfreg@gmail.com> Date: Tue Dec 23 13:42:19 2025 -0500 Functional support for new Dear ImGui texture Most things now seem to work, all but one samples are fully functional. DPI sample is currently disabled, needs to have it handle the new font scaling properly, and add a sample to test old style too. commit 33493fc Author: Sammy Fatnassi <sammyfreg@gmail.com> Date: Fri Dec 19 17:51:49 2025 -0500 Support for texture update in Need to fix texture deletion proper release commit c680bdb Author: Sammy Fatnassi <sammyfreg@gmail.com> Date: Fri Jul 11 17:41:55 2025 -0400 Support Server window DPI Scale when drawing client commit 3ee5e29 Author: Sammy Fatnassi <sammyfreg@gmail.com> Date: Mon Jul 7 20:23:04 2025 -0400 Updated Dear ImGui to 1.92 Lots of changes to support dynamic font and texture update. This is a first pass where most things compiles, but things are far from fully functional. Still need to : -Handle texture partial updates -Handle Server DPI setting application on client -Fix all samples to work properly commit cf65167 Author: Sammy Fatnassi <sammyfreg@gmail.com> Date: Mon Mar 10 19:42:19 2025 -0400 New Font Texture Update support Initial support, with some issue (texture management, font scaling, etc...) and cleanup left to do commit 9b9b465 Author: Sammy Fatnassi <sammyfreg@gmail.com> Date: Sat Dec 28 10:30:39 2024 -0500 Font Atlas rework 1st version with remote display working with new font atlas update support. Unreliable and messy commit cf3de75 Author: Sammy Fatnassi <sammyfreg@gmail.com> Date: Sun Dec 15 18:32:51 2024 -0500 Fixed NetImguiServer to run with new Dear ImGui branch Temp disabling docking features Client do not render yet commit 697bb86 Author: Sammy Fatnassi <sammyfreg@gmail.com> Date: Sat Dec 14 14:26:08 2024 -0500 Updated to experimental font branch Updated Dear ImGui to experiemental font gen branch, and made sure Sample can run NetImgui textures not functional yet.
1 parent 1451235 commit e986632

71 files changed

Lines changed: 12871 additions & 8049 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Build/netImgui.sharpmake.cs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,31 @@ namespace NetImgui
1313
// PROJECTS
1414
//=============================================================================================
1515
// Generate the default Imgui/netImgui Libraries (used to link against with Samples/Server)
16-
[Sharpmake.Generate] public class ProjectNetImgui16_Default : ProjectNetImgui
16+
[Sharpmake.Generate] public class ProjectNetImgui16_Default : ProjectNetImgui
1717
{
1818
public ProjectNetImgui16_Default() : base(NetImguiTarget.GetPath(ProjectImgui.sDefaultPath)) { Name = "NetImgui16Lib"; }
19+
20+
public override void ConfigureAll(Configuration conf, NetImguiTarget target)
21+
{
22+
base.ConfigureAll(conf, target);
23+
conf.Defines.Add("NETIMGUI_ENABLED=1");
24+
}
1925
}
2026

21-
[Sharpmake.Generate] public class ProjectNetImgui32_Default : ProjectNetImgui
27+
[Sharpmake.Generate] public class ProjectNetImgui32_Default : ProjectNetImgui
2228
{
2329
public ProjectNetImgui32_Default() : base(NetImguiTarget.GetPath(ProjectImgui.sDefaultPath)) { Name = "NetImgui32Lib"; }
2430

2531
public override void ConfigureAll(Configuration conf, NetImguiTarget target)
2632
{
2733
base.ConfigureAll(conf, target);
2834
conf.Defines.Add("ImDrawIdx=unsigned int");
29-
}
35+
conf.Defines.Add("NETIMGUI_ENABLED=1");
36+
}
3037
}
3138

3239
// Test compiling netImgui with the Disabled Define
33-
[Sharpmake.Generate] public class ProjectNetImgui_Disabled : ProjectNetImgui
40+
[Sharpmake.Generate] public class ProjectNetImgui_Disabled : ProjectNetImgui
3441
{
3542
public ProjectNetImgui_Disabled() : base(NetImguiTarget.GetPath(ProjectImgui.sDefaultPath)) { Name = "NetImguiLib (Disabled)"; }
3643

@@ -64,7 +71,7 @@ public ProjectNetImguiServer()
6471
// For the OpenGL Server build
6572
AdditionalSourceRootPaths.Add(NetImguiTarget.GetPath(@"\Code\ThirdParty\glfw\include"));
6673
AdditionalSourceRootPaths.Add(NetImguiTarget.GetPath(@"\Code\ThirdParty\glad30core\include"));
67-
AdditionalSourceRootPaths.Add(NetImguiTarget.GetPath(@"\Code\ThirdParty\glad30core\src"));
74+
AdditionalSourceRootPaths.Add(NetImguiTarget.GetPath(@"\Code\ThirdParty\glad30core\src"));
6875
SourceFilesBuildExcludeRegex.Add(@"ThirdParty\\glfw\\");
6976
//---------------------------------------------
7077
}
@@ -77,7 +84,7 @@ public override void ConfigureAll(Configuration conf, NetImguiTarget target)
7784
conf.AddPublicDependency<ProjectNetImgui32_Default>(target);
7885

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

8289
conf.IncludePaths.Add(SourceRootPath + @"\Source");
8390
conf.IncludePaths.Add(NetImguiTarget.GetPath(ProjectImgui.sDefaultPath));
@@ -149,8 +156,6 @@ public override void ConfigureAll(Configuration conf, NetImguiTarget target)
149156
// Standard samples
150157
//-------------------------------------------------------------------------
151158
[Sharpmake.Generate] public class ProjectSample_Basic : ProjectSample { public ProjectSample_Basic() : base("SampleBasic"){} }
152-
[Sharpmake.Generate] public class ProjectSample_FontDPI : ProjectSample { public ProjectSample_FontDPI() : base("SampleFontDPI"){} }
153-
[Sharpmake.Generate] public class ProjectSample_DualUI : ProjectSample { public ProjectSample_DualUI() : base("SampleDualUI"){} }
154159
[Sharpmake.Generate] public class ProjectSample_Textures : ProjectSample { public ProjectSample_Textures() : base("SampleTextures"){} }
155160
[Sharpmake.Generate] public class ProjectSample_NewFrame : ProjectSample { public ProjectSample_NewFrame() : base("SampleNewFrame"){} }
156161
[Sharpmake.Generate] public class ProjectSample_Background : ProjectSample { public ProjectSample_Background() : base("SampleBackground"){} }
@@ -279,8 +284,6 @@ public static void AddSampleProjects(Configuration conf, NetImguiTarget target)
279284
{
280285
string SolutionFolder = "Samples";
281286
conf.AddProject<ProjectSample_Basic>(target, false, SolutionFolder);
282-
conf.AddProject<ProjectSample_FontDPI>(target, false, SolutionFolder);
283-
conf.AddProject<ProjectSample_DualUI>(target, false, SolutionFolder);
284287
conf.AddProject<ProjectSample_NewFrame>(target, false, SolutionFolder);
285288
conf.AddProject<ProjectSample_Compression>(target, false, SolutionFolder);
286289
conf.AddProject<ProjectSample_Textures>(target, false, SolutionFolder);
@@ -329,4 +332,4 @@ public static void SharpmakeMain(Sharpmake.Arguments arguments)
329332
arguments.Generate<SolutionSample>();
330333
}
331334
}
332-
}
335+
}

Build/shared.sharpmake.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,13 @@ public ProjectImgui()
244244
SourceRootPath = NetImguiTarget.GetPath(sDefaultPath);
245245
SourceFilesExcludeRegex.Add(@"backends\.*");
246246
}
247-
247+
248+
public override void ConfigureAll(Configuration conf, NetImguiTarget target)
249+
{
250+
base.ConfigureAll(conf, target);
251+
conf.IncludePaths.Add(NetImguiTarget.GetPath(sDefaultPath));
252+
}
253+
248254
public static string sDefaultPath = @"\Code\ThirdParty\DearImgui";
249255
}
250256

@@ -263,7 +269,7 @@ public override void ConfigureAll(Configuration conf, NetImguiTarget target)
263269

264270
// Dear ImGui Library, 32bits index
265271
[Sharpmake.Generate]
266-
public class ProjectImguiIndex32 : ProjectImgui
272+
public class ProjectImguiIndex32 : ProjectImgui
267273
{
268274
public ProjectImguiIndex32() { Name = "DearImguiIndex32Lib"; }
269275

@@ -283,7 +289,7 @@ public class ProjectImguiServer : ProjectImgui
283289
public override void ConfigureAll(Configuration conf, NetImguiTarget target)
284290
{
285291
base.ConfigureAll(conf, target);
286-
conf.Defines.Add("ImTextureID=ImU64"); // Server must absolutly use at minimum 64bits texture id, even when compiled in 32 bits
292+
conf.Defines.Add("ImTextureUserID=ImU64"); // Server must absolutly use at minimum 64bits texture id, even when compiled in 32 bits
287293
EnabledImguiIndex32Bits(conf);
288294
}
289295
}

Code/Client/NetImgui_Api.h

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44
//! @Name : NetImgui
55
//=================================================================================================
66
//! @author : Sammy Fatnassi
7-
//! @date : 2024/12/10
8-
//! @version : v1.12.1
7+
//! @date : 2026/01/01
8+
//! @version : v1.12.3
99
//! @Details : For integration info : https://github.com/sammyfreg/netImgui/wiki
1010
//=================================================================================================
11-
#define NETIMGUI_VERSION "1.12.1" // Fixed disconnect thread contention and clipboard command
12-
#define NETIMGUI_VERSION_NUM 11201
13-
14-
11+
#define NETIMGUI_VERSION "1.12.3" // Imported Texture rework into dev branch
12+
#define NETIMGUI_VERSION_NUM 11203
1513

1614

1715
//-------------------------------------------------------------------------------------------------
@@ -53,7 +51,7 @@
5351
// we define this library as 'Disabled'
5452
//-------------------------------------------------------------------------------------------------
5553
#ifndef NETIMGUI_ENABLED
56-
#define NETIMGUI_ENABLED 0
54+
#define NETIMGUI_ENABLED 0
5755
#endif
5856

5957
//-------------------------------------------------------------------------------------------------
@@ -63,7 +61,19 @@
6361
//-------------------------------------------------------------------------------------------------
6462
#if !defined(IMGUI_VERSION)
6563
#undef NETIMGUI_ENABLED
66-
#define NETIMGUI_ENABLED 0
64+
#define NETIMGUI_ENABLED 0
65+
#endif
66+
67+
//-------------------------------------------------------------------------------------------------
68+
// Control support for native Dear ImGui texture backend support
69+
// At the moment, meant to always be active on recent Dear Imgui version (1.92+)
70+
//-------------------------------------------------------------------------------------------------
71+
#ifndef NETIMGUI_IMGUI_TEXTURES_ENABLED
72+
#ifdef IMGUI_HAS_TEXTURES
73+
#define NETIMGUI_IMGUI_TEXTURES_ENABLED 1
74+
#else
75+
#define NETIMGUI_IMGUI_TEXTURES_ENABLED 0
76+
#endif
6777
#endif
6878

6979
#if NETIMGUI_ENABLED
@@ -74,20 +84,19 @@
7484
// Default Build settings defines values
7585
// Assign default values when not set in user NetImgui_Config.h
7686
//=================================================================================================
77-
7887
//-------------------------------------------------------------------------------------------------
7988
// Prepended to functions signature, for dll export/import
8089
//-------------------------------------------------------------------------------------------------
8190
#ifndef NETIMGUI_API
82-
#define NETIMGUI_API IMGUI_API // Use same value as defined by Dear ImGui by default
91+
#define NETIMGUI_API IMGUI_API // Use same value as defined by Dear ImGui by default
8392
#endif
8493

8594
//-------------------------------------------------------------------------------------------------
8695
// Enable TCP socket 'reuse port' option when opening it as a 'listener'.
8796
// Note: Can help when unable to open a socket because it wasn't properly released after a crash.
8897
//-------------------------------------------------------------------------------------------------
8998
#ifndef NETIMGUI_FORCE_TCP_LISTEN_BINDING
90-
#define NETIMGUI_FORCE_TCP_LISTEN_BINDING 0 // Doesn't seem to be needed on Window/Linux
99+
#define NETIMGUI_FORCE_TCP_LISTEN_BINDING 0 // Doesn't seem to be needed on Window/Linux
91100
#endif
92101

93102
//-------------------------------------------------------------------------------------------------
@@ -102,24 +111,17 @@
102111
#define NETIMGUI_IMGUI_CALLBACK_ENABLED (IMGUI_VERSION_NUM >= 18100) // Not supported pre Dear ImGui 1.81
103112
#endif
104113

105-
// Temporary code to support the new Font Texture Update
106-
// Very inneficient, this is a stop gap measure until
107-
// the partial texture update support is finished in NetImgui
108-
#ifdef IMGUI_HAS_TEXTURES
109-
#define NETIMGUI_FONTUPDATE_TEMP_WORKAROUND 1
110-
#else
111-
#define NETIMGUI_FONTUPDATE_TEMP_WORKAROUND 0
112-
#endif
113-
114114
namespace NetImgui
115115
{
116116

117117
//=================================================================================================
118118
// List of texture format supported
119119
//=================================================================================================
120120
enum eTexFormat {
121-
kTexFmtA8,
121+
// Match Dear Imgui 1.92 'ImTextureFormat'
122122
kTexFmtRGBA8,
123+
kTexFmtA8,
124+
123125

124126
// Support of 'user defined' texture format.
125127
// Implementation must be added on both client and Server code.
@@ -176,6 +178,7 @@ NETIMGUI_API void Shutdown();
176178
// the font atlas, because of a monitor DPI change. When left to nullptr,
177179
// uses 'ImGuiIO.FontGlobalScale' instead to increase text size,
178180
// with blurier results.
181+
// NOTE: Not used by Dear ImGui 1.92+, unneeded with font update support.
179182
//=================================================================================================
180183
NETIMGUI_API bool ConnectToApp(const char* clientName, const char* serverHost, uint32_t serverPort=kDefaultServerPort, ThreadFunctPtr threadFunction=0, FontCreateFuncPtr FontCreateFunction=0);
181184
NETIMGUI_API bool ConnectFromApp(const char* clientName, uint32_t clientPort=kDefaultClientPort, ThreadFunctPtr threadFunction=0, FontCreateFuncPtr fontCreateFunction=0);
@@ -211,8 +214,10 @@ NETIMGUI_API bool IsDrawingRemote(void);
211214
//=================================================================================================
212215
// Send an updated texture used by imgui, to the NetImguiServer application
213216
// Note: To remove a texture, set pData to nullptr
214-
// Note: User needs to provide a valid 'dataSize' when using format 'kTexFmtCustom',
217+
// Note: User needs to provide a valid 'dataSize' when using format 'kTexFmtCustom',
215218
// can be ignored otherwise
219+
// Note: Can now rely on native Dear ImGui managed texture support to let the system handle their
220+
// creation/update/destruction automatically (since Dear ImGui 1.92+. See 'SampleTextures').
216221
//=================================================================================================
217222
NETIMGUI_API void SendDataTexture(ImTextureID textureId, void* pData, uint16_t width, uint16_t height, eTexFormat format, uint32_t dataSize=0);
218223

@@ -251,6 +256,9 @@ NETIMGUI_API ImGuiContext* GetContext();
251256
NETIMGUI_API void SetBackground(const ImVec4& bgColor);
252257
NETIMGUI_API void SetBackground(const ImVec4& bgColor, const ImVec4& textureTint );
253258
NETIMGUI_API void SetBackground(const ImVec4& bgColor, const ImVec4& textureTint, ImTextureID bgTextureID);
259+
#if NETIMGUI_IMGUI_TEXTURES_ENABLED
260+
NETIMGUI_API void SetBackground(const ImVec4& bgColor, const ImVec4& textureTint, const ImTextureRef& bgTextureRef);
261+
#endif
254262

255263
//=================================================================================================
256264
// Control the data compression for communications between Client/Server
@@ -264,7 +272,7 @@ NETIMGUI_API eCompressionMode GetCompressionMode();
264272
NETIMGUI_API uint8_t GetTexture_BitsPerPixel (eTexFormat eFormat);
265273
NETIMGUI_API uint32_t GetTexture_BytePerLine (eTexFormat eFormat, uint32_t pixelWidth);
266274
NETIMGUI_API uint32_t GetTexture_BytePerImage (eTexFormat eFormat, uint32_t pixelWidth, uint32_t pixelHeight);
267-
}
275+
}
268276

269277
//=================================================================================================
270278
// Optional single include compiling option

0 commit comments

Comments
 (0)