mirror of https://github.com/ocornut/imgui
Examples: DirectX9: fixed duplicate creation of vertex buffer. Size of static vertex buffer at top of the code.
This commit is contained in:
parent
f4970d0e00
commit
d3e444dfd9
|
@ -27,6 +27,7 @@ static ID3D11PixelShader* g_pPixelShader = NULL;
|
|||
static ID3D11SamplerState* g_pFontSampler = NULL;
|
||||
static ID3D11ShaderResourceView*g_pFontTextureView = NULL;
|
||||
static ID3D11BlendState* g_blendState = NULL;
|
||||
static int VERTEX_BUFFER_SIZE = 30000; // TODO: Make vertex buffer smaller and grow dynamically as needed.
|
||||
|
||||
struct CUSTOMVERTEX
|
||||
{
|
||||
|
@ -358,7 +359,7 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
|
|||
D3D11_BUFFER_DESC bufferDesc;
|
||||
memset(&bufferDesc, 0, sizeof(D3D11_BUFFER_DESC));
|
||||
bufferDesc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
bufferDesc.ByteWidth = 100000 * sizeof(CUSTOMVERTEX); // Maybe we should handle that more dynamically?
|
||||
bufferDesc.ByteWidth = VERTEX_BUFFER_SIZE * sizeof(CUSTOMVERTEX);
|
||||
bufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
||||
bufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
bufferDesc.MiscFlags = 0;
|
||||
|
|
|
@ -15,6 +15,7 @@ static INT64 g_Time = 0;
|
|||
static INT64 g_TicksPerSecond = 0;
|
||||
static LPDIRECT3DDEVICE9 g_pd3dDevice = NULL;
|
||||
static LPDIRECT3DVERTEXBUFFER9 g_pVB = NULL;
|
||||
static int VERTEX_BUFFER_SIZE = 30000; // TODO: Make vertex buffer smaller and grow dynamically as needed.
|
||||
|
||||
struct CUSTOMVERTEX
|
||||
{
|
||||
|
@ -183,9 +184,6 @@ bool ImGui_ImplDX9_Init(void* hwnd, IDirect3DDevice9* device)
|
|||
io.RenderDrawListsFn = ImGui_ImplDX9_RenderDrawLists;
|
||||
io.ImeWindowHandle = g_hWnd;
|
||||
|
||||
if (g_pd3dDevice->CreateVertexBuffer(10000 * sizeof(CUSTOMVERTEX), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB, NULL) < 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -232,7 +230,7 @@ bool ImGui_ImplDX9_CreateDeviceObjects()
|
|||
if (!g_pd3dDevice)
|
||||
return false;
|
||||
|
||||
if (g_pd3dDevice->CreateVertexBuffer(10000 * sizeof(CUSTOMVERTEX), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB, NULL) < 0)
|
||||
if (g_pd3dDevice->CreateVertexBuffer(VERTEX_BUFFER_SIZE * sizeof(CUSTOMVERTEX), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB, NULL) < 0)
|
||||
return false;
|
||||
|
||||
ImGui_ImplDX9_CreateFontsTexture();
|
||||
|
|
Loading…
Reference in New Issue