Textures in Direct3D to display text on cube face

Hello all,

I have created an application with D3DX9. My application displays text on the faces on 400 cubes using Textures. The heights of the cubes are changed every 100 milliseconds (in OnTimer call). I display text using the following sequence of calls (pseudocode is below):

OnTimer()
{
for (I=0 to 399)
{
if(texture != NULL)
{
texture->Release()
texture = NULL
}

CreateTexture(texture)
MyFont->DrawTextA(texture, word)
CreateMeshObject(cube) //Cube height changes for every OnTimer call.
cube->SetTexture(texture)
Render(cube)
}
}

This code hangs after a few calls to OnTimer. My VRAM seems to be hogging up. Calling the Release for texture does not seem to be really releasing the memory in VRAM. Am I doing anything wrong here? Is there a better way to display text on the cube's face? Does D3DX11 have a better way of doing this? Any suggestion is welcome.

Regards
STX970
 
Back