Examples: DirectX9: fixed duplicate creation of vertex buffer. Size of static vertex buffer at top of the code.

This commit is contained in:
ocornut
2015-03-16 10:02:10 +00:00
parent f4970d0e00
commit d3e444dfd9
2 changed files with 4 additions and 5 deletions

View File

@ -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();