next imgui/examples/example_glfw_vulkan/main.cpp:67 │ imgui/examples/example_sdl_vulkan/main.cpp:59
│
VkResult err; │ VkResult err;
│
// Create Vulkan Instance │ // Create Vulkan Instance
{ │ {
VkInstanceCreateInfo create_info = {}; │ VkInstanceCreateInfo create_info = {};
create_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; │ create_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
create_info.enabledExtensionCount = extensions_count; │ create_info.enabledExtensionCount = extensions_count;
create_info.ppEnabledExtensionNames = extensions; │ create_info.ppEnabledExtensionNames = extensions;
#ifdef IMGUI_VULKAN_DEBUG_REPORT │ #ifdef IMGUI_VULKAN_DEBUG_REPORT
// Enabling validation layers │ // Enabling validation layers
const char* layers[] = { "VK_LAYER_KHRONOS_validation" }; │ const char* layers[] = { "VK_LAYER_KHRONOS_validation" };
create_info.enabledLayerCount = 1; │ create_info.enabledLayerCount = 1;
create_info.ppEnabledLayerNames = layers; │ create_info.ppEnabledLayerNames = layers;
│
// Enable debug report extension (we need additional storage, so we duplicate th │ // Enable debug report extension (we need additional storage, so we duplicate th
const char** extensions_ext = (const char**)malloc(sizeof(const char*) * (extens │ const char** extensions_ext = (const char**)malloc(sizeof(const char*) * (extens
memcpy(extensions_ext, extensions, extensions_count * sizeof(const char*)); │ memcpy(extensions_ext, extensions, extensions_count * sizeof(const char*));
extensions_ext[extensions_count] = "VK_EXT_debug_report"; │ extensions_ext[extensions_count] = "VK_EXT_debug_report";
create_info.enabledExtensionCount = extensions_count + 1; │ create_info.enabledExtensionCount = extensions_count + 1;
create_info.ppEnabledExtensionNames = extensions_ext; │ create_info.ppEnabledExtensionNames = extensions_ext;
│
// Create Vulkan Instance │ // Create Vulkan Instance
err = vkCreateInstance(&create_info, g_Allocator, &g_Instance); │ err = vkCreateInstance(&create_info, g_Allocator, &g_Instance);
check_vk_result(err); │ check_vk_result(err);
free(extensions_ext); │ free(extensions_ext);
│
// Get the function pointer (required for any extensions) │ // Get the function pointer (required for any extensions)
auto vkCreateDebugReportCallbackEXT = (PFN_vkCreateDebugReportCallbackEXT)vkGetI │ auto vkCreateDebugReportCallbackEXT = (PFN_vkCreateDebugReportCallbackEXT)vkGetI
IM_ASSERT(vkCreateDebugReportCallbackEXT != NULL); │ IM_ASSERT(vkCreateDebugReportCallbackEXT != NULL);
│
// Setup the debug report callback │ // Setup the debug report callback
VkDebugReportCallbackCreateInfoEXT debug_report_ci = {}; │ VkDebugReportCallbackCreateInfoEXT debug_report_ci = {};
debug_report_ci.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT; │ debug_report_ci.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT;
debug_report_ci.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_ │ debug_report_ci.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_
debug_report_ci.pfnCallback = debug_report; │ debug_report_ci.pfnCallback = debug_report;
debug_report_ci.pUserData = NULL; │ debug_report_ci.pUserData = NULL;
err = vkCreateDebugReportCallbackEXT(g_Instance, &debug_report_ci, g_Allocator, │ err = vkCreateDebugReportCallbackEXT(g_Instance, &debug_report_ci, g_Allocator,
check_vk_result(err); │ check_vk_result(err);
#else │ #else
// Create Vulkan Instance without any debug feature │ // Create Vulkan Instance without any debug feature
err = vkCreateInstance(&create_info, g_Allocator, &g_Instance); │ err = vkCreateInstance(&create_info, g_Allocator, &g_Instance);
check_vk_result(err); │ check_vk_result(err);
IM_UNUSED(g_DebugReport); │ IM_UNUSED(g_DebugReport);
#endif │ #endif
} │ }
│
// Select GPU │ // Select GPU
{ │ {
uint32_t gpu_count; │ uint32_t gpu_count;
err = vkEnumeratePhysicalDevices(g_Instance, &gpu_count, NULL); │ err = vkEnumeratePhysicalDevices(g_Instance, &gpu_count, NULL);
check_vk_result(err); │ check_vk_result(err);
IM_ASSERT(gpu_count > 0); │ IM_ASSERT(gpu_count > 0);
│
VkPhysicalDevice* gpus = (VkPhysicalDevice*)malloc(sizeof(VkPhysicalDevice) * gp │ VkPhysicalDevice* gpus = (VkPhysicalDevice*)malloc(sizeof(VkPhysicalDevice) * gp
err = vkEnumeratePhysicalDevices(g_Instance, &gpu_count, gpus); │ err = vkEnumeratePhysicalDevices(g_Instance, &gpu_count, gpus);
check_vk_result(err); │ check_vk_result(err);
│
// If a number >1 of GPUs got reported, find discrete GPU if present, or use fir │ // If a number >1 of GPUs got reported, find discrete GPU if present, or use fir
// most common cases (multi-gpu/integrated+dedicated graphics). Handling more co │ // most common cases (multi-gpu/integrated+dedicated graphics). Handling more co
// dedicated GPUs) is out of scope of this sample. │ // dedicated GPUs) is out of scope of this sample.
int use_gpu = 0; │ int use_gpu = 0;
for (int i = 0; i < (int)gpu_count; i++) │ for (int i = 0; i < (int)gpu_count; i++)
{ │ {
VkPhysicalDeviceProperties properties; │ VkPhysicalDeviceProperties properties;
vkGetPhysicalDeviceProperties(gpus[i], &properties); │ vkGetPhysicalDeviceProperties(gpus[i], &properties);
if (properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) │ if (properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU)
{ │ {
use_gpu = i; │ use_gpu = i;
break; │ break;
} │ }
} │ }
│
g_PhysicalDevice = gpus[use_gpu]; │ g_PhysicalDevice = gpus[use_gpu];
free(gpus); │ free(gpus);
} │ }
│
// Select graphics queue family │ // Select graphics queue family
{ │ {
uint32_t count; │ uint32_t count;
vkGetPhysicalDeviceQueueFamilyProperties(g_PhysicalDevice, &count, NULL); │ vkGetPhysicalDeviceQueueFamilyProperties(g_PhysicalDevice, &count, NULL);
VkQueueFamilyProperties* queues = (VkQueueFamilyProperties*)malloc(sizeof(VkQueu │ VkQueueFamilyProperties* queues = (VkQueueFamilyProperties*)malloc(sizeof(VkQueu
vkGetPhysicalDeviceQueueFamilyProperties(g_PhysicalDevice, &count, queues); │ vkGetPhysicalDeviceQueueFamilyProperties(g_PhysicalDevice, &count, queues);
for (uint32_t i = 0; i < count; i++) │ for (uint32_t i = 0; i < count; i++)
if (queues[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) │ if (queues[i].queueFlags & VK_QUEUE_GRAPHICS_BIT)
{ │ {
g_QueueFamily = i; │ g_QueueFamily = i;
break; │ break;
} │ }
free(queues); │ free(queues);
IM_ASSERT(g_QueueFamily != (uint32_t)-1); │ IM_ASSERT(g_QueueFamily != (uint32_t)-1);
} │ }
│
// Create Logical Device (with 1 queue) │ // Create Logical Device (with 1 queue)
{ │ {
int device_extension_count = 1; │ int device_extension_count = 1;
const char* device_extensions[] = { "VK_KHR_swapchain" }; │ const char* device_extensions[] = { "VK_KHR_swapchain" };
const float queue_priority[] = { 1.0f }; │ const float queue_priority[] = { 1.0f };
VkDeviceQueueCreateInfo queue_info[1] = {}; │ VkDeviceQueueCreateInfo queue_info[1] = {};
queue_info[0].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; │ queue_info[0].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
queue_info[0].queueFamilyIndex = g_QueueFamily; │ queue_info[0].queueFamilyIndex = g_QueueFamily;
queue_info[0].queueCount = 1; │ queue_info[0].queueCount = 1;
queue_info[0].pQueuePriorities = queue_priority; │ queue_info[0].pQueuePriorities = queue_priority;
VkDeviceCreateInfo create_info = {}; │ VkDeviceCreateInfo create_info = {};
create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; │ create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
create_info.queueCreateInfoCount = sizeof(queue_info) / sizeof(queue_info[0]); │ create_info.queueCreateInfoCount = sizeof(queue_info) / sizeof(queue_info[0]);
create_info.pQueueCreateInfos = queue_info; │ create_info.pQueueCreateInfos = queue_info;
create_info.enabledExtensionCount = device_extension_count; │ create_info.enabledExtensionCount = device_extension_count;
create_info.ppEnabledExtensionNames = device_extensions; │ create_info.ppEnabledExtensionNames = device_extensions;
err = vkCreateDevice(g_PhysicalDevice, &create_info, g_Allocator, &g_Device); │ err = vkCreateDevice(g_PhysicalDevice, &create_info, g_Allocator, &g_Device);
check_vk_result(err); │ check_vk_result(err);
vkGetDeviceQueue(g_Device, g_QueueFamily, 0, &g_Queue); │ vkGetDeviceQueue(g_Device, g_QueueFamily, 0, &g_Queue);
} │ }
│
// Create Descriptor Pool │ // Create Descriptor Pool
{ │ {
VkDescriptorPoolSize pool_sizes[] = │ VkDescriptorPoolSize pool_sizes[] =
{ │ {
{ VK_DESCRIPTOR_TYPE_SAMPLER, 1000 }, │ { VK_DESCRIPTOR_TYPE_SAMPLER, 1000 },
{ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1000 }, │ { VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1000 },
{ VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 1000 }, │ { VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 1000 },
{ VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1000 }, │ { VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1000 },
{ VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, 1000 }, │ { VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, 1000 },
{ VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, 1000 }, │ { VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, 1000 },
{ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1000 }, │ { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1000 },
{ VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1000 }, │ { VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1000 },
{ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1000 }, │ { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1000 },
{ VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, 1000 }, │ { VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, 1000 },
{ VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1000 } │ { VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1000 }
}; │ };
VkDescriptorPoolCreateInfo pool_info = {}; │ VkDescriptorPoolCreateInfo pool_info = {};
pool_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; │ pool_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
pool_info.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT; │ pool_info.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT;
pool_info.maxSets = 1000 * IM_ARRAYSIZE(pool_sizes); │ pool_info.maxSets = 1000 * IM_ARRAYSIZE(pool_sizes);
pool_info.poolSizeCount = (uint32_t)IM_ARRAYSIZE(pool_sizes); │ pool_info.poolSizeCount = (uint32_t)IM_ARRAYSIZE(pool_sizes);
pool_info.pPoolSizes = pool_sizes; │ pool_info.pPoolSizes = pool_sizes;
err = vkCreateDescriptorPool(g_Device, &pool_info, g_Allocator, &g_DescriptorPoo │ err = vkCreateDescriptorPool(g_Device, &pool_info, g_Allocator, &g_DescriptorPoo
check_vk_result(err); │ check_vk_result(err);
} │ }
} │
next prev up imgui/backends/imgui_impl_dx10.cpp:357 │ imgui/backends/imgui_impl_dx11.cpp:369
│
ImGui_ImplDX10_Data* bd = ImGui_ImplDX10_GetBackendData(); │ ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData();
if (!bd->pd3dDevice) │ if (!bd->pd3dDevice)
return false; │ return false;
if (bd->pFontSampler) │ if (bd->pFontSampler)
ImGui_ImplDX10_InvalidateDeviceObjects(); │ ImGui_ImplDX11_InvalidateDeviceObjects();
│
// By using D3DCompile() from <d3dcompiler.h> / d3dcompiler.lib, we introduce a depe │ // By using D3DCompile() from <d3dcompiler.h> / d3dcompiler.lib, we introduce a depe
// If you would like to use this DX10 sample code but remove this dependency you can │ // If you would like to use this DX11 sample code but remove this dependency you can
// 1) compile once, save the compiled shader blobs into a file or source code and p │ // 1) compile once, save the compiled shader blobs into a file or source code and p
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile fr │ // 2) use code to detect any version of the DLL and grab a pointer to D3DCompile fr
// See https://github.com/ocornut/imgui/pull/638 for sources and details. │ // See https://github.com/ocornut/imgui/pull/638 for sources and details.
│
// Create the vertex shader │ // Create the vertex shader
{ │ {
static const char* vertexShader = │ static const char* vertexShader =
"cbuffer vertexBuffer : register(b0) \ │ "cbuffer vertexBuffer : register(b0) \
{\ │ {\
float4x4 ProjectionMatrix; \ │ float4x4 ProjectionMatrix; \
};\ │ };\
struct VS_INPUT\ │ struct VS_INPUT\
{\ │ {\
float2 pos : POSITION;\ │ float2 pos : POSITION;\
float4 col : COLOR0;\ │ float4 col : COLOR0;\
float2 uv : TEXCOORD0;\ │ float2 uv : TEXCOORD0;\
};\ │ };\
\ │ \
struct PS_INPUT\ │ struct PS_INPUT\
{\ │ {\
float4 pos : SV_POSITION;\ │ float4 pos : SV_POSITION;\
float4 col : COLOR0;\ │ float4 col : COLOR0;\
float2 uv : TEXCOORD0;\ │ float2 uv : TEXCOORD0;\
};\ │ };\
\ │ \
PS_INPUT main(VS_INPUT input)\ │ PS_INPUT main(VS_INPUT input)\
{\ │ {\
PS_INPUT output;\ │ PS_INPUT output;\
output.pos = mul( ProjectionMatrix, float4(input.pos.xy, 0.f, 1.f));\ │ output.pos = mul( ProjectionMatrix, float4(input.pos.xy, 0.f, 1.f));\
output.col = input.col;\ │ output.col = input.col;\
output.uv = input.uv;\ │ output.uv = input.uv;\
return output;\ │ return output;\
}"; │ }";
│
ID3DBlob* vertexShaderBlob; │ ID3DBlob* vertexShaderBlob;
if (FAILED(D3DCompile(vertexShader, strlen(vertexShader), NULL, NULL, NULL, "mai │ if (FAILED(D3DCompile(vertexShader, strlen(vertexShader), NULL, NULL, NULL, "mai
return false; // NB: Pass ID3DBlob* pErrorBlob to D3DCompile() to get error │ return false; // NB: Pass ID3DBlob* pErrorBlob to D3DCompile() to get error
if (bd->pd3dDevice->CreateVertexShader(vertexShaderBlob->GetBufferPointer(), ver │ if (bd->pd3dDevice->CreateVertexShader(vertexShaderBlob->GetBufferPointer(), ver
{ │ {
vertexShaderBlob->Release(); │ vertexShaderBlob->Release();
return false; │ return false;
} │ }
│
// Create the input layout │ // Create the input layout
D3D10_INPUT_ELEMENT_DESC local_layout[] = │ D3D11_INPUT_ELEMENT_DESC local_layout[] =
{ │ {
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert │ { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert │ { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert
{ "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (UINT)IM_OFFSETOF(ImDrawVert │ { "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (UINT)IM_OFFSETOF(ImDrawVert
}; │ };
if (bd->pd3dDevice->CreateInputLayout(local_layout, 3, vertexShaderBlob->GetBuff │ if (bd->pd3dDevice->CreateInputLayout(local_layout, 3, vertexShaderBlob->GetBuff
{ │ {
vertexShaderBlob->Release(); │ vertexShaderBlob->Release();
return false; │ return false;
} │ }
vertexShaderBlob->Release(); │ vertexShaderBlob->Release();
│
// Create the constant buffer │ // Create the constant buffer
{ │ {
D3D10_BUFFER_DESC desc; │ D3D11_BUFFER_DESC desc;
desc.ByteWidth = sizeof(VERTEX_CONSTANT_BUFFER); │ desc.ByteWidth = sizeof(VERTEX_CONSTANT_BUFFER);
desc.Usage = D3D10_USAGE_DYNAMIC; │ desc.Usage = D3D11_USAGE_DYNAMIC;
desc.BindFlags = D3D10_BIND_CONSTANT_BUFFER; │ desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
desc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE; │ desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
desc.MiscFlags = 0; │ desc.MiscFlags = 0;
bd->pd3dDevice->CreateBuffer(&desc, NULL, &bd->pVertexConstantBuffer); │ bd->pd3dDevice->CreateBuffer(&desc, NULL, &bd->pVertexConstantBuffer);
} │ }
} │ }
│
// Create the pixel shader │ // Create the pixel shader
{ │ {
static const char* pixelShader = │ static const char* pixelShader =
"struct PS_INPUT\ │ "struct PS_INPUT\
{\ │ {\
float4 pos : SV_POSITION;\ │ float4 pos : SV_POSITION;\
float4 col : COLOR0;\ │ float4 col : COLOR0;\
float2 uv : TEXCOORD0;\ │ float2 uv : TEXCOORD0;\
};\ │ };\
sampler sampler0;\ │ sampler sampler0;\
Texture2D texture0;\ │ Texture2D texture0;\
\ │ \
float4 main(PS_INPUT input) : SV_Target\ │ float4 main(PS_INPUT input) : SV_Target\
{\ │ {\
float4 out_col = input.col * texture0.Sample(sampler0, input.uv); \ │ float4 out_col = input.col * texture0.Sample(sampler0, input.uv); \
return out_col; \ │ return out_col; \
}"; │ }";
│
ID3DBlob* pixelShaderBlob; │ ID3DBlob* pixelShaderBlob;
if (FAILED(D3DCompile(pixelShader, strlen(pixelShader), NULL, NULL, NULL, "main" │ if (FAILED(D3DCompile(pixelShader, strlen(pixelShader), NULL, NULL, NULL, "main"
return false; // NB: Pass ID3DBlob* pErrorBlob to D3DCompile() to get error │ return false; // NB: Pass ID3DBlob* pErrorBlob to D3DCompile() to get error
if (bd->pd3dDevice->CreatePixelShader(pixelShaderBlob->GetBufferPointer(), pixel │ if (bd->pd3dDevice->CreatePixelShader(pixelShaderBlob->GetBufferPointer(), pixel
{ │ {
pixelShaderBlob->Release(); │ pixelShaderBlob->Release();
return false; │ return false;
} │ }
pixelShaderBlob->Release(); │ pixelShaderBlob->Release();
} │ }
│
// Create the blending setup │ // Create the blending setup
{ │ {
D3D10_BLEND_DESC desc; │ D3D11_BLEND_DESC desc;
ZeroMemory(&desc, sizeof(desc)); │ ZeroMemory(&desc, sizeof(desc));
desc.AlphaToCoverageEnable = false; │ desc.AlphaToCoverageEnable = false;
desc.BlendEnable[0] = true; │ desc.RenderTarget[0].BlendEnable = true;
desc.SrcBlend = D3D10_BLEND_SRC_ALPHA; │ desc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
desc.DestBlend = D3D10_BLEND_INV_SRC_ALPHA; │ desc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
desc.BlendOp = D3D10_BLEND_OP_ADD; │ desc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
desc.SrcBlendAlpha = D3D10_BLEND_ONE; │ desc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
desc.DestBlendAlpha = D3D10_BLEND_INV_SRC_ALPHA; │ desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA;
desc.BlendOpAlpha = D3D10_BLEND_OP_ADD; │ desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
desc.RenderTargetWriteMask[0] = D3D10_COLOR_WRITE_ENABLE_ALL; │ desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
bd->pd3dDevice->CreateBlendState(&desc, &bd->pBlendState); │ bd->pd3dDevice->CreateBlendState(&desc, &bd->pBlendState);
} │ }
│
// Create the rasterizer state │ // Create the rasterizer state
{ │ {
D3D10_RASTERIZER_DESC desc; │ D3D11_RASTERIZER_DESC desc;
ZeroMemory(&desc, sizeof(desc)); │ ZeroMemory(&desc, sizeof(desc));
desc.FillMode = D3D10_FILL_SOLID; │ desc.FillMode = D3D11_FILL_SOLID;
desc.CullMode = D3D10_CULL_NONE; │ desc.CullMode = D3D11_CULL_NONE;
desc.ScissorEnable = true; │ desc.ScissorEnable = true;
desc.DepthClipEnable = true; │ desc.DepthClipEnable = true;
bd->pd3dDevice->CreateRasterizerState(&desc, &bd->pRasterizerState); │ bd->pd3dDevice->CreateRasterizerState(&desc, &bd->pRasterizerState);
} │ }
│
// Create depth-stencil State │ // Create depth-stencil State
{ │ {
D3D10_DEPTH_STENCIL_DESC desc; │ D3D11_DEPTH_STENCIL_DESC desc;
ZeroMemory(&desc, sizeof(desc)); │ ZeroMemory(&desc, sizeof(desc));
desc.DepthEnable = false; │ desc.DepthEnable = false;
desc.DepthWriteMask = D3D10_DEPTH_WRITE_MASK_ALL; │ desc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
desc.DepthFunc = D3D10_COMPARISON_ALWAYS; │ desc.DepthFunc = D3D11_COMPARISON_ALWAYS;
desc.StencilEnable = false; │ desc.StencilEnable = false;
desc.FrontFace.StencilFailOp = desc.FrontFace.StencilDepthFailOp = desc.FrontFac │ desc.FrontFace.StencilFailOp = desc.FrontFace.StencilDepthFailOp = desc.FrontFac
desc.FrontFace.StencilFunc = D3D10_COMPARISON_ALWAYS; │ desc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
desc.BackFace = desc.FrontFace; │ desc.BackFace = desc.FrontFace;
bd->pd3dDevice->CreateDepthStencilState(&desc, &bd->pDepthStencilState); │ bd->pd3dDevice->CreateDepthStencilState(&desc, &bd->pDepthStencilState);
} │ }
│
ImGui_ImplDX10_CreateFontsTexture(); │ ImGui_ImplDX11_CreateFontsTexture();
│
return true; │ return true;
} │
next prev up imgui/examples/example_win32_directx11/main.cpp:26 │ imgui/examples/example_win32_directx9/main.cpp:24
│
// Create application window │ // Create application window
//ImGui_ImplWin32_EnableDpiAwareness(); │ //ImGui_ImplWin32_EnableDpiAwareness();
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(N │ WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(N
::RegisterClassEx(&wc); │ ::RegisterClassEx(&wc);
HWND hwnd = ::CreateWindow(wc.lpszClassName, _T("Dear ImGui DirectX11 Example"), WS_ │ HWND hwnd = ::CreateWindow(wc.lpszClassName, _T("Dear ImGui DirectX9 Example"), WS_O
│
// Initialize Direct3D │ // Initialize Direct3D
if (!CreateDeviceD3D(hwnd)) │ if (!CreateDeviceD3D(hwnd))
{ │ {
CleanupDeviceD3D(); │ CleanupDeviceD3D();
::UnregisterClass(wc.lpszClassName, wc.hInstance); │ ::UnregisterClass(wc.lpszClassName, wc.hInstance);
return 1; │ return 1;
} │ }
│
// Show the window │ // Show the window
::ShowWindow(hwnd, SW_SHOWDEFAULT); │ ::ShowWindow(hwnd, SW_SHOWDEFAULT);
::UpdateWindow(hwnd); │ ::UpdateWindow(hwnd);
│
// Setup Dear ImGui context │ // Setup Dear ImGui context
IMGUI_CHECKVERSION(); │ IMGUI_CHECKVERSION();
ImGui::CreateContext(); │ ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io; │ ImGuiIO& io = ImGui::GetIO(); (void)io;
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Contr │ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Contr
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Contro │ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Contro
│
// Setup Dear ImGui style │ // Setup Dear ImGui style
ImGui::StyleColorsDark(); │ ImGui::StyleColorsDark();
//ImGui::StyleColorsClassic(); │ //ImGui::StyleColorsClassic();
│
// Setup Platform/Renderer backends │ // Setup Platform/Renderer backends
ImGui_ImplWin32_Init(hwnd); │ ImGui_ImplWin32_Init(hwnd);
ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext); │ ImGui_ImplDX9_Init(g_pd3dDevice);
│
// Load Fonts │ // Load Fonts
// - If no fonts are loaded, dear imgui will use the default font. You can also load │ // - If no fonts are loaded, dear imgui will use the default font. You can also load
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to │ // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to
// - If the file cannot be loaded, the function will return NULL. Please handle thos │ // - If the file cannot be loaded, the function will return NULL. Please handle thos
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into │ // - The fonts will be rasterized at a given size (w/ oversampling) and stored into
// - Read 'docs/FONTS.md' for more instructions and details. │ // - Read 'docs/FONTS.md' for more instructions and details.
// - Remember that in C/C++ if you want to include a backslash \ in a string literal │ // - Remember that in C/C++ if you want to include a backslash \ in a string literal
//io.Fonts->AddFontDefault(); │ //io.Fonts->AddFontDefault();
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f); │ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f); │ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f); │ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f); │ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18 │ //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18
//IM_ASSERT(font != NULL); │ //IM_ASSERT(font != NULL);
│
// Our state │ // Our state
bool show_demo_window = true; │ bool show_demo_window = true;
bool show_another_window = false; │ bool show_another_window = false;
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); │ ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
│
// Main loop │ // Main loop
bool done = false; │ bool done = false;
while (!done) │ while (!done)
{ │ {
// Poll and handle messages (inputs, window resize, etc.) │ // Poll and handle messages (inputs, window resize, etc.)
// See the WndProc() function below for our to dispatch events to the Win32 back │ // See the WndProc() function below for our to dispatch events to the Win32 back
MSG msg; │ MSG msg;
while (::PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) │ while (::PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
{ │ {
::TranslateMessage(&msg); │ ::TranslateMessage(&msg);
::DispatchMessage(&msg); │ ::DispatchMessage(&msg);
if (msg.message == WM_QUIT) │ if (msg.message == WM_QUIT)
done = true; │ done = true;
} │ }
if (done) │ if (done)
break; │ break;
│
// Start the Dear ImGui frame │ // Start the Dear ImGui frame
ImGui_ImplDX11_NewFrame(); │ ImGui_ImplDX9_NewFrame();
ImGui_ImplWin32_NewFrame(); │ ImGui_ImplWin32_NewFrame();
ImGui::NewFrame(); │ ImGui::NewFrame();
│
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWin │ // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWin
if (show_demo_window) │ if (show_demo_window)
ImGui::ShowDemoWindow(&show_demo_window); │ ImGui::ShowDemoWindow(&show_demo_window);
│
// 2. Show a simple window that we create ourselves. We use a Begin/End pair to │ // 2. Show a simple window that we create ourselves. We use a Begin/End pair to
{ │ {
static float f = 0.0f; │ static float f = 0.0f;
static int counter = 0; │ static int counter = 0;
│
ImGui::Begin("Hello, world!"); // Create a window c │ ImGui::Begin("Hello, world!"); // Create a window c
│
ImGui::Text("This is some useful text."); // Display some text │ ImGui::Text("This is some useful text."); // Display some text
ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storin │ ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storin
ImGui::Checkbox("Another Window", &show_another_window); │ ImGui::Checkbox("Another Window", &show_another_window);
│
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float usin │ ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float usin
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats rep │ ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats rep
│
if (ImGui::Button("Button")) // Buttons return tr │ if (ImGui::Button("Button")) // Buttons return tr
counter++; │ counter++;
ImGui::SameLine(); │ ImGui::SameLine();
ImGui::Text("counter = %d", counter); │ ImGui::Text("counter = %d", counter);
│
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui: │ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui:
ImGui::End(); │ ImGui::End();
} │ }
│
// 3. Show another simple window. │ // 3. Show another simple window.
if (show_another_window) │ if (show_another_window)
{ │ {
ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to │ ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to
ImGui::Text("Hello from another window!"); │ ImGui::Text("Hello from another window!");
if (ImGui::Button("Close Me")) │ if (ImGui::Button("Close Me"))
show_another_window = false; │ show_another_window = false;
ImGui::End(); │ ImGui::End();
} │ }
│
// Rendering │ // Rendering
ImGui::Render(); │ ImGui::EndFrame();
const float clear_color_with_alpha[4] = { clear_color.x * clear_color.w, clear_c │ g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, FALSE);
g_pd3dDeviceContext->OMSetRenderTargets(1, &g_mainRenderTargetView, NULL); │ g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
g_pd3dDeviceContext->ClearRenderTargetView(g_mainRenderTargetView, clear_color_w │ g_pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData()); │ D3DCOLOR clear_col_dx = D3DCOLOR_RGBA((int)(clear_color.x*clear_color.w*255.0f),
│ g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, clear_col_dx, 1
│ if (g_pd3dDevice->BeginScene() >= 0)
│ {
│ ImGui::Render();
│ ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData());
│ g_pd3dDevice->EndScene();
│ }
│ HRESULT result = g_pd3dDevice->Present(NULL, NULL, NULL, NULL);
│
g_pSwapChain->Present(1, 0); // Present with vsync │ // Handle loss of D3D9 device
//g_pSwapChain->Present(0, 0); // Present without vsync │ if (result == D3DERR_DEVICELOST && g_pd3dDevice->TestCooperativeLevel() == D3DER
│ ResetDevice();
} │ }
│
// Cleanup │ ImGui_ImplDX9_Shutdown();
ImGui_ImplDX11_Shutdown(); │
ImGui_ImplWin32_Shutdown(); │ ImGui_ImplWin32_Shutdown();
ImGui::DestroyContext(); │ ImGui::DestroyContext();
│
CleanupDeviceD3D(); │ CleanupDeviceD3D();
::DestroyWindow(hwnd); │ ::DestroyWindow(hwnd);
::UnregisterClass(wc.lpszClassName, wc.hInstance); │ ::UnregisterClass(wc.lpszClassName, wc.hInstance);
│
return 0; │ return 0;
} │
next prev up imgui/examples/example_win32_directx10/main.cpp:26 │ imgui/examples/example_win32_directx9/main.cpp:24
│
// Create application window │ // Create application window
//ImGui_ImplWin32_EnableDpiAwareness(); │ //ImGui_ImplWin32_EnableDpiAwareness();
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(N │ WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(N
::RegisterClassEx(&wc); │ ::RegisterClassEx(&wc);
HWND hwnd = ::CreateWindow(wc.lpszClassName, _T("Dear ImGui DirectX10 Example"), WS_ │ HWND hwnd = ::CreateWindow(wc.lpszClassName, _T("Dear ImGui DirectX9 Example"), WS_O
│
// Initialize Direct3D │ // Initialize Direct3D
if (!CreateDeviceD3D(hwnd)) │ if (!CreateDeviceD3D(hwnd))
{ │ {
CleanupDeviceD3D(); │ CleanupDeviceD3D();
::UnregisterClass(wc.lpszClassName, wc.hInstance); │ ::UnregisterClass(wc.lpszClassName, wc.hInstance);
return 1; │ return 1;
} │ }
│
// Show the window │ // Show the window
::ShowWindow(hwnd, SW_SHOWDEFAULT); │ ::ShowWindow(hwnd, SW_SHOWDEFAULT);
::UpdateWindow(hwnd); │ ::UpdateWindow(hwnd);
│
// Setup Dear ImGui context │ // Setup Dear ImGui context
IMGUI_CHECKVERSION(); │ IMGUI_CHECKVERSION();
ImGui::CreateContext(); │ ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io; │ ImGuiIO& io = ImGui::GetIO(); (void)io;
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Contr │ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Contr
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Contro │ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Contro
│
// Setup Dear ImGui style │ // Setup Dear ImGui style
ImGui::StyleColorsDark(); │ ImGui::StyleColorsDark();
//ImGui::StyleColorsClassic(); │ //ImGui::StyleColorsClassic();
│
// Setup Platform/Renderer backends │ // Setup Platform/Renderer backends
ImGui_ImplWin32_Init(hwnd); │ ImGui_ImplWin32_Init(hwnd);
ImGui_ImplDX10_Init(g_pd3dDevice); │ ImGui_ImplDX9_Init(g_pd3dDevice);
│
// Load Fonts │ // Load Fonts
// - If no fonts are loaded, dear imgui will use the default font. You can also load │ // - If no fonts are loaded, dear imgui will use the default font. You can also load
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to │ // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to
// - If the file cannot be loaded, the function will return NULL. Please handle thos │ // - If the file cannot be loaded, the function will return NULL. Please handle thos
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into │ // - The fonts will be rasterized at a given size (w/ oversampling) and stored into
// - Read 'docs/FONTS.md' for more instructions and details. │ // - Read 'docs/FONTS.md' for more instructions and details.
// - Remember that in C/C++ if you want to include a backslash \ in a string literal │ // - Remember that in C/C++ if you want to include a backslash \ in a string literal
//io.Fonts->AddFontDefault(); │ //io.Fonts->AddFontDefault();
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f); │ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f); │ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f); │ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f); │ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18 │ //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18
//IM_ASSERT(font != NULL); │ //IM_ASSERT(font != NULL);
│
// Our state │ // Our state
bool show_demo_window = true; │ bool show_demo_window = true;
bool show_another_window = false; │ bool show_another_window = false;
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); │ ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
│
// Main loop │ // Main loop
bool done = false; │ bool done = false;
while (!done) │ while (!done)
{ │ {
// Poll and handle messages (inputs, window resize, etc.) │ // Poll and handle messages (inputs, window resize, etc.)
// See the WndProc() function below for our to dispatch events to the Win32 back │ // See the WndProc() function below for our to dispatch events to the Win32 back
MSG msg; │ MSG msg;
while (::PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) │ while (::PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
{ │ {
::TranslateMessage(&msg); │ ::TranslateMessage(&msg);
::DispatchMessage(&msg); │ ::DispatchMessage(&msg);
if (msg.message == WM_QUIT) │ if (msg.message == WM_QUIT)
done = true; │ done = true;
} │ }
if (done) │ if (done)
break; │ break;
│
// Start the Dear ImGui frame │ // Start the Dear ImGui frame
ImGui_ImplDX10_NewFrame(); │ ImGui_ImplDX9_NewFrame();
ImGui_ImplWin32_NewFrame(); │ ImGui_ImplWin32_NewFrame();
ImGui::NewFrame(); │ ImGui::NewFrame();
│
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWin │ // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWin
if (show_demo_window) │ if (show_demo_window)
ImGui::ShowDemoWindow(&show_demo_window); │ ImGui::ShowDemoWindow(&show_demo_window);
│
// 2. Show a simple window that we create ourselves. We use a Begin/End pair to │ // 2. Show a simple window that we create ourselves. We use a Begin/End pair to
{ │ {
static float f = 0.0f; │ static float f = 0.0f;
static int counter = 0; │ static int counter = 0;
│
ImGui::Begin("Hello, world!"); // Create a window c │ ImGui::Begin("Hello, world!"); // Create a window c
│
ImGui::Text("This is some useful text."); // Display some text │ ImGui::Text("This is some useful text."); // Display some text
ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storin │ ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storin
ImGui::Checkbox("Another Window", &show_another_window); │ ImGui::Checkbox("Another Window", &show_another_window);
│
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float usin │ ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float usin
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats rep │ ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats rep
│
if (ImGui::Button("Button")) // Buttons return tr │ if (ImGui::Button("Button")) // Buttons return tr
counter++; │ counter++;
ImGui::SameLine(); │ ImGui::SameLine();
ImGui::Text("counter = %d", counter); │ ImGui::Text("counter = %d", counter);
│
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui: │ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui:
ImGui::End(); │ ImGui::End();
} │ }
│
// 3. Show another simple window. │ // 3. Show another simple window.
if (show_another_window) │ if (show_another_window)
{ │ {
ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to │ ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to
ImGui::Text("Hello from another window!"); │ ImGui::Text("Hello from another window!");
if (ImGui::Button("Close Me")) │ if (ImGui::Button("Close Me"))
show_another_window = false; │ show_another_window = false;
ImGui::End(); │ ImGui::End();
} │ }
│
// Rendering │ // Rendering
ImGui::Render(); │ ImGui::EndFrame();
const float clear_color_with_alpha[4] = { clear_color.x * clear_color.w, clear_c │ g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, FALSE);
g_pd3dDevice->OMSetRenderTargets(1, &g_mainRenderTargetView, NULL); │ g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
g_pd3dDevice->ClearRenderTargetView(g_mainRenderTargetView, clear_color_with_alp │ g_pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
ImGui_ImplDX10_RenderDrawData(ImGui::GetDrawData()); │ D3DCOLOR clear_col_dx = D3DCOLOR_RGBA((int)(clear_color.x*clear_color.w*255.0f),
│ g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, clear_col_dx, 1
│ if (g_pd3dDevice->BeginScene() >= 0)
│ {
│ ImGui::Render();
│ ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData());
│ g_pd3dDevice->EndScene();
│ }
│ HRESULT result = g_pd3dDevice->Present(NULL, NULL, NULL, NULL);
│
g_pSwapChain->Present(1, 0); // Present with vsync │ // Handle loss of D3D9 device
//g_pSwapChain->Present(0, 0); // Present without vsync │ if (result == D3DERR_DEVICELOST && g_pd3dDevice->TestCooperativeLevel() == D3DER
│ ResetDevice();
} │ }
│
ImGui_ImplDX10_Shutdown(); │ ImGui_ImplDX9_Shutdown();
ImGui_ImplWin32_Shutdown(); │ ImGui_ImplWin32_Shutdown();
ImGui::DestroyContext(); │ ImGui::DestroyContext();
│
CleanupDeviceD3D(); │ CleanupDeviceD3D();
::DestroyWindow(hwnd); │ ::DestroyWindow(hwnd);
::UnregisterClass(wc.lpszClassName, wc.hInstance); │ ::UnregisterClass(wc.lpszClassName, wc.hInstance);
│
return 0; │ return 0;
} │
next prev up imgui/examples/example_win32_directx10/main.cpp:26 │ imgui/examples/example_win32_directx11/main.cpp:26
│
// Create application window │ // Create application window
//ImGui_ImplWin32_EnableDpiAwareness(); │ //ImGui_ImplWin32_EnableDpiAwareness();
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(N │ WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(N
::RegisterClassEx(&wc); │ ::RegisterClassEx(&wc);
HWND hwnd = ::CreateWindow(wc.lpszClassName, _T("Dear ImGui DirectX10 Example"), WS_ │ HWND hwnd = ::CreateWindow(wc.lpszClassName, _T("Dear ImGui DirectX11 Example"), WS_
│
// Initialize Direct3D │ // Initialize Direct3D
if (!CreateDeviceD3D(hwnd)) │ if (!CreateDeviceD3D(hwnd))
{ │ {
CleanupDeviceD3D(); │ CleanupDeviceD3D();
::UnregisterClass(wc.lpszClassName, wc.hInstance); │ ::UnregisterClass(wc.lpszClassName, wc.hInstance);
return 1; │ return 1;
} │ }
│
// Show the window │ // Show the window
::ShowWindow(hwnd, SW_SHOWDEFAULT); │ ::ShowWindow(hwnd, SW_SHOWDEFAULT);
::UpdateWindow(hwnd); │ ::UpdateWindow(hwnd);
│
// Setup Dear ImGui context │ // Setup Dear ImGui context
IMGUI_CHECKVERSION(); │ IMGUI_CHECKVERSION();
ImGui::CreateContext(); │ ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io; │ ImGuiIO& io = ImGui::GetIO(); (void)io;
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Contr │ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Contr
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Contro │ //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Contro
│
// Setup Dear ImGui style │ // Setup Dear ImGui style
ImGui::StyleColorsDark(); │ ImGui::StyleColorsDark();
//ImGui::StyleColorsClassic(); │ //ImGui::StyleColorsClassic();
│
// Setup Platform/Renderer backends │ // Setup Platform/Renderer backends
ImGui_ImplWin32_Init(hwnd); │ ImGui_ImplWin32_Init(hwnd);
ImGui_ImplDX10_Init(g_pd3dDevice); │ ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext);
│
// Load Fonts │ // Load Fonts
// - If no fonts are loaded, dear imgui will use the default font. You can also load │ // - If no fonts are loaded, dear imgui will use the default font. You can also load
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to │ // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to
// - If the file cannot be loaded, the function will return NULL. Please handle thos │ // - If the file cannot be loaded, the function will return NULL. Please handle thos
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into │ // - The fonts will be rasterized at a given size (w/ oversampling) and stored into
// - Read 'docs/FONTS.md' for more instructions and details. │ // - Read 'docs/FONTS.md' for more instructions and details.
// - Remember that in C/C++ if you want to include a backslash \ in a string literal │ // - Remember that in C/C++ if you want to include a backslash \ in a string literal
//io.Fonts->AddFontDefault(); │ //io.Fonts->AddFontDefault();
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f); │ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f); │ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f); │ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f); │ //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18 │ //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18
//IM_ASSERT(font != NULL); │ //IM_ASSERT(font != NULL);
│
// Our state │ // Our state
bool show_demo_window = true; │ bool show_demo_window = true;
bool show_another_window = false; │ bool show_another_window = false;
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); │ ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
│
// Main loop │ // Main loop
bool done = false; │ bool done = false;
while (!done) │ while (!done)
{ │ {
// Poll and handle messages (inputs, window resize, etc.) │ // Poll and handle messages (inputs, window resize, etc.)
// See the WndProc() function below for our to dispatch events to the Win32 back │ // See the WndProc() function below for our to dispatch events to the Win32 back
MSG msg; │ MSG msg;
while (::PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) │ while (::PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
{ │ {
::TranslateMessage(&msg); │ ::TranslateMessage(&msg);
::DispatchMessage(&msg); │ ::DispatchMessage(&msg);
if (msg.message == WM_QUIT) │ if (msg.message == WM_QUIT)
done = true; │ done = true;
} │ }
if (done) │ if (done)
break; │ break;
│
// Start the Dear ImGui frame │ // Start the Dear ImGui frame
ImGui_ImplDX10_NewFrame(); │ ImGui_ImplDX11_NewFrame();
ImGui_ImplWin32_NewFrame(); │ ImGui_ImplWin32_NewFrame();
ImGui::NewFrame(); │ ImGui::NewFrame();
│
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWin │ // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWin
if (show_demo_window) │ if (show_demo_window)
ImGui::ShowDemoWindow(&show_demo_window); │ ImGui::ShowDemoWindow(&show_demo_window);
│
// 2. Show a simple window that we create ourselves. We use a Begin/End pair to │ // 2. Show a simple window that we create ourselves. We use a Begin/End pair to
{ │ {
static float f = 0.0f; │ static float f = 0.0f;
static int counter = 0; │ static int counter = 0;
│
ImGui::Begin("Hello, world!"); // Create a window c │ ImGui::Begin("Hello, world!"); // Create a window c
│
ImGui::Text("This is some useful text."); // Display some text │ ImGui::Text("This is some useful text."); // Display some text
ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storin │ ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storin
ImGui::Checkbox("Another Window", &show_another_window); │ ImGui::Checkbox("Another Window", &show_another_window);
│
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float usin │ ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float usin
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats rep │ ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats rep
│
if (ImGui::Button("Button")) // Buttons return tr │ if (ImGui::Button("Button")) // Buttons return tr
counter++; │ counter++;
ImGui::SameLine(); │ ImGui::SameLine();
ImGui::Text("counter = %d", counter); │ ImGui::Text("counter = %d", counter);
│
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui: │ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui:
ImGui::End(); │ ImGui::End();
} │ }
│
// 3. Show another simple window. │ // 3. Show another simple window.
if (show_another_window) │ if (show_another_window)
{ │ {
ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to │ ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to
ImGui::Text("Hello from another window!"); │ ImGui::Text("Hello from another window!");
if (ImGui::Button("Close Me")) │ if (ImGui::Button("Close Me"))
show_another_window = false; │ show_another_window = false;
ImGui::End(); │ ImGui::End();
} │ }
│
// Rendering │ // Rendering
ImGui::Render(); │ ImGui::Render();
const float clear_color_with_alpha[4] = { clear_color.x * clear_color.w, clear_c │ const float clear_color_with_alpha[4] = { clear_color.x * clear_color.w, clear_c
g_pd3dDevice->OMSetRenderTargets(1, &g_mainRenderTargetView, NULL); │ g_pd3dDeviceContext->OMSetRenderTargets(1, &g_mainRenderTargetView, NULL);
g_pd3dDevice->ClearRenderTargetView(g_mainRenderTargetView, clear_color_with_alp │ g_pd3dDeviceContext->ClearRenderTargetView(g_mainRenderTargetView, clear_color_w
ImGui_ImplDX10_RenderDrawData(ImGui::GetDrawData()); │ ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
│
g_pSwapChain->Present(1, 0); // Present with vsync │ g_pSwapChain->Present(1, 0); // Present with vsync
//g_pSwapChain->Present(0, 0); // Present without vsync │ //g_pSwapChain->Present(0, 0); // Present without vsync
} │ }
│
ImGui_ImplDX10_Shutdown(); │ // Cleanup
│ ImGui_ImplDX11_Shutdown();
ImGui_ImplWin32_Shutdown(); │ ImGui_ImplWin32_Shutdown();
ImGui::DestroyContext(); │ ImGui::DestroyContext();
│
CleanupDeviceD3D(); │ CleanupDeviceD3D();
::DestroyWindow(hwnd); │ ::DestroyWindow(hwnd);
::UnregisterClass(wc.lpszClassName, wc.hInstance); │ ::UnregisterClass(wc.lpszClassName, wc.hInstance);
│
return 0; │ return 0;
} │
next prev up imgui/examples/example_glfw_vulkan/main.cpp:467 │ imgui/examples/example_sdl_vulkan/main.cpp:460
│
// Poll and handle events (inputs, window resize, etc.) │ // Poll and handle events (inputs, window resize, etc.)
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if │ // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your │ // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to │ // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to
// Generally you may always pass all inputs to dear imgui, and hide them from yo │ // Generally you may always pass all inputs to dear imgui, and hide them from yo
glfwPollEvents(); │ SDL_Event event;
│ while (SDL_PollEvent(&event))
│ {
│ ImGui_ImplSDL2_ProcessEvent(&event);
│ if (event.type == SDL_QUIT)
│ done = true;
│ if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_C
│ done = true;
│ }
│
// Resize swap chain? │ // Resize swap chain?
if (g_SwapChainRebuild) │ if (g_SwapChainRebuild)
{ │ {
int width, height; │ int width, height;
glfwGetFramebufferSize(window, &width, &height); │ SDL_GetWindowSize(window, &width, &height);
if (width > 0 && height > 0) │ if (width > 0 && height > 0)
{ │ {
ImGui_ImplVulkan_SetMinImageCount(g_MinImageCount); │ ImGui_ImplVulkan_SetMinImageCount(g_MinImageCount);
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_D │ ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_D
g_MainWindowData.FrameIndex = 0; │ g_MainWindowData.FrameIndex = 0;
g_SwapChainRebuild = false; │ g_SwapChainRebuild = false;
} │ }
} │ }
│
// Start the Dear ImGui frame │ // Start the Dear ImGui frame
ImGui_ImplVulkan_NewFrame(); │ ImGui_ImplVulkan_NewFrame();
ImGui_ImplGlfw_NewFrame(); │ ImGui_ImplSDL2_NewFrame();
ImGui::NewFrame(); │ ImGui::NewFrame();
│
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWin │ // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWin
if (show_demo_window) │ if (show_demo_window)
ImGui::ShowDemoWindow(&show_demo_window); │ ImGui::ShowDemoWindow(&show_demo_window);
│
// 2. Show a simple window that we create ourselves. We use a Begin/End pair to │ // 2. Show a simple window that we create ourselves. We use a Begin/End pair to
{ │ {
static float f = 0.0f; │ static float f = 0.0f;
static int counter = 0; │ static int counter = 0;
│
ImGui::Begin("Hello, world!"); // Create a window c │ ImGui::Begin("Hello, world!"); // Create a window c
│
ImGui::Text("This is some useful text."); // Display some text │ ImGui::Text("This is some useful text."); // Display some text
ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storin │ ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storin
ImGui::Checkbox("Another Window", &show_another_window); │ ImGui::Checkbox("Another Window", &show_another_window);
│
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float usin │ ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float usin
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats rep │ ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats rep
│
if (ImGui::Button("Button")) // Buttons return tr │ if (ImGui::Button("Button")) // Buttons return tr
counter++; │ counter++;
ImGui::SameLine(); │ ImGui::SameLine();
ImGui::Text("counter = %d", counter); │ ImGui::Text("counter = %d", counter);
│
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui: │ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui:
ImGui::End(); │ ImGui::End();
} │ }
│
// 3. Show another simple window. │ // 3. Show another simple window.
if (show_another_window) │ if (show_another_window)
{ │ {
ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to │ ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to
ImGui::Text("Hello from another window!"); │ ImGui::Text("Hello from another window!");
if (ImGui::Button("Close Me")) │ if (ImGui::Button("Close Me"))
show_another_window = false; │ show_another_window = false;
ImGui::End(); │ ImGui::End();
} │ }
│
// Rendering │ // Rendering
ImGui::Render(); │ ImGui::Render();
ImDrawData* draw_data = ImGui::GetDrawData(); │ ImDrawData* draw_data = ImGui::GetDrawData();
const bool is_minimized = (draw_data->DisplaySize.x <= 0.0f || draw_data->Displa │ const bool is_minimized = (draw_data->DisplaySize.x <= 0.0f || draw_data->Displa
if (!is_minimized) │ if (!is_minimized)
{ │ {
wd->ClearValue.color.float32[0] = clear_color.x * clear_color.w; │ wd->ClearValue.color.float32[0] = clear_color.x * clear_color.w;
wd->ClearValue.color.float32[1] = clear_color.y * clear_color.w; │ wd->ClearValue.color.float32[1] = clear_color.y * clear_color.w;
wd->ClearValue.color.float32[2] = clear_color.z * clear_color.w; │ wd->ClearValue.color.float32[2] = clear_color.z * clear_color.w;
wd->ClearValue.color.float32[3] = clear_color.w; │ wd->ClearValue.color.float32[3] = clear_color.w;
FrameRender(wd, draw_data); │ FrameRender(wd, draw_data);
FramePresent(wd); │ FramePresent(wd);
} │ }
} │
next prev up imgui/examples/example_sdl_opengl2/main.cpp:79 │ imgui/examples/example_glfw_opengl2/main.cpp:80
│
// Poll and handle events (inputs, window resize, etc.) │ // Poll and handle events (inputs, window resize, etc.)
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if │ // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your │ // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to │ // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to
// Generally you may always pass all inputs to dear imgui, and hide them from yo │ // Generally you may always pass all inputs to dear imgui, and hide them from yo
SDL_Event event; │ glfwPollEvents();
while (SDL_PollEvent(&event)) │
{ │
ImGui_ImplSDL2_ProcessEvent(&event); │
if (event.type == SDL_QUIT) │
done = true; │
if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_C │
done = true; │
} │
│
// Start the Dear ImGui frame │ // Start the Dear ImGui frame
ImGui_ImplOpenGL2_NewFrame(); │ ImGui_ImplOpenGL2_NewFrame();
ImGui_ImplSDL2_NewFrame(); │ ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame(); │ ImGui::NewFrame();
│
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWin │ // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWin
if (show_demo_window) │ if (show_demo_window)
ImGui::ShowDemoWindow(&show_demo_window); │ ImGui::ShowDemoWindow(&show_demo_window);
│
// 2. Show a simple window that we create ourselves. We use a Begin/End pair to │ // 2. Show a simple window that we create ourselves. We use a Begin/End pair to
{ │ {
static float f = 0.0f; │ static float f = 0.0f;
static int counter = 0; │ static int counter = 0;
│
ImGui::Begin("Hello, world!"); // Create a window c │ ImGui::Begin("Hello, world!"); // Create a window c
│
ImGui::Text("This is some useful text."); // Display some text │ ImGui::Text("This is some useful text."); // Display some text
ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storin │ ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storin
ImGui::Checkbox("Another Window", &show_another_window); │ ImGui::Checkbox("Another Window", &show_another_window);
│
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float usin │ ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float usin
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats rep │ ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats rep
│
if (ImGui::Button("Button")) // Buttons return tr │ if (ImGui::Button("Button")) // Buttons return tr
counter++; │ counter++;
ImGui::SameLine(); │ ImGui::SameLine();
ImGui::Text("counter = %d", counter); │ ImGui::Text("counter = %d", counter);
│
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui: │ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui:
ImGui::End(); │ ImGui::End();
} │ }
│
// 3. Show another simple window. │ // 3. Show another simple window.
if (show_another_window) │ if (show_another_window)
{ │ {
ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to │ ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to
ImGui::Text("Hello from another window!"); │ ImGui::Text("Hello from another window!");
if (ImGui::Button("Close Me")) │ if (ImGui::Button("Close Me"))
show_another_window = false; │ show_another_window = false;
ImGui::End(); │ ImGui::End();
} │ }
│
// Rendering │ // Rendering
ImGui::Render(); │ ImGui::Render();
glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y); │ int display_w, display_h;
│ glfwGetFramebufferSize(window, &display_w, &display_h);
│ glViewport(0, 0, display_w, display_h);
glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear │ glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear
glClear(GL_COLOR_BUFFER_BIT); │ glClear(GL_COLOR_BUFFER_BIT);
//glUseProgram(0); // You may want this if using this code in an OpenGL 3+ conte │
│ // If you are using this code with non-legacy OpenGL header/contexts (which you
│ // you may need to backup/reset/restore other state, e.g. for current shader usi
│ //GLint last_program;
│ //glGetIntegerv(GL_CURRENT_PROGRAM, &last_program);
│ //glUseProgram(0);
ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData()); │ ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
SDL_GL_SwapWindow(window); │ //glUseProgram(last_program);
│
│ glfwMakeContextCurrent(window);
│ glfwSwapBuffers(window);
} │
next prev up imgui/examples/example_sdl_opengl3/main.cpp:101 │ imgui/examples/example_glfw_opengl2/main.cpp:80
│
// Poll and handle events (inputs, window resize, etc.) │ // Poll and handle events (inputs, window resize, etc.)
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if │ // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your │ // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to │ // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to
// Generally you may always pass all inputs to dear imgui, and hide them from yo │ // Generally you may always pass all inputs to dear imgui, and hide them from yo
SDL_Event event; │ glfwPollEvents();
while (SDL_PollEvent(&event)) │
{ │
ImGui_ImplSDL2_ProcessEvent(&event); │
if (event.type == SDL_QUIT) │
done = true; │
if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_C │
done = true; │
} │
│
// Start the Dear ImGui frame │ // Start the Dear ImGui frame
ImGui_ImplOpenGL3_NewFrame(); │ ImGui_ImplOpenGL2_NewFrame();
ImGui_ImplSDL2_NewFrame(); │ ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame(); │ ImGui::NewFrame();
│
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWin │ // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWin
if (show_demo_window) │ if (show_demo_window)
ImGui::ShowDemoWindow(&show_demo_window); │ ImGui::ShowDemoWindow(&show_demo_window);
│
// 2. Show a simple window that we create ourselves. We use a Begin/End pair to │ // 2. Show a simple window that we create ourselves. We use a Begin/End pair to
{ │ {
static float f = 0.0f; │ static float f = 0.0f;
static int counter = 0; │ static int counter = 0;
│
ImGui::Begin("Hello, world!"); // Create a window c │ ImGui::Begin("Hello, world!"); // Create a window c
│
ImGui::Text("This is some useful text."); // Display some text │ ImGui::Text("This is some useful text."); // Display some text
ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storin │ ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storin
ImGui::Checkbox("Another Window", &show_another_window); │ ImGui::Checkbox("Another Window", &show_another_window);
│
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float usin │ ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float usin
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats rep │ ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats rep
│
if (ImGui::Button("Button")) // Buttons return tr │ if (ImGui::Button("Button")) // Buttons return tr
counter++; │ counter++;
ImGui::SameLine(); │ ImGui::SameLine();
ImGui::Text("counter = %d", counter); │ ImGui::Text("counter = %d", counter);
│
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui: │ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui:
ImGui::End(); │ ImGui::End();
} │ }
│
// 3. Show another simple window. │ // 3. Show another simple window.
if (show_another_window) │ if (show_another_window)
{ │ {
ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to │ ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to
ImGui::Text("Hello from another window!"); │ ImGui::Text("Hello from another window!");
if (ImGui::Button("Close Me")) │ if (ImGui::Button("Close Me"))
show_another_window = false; │ show_another_window = false;
ImGui::End(); │ ImGui::End();
} │ }
│
// Rendering │ // Rendering
ImGui::Render(); │ ImGui::Render();
glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y); │ int display_w, display_h;
│ glfwGetFramebufferSize(window, &display_w, &display_h);
│ glViewport(0, 0, display_w, display_h);
glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear │ glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear
glClear(GL_COLOR_BUFFER_BIT); │ glClear(GL_COLOR_BUFFER_BIT);
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); │
SDL_GL_SwapWindow(window); │ // If you are using this code with non-legacy OpenGL header/contexts (which you
│ // you may need to backup/reset/restore other state, e.g. for current shader usi
│ //GLint last_program;
│ //glGetIntegerv(GL_CURRENT_PROGRAM, &last_program);
│ //glUseProgram(0);
│ ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
│ //glUseProgram(last_program);
│
│ glfwMakeContextCurrent(window);
│ glfwSwapBuffers(window);
} │
next prev up imgui/examples/example_sdl_opengl3/main.cpp:101 │ imgui/examples/example_sdl_opengl2/main.cpp:79
│
// Poll and handle events (inputs, window resize, etc.) │ // Poll and handle events (inputs, window resize, etc.)
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if │ // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your │ // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to │ // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to
// Generally you may always pass all inputs to dear imgui, and hide them from yo │ // Generally you may always pass all inputs to dear imgui, and hide them from yo
SDL_Event event; │ SDL_Event event;
while (SDL_PollEvent(&event)) │ while (SDL_PollEvent(&event))
{ │ {
ImGui_ImplSDL2_ProcessEvent(&event); │ ImGui_ImplSDL2_ProcessEvent(&event);
if (event.type == SDL_QUIT) │ if (event.type == SDL_QUIT)
done = true; │ done = true;
if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_C │ if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_C
done = true; │ done = true;
} │ }
│
// Start the Dear ImGui frame │ // Start the Dear ImGui frame
ImGui_ImplOpenGL3_NewFrame(); │ ImGui_ImplOpenGL2_NewFrame();
ImGui_ImplSDL2_NewFrame(); │ ImGui_ImplSDL2_NewFrame();
ImGui::NewFrame(); │ ImGui::NewFrame();
│
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWin │ // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWin
if (show_demo_window) │ if (show_demo_window)
ImGui::ShowDemoWindow(&show_demo_window); │ ImGui::ShowDemoWindow(&show_demo_window);
│
// 2. Show a simple window that we create ourselves. We use a Begin/End pair to │ // 2. Show a simple window that we create ourselves. We use a Begin/End pair to
{ │ {
static float f = 0.0f; │ static float f = 0.0f;
static int counter = 0; │ static int counter = 0;
│
ImGui::Begin("Hello, world!"); // Create a window c │ ImGui::Begin("Hello, world!"); // Create a window c
│
ImGui::Text("This is some useful text."); // Display some text │ ImGui::Text("This is some useful text."); // Display some text
ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storin │ ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storin
ImGui::Checkbox("Another Window", &show_another_window); │ ImGui::Checkbox("Another Window", &show_another_window);
│
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float usin │ ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float usin
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats rep │ ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats rep
│
if (ImGui::Button("Button")) // Buttons return tr │ if (ImGui::Button("Button")) // Buttons return tr
counter++; │ counter++;
ImGui::SameLine(); │ ImGui::SameLine();
ImGui::Text("counter = %d", counter); │ ImGui::Text("counter = %d", counter);
│
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui: │ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui:
ImGui::End(); │ ImGui::End();
} │ }
│
// 3. Show another simple window. │ // 3. Show another simple window.
if (show_another_window) │ if (show_another_window)
{ │ {
ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to │ ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to
ImGui::Text("Hello from another window!"); │ ImGui::Text("Hello from another window!");
if (ImGui::Button("Close Me")) │ if (ImGui::Button("Close Me"))
show_another_window = false; │ show_another_window = false;
ImGui::End(); │ ImGui::End();
} │ }
│
// Rendering │ // Rendering
ImGui::Render(); │ ImGui::Render();
glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y); │ glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y);
glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear │ glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear
glClear(GL_COLOR_BUFFER_BIT); │ glClear(GL_COLOR_BUFFER_BIT);
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); │ //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ conte
│ ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
SDL_GL_SwapWindow(window); │ SDL_GL_SwapWindow(window);
} │
next prev up imgui/examples/example_glfw_opengl3/main.cpp:101 │ imgui/examples/example_glfw_opengl2/main.cpp:80
│
// Poll and handle events (inputs, window resize, etc.) │ // Poll and handle events (inputs, window resize, etc.)
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if │ // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your │ // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to │ // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to
// Generally you may always pass all inputs to dear imgui, and hide them from yo │ // Generally you may always pass all inputs to dear imgui, and hide them from yo
glfwPollEvents(); │ glfwPollEvents();
│
// Start the Dear ImGui frame │ // Start the Dear ImGui frame
ImGui_ImplOpenGL3_NewFrame(); │ ImGui_ImplOpenGL2_NewFrame();
ImGui_ImplGlfw_NewFrame(); │ ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame(); │ ImGui::NewFrame();
│
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWin │ // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWin
if (show_demo_window) │ if (show_demo_window)
ImGui::ShowDemoWindow(&show_demo_window); │ ImGui::ShowDemoWindow(&show_demo_window);
│
// 2. Show a simple window that we create ourselves. We use a Begin/End pair to │ // 2. Show a simple window that we create ourselves. We use a Begin/End pair to
{ │ {
static float f = 0.0f; │ static float f = 0.0f;
static int counter = 0; │ static int counter = 0;
│
ImGui::Begin("Hello, world!"); // Create a window c │ ImGui::Begin("Hello, world!"); // Create a window c
│
ImGui::Text("This is some useful text."); // Display some text │ ImGui::Text("This is some useful text."); // Display some text
ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storin │ ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storin
ImGui::Checkbox("Another Window", &show_another_window); │ ImGui::Checkbox("Another Window", &show_another_window);
│
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float usin │ ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float usin
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats rep │ ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats rep
│
if (ImGui::Button("Button")) // Buttons return tr │ if (ImGui::Button("Button")) // Buttons return tr
counter++; │ counter++;
ImGui::SameLine(); │ ImGui::SameLine();
ImGui::Text("counter = %d", counter); │ ImGui::Text("counter = %d", counter);
│
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui: │ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui:
ImGui::End(); │ ImGui::End();
} │ }
│
// 3. Show another simple window. │ // 3. Show another simple window.
if (show_another_window) │ if (show_another_window)
{ │ {
ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to │ ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to
ImGui::Text("Hello from another window!"); │ ImGui::Text("Hello from another window!");
if (ImGui::Button("Close Me")) │ if (ImGui::Button("Close Me"))
show_another_window = false; │ show_another_window = false;
ImGui::End(); │ ImGui::End();
} │ }
│
// Rendering │ // Rendering
ImGui::Render(); │ ImGui::Render();
int display_w, display_h; │ int display_w, display_h;
glfwGetFramebufferSize(window, &display_w, &display_h); │ glfwGetFramebufferSize(window, &display_w, &display_h);
glViewport(0, 0, display_w, display_h); │ glViewport(0, 0, display_w, display_h);
glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear │ glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear
glClear(GL_COLOR_BUFFER_BIT); │ glClear(GL_COLOR_BUFFER_BIT);
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); │
│
│ // If you are using this code with non-legacy OpenGL header/contexts (which you
│ // you may need to backup/reset/restore other state, e.g. for current shader usi
│ //GLint last_program;
│ //glGetIntegerv(GL_CURRENT_PROGRAM, &last_program);
│ //glUseProgram(0);
│ ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
│ //glUseProgram(last_program);
│
│ glfwMakeContextCurrent(window);
glfwSwapBuffers(window); │ glfwSwapBuffers(window);
} │
next prev up imgui/examples/example_glfw_opengl3/main.cpp:101 │ imgui/examples/example_sdl_opengl2/main.cpp:79
│
// Poll and handle events (inputs, window resize, etc.) │ // Poll and handle events (inputs, window resize, etc.)
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if │ // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your │ // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to │ // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to
// Generally you may always pass all inputs to dear imgui, and hide them from yo │ // Generally you may always pass all inputs to dear imgui, and hide them from yo
glfwPollEvents(); │ SDL_Event event;
│ while (SDL_PollEvent(&event))
│ {
│ ImGui_ImplSDL2_ProcessEvent(&event);
│ if (event.type == SDL_QUIT)
│ done = true;
│ if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_C
│ done = true;
│ }
│
// Start the Dear ImGui frame │ // Start the Dear ImGui frame
ImGui_ImplOpenGL3_NewFrame(); │ ImGui_ImplOpenGL2_NewFrame();
ImGui_ImplGlfw_NewFrame(); │ ImGui_ImplSDL2_NewFrame();
ImGui::NewFrame(); │ ImGui::NewFrame();
│
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWin │ // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWin
if (show_demo_window) │ if (show_demo_window)
ImGui::ShowDemoWindow(&show_demo_window); │ ImGui::ShowDemoWindow(&show_demo_window);
│
// 2. Show a simple window that we create ourselves. We use a Begin/End pair to │ // 2. Show a simple window that we create ourselves. We use a Begin/End pair to
{ │ {
static float f = 0.0f; │ static float f = 0.0f;
static int counter = 0; │ static int counter = 0;
│
ImGui::Begin("Hello, world!"); // Create a window c │ ImGui::Begin("Hello, world!"); // Create a window c
│
ImGui::Text("This is some useful text."); // Display some text │ ImGui::Text("This is some useful text."); // Display some text
ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storin │ ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storin
ImGui::Checkbox("Another Window", &show_another_window); │ ImGui::Checkbox("Another Window", &show_another_window);
│
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float usin │ ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float usin
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats rep │ ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats rep
│
if (ImGui::Button("Button")) // Buttons return tr │ if (ImGui::Button("Button")) // Buttons return tr
counter++; │ counter++;
ImGui::SameLine(); │ ImGui::SameLine();
ImGui::Text("counter = %d", counter); │ ImGui::Text("counter = %d", counter);
│
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui: │ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui:
ImGui::End(); │ ImGui::End();
} │ }
│
// 3. Show another simple window. │ // 3. Show another simple window.
if (show_another_window) │ if (show_another_window)
{ │ {
ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to │ ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to
ImGui::Text("Hello from another window!"); │ ImGui::Text("Hello from another window!");
if (ImGui::Button("Close Me")) │ if (ImGui::Button("Close Me"))
show_another_window = false; │ show_another_window = false;
ImGui::End(); │ ImGui::End();
} │ }
│
// Rendering │ // Rendering
ImGui::Render(); │ ImGui::Render();
int display_w, display_h; │ glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y);
glfwGetFramebufferSize(window, &display_w, &display_h); │
glViewport(0, 0, display_w, display_h); │
glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear │ glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear
glClear(GL_COLOR_BUFFER_BIT); │ glClear(GL_COLOR_BUFFER_BIT);
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); │ //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ conte
│ ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
glfwSwapBuffers(window); │ SDL_GL_SwapWindow(window);
} │
next prev up imgui/examples/example_glfw_opengl3/main.cpp:101 │ imgui/examples/example_sdl_opengl3/main.cpp:101
│
// Poll and handle events (inputs, window resize, etc.) │ // Poll and handle events (inputs, window resize, etc.)
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if │ // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your │ // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to │ // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to
// Generally you may always pass all inputs to dear imgui, and hide them from yo │ // Generally you may always pass all inputs to dear imgui, and hide them from yo
glfwPollEvents(); │ SDL_Event event;
│ while (SDL_PollEvent(&event))
│ {
│ ImGui_ImplSDL2_ProcessEvent(&event);
│ if (event.type == SDL_QUIT)
│ done = true;
│ if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_C
│ done = true;
│ }
│
// Start the Dear ImGui frame │ // Start the Dear ImGui frame
ImGui_ImplOpenGL3_NewFrame(); │ ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame(); │ ImGui_ImplSDL2_NewFrame();
ImGui::NewFrame(); │ ImGui::NewFrame();
│
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWin │ // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWin
if (show_demo_window) │ if (show_demo_window)
ImGui::ShowDemoWindow(&show_demo_window); │ ImGui::ShowDemoWindow(&show_demo_window);
│
// 2. Show a simple window that we create ourselves. We use a Begin/End pair to │ // 2. Show a simple window that we create ourselves. We use a Begin/End pair to
{ │ {
static float f = 0.0f; │ static float f = 0.0f;
static int counter = 0; │ static int counter = 0;
│
ImGui::Begin("Hello, world!"); // Create a window c │ ImGui::Begin("Hello, world!"); // Create a window c
│
ImGui::Text("This is some useful text."); // Display some text │ ImGui::Text("This is some useful text."); // Display some text
ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storin │ ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storin
ImGui::Checkbox("Another Window", &show_another_window); │ ImGui::Checkbox("Another Window", &show_another_window);
│
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float usin │ ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float usin
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats rep │ ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats rep
│
if (ImGui::Button("Button")) // Buttons return tr │ if (ImGui::Button("Button")) // Buttons return tr
counter++; │ counter++;
ImGui::SameLine(); │ ImGui::SameLine();
ImGui::Text("counter = %d", counter); │ ImGui::Text("counter = %d", counter);
│
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui: │ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui:
ImGui::End(); │ ImGui::End();
} │ }
│
// 3. Show another simple window. │ // 3. Show another simple window.
if (show_another_window) │ if (show_another_window)
{ │ {
ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to │ ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to
ImGui::Text("Hello from another window!"); │ ImGui::Text("Hello from another window!");
if (ImGui::Button("Close Me")) │ if (ImGui::Button("Close Me"))
show_another_window = false; │ show_another_window = false;
ImGui::End(); │ ImGui::End();
} │ }
│
// Rendering │ // Rendering
ImGui::Render(); │ ImGui::Render();
int display_w, display_h; │ glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y);
glfwGetFramebufferSize(window, &display_w, &display_h); │
glViewport(0, 0, display_w, display_h); │
glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear │ glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear
glClear(GL_COLOR_BUFFER_BIT); │ glClear(GL_COLOR_BUFFER_BIT);
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); │ ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
│ SDL_GL_SwapWindow(window);
glfwSwapBuffers(window); │
} │
next prev up imgui/examples/example_glfw_vulkan/main.cpp:262 │ imgui/examples/example_sdl_vulkan/main.cpp:254
│
VkResult err; │ VkResult err;
│
VkSemaphore image_acquired_semaphore = wd->FrameSemaphores[wd->SemaphoreIndex].Imag │ VkSemaphore image_acquired_semaphore = wd->FrameSemaphores[wd->SemaphoreIndex].Imag
VkSemaphore render_complete_semaphore = wd->FrameSemaphores[wd->SemaphoreIndex].Rend │ VkSemaphore render_complete_semaphore = wd->FrameSemaphores[wd->SemaphoreIndex].Rend
err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_sema │ err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_sema
if (err == VK_ERROR_OUT_OF_DATE_KHR || err == VK_SUBOPTIMAL_KHR) │ if (err == VK_ERROR_OUT_OF_DATE_KHR || err == VK_SUBOPTIMAL_KHR)
{ │ {
g_SwapChainRebuild = true; │ g_SwapChainRebuild = true;
return; │ return;
} │ }
check_vk_result(err); │ check_vk_result(err);
│
ImGui_ImplVulkanH_Frame* fd = &wd->Frames[wd->FrameIndex]; │ ImGui_ImplVulkanH_Frame* fd = &wd->Frames[wd->FrameIndex];
{ │ {
err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait │ err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait
check_vk_result(err); │ check_vk_result(err);
│
err = vkResetFences(g_Device, 1, &fd->Fence); │ err = vkResetFences(g_Device, 1, &fd->Fence);
check_vk_result(err); │ check_vk_result(err);
} │ }
{ │ {
err = vkResetCommandPool(g_Device, fd->CommandPool, 0); │ err = vkResetCommandPool(g_Device, fd->CommandPool, 0);
check_vk_result(err); │ check_vk_result(err);
VkCommandBufferBeginInfo info = {}; │ VkCommandBufferBeginInfo info = {};
info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; │ info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; │ info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
err = vkBeginCommandBuffer(fd->CommandBuffer, &info); │ err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
check_vk_result(err); │ check_vk_result(err);
} │ }
{ │ {
VkRenderPassBeginInfo info = {}; │ VkRenderPassBeginInfo info = {};
info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; │ info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
info.renderPass = wd->RenderPass; │ info.renderPass = wd->RenderPass;
info.framebuffer = fd->Framebuffer; │ info.framebuffer = fd->Framebuffer;
info.renderArea.extent.width = wd->Width; │ info.renderArea.extent.width = wd->Width;
info.renderArea.extent.height = wd->Height; │ info.renderArea.extent.height = wd->Height;
info.clearValueCount = 1; │ info.clearValueCount = 1;
info.pClearValues = &wd->ClearValue; │ info.pClearValues = &wd->ClearValue;
vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE); │ vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
} │ }
│
// Record dear imgui primitives into command buffer │ // Record dear imgui primitives into command buffer
ImGui_ImplVulkan_RenderDrawData(draw_data, fd->CommandBuffer); │ ImGui_ImplVulkan_RenderDrawData(draw_data, fd->CommandBuffer);
│
// Submit command buffer │ // Submit command buffer
vkCmdEndRenderPass(fd->CommandBuffer); │ vkCmdEndRenderPass(fd->CommandBuffer);
{ │ {
VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; │ VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
VkSubmitInfo info = {}; │ VkSubmitInfo info = {};
info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; │ info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
info.waitSemaphoreCount = 1; │ info.waitSemaphoreCount = 1;
info.pWaitSemaphores = &image_acquired_semaphore; │ info.pWaitSemaphores = &image_acquired_semaphore;
info.pWaitDstStageMask = &wait_stage; │ info.pWaitDstStageMask = &wait_stage;
info.commandBufferCount = 1; │ info.commandBufferCount = 1;
info.pCommandBuffers = &fd->CommandBuffer; │ info.pCommandBuffers = &fd->CommandBuffer;
info.signalSemaphoreCount = 1; │ info.signalSemaphoreCount = 1;
info.pSignalSemaphores = &render_complete_semaphore; │ info.pSignalSemaphores = &render_complete_semaphore;
│
err = vkEndCommandBuffer(fd->CommandBuffer); │ err = vkEndCommandBuffer(fd->CommandBuffer);
check_vk_result(err); │ check_vk_result(err);
err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence); │ err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence);
check_vk_result(err); │ check_vk_result(err);
} │ }
} │
next prev up imgui/backends/imgui_impl_dx11.cpp:307 │ imgui/backends/imgui_impl_dx10.cpp:295
│
// Build texture atlas │ // Build texture atlas
│ ImGui_ImplDX10_Data* bd = ImGui_ImplDX10_GetBackendData();
ImGuiIO& io = ImGui::GetIO(); │ ImGuiIO& io = ImGui::GetIO();
ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData(); │
unsigned char* pixels; │ unsigned char* pixels;
int width, height; │ int width, height;
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); │ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
│
// Upload texture to graphics system │ // Upload texture to graphics system
{ │ {
D3D11_TEXTURE2D_DESC desc; │ D3D10_TEXTURE2D_DESC desc;
ZeroMemory(&desc, sizeof(desc)); │ ZeroMemory(&desc, sizeof(desc));
desc.Width = width; │ desc.Width = width;
desc.Height = height; │ desc.Height = height;
desc.MipLevels = 1; │ desc.MipLevels = 1;
desc.ArraySize = 1; │ desc.ArraySize = 1;
desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; │ desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
desc.SampleDesc.Count = 1; │ desc.SampleDesc.Count = 1;
desc.Usage = D3D11_USAGE_DEFAULT; │ desc.Usage = D3D10_USAGE_DEFAULT;
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; │ desc.BindFlags = D3D10_BIND_SHADER_RESOURCE;
desc.CPUAccessFlags = 0; │ desc.CPUAccessFlags = 0;
│
ID3D11Texture2D* pTexture = NULL; │ ID3D10Texture2D* pTexture = NULL;
D3D11_SUBRESOURCE_DATA subResource; │ D3D10_SUBRESOURCE_DATA subResource;
subResource.pSysMem = pixels; │ subResource.pSysMem = pixels;
subResource.SysMemPitch = desc.Width * 4; │ subResource.SysMemPitch = desc.Width * 4;
subResource.SysMemSlicePitch = 0; │ subResource.SysMemSlicePitch = 0;
bd->pd3dDevice->CreateTexture2D(&desc, &subResource, &pTexture); │ bd->pd3dDevice->CreateTexture2D(&desc, &subResource, &pTexture);
IM_ASSERT(pTexture != NULL); │ IM_ASSERT(pTexture != NULL);
│
// Create texture view │ // Create texture view
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc; │ D3D10_SHADER_RESOURCE_VIEW_DESC srv_desc;
ZeroMemory(&srvDesc, sizeof(srvDesc)); │ ZeroMemory(&srv_desc, sizeof(srv_desc));
srvDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; │ srv_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; │ srv_desc.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE2D;
srvDesc.Texture2D.MipLevels = desc.MipLevels; │ srv_desc.Texture2D.MipLevels = desc.MipLevels;
srvDesc.Texture2D.MostDetailedMip = 0; │ srv_desc.Texture2D.MostDetailedMip = 0;
bd->pd3dDevice->CreateShaderResourceView(pTexture, &srvDesc, &bd->pFontTextureVi │ bd->pd3dDevice->CreateShaderResourceView(pTexture, &srv_desc, &bd->pFontTextureV
pTexture->Release(); │ pTexture->Release();
} │ }
│
// Store our identifier │ // Store our identifier
io.Fonts->SetTexID((ImTextureID)bd->pFontTextureView); │ io.Fonts->SetTexID((ImTextureID)bd->pFontTextureView);
│
// Create texture sampler │ // Create texture sampler
// (Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFla │ // (Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFla
{ │ {
D3D11_SAMPLER_DESC desc; │ D3D10_SAMPLER_DESC desc;
ZeroMemory(&desc, sizeof(desc)); │ ZeroMemory(&desc, sizeof(desc));
desc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; │ desc.Filter = D3D10_FILTER_MIN_MAG_MIP_LINEAR;
desc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP; │ desc.AddressU = D3D10_TEXTURE_ADDRESS_WRAP;
desc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP; │ desc.AddressV = D3D10_TEXTURE_ADDRESS_WRAP;
desc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP; │ desc.AddressW = D3D10_TEXTURE_ADDRESS_WRAP;
desc.MipLODBias = 0.f; │ desc.MipLODBias = 0.f;
desc.ComparisonFunc = D3D11_COMPARISON_ALWAYS; │ desc.ComparisonFunc = D3D10_COMPARISON_ALWAYS;
desc.MinLOD = 0.f; │ desc.MinLOD = 0.f;
desc.MaxLOD = 0.f; │ desc.MaxLOD = 0.f;
bd->pd3dDevice->CreateSamplerState(&desc, &bd->pFontSampler); │ bd->pd3dDevice->CreateSamplerState(&desc, &bd->pFontSampler);
} │ }
} │
next prev up imgui/imstb_truetype.h:4021 │ imgui/imstb_truetype.h:4083
│
unsigned char buffer[STBTT_MAX_OVERSAMPLE]; │ unsigned char buffer[STBTT_MAX_OVERSAMPLE];
int safe_w = w - kernel_width; │ int safe_h = h - kernel_width;
int j; │ int j;
STBTT_memset(buffer, 0, STBTT_MAX_OVERSAMPLE); // suppress bogus warning from VS2013 │ STBTT_memset(buffer, 0, STBTT_MAX_OVERSAMPLE); // suppress bogus warning from VS2013
for (j=0; j < h; ++j) { │ for (j=0; j < w; ++j) {
int i; │ int i;
unsigned int total; │ unsigned int total;
STBTT_memset(buffer, 0, kernel_width); │ STBTT_memset(buffer, 0, kernel_width);
│
total = 0; │ total = 0;
│
// make kernel_width a constant in common cases so compiler can optimize out the d │ // make kernel_width a constant in common cases so compiler can optimize out the d
switch (kernel_width) { │ switch (kernel_width) {
case 2: │ case 2:
for (i=0; i <= safe_w; ++i) { │ for (i=0; i <= safe_h; ++i) {
total += pixels[i] - buffer[i & STBTT__OVER_MASK]; │ total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK];
buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; │ buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes];
pixels[i] = (unsigned char) (total / 2); │ pixels[i*stride_in_bytes] = (unsigned char) (total / 2);
} │ }
break; │ break;
case 3: │ case 3:
for (i=0; i <= safe_w; ++i) { │ for (i=0; i <= safe_h; ++i) {
total += pixels[i] - buffer[i & STBTT__OVER_MASK]; │ total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK];
buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; │ buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes];
pixels[i] = (unsigned char) (total / 3); │ pixels[i*stride_in_bytes] = (unsigned char) (total / 3);
} │ }
break; │ break;
case 4: │ case 4:
for (i=0; i <= safe_w; ++i) { │ for (i=0; i <= safe_h; ++i) {
total += pixels[i] - buffer[i & STBTT__OVER_MASK]; │ total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK];
buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; │ buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes];
pixels[i] = (unsigned char) (total / 4); │ pixels[i*stride_in_bytes] = (unsigned char) (total / 4);
} │ }
break; │ break;
case 5: │ case 5:
for (i=0; i <= safe_w; ++i) { │ for (i=0; i <= safe_h; ++i) {
total += pixels[i] - buffer[i & STBTT__OVER_MASK]; │ total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK];
buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; │ buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes];
pixels[i] = (unsigned char) (total / 5); │ pixels[i*stride_in_bytes] = (unsigned char) (total / 5);
} │ }
break; │ break;
default: │ default:
for (i=0; i <= safe_w; ++i) { │ for (i=0; i <= safe_h; ++i) {
total += pixels[i] - buffer[i & STBTT__OVER_MASK]; │ total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK];
buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; │ buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes];
pixels[i] = (unsigned char) (total / kernel_width); │ pixels[i*stride_in_bytes] = (unsigned char) (total / kernel_width);
} │ }
break; │ break;
} │ }
│
for (; i < w; ++i) { │ for (; i < h; ++i) {
STBTT_assert(pixels[i] == 0); │ STBTT_assert(pixels[i*stride_in_bytes] == 0);
total -= buffer[i & STBTT__OVER_MASK]; │ total -= buffer[i & STBTT__OVER_MASK];
pixels[i] = (unsigned char) (total / kernel_width); │ pixels[i*stride_in_bytes] = (unsigned char) (total / kernel_width);
} │ }
│
pixels += stride_in_bytes; │ pixels += 1;
} │ }
} │
next prev up imgui/backends/imgui_impl_dx9.cpp:235 │ imgui/backends/imgui_impl_dx12.cpp:246
│
const ImDrawList* cmd_list = draw_data->CmdLists[n]; │ const ImDrawList* cmd_list = draw_data->CmdLists[n];
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) │ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{ │ {
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; │ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback != NULL) │ if (pcmd->UserCallback != NULL)
{ │ {
// User callback, registered via ImDrawList::AddCallback() │ // User callback, registered via ImDrawList::AddCallback()
// (ImDrawCallback_ResetRenderState is a special callback value used by │ // (ImDrawCallback_ResetRenderState is a special callback value used by
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState) │ if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
ImGui_ImplDX9_SetupRenderState(draw_data); │ ImGui_ImplDX12_SetupRenderState(draw_data, ctx, fr);
else │ else
pcmd->UserCallback(cmd_list, pcmd); │ pcmd->UserCallback(cmd_list, pcmd);
} │ }
else │ else
{ │ {
// Project scissor/clipping rectangles into framebuffer space │ // Project scissor/clipping rectangles into framebuffer space
ImVec2 clip_min(pcmd->ClipRect.x - clip_off.x, pcmd->ClipRect.y - clip_o │ ImVec2 clip_min(pcmd->ClipRect.x - clip_off.x, pcmd->ClipRect.y - clip_o
ImVec2 clip_max(pcmd->ClipRect.z - clip_off.x, pcmd->ClipRect.w - clip_o │ ImVec2 clip_max(pcmd->ClipRect.z - clip_off.x, pcmd->ClipRect.w - clip_o
if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y) │ if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y)
continue; │ continue;
│
// Apply Scissor/clipping rectangle, Bind texture, Draw │ // Apply Scissor/clipping rectangle, Bind texture, Draw
const RECT r = { (LONG)clip_min.x, (LONG)clip_min.y, (LONG)clip_max.x, ( │ const D3D12_RECT r = { (LONG)clip_min.x, (LONG)clip_min.y, (LONG)clip_ma
const LPDIRECT3DTEXTURE9 texture = (LPDIRECT3DTEXTURE9)pcmd->GetTexID(); │ D3D12_GPU_DESCRIPTOR_HANDLE texture_handle = {};
bd->pd3dDevice->SetTexture(0, texture); │ texture_handle.ptr = (UINT64)pcmd->GetTexID();
bd->pd3dDevice->SetScissorRect(&r); │ ctx->SetGraphicsRootDescriptorTable(1, texture_handle);
bd->pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, pcmd->VtxOffset │ ctx->RSSetScissorRects(1, &r);
│ ctx->DrawIndexedInstanced(pcmd->ElemCount, 1, pcmd->IdxOffset + global_i
} │ }
} │ }
global_idx_offset += cmd_list->IdxBuffer.Size; │ global_idx_offset += cmd_list->IdxBuffer.Size;
global_vtx_offset += cmd_list->VtxBuffer.Size; │ global_vtx_offset += cmd_list->VtxBuffer.Size;
} │
next prev up imgui/backends/imgui_impl_dx10.cpp:240 │ imgui/backends/imgui_impl_dx12.cpp:246
│
const ImDrawList* cmd_list = draw_data->CmdLists[n]; │ const ImDrawList* cmd_list = draw_data->CmdLists[n];
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) │ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{ │ {
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; │ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback) │ if (pcmd->UserCallback != NULL)
{ │ {
// User callback, registered via ImDrawList::AddCallback() │ // User callback, registered via ImDrawList::AddCallback()
// (ImDrawCallback_ResetRenderState is a special callback value used by │ // (ImDrawCallback_ResetRenderState is a special callback value used by
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState) │ if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
ImGui_ImplDX10_SetupRenderState(draw_data, ctx); │ ImGui_ImplDX12_SetupRenderState(draw_data, ctx, fr);
else │ else
pcmd->UserCallback(cmd_list, pcmd); │ pcmd->UserCallback(cmd_list, pcmd);
} │ }
else │ else
{ │ {
// Project scissor/clipping rectangles into framebuffer space │ // Project scissor/clipping rectangles into framebuffer space
ImVec2 clip_min(pcmd->ClipRect.x - clip_off.x, pcmd->ClipRect.y - clip_o │ ImVec2 clip_min(pcmd->ClipRect.x - clip_off.x, pcmd->ClipRect.y - clip_o
ImVec2 clip_max(pcmd->ClipRect.z - clip_off.x, pcmd->ClipRect.w - clip_o │ ImVec2 clip_max(pcmd->ClipRect.z - clip_off.x, pcmd->ClipRect.w - clip_o
if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y) │ if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y)
continue; │ continue;
│
// Apply scissor/clipping rectangle │ // Apply Scissor/clipping rectangle, Bind texture, Draw
const D3D10_RECT r = { (LONG)clip_min.x, (LONG)clip_min.y, (LONG)clip_ma │ const D3D12_RECT r = { (LONG)clip_min.x, (LONG)clip_min.y, (LONG)clip_ma
│ D3D12_GPU_DESCRIPTOR_HANDLE texture_handle = {};
│ texture_handle.ptr = (UINT64)pcmd->GetTexID();
│ ctx->SetGraphicsRootDescriptorTable(1, texture_handle);
ctx->RSSetScissorRects(1, &r); │ ctx->RSSetScissorRects(1, &r);
│ ctx->DrawIndexedInstanced(pcmd->ElemCount, 1, pcmd->IdxOffset + global_i
// Bind texture, Draw │
ID3D10ShaderResourceView* texture_srv = (ID3D10ShaderResourceView*)pcmd- │
ctx->PSSetShaderResources(0, 1, &texture_srv); │
ctx->DrawIndexed(pcmd->ElemCount, pcmd->IdxOffset + global_idx_offset, p │
} │ }
} │ }
global_idx_offset += cmd_list->IdxBuffer.Size; │ global_idx_offset += cmd_list->IdxBuffer.Size;
global_vtx_offset += cmd_list->VtxBuffer.Size; │ global_vtx_offset += cmd_list->VtxBuffer.Size;
} │
next prev up imgui/backends/imgui_impl_dx10.cpp:240 │ imgui/backends/imgui_impl_dx11.cpp:250
│
const ImDrawList* cmd_list = draw_data->CmdLists[n]; │ const ImDrawList* cmd_list = draw_data->CmdLists[n];
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) │ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{ │ {
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; │ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback) │ if (pcmd->UserCallback != NULL)
{ │ {
// User callback, registered via ImDrawList::AddCallback() │ // User callback, registered via ImDrawList::AddCallback()
// (ImDrawCallback_ResetRenderState is a special callback value used by │ // (ImDrawCallback_ResetRenderState is a special callback value used by
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState) │ if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
ImGui_ImplDX10_SetupRenderState(draw_data, ctx); │ ImGui_ImplDX11_SetupRenderState(draw_data, ctx);
else │ else
pcmd->UserCallback(cmd_list, pcmd); │ pcmd->UserCallback(cmd_list, pcmd);
} │ }
else │ else
{ │ {
// Project scissor/clipping rectangles into framebuffer space │ // Project scissor/clipping rectangles into framebuffer space
ImVec2 clip_min(pcmd->ClipRect.x - clip_off.x, pcmd->ClipRect.y - clip_o │ ImVec2 clip_min(pcmd->ClipRect.x - clip_off.x, pcmd->ClipRect.y - clip_o
ImVec2 clip_max(pcmd->ClipRect.z - clip_off.x, pcmd->ClipRect.w - clip_o │ ImVec2 clip_max(pcmd->ClipRect.z - clip_off.x, pcmd->ClipRect.w - clip_o
if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y) │ if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y)
continue; │ continue;
│
// Apply scissor/clipping rectangle │ // Apply scissor/clipping rectangle
const D3D10_RECT r = { (LONG)clip_min.x, (LONG)clip_min.y, (LONG)clip_ma │ const D3D11_RECT r = { (LONG)clip_min.x, (LONG)clip_min.y, (LONG)clip_ma
ctx->RSSetScissorRects(1, &r); │ ctx->RSSetScissorRects(1, &r);
│
// Bind texture, Draw │ // Bind texture, Draw
ID3D10ShaderResourceView* texture_srv = (ID3D10ShaderResourceView*)pcmd- │ ID3D11ShaderResourceView* texture_srv = (ID3D11ShaderResourceView*)pcmd-
ctx->PSSetShaderResources(0, 1, &texture_srv); │ ctx->PSSetShaderResources(0, 1, &texture_srv);
ctx->DrawIndexed(pcmd->ElemCount, pcmd->IdxOffset + global_idx_offset, p │ ctx->DrawIndexed(pcmd->ElemCount, pcmd->IdxOffset + global_idx_offset, p
} │ }
} │ }
global_idx_offset += cmd_list->IdxBuffer.Size; │ global_idx_offset += cmd_list->IdxBuffer.Size;
global_vtx_offset += cmd_list->VtxBuffer.Size; │ global_vtx_offset += cmd_list->VtxBuffer.Size;
} │
next prev up imgui/backends/imgui_impl_opengl2.cpp:191 │ imgui/backends/imgui_impl_opengl3.cpp:461
│
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; │ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback) │ if (pcmd->UserCallback != NULL)
{ │ {
// User callback, registered via ImDrawList::AddCallback() │ // User callback, registered via ImDrawList::AddCallback()
// (ImDrawCallback_ResetRenderState is a special callback value used by │ // (ImDrawCallback_ResetRenderState is a special callback value used by
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState) │ if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
ImGui_ImplOpenGL2_SetupRenderState(draw_data, fb_width, fb_height); │ ImGui_ImplOpenGL3_SetupRenderState(draw_data, fb_width, fb_height, v
else │ else
pcmd->UserCallback(cmd_list, pcmd); │ pcmd->UserCallback(cmd_list, pcmd);
} │ }
else │ else
{ │ {
// Project scissor/clipping rectangles into framebuffer space │ // Project scissor/clipping rectangles into framebuffer space
ImVec2 clip_min((pcmd->ClipRect.x - clip_off.x) * clip_scale.x, (pcmd->C │ ImVec2 clip_min((pcmd->ClipRect.x - clip_off.x) * clip_scale.x, (pcmd->C
ImVec2 clip_max((pcmd->ClipRect.z - clip_off.x) * clip_scale.x, (pcmd->C │ ImVec2 clip_max((pcmd->ClipRect.z - clip_off.x) * clip_scale.x, (pcmd->C
if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y) │ if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y)
continue; │ continue;
│
// Apply scissor/clipping rectangle (Y is inverted in OpenGL) │ // Apply scissor/clipping rectangle (Y is inverted in OpenGL)
glScissor((int)clip_min.x, (int)(fb_height - clip_max.y), (int)(clip_max │ glScissor((int)clip_min.x, (int)((float)fb_height - clip_max.y), (int)(c
│
// Bind texture, Draw │ // Bind texture, Draw
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->GetTexID()); │ glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->GetTexID());
glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) │ #ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
│ if (bd->GlVersion >= 320)
│ glDrawElementsBaseVertex(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, siz
│ else
│ #endif
│ glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx)
} │ }
} │
next prev up imgui/examples/example_glfw_vulkan/main.cpp:211 │ imgui/examples/example_sdl_vulkan/main.cpp:203
│
wd->Surface = surface; │ wd->Surface = surface;
│
// Check for WSI support │ // Check for WSI support
VkBool32 res; │ VkBool32 res;
vkGetPhysicalDeviceSurfaceSupportKHR(g_PhysicalDevice, g_QueueFamily, wd->Surface, & │ vkGetPhysicalDeviceSurfaceSupportKHR(g_PhysicalDevice, g_QueueFamily, wd->Surface, &
if (res != VK_TRUE) │ if (res != VK_TRUE)
{ │ {
fprintf(stderr, "Error no WSI support on physical device 0\n"); │ fprintf(stderr, "Error no WSI support on physical device 0\n");
exit(-1); │ exit(-1);
} │ }
│
// Select Surface Format │ // Select Surface Format
const VkFormat requestSurfaceImageFormat[] = { VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_R │ const VkFormat requestSurfaceImageFormat[] = { VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_R
const VkColorSpaceKHR requestSurfaceColorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR; │ const VkColorSpaceKHR requestSurfaceColorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR;
wd->SurfaceFormat = ImGui_ImplVulkanH_SelectSurfaceFormat(g_PhysicalDevice, wd->Surf │ wd->SurfaceFormat = ImGui_ImplVulkanH_SelectSurfaceFormat(g_PhysicalDevice, wd->Surf
│
// Select Present Mode │ // Select Present Mode
#ifdef IMGUI_UNLIMITED_FRAME_RATE │ #ifdef IMGUI_UNLIMITED_FRAME_RATE
VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_MAILBOX_KHR, VK_PRESENT_MODE_IM │ VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_MAILBOX_KHR, VK_PRESENT_MODE_IM
#else │ #else
VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_FIFO_KHR }; │ VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_FIFO_KHR };
#endif │ #endif
wd->PresentMode = ImGui_ImplVulkanH_SelectPresentMode(g_PhysicalDevice, wd->Surface, │ wd->PresentMode = ImGui_ImplVulkanH_SelectPresentMode(g_PhysicalDevice, wd->Surface,
//printf("[vulkan] Selected PresentMode = %d\n", wd->PresentMode); │ //printf("[vulkan] Selected PresentMode = %d\n", wd->PresentMode);
│
// Create SwapChain, RenderPass, Framebuffer, etc. │ // Create SwapChain, RenderPass, Framebuffer, etc.
IM_ASSERT(g_MinImageCount >= 2); │ IM_ASSERT(g_MinImageCount >= 2);
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, wd, g │ ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, wd, g
} │
next prev up imgui/backends/imgui_impl_opengl2.cpp:238 │ imgui/backends/imgui_impl_opengl3.cpp:532
│
// Build texture atlas │
ImGuiIO& io = ImGui::GetIO(); │ ImGuiIO& io = ImGui::GetIO();
ImGui_ImplOpenGL2_Data* bd = ImGui_ImplOpenGL2_GetBackendData(); │ ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData();
│
│ // Build texture atlas
unsigned char* pixels; │ unsigned char* pixels;
int width, height; │ int width, height;
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bit (75 │ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bit (75
│
// Upload texture to graphics system │ // Upload texture to graphics system
// (Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFla │ // (Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFla
GLint last_texture; │ GLint last_texture;
glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture); │ glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
glGenTextures(1, &bd->FontTexture); │ glGenTextures(1, &bd->FontTexture);
glBindTexture(GL_TEXTURE_2D, bd->FontTexture); │ glBindTexture(GL_TEXTURE_2D, bd->FontTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); │ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); │ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
│ #ifdef GL_UNPACK_ROW_LENGTH // Not on WebGL/ES
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); │ glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
│ #endif
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, │ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
│
// Store our identifier │ // Store our identifier
io.Fonts->SetTexID((ImTextureID)(intptr_t)bd->FontTexture); │ io.Fonts->SetTexID((ImTextureID)(intptr_t)bd->FontTexture);
│
// Restore state │ // Restore state
glBindTexture(GL_TEXTURE_2D, last_texture); │ glBindTexture(GL_TEXTURE_2D, last_texture);
│
return true; │ return true;
} │
next prev up imgui/backends/imgui_impl_dx10.cpp:511 │ imgui/backends/imgui_impl_dx11.cpp:523
│
ImGui_ImplDX10_Data* bd = ImGui_ImplDX10_GetBackendData(); │ ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData();
if (!bd->pd3dDevice) │ if (!bd->pd3dDevice)
return; │ return;
│
if (bd->pFontSampler) { bd->pFontSampler->Release(); bd->pFontSampler = NU │ if (bd->pFontSampler) { bd->pFontSampler->Release(); bd->pFontSampler = NU
if (bd->pFontTextureView) { bd->pFontTextureView->Release(); bd->pFontTextureV │ if (bd->pFontTextureView) { bd->pFontTextureView->Release(); bd->pFontTextureV
if (bd->pIB) { bd->pIB->Release(); bd->pIB = NULL; } │ if (bd->pIB) { bd->pIB->Release(); bd->pIB = NULL; }
if (bd->pVB) { bd->pVB->Release(); bd->pVB = NULL; } │ if (bd->pVB) { bd->pVB->Release(); bd->pVB = NULL; }
if (bd->pBlendState) { bd->pBlendState->Release(); bd->pBlendState = NULL │ if (bd->pBlendState) { bd->pBlendState->Release(); bd->pBlendState = NULL
if (bd->pDepthStencilState) { bd->pDepthStencilState->Release(); bd->pDepthStenc │ if (bd->pDepthStencilState) { bd->pDepthStencilState->Release(); bd->pDepthStenc
if (bd->pRasterizerState) { bd->pRasterizerState->Release(); bd->pRasterizerSt │ if (bd->pRasterizerState) { bd->pRasterizerState->Release(); bd->pRasterizerSt
if (bd->pPixelShader) { bd->pPixelShader->Release(); bd->pPixelShader = NU │ if (bd->pPixelShader) { bd->pPixelShader->Release(); bd->pPixelShader = NU
if (bd->pVertexConstantBuffer) { bd->pVertexConstantBuffer->Release(); bd->pVertexC │ if (bd->pVertexConstantBuffer) { bd->pVertexConstantBuffer->Release(); bd->pVertexC
if (bd->pInputLayout) { bd->pInputLayout->Release(); bd->pInputLayout = NU │ if (bd->pInputLayout) { bd->pInputLayout->Release(); bd->pInputLayout = NU
if (bd->pVertexShader) { bd->pVertexShader->Release(); bd->pVertexShader = │ if (bd->pVertexShader) { bd->pVertexShader->Release(); bd->pVertexShader =
} │
next prev up imgui/examples/example_emscripten_wgpu/main.cpp:170 │ imgui/examples/example_emscripten_opengl3/main.cpp:134
│
static float f = 0.0f; │ static float f = 0.0f;
static int counter = 0; │ static int counter = 0;
│
ImGui::Begin("Hello, world!"); // Create a window │ ImGui::Begin("Hello, world!"); // Create a window
│
ImGui::Text("This is some useful text."); // Display some te │ ImGui::Text("This is some useful text."); // Display some te
ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools stor │ ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools stor
ImGui::Checkbox("Another Window", &show_another_window); │ ImGui::Checkbox("Another Window", &show_another_window);
│
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float us │ ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float us
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats r │ ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats r
│
if (ImGui::Button("Button")) // Buttons return │ if (ImGui::Button("Button")) // Buttons return
counter++; │ counter++;
ImGui::SameLine(); │ ImGui::SameLine();
ImGui::Text("counter = %d", counter); │ ImGui::Text("counter = %d", counter);
│
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::Get │ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::Get
ImGui::End(); │ ImGui::End();
} │
next prev up imgui/backends/imgui_impl_dx10.cpp:192 │ imgui/backends/imgui_impl_dx11.cpp:198
│
UINT ScissorRectsCount, ViewportsCount; │ UINT ScissorRectsCount, ViewportsCount;
D3D10_RECT ScissorRects[D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_C │ D3D11_RECT ScissorRects[D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_C
D3D10_VIEWPORT Viewports[D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUN │ D3D11_VIEWPORT Viewports[D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUN
ID3D10RasterizerState* RS; │ ID3D11RasterizerState* RS;
ID3D10BlendState* BlendState; │ ID3D11BlendState* BlendState;
FLOAT BlendFactor[4]; │ FLOAT BlendFactor[4];
UINT SampleMask; │ UINT SampleMask;
UINT StencilRef; │ UINT StencilRef;
ID3D10DepthStencilState* DepthStencilState; │ ID3D11DepthStencilState* DepthStencilState;
ID3D10ShaderResourceView* PSShaderResource; │ ID3D11ShaderResourceView* PSShaderResource;
ID3D10SamplerState* PSSampler; │ ID3D11SamplerState* PSSampler;
ID3D10PixelShader* PS; │ ID3D11PixelShader* PS;
ID3D10VertexShader* VS; │ ID3D11VertexShader* VS;
ID3D10GeometryShader* GS; │ ID3D11GeometryShader* GS;
D3D10_PRIMITIVE_TOPOLOGY PrimitiveTopology; │ UINT PSInstancesCount, VSInstancesCount, GSInstancesCount
ID3D10Buffer* IndexBuffer, *VertexBuffer, *VSConstantBuffer; │ ID3D11ClassInstance *PSInstances[256], *VSInstances[256], *GSInstances[2
│ D3D11_PRIMITIVE_TOPOLOGY PrimitiveTopology;
│ ID3D11Buffer* IndexBuffer, *VertexBuffer, *VSConstantBuffer;
UINT IndexBufferOffset, VertexBufferStride, VertexBufferO │ UINT IndexBufferOffset, VertexBufferStride, VertexBufferO
DXGI_FORMAT IndexBufferFormat; │ DXGI_FORMAT IndexBufferFormat;
ID3D10InputLayout* InputLayout; │ ID3D11InputLayout* InputLayout;
} │
next prev up imgui/examples/example_glfw_vulkan/main.cpp:431 │ imgui/examples/example_sdl_vulkan/main.cpp:423
│
// Use any command queue │ // Use any command queue
VkCommandPool command_pool = wd->Frames[wd->FrameIndex].CommandPool; │ VkCommandPool command_pool = wd->Frames[wd->FrameIndex].CommandPool;
VkCommandBuffer command_buffer = wd->Frames[wd->FrameIndex].CommandBuffer; │ VkCommandBuffer command_buffer = wd->Frames[wd->FrameIndex].CommandBuffer;
│
err = vkResetCommandPool(g_Device, command_pool, 0); │ err = vkResetCommandPool(g_Device, command_pool, 0);
check_vk_result(err); │ check_vk_result(err);
VkCommandBufferBeginInfo begin_info = {}; │ VkCommandBufferBeginInfo begin_info = {};
begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; │ begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
begin_info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; │ begin_info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
err = vkBeginCommandBuffer(command_buffer, &begin_info); │ err = vkBeginCommandBuffer(command_buffer, &begin_info);
check_vk_result(err); │ check_vk_result(err);
│
ImGui_ImplVulkan_CreateFontsTexture(command_buffer); │ ImGui_ImplVulkan_CreateFontsTexture(command_buffer);
│
VkSubmitInfo end_info = {}; │ VkSubmitInfo end_info = {};
end_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; │ end_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
end_info.commandBufferCount = 1; │ end_info.commandBufferCount = 1;
end_info.pCommandBuffers = &command_buffer; │ end_info.pCommandBuffers = &command_buffer;
err = vkEndCommandBuffer(command_buffer); │ err = vkEndCommandBuffer(command_buffer);
check_vk_result(err); │ check_vk_result(err);
err = vkQueueSubmit(g_Queue, 1, &end_info, VK_NULL_HANDLE); │ err = vkQueueSubmit(g_Queue, 1, &end_info, VK_NULL_HANDLE);
check_vk_result(err); │ check_vk_result(err);
│
err = vkDeviceWaitIdle(g_Device); │ err = vkDeviceWaitIdle(g_Device);
check_vk_result(err); │ check_vk_result(err);
ImGui_ImplVulkan_DestroyFontUploadObjects(); │ ImGui_ImplVulkan_DestroyFontUploadObjects();
} │
next prev up imgui/imgui_draw.cpp:3601 │ imgui/imgui_draw.cpp:3450
│
// Calculate how far we can render. Requires two passes on the string data b │ // Calculate how far we can render. Requires two passes on the string data b
if (!word_wrap_eol) │ if (!word_wrap_eol)
{ │ {
word_wrap_eol = CalcWordWrapPositionA(scale, s, text_end, wrap_width - ( │ word_wrap_eol = CalcWordWrapPositionA(scale, s, text_end, wrap_width - l
if (word_wrap_eol == s) // Wrap_width is too small to fit anything. Forc │ if (word_wrap_eol == s) // Wrap_width is too small to fit anything. Forc
word_wrap_eol++; // +1 may not be a character start point in UTF- │ word_wrap_eol++; // +1 may not be a character start point in UTF-
} │ }
│
if (s >= word_wrap_eol) │ if (s >= word_wrap_eol)
{ │ {
x = start_x; │ if (text_size.x < line_width)
y += line_height; │ text_size.x = line_width;
│ text_size.y += line_height;
│ line_width = 0.0f;
word_wrap_eol = NULL; │ word_wrap_eol = NULL;
│
// Wrapping skips upcoming blanks │ // Wrapping skips upcoming blanks
while (s < text_end) │ while (s < text_end)
{ │ {
const char c = *s; │ const char c = *s;
if (ImCharIsBlankA(c)) { s++; } else if (c == '\n') { s++; break; } │ if (ImCharIsBlankA(c)) { s++; } else if (c == '\n') { s++; break; }
} │ }
continue; │ continue;
} │ }
} │
next prev up imgui/examples/example_win32_directx11/main.cpp:165 │ imgui/examples/example_sdl_directx11/main.cpp:182
│
// Setup swap chain │ // Setup swap chain
DXGI_SWAP_CHAIN_DESC sd; │ DXGI_SWAP_CHAIN_DESC sd;
ZeroMemory(&sd, sizeof(sd)); │ ZeroMemory(&sd, sizeof(sd));
sd.BufferCount = 2; │ sd.BufferCount = 2;
sd.BufferDesc.Width = 0; │ sd.BufferDesc.Width = 0;
sd.BufferDesc.Height = 0; │ sd.BufferDesc.Height = 0;
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; │ sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
sd.BufferDesc.RefreshRate.Numerator = 60; │ sd.BufferDesc.RefreshRate.Numerator = 60;
sd.BufferDesc.RefreshRate.Denominator = 1; │ sd.BufferDesc.RefreshRate.Denominator = 1;
sd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; │ sd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; │ sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.OutputWindow = hWnd; │ sd.OutputWindow = hWnd;
sd.SampleDesc.Count = 1; │ sd.SampleDesc.Count = 1;
sd.SampleDesc.Quality = 0; │ sd.SampleDesc.Quality = 0;
sd.Windowed = TRUE; │ sd.Windowed = TRUE;
sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; │ sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
│
UINT createDeviceFlags = 0; │ UINT createDeviceFlags = 0;
//createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG; │ //createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
D3D_FEATURE_LEVEL featureLevel; │ D3D_FEATURE_LEVEL featureLevel;
const D3D_FEATURE_LEVEL featureLevelArray[2] = { D3D_FEATURE_LEVEL_11_0, D3D_FEATURE │ const D3D_FEATURE_LEVEL featureLevelArray[2] = { D3D_FEATURE_LEVEL_11_0, D3D_FEATURE
if (D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, createDevice │ if (D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, createDevice
return false; │ return false;
│
CreateRenderTarget(); │ CreateRenderTarget();
return true; │ return true;
} │
next prev up imgui/backends/imgui_impl_dx10.cpp:530 │ imgui/backends/imgui_impl_dx11.cpp:542
│
ImGuiIO& io = ImGui::GetIO(); │ ImGuiIO& io = ImGui::GetIO();
IM_ASSERT(io.BackendRendererUserData == NULL && "Already initialized a renderer back │ IM_ASSERT(io.BackendRendererUserData == NULL && "Already initialized a renderer back
│
// Setup backend capabilities flags │ // Setup backend capabilities flags
ImGui_ImplDX10_Data* bd = IM_NEW(ImGui_ImplDX10_Data)(); │ ImGui_ImplDX11_Data* bd = IM_NEW(ImGui_ImplDX11_Data)();
io.BackendRendererUserData = (void*)bd; │ io.BackendRendererUserData = (void*)bd;
io.BackendRendererName = "imgui_impl_dx10"; │ io.BackendRendererName = "imgui_impl_dx11";
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDr │ io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDr
│
// Get factory from device │ // Get factory from device
IDXGIDevice* pDXGIDevice = NULL; │ IDXGIDevice* pDXGIDevice = NULL;
IDXGIAdapter* pDXGIAdapter = NULL; │ IDXGIAdapter* pDXGIAdapter = NULL;
IDXGIFactory* pFactory = NULL; │ IDXGIFactory* pFactory = NULL;
│
if (device->QueryInterface(IID_PPV_ARGS(&pDXGIDevice)) == S_OK) │ if (device->QueryInterface(IID_PPV_ARGS(&pDXGIDevice)) == S_OK)
if (pDXGIDevice->GetParent(IID_PPV_ARGS(&pDXGIAdapter)) == S_OK) │ if (pDXGIDevice->GetParent(IID_PPV_ARGS(&pDXGIAdapter)) == S_OK)
if (pDXGIAdapter->GetParent(IID_PPV_ARGS(&pFactory)) == S_OK) │ if (pDXGIAdapter->GetParent(IID_PPV_ARGS(&pFactory)) == S_OK)
{ │ {
bd->pd3dDevice = device; │ bd->pd3dDevice = device;
│ bd->pd3dDeviceContext = device_context;
bd->pFactory = pFactory; │ bd->pFactory = pFactory;
} │ }
if (pDXGIDevice) pDXGIDevice->Release(); │ if (pDXGIDevice) pDXGIDevice->Release();
if (pDXGIAdapter) pDXGIAdapter->Release(); │ if (pDXGIAdapter) pDXGIAdapter->Release();
bd->pd3dDevice->AddRef(); │ bd->pd3dDevice->AddRef();
│ bd->pd3dDeviceContext->AddRef();
│
return true; │ return true;
} │
next prev up imgui/backends/imgui_impl_dx12.cpp:193 │ imgui/backends/imgui_impl_dx12.cpp:170
│
SafeRelease(fr->IndexBuffer); │ SafeRelease(fr->VertexBuffer);
fr->IndexBufferSize = draw_data->TotalIdxCount + 10000; │ fr->VertexBufferSize = draw_data->TotalVtxCount + 5000;
D3D12_HEAP_PROPERTIES props; │ D3D12_HEAP_PROPERTIES props;
memset(&props, 0, sizeof(D3D12_HEAP_PROPERTIES)); │ memset(&props, 0, sizeof(D3D12_HEAP_PROPERTIES));
props.Type = D3D12_HEAP_TYPE_UPLOAD; │ props.Type = D3D12_HEAP_TYPE_UPLOAD;
props.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; │ props.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
props.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; │ props.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
D3D12_RESOURCE_DESC desc; │ D3D12_RESOURCE_DESC desc;
memset(&desc, 0, sizeof(D3D12_RESOURCE_DESC)); │ memset(&desc, 0, sizeof(D3D12_RESOURCE_DESC));
desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; │ desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
desc.Width = fr->IndexBufferSize * sizeof(ImDrawIdx); │ desc.Width = fr->VertexBufferSize * sizeof(ImDrawVert);
desc.Height = 1; │ desc.Height = 1;
desc.DepthOrArraySize = 1; │ desc.DepthOrArraySize = 1;
desc.MipLevels = 1; │ desc.MipLevels = 1;
desc.Format = DXGI_FORMAT_UNKNOWN; │ desc.Format = DXGI_FORMAT_UNKNOWN;
desc.SampleDesc.Count = 1; │ desc.SampleDesc.Count = 1;
desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; │ desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
desc.Flags = D3D12_RESOURCE_FLAG_NONE; │ desc.Flags = D3D12_RESOURCE_FLAG_NONE;
if (bd->pd3dDevice->CreateCommittedResource(&props, D3D12_HEAP_FLAG_NONE, &desc, │ if (bd->pd3dDevice->CreateCommittedResource(&props, D3D12_HEAP_FLAG_NONE, &desc,
return; │ return;
} │
next prev up imgui/imgui_demo.cpp:4492 │ imgui/imgui_demo.cpp:4522
│
// We could also set ImGuiTableFlags_SizingFixedFit on the table and all col │ // We could also set ImGuiTableFlags_SizingFixedFit on the table and all col
ImGui::TableSetupColumn("one", ImGuiTableColumnFlags_WidthFixed, 100.0f); // │ ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, 100.0f);
ImGui::TableSetupColumn("two", ImGuiTableColumnFlags_WidthFixed, 200.0f); // │ ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDT
ImGui::TableSetupColumn("three", ImGuiTableColumnFlags_WidthFixed); // │ ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDT
ImGui::TableHeadersRow(); │ ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDT
for (int row = 0; row < 4; row++) │ for (int row = 0; row < 5; row++)
{ │ {
ImGui::TableNextRow(); │ ImGui::TableNextRow();
for (int column = 0; column < 3; column++) │ for (int column = 0; column < 4; column++)
{ │ {
ImGui::TableSetColumnIndex(column); │ ImGui::TableSetColumnIndex(column);
if (row == 0) │ if (row == 0)
ImGui::Text("(w: %5.1f)", ImGui::GetContentRegionAvail().x); │ ImGui::Text("(w: %5.1f)", ImGui::GetContentRegionAvail().x);
else │ else
ImGui::Text("Hello %d,%d", column, row); │ ImGui::Text("Hello %d,%d", column, row);
} │ }
} │ }
ImGui::EndTable(); │ ImGui::EndTable();
} │