Code/Sample/SampleDualUI/SampleDualUI.cpp
//=================================================================================================
// Function used by the sample, to draw all ImGui Content
//=================================================================================================
Function used by the sample, to draw all ImGui Content
Function used by the sample to draw all ImGui Content
const ImDrawData* Client_Draw()
{
	if( NetImgui::NewFrame(true) )
	{
		ClientUtil_ImGuiContent_Common("SampleDualUI", true);
		ImGui::SetNextWindowPos(ImVec2(32,48), ImGuiCond_Once);
		ImGui::SetNextWindowSize(ImVec2(400,400), ImGuiCond_Once);
		if (ImGui::Begin("SampleDualUI", nullptr))
		{	
			Client_Draw_MainContent();
			Client_Draw_SharedContent();			
			Client_Draw_LocalContent();
			Client_Draw_RemoteContent();
			ImGui::End();
		}
		NetImgui::EndFrame();
	}
	if( NetImgui::IsConnected() && skDisplayMode == eDisplayMode::LocalIndependent )
	{
		ImGui::NewFrame();
		ImGui::SetNextWindowSize(ImVec2(300, 220), ImGuiCond_Once);
		if( ImGui::Begin("Extra Local Window") )
		{
			ImGui::TextColored(ImVec4(0.1, 1, 0.1, 1), "Local Window");
			ImGui::TextWrapped("Demonstrate a window content displayed locally while we have some distinct content displayed remotely.");
			Client_Draw_SharedContent();
			Client_Draw_LocalContent();
			Client_Draw_RemoteContent();	
		}
		ImGui::End();
		ImGui::Render();
	}
	if( NetImgui::IsConnected() )
	{ 
		switch( skDisplayMode)
		{
		case eDisplayMode::LocalNone:			return nullptr;
		case eDisplayMode::LocalMirror:			return NetImgui::GetDrawData();
		case eDisplayMode::LocalIndependent:	return ImGui::GetDrawData();
		}
	}
	return NetImgui::GetDrawData();
}
const ImDrawData * Client_Draw ( ) { if ( NetImgui :: NewFrame ( true ) ) { ClientUtil_ImGuiContent_Common ( " " , true ) ; ImGui :: SetNextWindowPos ( ImVec2 ( 32 , 48 ) , ImGuiCond_Once ) ; ImGui :: SetNextWindowSize ( ImVec2 ( 400 , 400 ) , ImGuiCond_Once ) ; if ( ImGui :: Begin ( " " , nullptr ) ) { Client_Draw_MainContent ( ) ; Client_Draw_SharedContent ( ) ; Client_Draw_LocalContent ( ) ; Client_Draw_RemoteContent ( ) ; ImGui :: End ( ) ; } NetImgui :: EndFrame ( ) ; } if ( NetImgui :: IsConnected ( ) && skDisplayMode == eDisplayMode :: LocalIndependent ) { ImGui :: NewFrame ( ) ; ImGui :: SetNextWindowSize ( ImVec2 ( 300 , 220 ) , ImGuiCond_Once ) ; if ( ImGui :: Begin ( " " ) ) { ImGui :: TextColored ( ImVec4 ( 0.1 , 1 , 0.1 , 1 ) , " " ) ; ImGui :: TextWrapped ( " " ) ; Client_Draw_SharedContent ( ) ; Client_Draw_LocalContent ( ) ; Client_Draw_RemoteContent ( ) ; } ImGui :: End ( ) ; ImGui :: Render ( ) ; } if ( NetImgui :: IsConnected ( ) ) { switch ( skDisplayMode ) { case eDisplayMode :: LocalNone : return nullptr ; case eDisplayMode :: LocalMirror : return NetImgui :: GetDrawData ( ) ; case eDisplayMode :: LocalIndependent : return ImGui :: GetDrawData ( ) ; } } return NetImgui :: GetDrawData ( ) ; }
Function used by the sample, to draw all ImGui Content
Function used by the sample to draw all ImGui Content
//--------------------------------------------------------------------------------------------- // (1) Start a new Frame //--------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------- // (2) Draw ImGui Content 		 //----------------------------------------------------------------------------------------- // IMPORTANT NOTE: We are telling the connection that we want the original Context 'Cloned'. // Meaning a duplicate context will be created for remote drawing. This leaves the original  // Context untouched and free to continue using for a separate ImGui output in the  // 'Local Independent' UI drawing section. 'Cloning' the context is not needed if you are  // not planning to keep drawing in local windows while connected, or you can manage this  // yourself using your own new context. //--------------------------------------------------------------------------------------------- // (3) Finish the frame, preparing the drawing data and... // (3a) Send the data to the netImGui server when connected //--------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------- // (4) Draw a second UI for local display, when connected and display mode is 'Independent' //--------------------------------------------------------------------------------------------- // Demonstration: Even though we are calling this, we are testing where the output is meant to be, // inside the function, and will never end up be drawn here //--------------------------------------------------------------------------------------------- // (5) Decide what to render locally //--------------------------------------------------------------------------------------------- // When disconnected, NetImgui::GetDrawData() and ImGui::GetDrawData() are the same