mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 09:27:00 +00:00
Examples: WIn32: Prefixing every Win32 function calls with :: to denote global namespace in a consistent manner.
This commit is contained in:
parent
df9051ded2
commit
9fdf72e42b
@ -11,9 +11,9 @@ static INT64 g_TicksPerSecond = 0;
|
|||||||
// Functions
|
// Functions
|
||||||
bool ImGui_ImplWin32_Init(void* hwnd)
|
bool ImGui_ImplWin32_Init(void* hwnd)
|
||||||
{
|
{
|
||||||
if (!QueryPerformanceFrequency((LARGE_INTEGER *)&g_TicksPerSecond))
|
if (!::QueryPerformanceFrequency((LARGE_INTEGER *)&g_TicksPerSecond))
|
||||||
return false;
|
return false;
|
||||||
if (!QueryPerformanceCounter((LARGE_INTEGER *)&g_Time))
|
if (!::QueryPerformanceCounter((LARGE_INTEGER *)&g_Time))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
g_hWnd = (HWND)hwnd;
|
g_hWnd = (HWND)hwnd;
|
||||||
@ -55,19 +55,19 @@ void ImGui_ImplWin32_NewFrame()
|
|||||||
|
|
||||||
// Setup display size (every frame to accommodate for window resizing)
|
// Setup display size (every frame to accommodate for window resizing)
|
||||||
RECT rect;
|
RECT rect;
|
||||||
GetClientRect(g_hWnd, &rect);
|
::GetClientRect(g_hWnd, &rect);
|
||||||
io.DisplaySize = ImVec2((float)(rect.right - rect.left), (float)(rect.bottom - rect.top));
|
io.DisplaySize = ImVec2((float)(rect.right - rect.left), (float)(rect.bottom - rect.top));
|
||||||
|
|
||||||
// Setup time step
|
// Setup time step
|
||||||
INT64 current_time;
|
INT64 current_time;
|
||||||
QueryPerformanceCounter((LARGE_INTEGER *)¤t_time);
|
::QueryPerformanceCounter((LARGE_INTEGER *)¤t_time);
|
||||||
io.DeltaTime = (float)(current_time - g_Time) / g_TicksPerSecond;
|
io.DeltaTime = (float)(current_time - g_Time) / g_TicksPerSecond;
|
||||||
g_Time = current_time;
|
g_Time = current_time;
|
||||||
|
|
||||||
// Read keyboard modifiers inputs
|
// Read keyboard modifiers inputs
|
||||||
io.KeyCtrl = (GetKeyState(VK_CONTROL) & 0x8000) != 0;
|
io.KeyCtrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
|
||||||
io.KeyShift = (GetKeyState(VK_SHIFT) & 0x8000) != 0;
|
io.KeyShift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
|
||||||
io.KeyAlt = (GetKeyState(VK_MENU) & 0x8000) != 0;
|
io.KeyAlt = (::GetKeyState(VK_MENU) & 0x8000) != 0;
|
||||||
io.KeySuper = false;
|
io.KeySuper = false;
|
||||||
// io.KeysDown : filled by WM_KEYDOWN/WM_KEYUP events
|
// io.KeysDown : filled by WM_KEYDOWN/WM_KEYUP events
|
||||||
// io.MousePos : filled by WM_MOUSEMOVE events
|
// io.MousePos : filled by WM_MOUSEMOVE events
|
||||||
@ -78,13 +78,13 @@ void ImGui_ImplWin32_NewFrame()
|
|||||||
if (io.WantMoveMouse)
|
if (io.WantMoveMouse)
|
||||||
{
|
{
|
||||||
POINT pos = { (int)io.MousePos.x, (int)io.MousePos.y };
|
POINT pos = { (int)io.MousePos.x, (int)io.MousePos.y };
|
||||||
ClientToScreen(g_hWnd, &pos);
|
::ClientToScreen(g_hWnd, &pos);
|
||||||
SetCursorPos(pos.x, pos.y);
|
::SetCursorPos(pos.x, pos.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hide OS mouse cursor if ImGui is drawing it
|
// Hide OS mouse cursor if ImGui is drawing it
|
||||||
if (io.MouseDrawCursor)
|
if (io.MouseDrawCursor)
|
||||||
SetCursor(NULL);
|
::SetCursor(NULL);
|
||||||
|
|
||||||
// Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application.
|
// Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application.
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
|
Loading…
Reference in New Issue
Block a user