VR-Forces 5.0.3 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
NetImgui_Api.h
Go to the documentation of this file.
1 #pragma once
2 // VRV_PATCH
3 // minor changes to support exporting of symbols and hiding "private" header files
4 
5 //=================================================================================================
7 //=================================================================================================
12 //=================================================================================================
13 #define NETIMGUI_VERSION "1.7.0"
14 #define NETIMGUI_VERSION_NUM 10700
15 
16 #include <stdint.h>
17 //#include "Private/NetImgui_WarningDisable.h"
18 
19 #ifdef NETIMGUI_IMPLEMENTATION
20  #define NETIMGUI_INTERNAL_INCLUDE
21 #endif
22 #include "NetImgui_Config.h"
23 #ifdef NETIMGUI_IMPLEMENTATION
24  #undef NETIMGUI_INTERNAL_INCLUDE
25 #endif
26 
27 //=================================================================================================
28 // If 'NETIMGUI_ENABLED' hasn't been defined yet (in project settings or NetImgui_Config.h')
29 // we define this library as 'Disabled'
30 //=================================================================================================
31 #if !defined(NETIMGUI_ENABLED)
32  #define NETIMGUI_ENABLED 0
33 #endif
34 
35 // NetImgui needs to detect Dear ImGui to be active, otherwise we disable it
36 #if !defined(IMGUI_VERSION)
37  #undef NETIMGUI_ENABLED
38  #define NETIMGUI_ENABLED 0
39 #endif
40 
41 //=================================================================================================
42 // List of texture format supported
43 //=================================================================================================
44 #if NETIMGUI_ENABLED
45 namespace NetImgui
46 {
47 enum class eTexFormat : uint8_t {
48  kTexFmtA8,
49  kTexFmtRGBA8,
50  kTexFmt_Count,
51  kTexFmt_Invalid=kTexFmt_Count
52 };
53 
54 //=================================================================================================
55 // Data Compression wanted status
56 //=================================================================================================
57 enum class eCompressionMode : uint8_t {
58  kForceDisable, // Disable data compression for communications
59  kForceEnable, // Enable data compression for communications
60  kUseServerSetting // Use Server setting for compression (default)
61 };
62 
63 typedef void ThreadFunctPtr(void threadedFunction(void* pClientInfo), void* pClientInfo) ;
64 
65 //=================================================================================================
66 // Initialize the Network Library
67 //=================================================================================================
68 IMGUI_API bool Startup(void);
69 
70 //=================================================================================================
71 // Free Resources
72 //-------------------------------------------------------------------------------------------------
73 // bWait : Wait until all communication threads have terminated before returning
74 //=================================================================================================
75 IMGUI_API void Shutdown(bool bWait);
76 
77 //=================================================================================================
78 // Try to establish a connection to NetImgui server application.
79 //
80 // Can establish connection with netImgui Server application by either reaching it directly
81 // using 'ConnectToApp' or waiting for Server to reach us after Client called 'ConnectFromApp'.
82 //
83 // Note: Start a new communication thread using std::Thread by default, but can receive custom
84 // thread start function instead (Look at ClientExample 'CustomCommunicationThread').
85 //-------------------------------------------------------------------------------------------------
86 // clientName : Named that will be displayed on the Server, for this Client
87 // serverHost : Address of the netImgui Server application (Ex1: 127.0.0.2, Ex2: localhost)
88 // serverPort : PortID of the netImgui Server application to connect to
89 // clientPort : PortID this Client should wait for connection from Server application
90 // threadFunction : User provided function to launch new networking thread.
91 // Use 'DefaultStartCommunicationThread' by default, relying on 'std::thread'.
92 //=================================================================================================
93 IMGUI_API bool ConnectToApp(const char* clientName, const char* serverHost, uint32_t serverPort=kDefaultServerPort, ThreadFunctPtr threadFunction=nullptr);
94 IMGUI_API bool ConnectFromApp(const char* clientName, uint32_t clientPort=kDefaultClientPort, ThreadFunctPtr threadFunction = nullptr);
95 
96 //=================================================================================================
97 // Request a disconnect from the netImguiApp server
98 //=================================================================================================
99 IMGUI_API void Disconnect(void);
100 
101 //=================================================================================================
102 // True if connected to netImguiApp server
103 //=================================================================================================
104 IMGUI_API bool IsConnected(void);
105 
106 //=================================================================================================
107 // True if connection request is waiting to be completed. For example, while waiting for
108 // Server to reach ud after having called 'ConnectFromApp()'
109 //=================================================================================================
110 IMGUI_API bool IsConnectionPending(void);
111 
112 //=================================================================================================
113 // True when Dear ImGui is currently expecting draw commands
114 // This means that we are between NewFrame() and EndFrame()
115 //=================================================================================================
116 IMGUI_API bool IsDrawing(void);
117 
118 //=================================================================================================
119 // True when Dear ImGui is currently expecting draw commands *sent to remote netImgui app*.
120 // This means that we are between NewFrame() and EndFrame() of drawing for remote application
121 //=================================================================================================
122 IMGUI_API bool IsDrawingRemote(void);
123 
124 //=================================================================================================
125 // Send an updated texture used by imgui, to netImguiApp server
126 // Note: To remove a texture, set pData to nullptr
127 //=================================================================================================
128 IMGUI_API void SendDataTexture(ImTextureID textureId, void* pData, uint16_t width, uint16_t height, eTexFormat format);
129 
130 //=================================================================================================
131 // Start a new Imgui Frame and wait for Draws commands, using a ImGui created internally
132 // for remote drawing. Returns true if we are awaiting a new ImGui frame.
133 //
134 // All ImGui drawing should be skipped when return is false.
135 //
136 // Note: This code can be used instead, to know if you should be drawing or not :
137 // 'if( !NetImgui::IsDrawing() )'
138 //
139 // Note: If your code cannot handle skipping a ImGui frame, leave 'bSupportFrameSkip=false',
140 // and this function will always call 'ImGui::NewFrame()' internally and return true
141 //
142 // Note: With Dear ImGui 1.81+, you can keep using the ImGui::BeginFrame()/Imgui::Render()
143 // without having to use NetImgui::NewFrame()/NetImgui::EndFrame()
144 // (unless wanting to support frame skip)
145 //=================================================================================================
146 IMGUI_API bool NewFrame(bool bSupportFrameSkip=false);
147 
148 //=================================================================================================
149 // Process all receives draws, send them to remote connection and restore the ImGui Context
150 //=================================================================================================
151 IMGUI_API void EndFrame(void);
152 
153 //=================================================================================================
154 // Return the context associated to this remote connection. Null when not connected.
155 //=================================================================================================
156 IMGUI_API ImGuiContext* GetContext();
157 
158 //=================================================================================================
159 // Set the remote client background color and texture
160 // Note: If no TextureID is specified, will use the default server texture
161 //=================================================================================================
162 IMGUI_API void SetBackground(const ImVec4& bgColor);
163 IMGUI_API void SetBackground(const ImVec4& bgColor, const ImVec4& textureTint );
164 IMGUI_API void SetBackground(const ImVec4& bgColor, const ImVec4& textureTint, ImTextureID bgTextureID);
165 
166 //=================================================================================================
167 // Control the data compression for communications between Client/Server
168 //=================================================================================================
169 IMGUI_API void SetCompressionMode(eCompressionMode eMode);
170 IMGUI_API eCompressionMode GetCompressionMode();
171 
172 //=================================================================================================
173 // Helper function to quickly create a context duplicate (sames settings/font/styles)
174 //=================================================================================================
175 IMGUI_API uint8_t GetTexture_BitsPerPixel (eTexFormat eFormat);
176 IMGUI_API uint32_t GetTexture_BytePerLine (eTexFormat eFormat, uint32_t pixelWidth);
177 IMGUI_API uint32_t GetTexture_BytePerImage (eTexFormat eFormat, uint32_t pixelWidth, uint32_t pixelHeight);
178 }
179 
180 //=================================================================================================
181 // Optional single include compiling option
182 // Note: User that do not wish adding the few NetImgui cpp files to their project,
183 // can instead define 'NETIMGUI_IMPLEMENTATION' *once* before including 'NetImgui_Api.h'
184 // and this will load the required cpp files alongside
185 //=================================================================================================
186 #if defined(NETIMGUI_IMPLEMENTATION)
187 
188 #include "Private/NetImgui_Api.cpp"
189 #include "Private/NetImgui_Client.cpp"
190 #include "Private/NetImgui_CmdPackets_DrawFrame.cpp"
191 #include "Private/NetImgui_NetworkPosix.cpp"
192 #include "Private/NetImgui_NetworkUE4.cpp"
193 #include "Private/NetImgui_NetworkWin32.cpp"
194 
195 #endif
196 #endif // NETIMGUI_ENABLED
197 
198 //#include "Private/NetImgui_WarningReenable.h"
constexpr uint32_t kDefaultClientPort
Default port Client waits for a connection.
Definition: NetImgui_Config.h:34
Definition: imgui.h:275
#define IMGUI_API
Definition: imgui.h:78
IMGUI_API void NewFrame()
IMGUI_API void Shutdown(ImGuiContext *context)
IMGUI_API void EndFrame()
Definition: imgui_internal.h:1457
constexpr uint32_t kDefaultServerPort
Default port Server waits for a connection.
Definition: NetImgui_Config.h:33
void * ImTextureID
Definition: imgui.h:213

Document ID: Generated on Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)