mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-14 00:39:55 +02:00
Compare commits
28 Commits
Author | SHA1 | Date | |
---|---|---|---|
f5dbb0a973 | |||
ade21a1ad5 | |||
868ba05a13 | |||
152878571e | |||
fa0aa5ace6 | |||
6267905a17 | |||
1509b8f634 | |||
2bc6346b48 | |||
9169b2911c | |||
a4b96445e8 | |||
6c11d7623e | |||
f33eb89018 | |||
a8d3b045b7 | |||
a830037eab | |||
309ff44579 | |||
f30d23a502 | |||
a905505cca | |||
46eee0cee4 | |||
29863b55ef | |||
530f103dfe | |||
7a3e6aa38d | |||
cda3aecc6a | |||
b6d1d85d86 | |||
9a426faf4f | |||
b0d5600ffb | |||
c52a54ef43 | |||
cc9d63b46a | |||
d3ad5ce475 |
@ -1,11 +1,13 @@
|
|||||||
ImGui
|
ImGui
|
||||||
=====
|
=====
|
||||||
|
|
||||||
ImGui is a bloat-free graphical user interface library for C++. It is portable, renderer agnostic and carries minimal amount of dependencies (only 3 files are needed). It is based on an "immediate" graphical user interface paradigm which allows you to build simple user interfaces with ease.
|
ImGui is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is portable, renderer agnostic and carries minimal amount of dependencies (only 3 files are needed). It is based on an "immediate" graphical user interface paradigm which allows you to build simple user interfaces with ease.
|
||||||
|
|
||||||
ImGui is designed to allow programmers to create "content creation" or "debug" tools (as opposed to tools for the average end-user). It favors simplicity and thus lacks certain features normally found in more high-level libraries, such as string localisation.
|
ImGui is designed to enable fast iteration and allow programmers to create "content creation" or "debug" tools (as opposed to tools for the average end-user). It favors simplicity and thus lacks certain features normally found in more high-level libraries, such as string localisation.
|
||||||
|
|
||||||
After ImGui is setup in your application, you can use it like in this example:
|
ImGui is particularly suited to integration in 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
|
||||||
|
|
||||||
|
After ImGui is setup in your engine, you can use it like in this example:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
@ -99,55 +99,6 @@ static void ImImpl_RenderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get text data in Win32 clipboard
|
|
||||||
static const char* ImImpl_GetClipboardTextFn()
|
|
||||||
{
|
|
||||||
static char* buf_local = NULL;
|
|
||||||
if (buf_local)
|
|
||||||
{
|
|
||||||
free(buf_local);
|
|
||||||
buf_local = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!OpenClipboard(NULL))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
HANDLE buf_handle = GetClipboardData(CF_TEXT);
|
|
||||||
if (buf_handle == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (char* buf_global = (char*)GlobalLock(buf_handle))
|
|
||||||
buf_local = strdup(buf_global);
|
|
||||||
GlobalUnlock(buf_handle);
|
|
||||||
CloseClipboard();
|
|
||||||
|
|
||||||
return buf_local;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set text data in Win32 clipboard
|
|
||||||
static void ImImpl_SetClipboardTextFn(const char* text, const char* text_end)
|
|
||||||
{
|
|
||||||
if (!OpenClipboard(NULL))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!text_end)
|
|
||||||
text_end = text + strlen(text);
|
|
||||||
|
|
||||||
const int buf_length = (text_end - text) + 1;
|
|
||||||
HGLOBAL buf_handle = GlobalAlloc(GMEM_MOVEABLE, buf_length * sizeof(char));
|
|
||||||
if (buf_handle == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
char* buf_global = (char *)GlobalLock(buf_handle);
|
|
||||||
memcpy(buf_global, text, text_end - text);
|
|
||||||
buf_global[text_end - text] = 0;
|
|
||||||
GlobalUnlock(buf_handle);
|
|
||||||
|
|
||||||
EmptyClipboard();
|
|
||||||
SetClipboardData(CF_TEXT, buf_handle);
|
|
||||||
CloseClipboard();
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT InitD3D(HWND hWnd)
|
HRESULT InitD3D(HWND hWnd)
|
||||||
{
|
{
|
||||||
if (NULL == (g_pD3D = Direct3DCreate9(D3D_SDK_VERSION)))
|
if (NULL == (g_pD3D = Direct3DCreate9(D3D_SDK_VERSION)))
|
||||||
@ -250,8 +201,6 @@ void InitImGui()
|
|||||||
io.KeyMap[ImGuiKey_Z] = 'Z';
|
io.KeyMap[ImGuiKey_Z] = 'Z';
|
||||||
|
|
||||||
io.RenderDrawListsFn = ImImpl_RenderDrawLists;
|
io.RenderDrawListsFn = ImImpl_RenderDrawLists;
|
||||||
io.SetClipboardTextFn = ImImpl_SetClipboardTextFn;
|
|
||||||
io.GetClipboardTextFn = ImImpl_GetClipboardTextFn;
|
|
||||||
|
|
||||||
// Create the vertex buffer
|
// Create the vertex buffer
|
||||||
if (g_pd3dDevice->CreateVertexBuffer(10000 * sizeof(CUSTOMVERTEX), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB, NULL) < 0)
|
if (g_pd3dDevice->CreateVertexBuffer(10000 * sizeof(CUSTOMVERTEX), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB, NULL) < 0)
|
||||||
@ -271,6 +220,35 @@ void InitImGui()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
INT64 ticks_per_second = 0;
|
||||||
|
INT64 time = 0;
|
||||||
|
|
||||||
|
void UpdateImGui()
|
||||||
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
// Setup timestep
|
||||||
|
INT64 current_time;
|
||||||
|
QueryPerformanceCounter((LARGE_INTEGER *)¤t_time);
|
||||||
|
io.DeltaTime = (float)(current_time - time) / ticks_per_second;
|
||||||
|
time = current_time;
|
||||||
|
|
||||||
|
// Setup inputs
|
||||||
|
// (we already got mouse position, buttons, wheel from the window message callback)
|
||||||
|
BYTE keystate[256];
|
||||||
|
GetKeyboardState(keystate);
|
||||||
|
for (int i = 0; i < 256; i++)
|
||||||
|
io.KeysDown[i] = (keystate[i] & 0x80) != 0;
|
||||||
|
io.KeyCtrl = (keystate[VK_CONTROL] & 0x80) != 0;
|
||||||
|
io.KeyShift = (keystate[VK_SHIFT] & 0x80) != 0;
|
||||||
|
// io.MousePos : filled by WM_MOUSEMOVE event
|
||||||
|
// io.MouseDown : filled by WM_*BUTTON* events
|
||||||
|
// io.MouseWheel : filled by WM_MOUSEWHEEL events
|
||||||
|
|
||||||
|
// Start the frame
|
||||||
|
ImGui::NewFrame();
|
||||||
|
}
|
||||||
|
|
||||||
int WINAPI wWinMain(HINSTANCE hInst, HINSTANCE, LPWSTR, int)
|
int WINAPI wWinMain(HINSTANCE hInst, HINSTANCE, LPWSTR, int)
|
||||||
{
|
{
|
||||||
// Register the window class
|
// Register the window class
|
||||||
@ -280,101 +258,91 @@ int WINAPI wWinMain(HINSTANCE hInst, HINSTANCE, LPWSTR, int)
|
|||||||
// Create the application's window
|
// Create the application's window
|
||||||
hWnd = CreateWindow(L"ImGui Example", L"ImGui DirectX9 Example", WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL);
|
hWnd = CreateWindow(L"ImGui Example", L"ImGui DirectX9 Example", WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL);
|
||||||
|
|
||||||
INT64 ticks_per_second, time;
|
|
||||||
if (!QueryPerformanceFrequency((LARGE_INTEGER *)&ticks_per_second))
|
if (!QueryPerformanceFrequency((LARGE_INTEGER *)&ticks_per_second))
|
||||||
return 1;
|
return 1;
|
||||||
if (!QueryPerformanceCounter((LARGE_INTEGER *)&time))
|
if (!QueryPerformanceCounter((LARGE_INTEGER *)&time))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
// Initialize Direct3D
|
// Initialize Direct3D
|
||||||
if (InitD3D(hWnd) >= 0)
|
if (InitD3D(hWnd) < 0)
|
||||||
|
{
|
||||||
|
if (g_pVB)
|
||||||
|
g_pVB->Release();
|
||||||
|
UnregisterClass(L"ImGui Example", wc.hInstance);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show the window
|
||||||
|
ShowWindow(hWnd, SW_SHOWDEFAULT);
|
||||||
|
UpdateWindow(hWnd);
|
||||||
|
|
||||||
|
InitImGui();
|
||||||
|
|
||||||
|
// Enter the message loop
|
||||||
|
MSG msg;
|
||||||
|
ZeroMemory(&msg, sizeof(msg));
|
||||||
|
while (msg.message != WM_QUIT)
|
||||||
{
|
{
|
||||||
// Show the window
|
if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
|
||||||
ShowWindow(hWnd, SW_SHOWDEFAULT);
|
|
||||||
UpdateWindow(hWnd);
|
|
||||||
|
|
||||||
InitImGui();
|
|
||||||
|
|
||||||
// Enter the message loop
|
|
||||||
MSG msg;
|
|
||||||
ZeroMemory(&msg, sizeof(msg));
|
|
||||||
while (msg.message != WM_QUIT)
|
|
||||||
{
|
{
|
||||||
if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
|
TranslateMessage(&msg);
|
||||||
{
|
DispatchMessage(&msg);
|
||||||
TranslateMessage(&msg);
|
continue;
|
||||||
DispatchMessage(&msg);
|
}
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 1) ImGui start frame, setup time delta & inputs
|
UpdateImGui();
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
INT64 current_time;
|
|
||||||
QueryPerformanceCounter((LARGE_INTEGER *)¤t_time);
|
|
||||||
io.DeltaTime = (float)(current_time - time) / ticks_per_second;
|
|
||||||
time = current_time;
|
|
||||||
BYTE keystate[256];
|
|
||||||
GetKeyboardState(keystate);
|
|
||||||
for (int i = 0; i < 256; i++)
|
|
||||||
io.KeysDown[i] = (keystate[i] & 0x80) != 0;
|
|
||||||
io.KeyCtrl = (keystate[VK_CONTROL] & 0x80) != 0;
|
|
||||||
io.KeyShift = (keystate[VK_SHIFT] & 0x80) != 0;
|
|
||||||
// io.MousePos : filled by WM_MOUSEMOVE event
|
|
||||||
// io.MouseDown : filled by WM_*BUTTON* events
|
|
||||||
// io.MouseWheel : filled by WM_MOUSEWHEEL events
|
|
||||||
ImGui::NewFrame();
|
|
||||||
|
|
||||||
// 2) ImGui usage
|
// Create a simple window
|
||||||
static bool show_test_window = true;
|
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
|
||||||
static bool show_another_window = false;
|
static bool show_test_window = true;
|
||||||
static float f;
|
static bool show_another_window = false;
|
||||||
ImGui::Text("Hello, world!");
|
static float f;
|
||||||
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
|
ImGui::Text("Hello, world!");
|
||||||
show_test_window ^= ImGui::Button("Test Window");
|
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
|
||||||
show_another_window ^= ImGui::Button("Another Window");
|
show_test_window ^= ImGui::Button("Test Window");
|
||||||
|
show_another_window ^= ImGui::Button("Another Window");
|
||||||
|
|
||||||
// Calculate and show framerate
|
// Calculate and show framerate
|
||||||
static float ms_per_frame[120] = { 0 };
|
static float ms_per_frame[120] = { 0 };
|
||||||
static int ms_per_frame_idx = 0;
|
static int ms_per_frame_idx = 0;
|
||||||
static float ms_per_frame_accum = 0.0f;
|
static float ms_per_frame_accum = 0.0f;
|
||||||
ms_per_frame_accum -= ms_per_frame[ms_per_frame_idx];
|
ms_per_frame_accum -= ms_per_frame[ms_per_frame_idx];
|
||||||
ms_per_frame[ms_per_frame_idx] = io.DeltaTime * 1000.0f;
|
ms_per_frame[ms_per_frame_idx] = ImGui::GetIO().DeltaTime * 1000.0f;
|
||||||
ms_per_frame_accum += ms_per_frame[ms_per_frame_idx];
|
ms_per_frame_accum += ms_per_frame[ms_per_frame_idx];
|
||||||
ms_per_frame_idx = (ms_per_frame_idx + 1) % 120;
|
ms_per_frame_idx = (ms_per_frame_idx + 1) % 120;
|
||||||
const float ms_per_frame_avg = ms_per_frame_accum / 120;
|
const float ms_per_frame_avg = ms_per_frame_accum / 120;
|
||||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", ms_per_frame_avg, 1000.0f / ms_per_frame_avg);
|
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", ms_per_frame_avg, 1000.0f / ms_per_frame_avg);
|
||||||
|
|
||||||
if (show_test_window)
|
// Show the ImGui test window
|
||||||
{
|
// Most of user example code is in ImGui::ShowTestWindow()
|
||||||
// More example code in ShowTestWindow()
|
if (show_test_window)
|
||||||
ImGui::SetNewWindowDefaultPos(ImVec2(650, 20)); // Normally user code doesn't need/want to call it because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
|
{
|
||||||
ImGui::ShowTestWindow(&show_test_window);
|
ImGui::SetNewWindowDefaultPos(ImVec2(650, 20)); // Normally user code doesn't need/want to call it because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
|
||||||
}
|
ImGui::ShowTestWindow(&show_test_window);
|
||||||
|
|
||||||
if (show_another_window)
|
|
||||||
{
|
|
||||||
ImGui::Begin("Another Window", &show_another_window, ImVec2(200,100));
|
|
||||||
ImGui::Text("Hello");
|
|
||||||
ImGui::End();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3) Rendering
|
|
||||||
// Clear frame buffer
|
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, false);
|
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, false);
|
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, false);
|
|
||||||
g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(204, 153, 153), 1.0f, 0);
|
|
||||||
if (g_pd3dDevice->BeginScene() >= 0)
|
|
||||||
{
|
|
||||||
// Render ImGui
|
|
||||||
ImGui::Render();
|
|
||||||
g_pd3dDevice->EndScene();
|
|
||||||
}
|
|
||||||
g_pd3dDevice->Present(NULL, NULL, NULL, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::Shutdown();
|
// Show another simple window
|
||||||
}
|
if (show_another_window)
|
||||||
|
{
|
||||||
|
ImGui::Begin("Another Window", &show_another_window, ImVec2(200,100));
|
||||||
|
ImGui::Text("Hello");
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rendering
|
||||||
|
g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, false);
|
||||||
|
g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, false);
|
||||||
|
g_pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, false);
|
||||||
|
g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(204, 153, 153), 1.0f, 0);
|
||||||
|
if (g_pd3dDevice->BeginScene() >= 0)
|
||||||
|
{
|
||||||
|
ImGui::Render();
|
||||||
|
g_pd3dDevice->EndScene();
|
||||||
|
}
|
||||||
|
g_pd3dDevice->Present(NULL, NULL, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::Shutdown();
|
||||||
|
|
||||||
if (g_pVB)
|
if (g_pVB)
|
||||||
g_pVB->Release();
|
g_pVB->Release();
|
||||||
|
@ -5,7 +5,8 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
CXXFLAGS=-framework OpenGL -framework Cocoa -framework IOKit
|
CXXFLAGS=-framework OpenGL -framework Cocoa -framework IOKit
|
||||||
#CXXFLAGS+=-L/usr/local/Cellar/glew/1.10.0/lib -L/usr/local/Cellar/glfw3/3.0.4/lib
|
CXXFLAGS+=-I/usr/local/Cellar/glew/1.10.0/include -I/usr/local/Cellar/glfw3/3.0.4/include
|
||||||
|
CXXFLAGS+=-L/usr/local/Cellar/glew/1.10.0/lib -L/usr/local/Cellar/glfw3/3.0.4/lib
|
||||||
CXXFLAGS+=-lglew -lglfw3
|
CXXFLAGS+=-lglew -lglfw3
|
||||||
CXXFLAGS+=-I../../
|
CXXFLAGS+=-I../../
|
||||||
CXXFLAGS+= -D__APPLE__
|
CXXFLAGS+= -D__APPLE__
|
||||||
|
@ -19,24 +19,26 @@ static void ImImpl_RenderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_c
|
|||||||
if (cmd_lists_count == 0)
|
if (cmd_lists_count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Setup render state: alpha-blending enabled, no face culling, no depth testing
|
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers.
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
//glEnable(GL_SCISSOR_TEST);
|
glEnable(GL_SCISSOR_TEST);
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
glEnableClientState(GL_COLOR_ARRAY);
|
glEnableClientState(GL_COLOR_ARRAY);
|
||||||
|
|
||||||
// Bind texture
|
// Setup texture
|
||||||
glBindTexture(GL_TEXTURE_2D, fontTex);
|
glBindTexture(GL_TEXTURE_2D, fontTex);
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
// Setup matrices
|
// Setup orthographic projection matrix
|
||||||
|
const float width = ImGui::GetIO().DisplaySize.x;
|
||||||
|
const float height = ImGui::GetIO().DisplaySize.y;
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glOrtho(0.0f, ImGui::GetIO().DisplaySize.x, ImGui::GetIO().DisplaySize.y, 0.0f, -1.0f, +1.0f);
|
glOrtho(0.0f, width, height, 0.0f, -1.0f, +1.0f);
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
@ -53,7 +55,7 @@ static void ImImpl_RenderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_c
|
|||||||
const ImDrawCmd* pcmd_end = cmd_list->commands.end();
|
const ImDrawCmd* pcmd_end = cmd_list->commands.end();
|
||||||
for (const ImDrawCmd* pcmd = cmd_list->commands.begin(); pcmd != pcmd_end; pcmd++)
|
for (const ImDrawCmd* pcmd = cmd_list->commands.begin(); pcmd != pcmd_end; pcmd++)
|
||||||
{
|
{
|
||||||
glScissor((int)pcmd->clip_rect.x, (int)pcmd->clip_rect.y, (int)(pcmd->clip_rect.z - pcmd->clip_rect.x), (int)(pcmd->clip_rect.w - pcmd->clip_rect.y));
|
glScissor((int)pcmd->clip_rect.x, (int)(height - pcmd->clip_rect.w), (int)(pcmd->clip_rect.z - pcmd->clip_rect.x), (int)(pcmd->clip_rect.w - pcmd->clip_rect.y));
|
||||||
glDrawArrays(GL_TRIANGLES, vtx_offset, pcmd->vtx_count);
|
glDrawArrays(GL_TRIANGLES, vtx_offset, pcmd->vtx_count);
|
||||||
vtx_offset += pcmd->vtx_count;
|
vtx_offset += pcmd->vtx_count;
|
||||||
}
|
}
|
||||||
@ -71,24 +73,33 @@ static void ImImpl_SetClipboardTextFn(const char* text, const char* text_end)
|
|||||||
if (!text_end)
|
if (!text_end)
|
||||||
text_end = text + strlen(text);
|
text_end = text + strlen(text);
|
||||||
|
|
||||||
// Add a zero-terminator because glfw function doesn't take a size
|
if (*text_end == 0)
|
||||||
char* buf = (char*)malloc(text_end - text + 1);
|
{
|
||||||
memcpy(buf, text, text_end-text);
|
// Already got a zero-terminator at 'text_end', we don't need to add one
|
||||||
buf[text_end-text] = '\0';
|
glfwSetClipboardString(window, text);
|
||||||
glfwSetClipboardString(window, buf);
|
}
|
||||||
free(buf);
|
else
|
||||||
|
{
|
||||||
|
// Add a zero-terminator because glfw function doesn't take a size
|
||||||
|
char* buf = (char*)malloc(text_end - text + 1);
|
||||||
|
memcpy(buf, text, text_end-text);
|
||||||
|
buf[text_end-text] = '\0';
|
||||||
|
glfwSetClipboardString(window, buf);
|
||||||
|
free(buf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// GLFW callbacks to get events
|
// GLFW callbacks to get events
|
||||||
static void glfw_error_callback(int error, const char* description)
|
static void glfw_error_callback(int error, const char* description)
|
||||||
{
|
{
|
||||||
fputs(description, stderr);
|
fputs(description, stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static float mouse_wheel = 0.0f;
|
|
||||||
static void glfw_scroll_callback(GLFWwindow* window, double xoffset, double yoffset)
|
static void glfw_scroll_callback(GLFWwindow* window, double xoffset, double yoffset)
|
||||||
{
|
{
|
||||||
mouse_wheel = (float)yoffset;
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
io.MouseWheel = (yoffset != 0.0f) ? yoffset > 0.0f ? 1 : - 1 : 0; // Mouse wheel: -1,0,+1
|
||||||
}
|
}
|
||||||
|
|
||||||
static void glfw_key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
static void glfw_key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||||
@ -171,37 +182,43 @@ void InitImGui()
|
|||||||
stbi_image_free(tex_data);
|
stbi_image_free(tex_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Shutdown()
|
void UpdateImGui()
|
||||||
{
|
{
|
||||||
ImGui::Shutdown();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
glfwTerminate();
|
|
||||||
|
// Setup timestep
|
||||||
|
static double time = 0.0f;
|
||||||
|
const double current_time = glfwGetTime();
|
||||||
|
io.DeltaTime = (float)(current_time - time);
|
||||||
|
time = current_time;
|
||||||
|
|
||||||
|
// Setup inputs
|
||||||
|
// (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
|
||||||
|
double mouse_x, mouse_y;
|
||||||
|
glfwGetCursorPos(window, &mouse_x, &mouse_y);
|
||||||
|
io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
|
||||||
|
io.MouseDown[0] = glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_LEFT) != 0;
|
||||||
|
io.MouseDown[1] = glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_RIGHT) != 0;
|
||||||
|
|
||||||
|
// Start the frame
|
||||||
|
ImGui::NewFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Application code
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
InitGL();
|
InitGL();
|
||||||
InitImGui();
|
InitImGui();
|
||||||
|
|
||||||
double time = glfwGetTime();
|
|
||||||
while (!glfwWindowShouldClose(window))
|
while (!glfwWindowShouldClose(window))
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
io.MouseWheel = 0;
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
|
UpdateImGui();
|
||||||
|
|
||||||
// 1) ImGui start frame, setup time delta & inputs
|
// Create a simple window
|
||||||
const double current_time = glfwGetTime();
|
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
|
||||||
io.DeltaTime = (float)(current_time - time);
|
|
||||||
time = current_time;
|
|
||||||
double mouse_x, mouse_y;
|
|
||||||
glfwGetCursorPos(window, &mouse_x, &mouse_y);
|
|
||||||
io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
|
|
||||||
io.MouseDown[0] = glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_LEFT) != 0;
|
|
||||||
io.MouseDown[1] = glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_RIGHT) != 0;
|
|
||||||
io.MouseWheel = (mouse_wheel != 0) ? mouse_wheel > 0.0f ? 1 : - 1 : 0; // Mouse wheel: -1,0,+1
|
|
||||||
mouse_wheel = 0.0f;
|
|
||||||
ImGui::NewFrame();
|
|
||||||
|
|
||||||
// 2) ImGui usage
|
|
||||||
static bool show_test_window = true;
|
static bool show_test_window = true;
|
||||||
static bool show_another_window = false;
|
static bool show_another_window = false;
|
||||||
static float f;
|
static float f;
|
||||||
@ -215,19 +232,21 @@ int main(int argc, char** argv)
|
|||||||
static int ms_per_frame_idx = 0;
|
static int ms_per_frame_idx = 0;
|
||||||
static float ms_per_frame_accum = 0.0f;
|
static float ms_per_frame_accum = 0.0f;
|
||||||
ms_per_frame_accum -= ms_per_frame[ms_per_frame_idx];
|
ms_per_frame_accum -= ms_per_frame[ms_per_frame_idx];
|
||||||
ms_per_frame[ms_per_frame_idx] = io.DeltaTime * 1000.0f;
|
ms_per_frame[ms_per_frame_idx] = ImGui::GetIO().DeltaTime * 1000.0f;
|
||||||
ms_per_frame_accum += ms_per_frame[ms_per_frame_idx];
|
ms_per_frame_accum += ms_per_frame[ms_per_frame_idx];
|
||||||
ms_per_frame_idx = (ms_per_frame_idx + 1) % 120;
|
ms_per_frame_idx = (ms_per_frame_idx + 1) % 120;
|
||||||
const float ms_per_frame_avg = ms_per_frame_accum / 120;
|
const float ms_per_frame_avg = ms_per_frame_accum / 120;
|
||||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", ms_per_frame_avg, 1000.0f / ms_per_frame_avg);
|
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", ms_per_frame_avg, 1000.0f / ms_per_frame_avg);
|
||||||
|
|
||||||
|
// Show the ImGui test window
|
||||||
|
// Most of user example code is in ImGui::ShowTestWindow()
|
||||||
if (show_test_window)
|
if (show_test_window)
|
||||||
{
|
{
|
||||||
// More example code in ShowTestWindow()
|
|
||||||
ImGui::SetNewWindowDefaultPos(ImVec2(650, 20)); // Normally user code doesn't need/want to call it because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
|
ImGui::SetNewWindowDefaultPos(ImVec2(650, 20)); // Normally user code doesn't need/want to call it because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
|
||||||
ImGui::ShowTestWindow(&show_test_window);
|
ImGui::ShowTestWindow(&show_test_window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show another simple window
|
||||||
if (show_another_window)
|
if (show_another_window)
|
||||||
{
|
{
|
||||||
ImGui::Begin("Another Window", &show_another_window, ImVec2(200,100));
|
ImGui::Begin("Another Window", &show_another_window, ImVec2(200,100));
|
||||||
@ -235,15 +254,15 @@ int main(int argc, char** argv)
|
|||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3) Rendering
|
// Rendering
|
||||||
glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y);
|
glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y);
|
||||||
glClearColor(0.8f, 0.6f, 0.6f, 1.0f);
|
glClearColor(0.8f, 0.6f, 0.6f, 1.0f);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
|
|
||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
Shutdown();
|
ImGui::Shutdown();
|
||||||
|
glfwTerminate();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
19
imconfig.h
19
imconfig.h
@ -4,15 +4,22 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
//----- Define your own ImVector<> type if you don't want to use the provided implementation defined in imgui.h
|
//---- Define your own ImVector<> type if you don't want to use the provided implementation defined in imgui.h
|
||||||
//#include <vector>
|
//#include <vector>
|
||||||
//#define ImVector std::vector
|
//#define ImVector std::vector
|
||||||
//#define ImVector MyVector
|
//#define ImVector MyVector
|
||||||
|
|
||||||
//----- Define assertion handler. Default to calling assert().
|
//---- Define assertion handler. Defaults to calling assert().
|
||||||
// #define IM_ASSERT(_EXPR) MyAssert(_EXPR)
|
//#define IM_ASSERT(_EXPR) MyAssert(_EXPR)
|
||||||
|
|
||||||
//----- Define implicit cast operators to convert back<>forth from your math types and ImVec2/ImVec4.
|
//---- Don't implement default clipboard handlers for Windows (so as not to link with OpenClipboard(), etc.)
|
||||||
|
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS
|
||||||
|
|
||||||
|
//---- If you are loading a custom font, ImGui expect to find a pure white pixel at (0,0)
|
||||||
|
// Change it's UV coordinate here if you can't have a white pixel at (0,0)
|
||||||
|
//#define IMGUI_FONT_TEX_UV_FOR_WHITE ImVec2(0.f/256.f,0.f/256.f)
|
||||||
|
|
||||||
|
//---- Define implicit cast operators to convert back<>forth from your math types and ImVec2/ImVec4.
|
||||||
/*
|
/*
|
||||||
#define IM_VEC2_CLASS_EXTRA \
|
#define IM_VEC2_CLASS_EXTRA \
|
||||||
ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \
|
ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \
|
||||||
@ -23,8 +30,8 @@
|
|||||||
operator MyVec4() const { return MyVec4(x,y,z,w); }
|
operator MyVec4() const { return MyVec4(x,y,z,w); }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//----- Freely implement extra functions within the ImGui:: namespace.
|
//---- Freely implement extra functions within the ImGui:: namespace.
|
||||||
//----- e.g. you can create variants of the ImGui::Value() helper for your low-level math types.
|
//---- e.g. you can create variants of the ImGui::Value() helper for your low-level math types.
|
||||||
/*
|
/*
|
||||||
namespace ImGui
|
namespace ImGui
|
||||||
{
|
{
|
||||||
|
66
imgui.h
66
imgui.h
@ -85,9 +85,9 @@ public:
|
|||||||
|
|
||||||
inline void clear() { if (_data) { _size = _capacity = 0; free(_data); _data = NULL; } }
|
inline void clear() { if (_data) { _size = _capacity = 0; free(_data); _data = NULL; } }
|
||||||
inline iterator begin() { return _data; }
|
inline iterator begin() { return _data; }
|
||||||
inline const iterator begin() const { return _data; }
|
inline const_iterator begin() const { return _data; }
|
||||||
inline iterator end() { return _data + _size; }
|
inline iterator end() { return _data + _size; }
|
||||||
inline const iterator end() const { return _data + _size; }
|
inline const_iterator end() const { return _data + _size; }
|
||||||
inline value_type& front() { return at(0); }
|
inline value_type& front() { return at(0); }
|
||||||
inline const value_type& front() const { return at(0); }
|
inline const value_type& front() const { return at(0); }
|
||||||
inline value_type& back() { IM_ASSERT(_size > 0); return at(_size-1); }
|
inline value_type& back() { IM_ASSERT(_size > 0); return at(_size-1); }
|
||||||
@ -135,7 +135,7 @@ namespace ImGui
|
|||||||
bool GetWindowIsFocused();
|
bool GetWindowIsFocused();
|
||||||
float GetWindowWidth();
|
float GetWindowWidth();
|
||||||
ImVec2 GetWindowPos(); // you should rarely need/care about the window position, but it can be useful if you want to use your own drawing
|
ImVec2 GetWindowPos(); // you should rarely need/care about the window position, but it can be useful if you want to use your own drawing
|
||||||
void SetWindowPos(ImVec2 pos); // unchecked
|
void SetWindowPos(const ImVec2& pos); // set current window pos
|
||||||
ImVec2 GetWindowSize();
|
ImVec2 GetWindowSize();
|
||||||
ImVec2 GetWindowContentRegionMin();
|
ImVec2 GetWindowContentRegionMin();
|
||||||
ImVec2 GetWindowContentRegionMax();
|
ImVec2 GetWindowContentRegionMax();
|
||||||
@ -149,9 +149,14 @@ namespace ImGui
|
|||||||
float GetItemWidth();
|
float GetItemWidth();
|
||||||
void PushAllowKeyboardFocus(bool v);
|
void PushAllowKeyboardFocus(bool v);
|
||||||
void PopAllowKeyboardFocus();
|
void PopAllowKeyboardFocus();
|
||||||
void PushStyleColor(ImGuiCol idx, ImVec4 col);
|
void PushStyleColor(ImGuiCol idx, const ImVec4& col);
|
||||||
void PopStyleColor();
|
void PopStyleColor();
|
||||||
|
|
||||||
|
// Tooltip
|
||||||
|
void SetTooltip(const char* fmt, ...); // set tooltip under mouse-cursor, typically use with ImGui::IsHovered(). last call wins.
|
||||||
|
void BeginTooltip(); // use to create full-featured tooltip windows that aren't just text.
|
||||||
|
void EndTooltip();
|
||||||
|
|
||||||
// Layout
|
// Layout
|
||||||
void Separator(); // horizontal line
|
void Separator(); // horizontal line
|
||||||
void SameLine(int column_x = 0, int spacing_w = -1); // call between widgets to layout them horizontally
|
void SameLine(int column_x = 0, int spacing_w = -1); // call between widgets to layout them horizontally
|
||||||
@ -161,8 +166,8 @@ namespace ImGui
|
|||||||
float GetColumnOffset(int column_index = -1);
|
float GetColumnOffset(int column_index = -1);
|
||||||
void SetColumnOffset(int column_index, float offset);
|
void SetColumnOffset(int column_index, float offset);
|
||||||
float GetColumnWidth(int column_index = -1);
|
float GetColumnWidth(int column_index = -1);
|
||||||
ImVec2 GetCursorPos(); // cursor position relative to window position
|
ImVec2 GetCursorPos(); // cursor position is relative to window position
|
||||||
void SetCursorPos(ImVec2 p);
|
void SetCursorPos(const ImVec2& pos); // "
|
||||||
void AlignFirstTextHeightToWidgets(); // call once if the first item on the line is a Text() item and you want to vertically lower it to match higher widgets.
|
void AlignFirstTextHeightToWidgets(); // call once if the first item on the line is a Text() item and you want to vertically lower it to match higher widgets.
|
||||||
float GetTextLineSpacing();
|
float GetTextLineSpacing();
|
||||||
float GetTextLineHeight();
|
float GetTextLineHeight();
|
||||||
@ -176,6 +181,7 @@ namespace ImGui
|
|||||||
// Widgets
|
// Widgets
|
||||||
void Text(const char* fmt, ...);
|
void Text(const char* fmt, ...);
|
||||||
void TextV(const char* fmt, va_list args);
|
void TextV(const char* fmt, va_list args);
|
||||||
|
void TextColored(const ImVec4& col, const char* fmt, ...); // shortcut to doing PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor();
|
||||||
void TextUnformatted(const char* text, const char* text_end = NULL); // doesn't require null terminated string if 'text_end' is specified. no copy done to any bounded stack buffer, better for long chunks of text.
|
void TextUnformatted(const char* text, const char* text_end = NULL); // doesn't require null terminated string if 'text_end' is specified. no copy done to any bounded stack buffer, better for long chunks of text.
|
||||||
void LabelText(const char* label, const char* fmt, ...);
|
void LabelText(const char* label, const char* fmt, ...);
|
||||||
void BulletText(const char* fmt, ...);
|
void BulletText(const char* fmt, ...);
|
||||||
@ -183,16 +189,18 @@ namespace ImGui
|
|||||||
bool SmallButton(const char* label);
|
bool SmallButton(const char* label);
|
||||||
bool CollapsingHeader(const char* label, const char* str_id = NULL, const bool display_frame = true, const bool default_open = false);
|
bool CollapsingHeader(const char* label, const char* str_id = NULL, const bool display_frame = true, const bool default_open = false);
|
||||||
bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
|
bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
|
||||||
|
bool SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
|
||||||
bool SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
|
bool SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
|
||||||
bool SliderAngle(const char* label, float* v, float v_degrees_min = -360.0f, float v_degrees_max = +360.0f); // *v in radians
|
bool SliderAngle(const char* label, float* v, float v_degrees_min = -360.0f, float v_degrees_max = +360.0f); // *v in radians
|
||||||
bool SliderInt(const char* label, int* v, int v_min, int v_max, const char* display_format = "%.0f");
|
bool SliderInt(const char* label, int* v, int v_min, int v_max, const char* display_format = "%.0f");
|
||||||
void PlotLines(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0));
|
void PlotLines(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0), size_t stride = sizeof(float));
|
||||||
void PlotHistogram(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0));
|
void PlotHistogram(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0), size_t stride = sizeof(float));
|
||||||
void Checkbox(const char* label, bool* v);
|
void Checkbox(const char* label, bool* v);
|
||||||
void CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value);
|
void CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value);
|
||||||
bool RadioButton(const char* label, bool active);
|
bool RadioButton(const char* label, bool active);
|
||||||
bool RadioButton(const char* label, int* v, int v_button);
|
bool RadioButton(const char* label, int* v, int v_button);
|
||||||
bool InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, int decimal_precision = -1);
|
bool InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, int decimal_precision = -1);
|
||||||
|
bool InputFloat2(const char* label, float v[2], int decimal_precision = -1);
|
||||||
bool InputFloat3(const char* label, float v[3], int decimal_precision = -1);
|
bool InputFloat3(const char* label, float v[3], int decimal_precision = -1);
|
||||||
bool InputInt(const char* label, int* v, int step = 1, int step_fast = 100);
|
bool InputInt(const char* label, int* v, int step = 1, int step_fast = 100);
|
||||||
bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0);
|
bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0);
|
||||||
@ -227,10 +235,11 @@ namespace ImGui
|
|||||||
void LogToClipboard(int max_depth = -1);
|
void LogToClipboard(int max_depth = -1);
|
||||||
|
|
||||||
// Utilities
|
// Utilities
|
||||||
void SetTooltip(const char* fmt, ...); // set tooltip under mouse-cursor, typically use with ImGui::IsHovered(). (currently no contention handling, last call win)
|
void SetNewWindowDefaultPos(const ImVec2& pos); // set position of window that do
|
||||||
void SetNewWindowDefaultPos(ImVec2 pos); // set position of window that do
|
|
||||||
bool IsHovered(); // was the last item active area hovered by mouse?
|
bool IsHovered(); // was the last item active area hovered by mouse?
|
||||||
bool IsClipped(ImVec2 item_size); // to perform coarse clipping on user's side (as an optimisation)
|
ImVec2 GetItemBoxMin(); // get bounding box of last item
|
||||||
|
ImVec2 GetItemBoxMax(); // get bounding box of last item
|
||||||
|
bool IsClipped(const ImVec2& item_size); // to perform coarse clipping on user's side (as an optimisation)
|
||||||
bool IsKeyPressed(int key_index, bool repeat = true); // key_index into the keys_down[512] array, imgui doesn't know the semantic of each entry
|
bool IsKeyPressed(int key_index, bool repeat = true); // key_index into the keys_down[512] array, imgui doesn't know the semantic of each entry
|
||||||
bool IsMouseClicked(int button, bool repeat = false);
|
bool IsMouseClicked(int button, bool repeat = false);
|
||||||
bool IsMouseDoubleClicked(int button);
|
bool IsMouseDoubleClicked(int button);
|
||||||
@ -380,14 +389,20 @@ struct ImGuiIO
|
|||||||
bool FontAllowScaling; // = false // Set to allow scaling text with CTRL+Wheel.
|
bool FontAllowScaling; // = false // Set to allow scaling text with CTRL+Wheel.
|
||||||
float PixelCenterOffset; // = 0.5f // Set to 0.0f for DirectX <= 9, 0.5f for Direct3D >= 10 and OpenGL.
|
float PixelCenterOffset; // = 0.5f // Set to 0.0f for DirectX <= 9, 0.5f for Direct3D >= 10 and OpenGL.
|
||||||
|
|
||||||
// Settings - Functions (fill once)
|
// Settings - Rendering function (REQUIRED)
|
||||||
void (*RenderDrawListsFn)(ImDrawList** const draw_lists, int count); // Required
|
// See example code if you are unsure of how to implement this.
|
||||||
const char* (*GetClipboardTextFn)(); // Required for clipboard support
|
void (*RenderDrawListsFn)(ImDrawList** const draw_lists, int count);
|
||||||
void (*SetClipboardTextFn)(const char* text, const char* text_end); // Required for clipboard support (nb- the string is *NOT* zero-terminated at 'text_end')
|
|
||||||
|
// Settings - Clipboard Support
|
||||||
|
// Override to provide your clipboard handlers.
|
||||||
|
// On Windows architecture, defaults to use the native Win32 clipboard, otherwise default to use a ImGui private clipboard.
|
||||||
|
// NB- for SetClipboardTextFn, the string is *NOT* zero-terminated at 'text_end'
|
||||||
|
const char* (*GetClipboardTextFn)();
|
||||||
|
void (*SetClipboardTextFn)(const char* text, const char* text_end);
|
||||||
|
|
||||||
// Input - Fill before calling NewFrame()
|
// Input - Fill before calling NewFrame()
|
||||||
ImVec2 MousePos; // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
|
ImVec2 MousePos; // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
|
||||||
bool MouseDown[2]; // Mouse buttons
|
bool MouseDown[5]; // Mouse buttons. ImGui itself only uses button 0 (left button) but you can use others as storage for convenience.
|
||||||
int MouseWheel; // Mouse wheel: -1,0,+1
|
int MouseWheel; // Mouse wheel: -1,0,+1
|
||||||
bool KeyCtrl; // Keyboard modifier pressed: Control
|
bool KeyCtrl; // Keyboard modifier pressed: Control
|
||||||
bool KeyShift; // Keyboard modifier pressed: Shift
|
bool KeyShift; // Keyboard modifier pressed: Shift
|
||||||
@ -404,11 +419,11 @@ struct ImGuiIO
|
|||||||
// [Internal] ImGui will maintain those fields for you
|
// [Internal] ImGui will maintain those fields for you
|
||||||
ImVec2 MousePosPrev;
|
ImVec2 MousePosPrev;
|
||||||
ImVec2 MouseDelta;
|
ImVec2 MouseDelta;
|
||||||
bool MouseClicked[2];
|
bool MouseClicked[5];
|
||||||
ImVec2 MouseClickedPos[2];
|
ImVec2 MouseClickedPos[5];
|
||||||
float MouseClickedTime[2];
|
float MouseClickedTime[5];
|
||||||
bool MouseDoubleClicked[2];
|
bool MouseDoubleClicked[5];
|
||||||
float MouseDownTime[2];
|
float MouseDownTime[5];
|
||||||
float KeysDownTime[512];
|
float KeysDownTime[512];
|
||||||
|
|
||||||
ImGuiIO();
|
ImGuiIO();
|
||||||
@ -505,8 +520,8 @@ struct ImDrawCmd
|
|||||||
ImVec4 clip_rect;
|
ImVec4 clip_rect;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef IMDRAW_TEX_UV_FOR_WHITE
|
#ifndef IMGUI_FONT_TEX_UV_FOR_WHITE
|
||||||
#define IMDRAW_TEX_UV_FOR_WHITE ImVec2(0,0)
|
#define IMGUI_FONT_TEX_UV_FOR_WHITE ImVec2(0.f,0.f)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// sizeof() == 20
|
// sizeof() == 20
|
||||||
@ -521,8 +536,11 @@ struct ImDrawVert
|
|||||||
// User is responsible for providing a renderer for this in ImGuiIO::RenderDrawListFn
|
// User is responsible for providing a renderer for this in ImGuiIO::RenderDrawListFn
|
||||||
struct ImDrawList
|
struct ImDrawList
|
||||||
{
|
{
|
||||||
ImVector<ImDrawCmd> commands;
|
// This is what you have to render
|
||||||
|
ImVector<ImDrawCmd> commands; // commands
|
||||||
ImVector<ImDrawVert> vtx_buffer; // each command consume ImDrawCmd::vtx_count of those
|
ImVector<ImDrawVert> vtx_buffer; // each command consume ImDrawCmd::vtx_count of those
|
||||||
|
|
||||||
|
// [Internal to ImGui]
|
||||||
ImVector<ImVec4> clip_rect_stack; // [internal] clip rect stack while building the command-list (so text command can perform clipping early on)
|
ImVector<ImVec4> clip_rect_stack; // [internal] clip rect stack while building the command-list (so text command can perform clipping early on)
|
||||||
ImDrawVert* vtx_write; // [internal] point within vtx_buffer after each add command (to avoid using the ImVector<> operators too much)
|
ImDrawVert* vtx_write; // [internal] point within vtx_buffer after each add command (to avoid using the ImVector<> operators too much)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user