mirror of
https://github.com/nillerusr/source-engine.git
synced 2026-07-16 06:19:58 +00:00
fix(ImGui): Should build on windows now.
fix(microprofiler): MacOS support? Untested.
This commit is contained in:
parent
f57ac89fee
commit
a45b0ceeb2
@ -159,6 +159,23 @@ void ImGui_ImplSource_RenderDrawData( ImDrawData *draw_data )
|
||||
ctx->PopMatrix();
|
||||
}
|
||||
|
||||
static const char* ImGui_ImplSource_GetClipboardText(ImGuiContext* ctx)
|
||||
{
|
||||
auto &g = *static_cast<ImGuiContext *>( ctx );
|
||||
g.ClipboardHandlerData.clear();
|
||||
auto len = vgui::system()->GetClipboardTextCount();
|
||||
if ( !len )
|
||||
return nullptr;
|
||||
g.ClipboardHandlerData.resize( len );
|
||||
vgui::system()->GetClipboardText( 0, g.ClipboardHandlerData.Data, g.ClipboardHandlerData.Size );
|
||||
return g.ClipboardHandlerData.Data;
|
||||
}
|
||||
|
||||
static void ImGui_ImplSource_SetClipboardText(ImGuiContext*, const char* text)
|
||||
{
|
||||
vgui::system()->SetClipboardText( text, V_strlen( text ) );
|
||||
}
|
||||
|
||||
bool ImGui_ImplSource_Init()
|
||||
{
|
||||
// Setup backend capabilities flags
|
||||
@ -167,22 +184,8 @@ bool ImGui_ImplSource_Init()
|
||||
io.BackendPlatformName = "source";
|
||||
io.BackendRendererName = "imgui_impl_source";
|
||||
io.BackendFlags = ImGuiBackendFlags_None;
|
||||
platform_io.Platform_SetClipboardTextFn = []( void *, const char *c )
|
||||
{
|
||||
vgui::system()->SetClipboardText( c, V_strlen( c ) );
|
||||
};
|
||||
platform_io.Platform_GetClipboardTextFn = []( void *ctx ) -> const char *
|
||||
{
|
||||
auto &g = *static_cast<ImGuiContext *>( ctx );
|
||||
g.ClipboardHandlerData.clear();
|
||||
auto len = vgui::system()->GetClipboardTextCount();
|
||||
if ( !len )
|
||||
return nullptr;
|
||||
g.ClipboardHandlerData.resize( len );
|
||||
vgui::system()->GetClipboardText( 0, g.ClipboardHandlerData.Data, g.ClipboardHandlerData.Size );
|
||||
return g.ClipboardHandlerData.Data;
|
||||
};
|
||||
|
||||
platform_io.Platform_SetClipboardTextFn = ImGui_ImplSource_SetClipboardText;
|
||||
platform_io.Platform_GetClipboardTextFn = ImGui_ImplSource_GetClipboardText;
|
||||
ImGui_ImplSource_CreateDeviceObjects();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -30,39 +30,11 @@ PLATFORM_INTERFACE int64 GetHardwareClockReliably();
|
||||
#include <x86intrin.h>
|
||||
#endif
|
||||
|
||||
#if (defined(_LINUX) || defined( OSX )) && !defined(__e2k__)
|
||||
inline unsigned long long GetTimebaseRegister( void )
|
||||
{
|
||||
#ifdef PLATFORM_64BITS
|
||||
unsigned long long Low, High;
|
||||
__asm__ __volatile__ ( "rdtsc" : "=a" (Low), "=d" (High) );
|
||||
return ( High << 32 ) | ( Low & 0xffffffff );
|
||||
#else
|
||||
unsigned long long Val;
|
||||
__asm__ __volatile__ ( "rdtsc" : "=A" (Val) );
|
||||
return Val;
|
||||
#endif
|
||||
return Plat_Rdtsc();
|
||||
}
|
||||
|
||||
#else
|
||||
// Warning: THere's a hardware bug with 64-bit MFTB on PS3 (not sure about X360): sometimes it returns incorrect results (when low word overflows, the high word doesn't increment for some time)
|
||||
inline int64 GetTimebaseRegister()
|
||||
{
|
||||
#if defined( _X360 )
|
||||
return __mftb32(); // X360: ~64 CPU ticks resolution
|
||||
#elif defined( _PS3 )
|
||||
// The timebase frequency on PS/3 is 79.8 MHz, see sys_time_get_timebase_frequency()
|
||||
// this works out to 40.10025 clock ticks per timebase tick
|
||||
return __mftb();
|
||||
#elif defined( OSX )
|
||||
return GetTimebaseRegister();
|
||||
#else
|
||||
return __rdtsc();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if ENABLE_MICRO_PROFILER > 0
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user