mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 20:07:01 +00:00
Examples: DirectX10,DirectX11 : Minor renaming
This commit is contained in:
parent
518f32ccfe
commit
552246feed
@ -277,33 +277,33 @@ static void ImGui_ImplDX10_CreateFontsTexture()
|
|||||||
|
|
||||||
// Create DX10 texture
|
// Create DX10 texture
|
||||||
{
|
{
|
||||||
D3D10_TEXTURE2D_DESC texDesc;
|
D3D10_TEXTURE2D_DESC desc;
|
||||||
ZeroMemory(&texDesc, sizeof(texDesc));
|
ZeroMemory(&desc, sizeof(desc));
|
||||||
texDesc.Width = width;
|
desc.Width = width;
|
||||||
texDesc.Height = height;
|
desc.Height = height;
|
||||||
texDesc.MipLevels = 1;
|
desc.MipLevels = 1;
|
||||||
texDesc.ArraySize = 1;
|
desc.ArraySize = 1;
|
||||||
texDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||||
texDesc.SampleDesc.Count = 1;
|
desc.SampleDesc.Count = 1;
|
||||||
texDesc.Usage = D3D10_USAGE_DEFAULT;
|
desc.Usage = D3D10_USAGE_DEFAULT;
|
||||||
texDesc.BindFlags = D3D10_BIND_SHADER_RESOURCE;
|
desc.BindFlags = D3D10_BIND_SHADER_RESOURCE;
|
||||||
texDesc.CPUAccessFlags = 0;
|
desc.CPUAccessFlags = 0;
|
||||||
|
|
||||||
ID3D10Texture2D *pTexture = NULL;
|
ID3D10Texture2D *pTexture = NULL;
|
||||||
D3D10_SUBRESOURCE_DATA subResource;
|
D3D10_SUBRESOURCE_DATA subResource;
|
||||||
subResource.pSysMem = pixels;
|
subResource.pSysMem = pixels;
|
||||||
subResource.SysMemPitch = texDesc.Width * 4;
|
subResource.SysMemPitch = desc.Width * 4;
|
||||||
subResource.SysMemSlicePitch = 0;
|
subResource.SysMemSlicePitch = 0;
|
||||||
g_pd3dDevice->CreateTexture2D(&texDesc, &subResource, &pTexture);
|
g_pd3dDevice->CreateTexture2D(&desc, &subResource, &pTexture);
|
||||||
|
|
||||||
// Create texture view
|
// Create texture view
|
||||||
D3D10_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 = D3D10_SRV_DIMENSION_TEXTURE2D;
|
srv_desc.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE2D;
|
||||||
srvDesc.Texture2D.MipLevels = texDesc.MipLevels;
|
srv_desc.Texture2D.MipLevels = desc.MipLevels;
|
||||||
srvDesc.Texture2D.MostDetailedMip = 0;
|
srv_desc.Texture2D.MostDetailedMip = 0;
|
||||||
g_pd3dDevice->CreateShaderResourceView(pTexture, &srvDesc, &g_pFontTextureView);
|
g_pd3dDevice->CreateShaderResourceView(pTexture, &srv_desc, &g_pFontTextureView);
|
||||||
pTexture->Release();
|
pTexture->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,17 +312,17 @@ static void ImGui_ImplDX10_CreateFontsTexture()
|
|||||||
|
|
||||||
// Create texture sampler
|
// Create texture sampler
|
||||||
{
|
{
|
||||||
D3D10_SAMPLER_DESC samplerDesc;
|
D3D10_SAMPLER_DESC desc;
|
||||||
ZeroMemory(&samplerDesc, sizeof(samplerDesc));
|
ZeroMemory(&desc, sizeof(desc));
|
||||||
samplerDesc.Filter = D3D10_FILTER_MIN_MAG_MIP_LINEAR;
|
desc.Filter = D3D10_FILTER_MIN_MAG_MIP_LINEAR;
|
||||||
samplerDesc.AddressU = D3D10_TEXTURE_ADDRESS_WRAP;
|
desc.AddressU = D3D10_TEXTURE_ADDRESS_WRAP;
|
||||||
samplerDesc.AddressV = D3D10_TEXTURE_ADDRESS_WRAP;
|
desc.AddressV = D3D10_TEXTURE_ADDRESS_WRAP;
|
||||||
samplerDesc.AddressW = D3D10_TEXTURE_ADDRESS_WRAP;
|
desc.AddressW = D3D10_TEXTURE_ADDRESS_WRAP;
|
||||||
samplerDesc.MipLODBias = 0.f;
|
desc.MipLODBias = 0.f;
|
||||||
samplerDesc.ComparisonFunc = D3D10_COMPARISON_ALWAYS;
|
desc.ComparisonFunc = D3D10_COMPARISON_ALWAYS;
|
||||||
samplerDesc.MinLOD = 0.f;
|
desc.MinLOD = 0.f;
|
||||||
samplerDesc.MaxLOD = 0.f;
|
desc.MaxLOD = 0.f;
|
||||||
g_pd3dDevice->CreateSamplerState(&samplerDesc, &g_pFontSampler);
|
g_pd3dDevice->CreateSamplerState(&desc, &g_pFontSampler);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup (don't clear the input data if you want to append new fonts later)
|
// Cleanup (don't clear the input data if you want to append new fonts later)
|
||||||
@ -374,24 +374,24 @@ bool ImGui_ImplDX10_CreateDeviceObjects()
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Create the input layout
|
// Create the input layout
|
||||||
D3D10_INPUT_ELEMENT_DESC localLayout[] = {
|
D3D10_INPUT_ELEMENT_DESC local_layout[] =
|
||||||
|
{
|
||||||
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (size_t)(&((ImDrawVert*)0)->pos), D3D10_INPUT_PER_VERTEX_DATA, 0 },
|
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (size_t)(&((ImDrawVert*)0)->pos), D3D10_INPUT_PER_VERTEX_DATA, 0 },
|
||||||
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (size_t)(&((ImDrawVert*)0)->uv), D3D10_INPUT_PER_VERTEX_DATA, 0 },
|
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (size_t)(&((ImDrawVert*)0)->uv), D3D10_INPUT_PER_VERTEX_DATA, 0 },
|
||||||
{ "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (size_t)(&((ImDrawVert*)0)->col), D3D10_INPUT_PER_VERTEX_DATA, 0 },
|
{ "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (size_t)(&((ImDrawVert*)0)->col), D3D10_INPUT_PER_VERTEX_DATA, 0 },
|
||||||
};
|
};
|
||||||
|
if (g_pd3dDevice->CreateInputLayout(local_layout, 3, g_pVertexShaderBlob->GetBufferPointer(), g_pVertexShaderBlob->GetBufferSize(), &g_pInputLayout) != S_OK)
|
||||||
if (g_pd3dDevice->CreateInputLayout(localLayout, 3, g_pVertexShaderBlob->GetBufferPointer(), g_pVertexShaderBlob->GetBufferSize(), &g_pInputLayout) != S_OK)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Create the constant buffer
|
// Create the constant buffer
|
||||||
{
|
{
|
||||||
D3D10_BUFFER_DESC cbDesc;
|
D3D10_BUFFER_DESC desc;
|
||||||
cbDesc.ByteWidth = sizeof(VERTEX_CONSTANT_BUFFER);
|
desc.ByteWidth = sizeof(VERTEX_CONSTANT_BUFFER);
|
||||||
cbDesc.Usage = D3D10_USAGE_DYNAMIC;
|
desc.Usage = D3D10_USAGE_DYNAMIC;
|
||||||
cbDesc.BindFlags = D3D10_BIND_CONSTANT_BUFFER;
|
desc.BindFlags = D3D10_BIND_CONSTANT_BUFFER;
|
||||||
cbDesc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE;
|
desc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE;
|
||||||
cbDesc.MiscFlags = 0;
|
desc.MiscFlags = 0;
|
||||||
g_pd3dDevice->CreateBuffer(&cbDesc, NULL, &g_pVertexConstantBuffer);
|
g_pd3dDevice->CreateBuffer(&desc, NULL, &g_pVertexConstantBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,13 +67,13 @@ void ImGui_ImplDX11_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
{
|
{
|
||||||
if (g_pIB) { g_pIB->Release(); g_pIB = NULL; }
|
if (g_pIB) { g_pIB->Release(); g_pIB = NULL; }
|
||||||
g_IndexBufferSize = draw_data->TotalIdxCount + 10000;
|
g_IndexBufferSize = draw_data->TotalIdxCount + 10000;
|
||||||
D3D11_BUFFER_DESC buffer_desc;
|
D3D11_BUFFER_DESC desc;
|
||||||
memset(&buffer_desc, 0, sizeof(D3D11_BUFFER_DESC));
|
memset(&desc, 0, sizeof(D3D11_BUFFER_DESC));
|
||||||
buffer_desc.Usage = D3D11_USAGE_DYNAMIC;
|
desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||||
buffer_desc.ByteWidth = g_IndexBufferSize * sizeof(ImDrawIdx);
|
desc.ByteWidth = g_IndexBufferSize * sizeof(ImDrawIdx);
|
||||||
buffer_desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
||||||
buffer_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||||
if (g_pd3dDevice->CreateBuffer(&buffer_desc, NULL, &g_pIB) < 0)
|
if (g_pd3dDevice->CreateBuffer(&desc, NULL, &g_pIB) < 0)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,31 +283,31 @@ static void ImGui_ImplDX11_CreateFontsTexture()
|
|||||||
|
|
||||||
// Upload texture to graphics system
|
// Upload texture to graphics system
|
||||||
{
|
{
|
||||||
D3D11_TEXTURE2D_DESC texDesc;
|
D3D11_TEXTURE2D_DESC desc;
|
||||||
ZeroMemory(&texDesc, sizeof(texDesc));
|
ZeroMemory(&desc, sizeof(desc));
|
||||||
texDesc.Width = width;
|
desc.Width = width;
|
||||||
texDesc.Height = height;
|
desc.Height = height;
|
||||||
texDesc.MipLevels = 1;
|
desc.MipLevels = 1;
|
||||||
texDesc.ArraySize = 1;
|
desc.ArraySize = 1;
|
||||||
texDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||||
texDesc.SampleDesc.Count = 1;
|
desc.SampleDesc.Count = 1;
|
||||||
texDesc.Usage = D3D11_USAGE_DEFAULT;
|
desc.Usage = D3D11_USAGE_DEFAULT;
|
||||||
texDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
||||||
texDesc.CPUAccessFlags = 0;
|
desc.CPUAccessFlags = 0;
|
||||||
|
|
||||||
ID3D11Texture2D *pTexture = NULL;
|
ID3D11Texture2D *pTexture = NULL;
|
||||||
D3D11_SUBRESOURCE_DATA subResource;
|
D3D11_SUBRESOURCE_DATA subResource;
|
||||||
subResource.pSysMem = pixels;
|
subResource.pSysMem = pixels;
|
||||||
subResource.SysMemPitch = texDesc.Width * 4;
|
subResource.SysMemPitch = desc.Width * 4;
|
||||||
subResource.SysMemSlicePitch = 0;
|
subResource.SysMemSlicePitch = 0;
|
||||||
g_pd3dDevice->CreateTexture2D(&texDesc, &subResource, &pTexture);
|
g_pd3dDevice->CreateTexture2D(&desc, &subResource, &pTexture);
|
||||||
|
|
||||||
// Create texture view
|
// Create texture view
|
||||||
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
|
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
|
||||||
ZeroMemory(&srvDesc, sizeof(srvDesc));
|
ZeroMemory(&srvDesc, sizeof(srvDesc));
|
||||||
srvDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
srvDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||||
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
|
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
|
||||||
srvDesc.Texture2D.MipLevels = texDesc.MipLevels;
|
srvDesc.Texture2D.MipLevels = desc.MipLevels;
|
||||||
srvDesc.Texture2D.MostDetailedMip = 0;
|
srvDesc.Texture2D.MostDetailedMip = 0;
|
||||||
g_pd3dDevice->CreateShaderResourceView(pTexture, &srvDesc, &g_pFontTextureView);
|
g_pd3dDevice->CreateShaderResourceView(pTexture, &srvDesc, &g_pFontTextureView);
|
||||||
pTexture->Release();
|
pTexture->Release();
|
||||||
@ -318,17 +318,17 @@ static void ImGui_ImplDX11_CreateFontsTexture()
|
|||||||
|
|
||||||
// Create texture sampler
|
// Create texture sampler
|
||||||
{
|
{
|
||||||
D3D11_SAMPLER_DESC samplerDesc;
|
D3D11_SAMPLER_DESC desc;
|
||||||
ZeroMemory(&samplerDesc, sizeof(samplerDesc));
|
ZeroMemory(&desc, sizeof(desc));
|
||||||
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
|
desc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
|
||||||
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
|
desc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||||
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
|
desc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||||
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
|
desc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||||
samplerDesc.MipLODBias = 0.f;
|
desc.MipLODBias = 0.f;
|
||||||
samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
|
desc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
|
||||||
samplerDesc.MinLOD = 0.f;
|
desc.MinLOD = 0.f;
|
||||||
samplerDesc.MaxLOD = 0.f;
|
desc.MaxLOD = 0.f;
|
||||||
g_pd3dDevice->CreateSamplerState(&samplerDesc, &g_pFontSampler);
|
g_pd3dDevice->CreateSamplerState(&desc, &g_pFontSampler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,24 +376,23 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Create the input layout
|
// Create the input layout
|
||||||
D3D11_INPUT_ELEMENT_DESC localLayout[] = {
|
D3D11_INPUT_ELEMENT_DESC local_layout[] = {
|
||||||
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (size_t)(&((ImDrawVert*)0)->pos), D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (size_t)(&((ImDrawVert*)0)->pos), D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||||
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (size_t)(&((ImDrawVert*)0)->uv), D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (size_t)(&((ImDrawVert*)0)->uv), D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||||
{ "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (size_t)(&((ImDrawVert*)0)->col), D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
{ "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (size_t)(&((ImDrawVert*)0)->col), D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||||
};
|
};
|
||||||
|
if (g_pd3dDevice->CreateInputLayout(local_layout, 3, g_pVertexShaderBlob->GetBufferPointer(), g_pVertexShaderBlob->GetBufferSize(), &g_pInputLayout) != S_OK)
|
||||||
if (g_pd3dDevice->CreateInputLayout(localLayout, 3, g_pVertexShaderBlob->GetBufferPointer(), g_pVertexShaderBlob->GetBufferSize(), &g_pInputLayout) != S_OK)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Create the constant buffer
|
// Create the constant buffer
|
||||||
{
|
{
|
||||||
D3D11_BUFFER_DESC cbDesc;
|
D3D11_BUFFER_DESC desc;
|
||||||
cbDesc.ByteWidth = sizeof(VERTEX_CONSTANT_BUFFER);
|
desc.ByteWidth = sizeof(VERTEX_CONSTANT_BUFFER);
|
||||||
cbDesc.Usage = D3D11_USAGE_DYNAMIC;
|
desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||||
cbDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
||||||
cbDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||||
cbDesc.MiscFlags = 0;
|
desc.MiscFlags = 0;
|
||||||
g_pd3dDevice->CreateBuffer(&cbDesc, NULL, &g_pVertexConstantBuffer);
|
g_pd3dDevice->CreateBuffer(&desc, NULL, &g_pVertexConstantBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user