It appears not. The thing is i want to render to already existing images (textures) rather than creating a new one. and to render to the texture it HAS to be created with the D3DUSAGE_RENDERTARGET flag :/ and I expect it probably has to be in the default memory pool as well, im learning to hate directX.
I came up with this function:
void TextToImage(int x, int y, char *Str, int ImgID, DWORD col) {
LPD3DXFONT FontID;
RECT FontPos;
D3DXFONT_DESC FontDesc = { 24, 0, 0, 1, 0, DEFAULT_CHARSET, OUT_TT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH, "Arial" };
LPDIRECT3DTEXTURE9 RenderTexture = NULL;
LPDIRECT3DSURFACE9 RenderSurface = NULL, BackBuffer = NULL;
D3DXMATRIX MatProj, MatProjOld;
if (dbImageExist(ImgID) != 1)
return;
dbGetPointer(ImgID)->GetSurfaceLevel(0, &RenderSurface);
D3DXMatrixPerspectiveFovLH(&MatProj, D3DX_PI / 4.0f, 1, 1, 100);
dbGetDirect3DDevice()->GetTransform(D3DTS_PROJECTION,&MatProjOld);
dbGetDirect3DDevice()->GetRenderTarget(0,&BackBuffer);
sprintf(FontDesc.FaceName, "%s", dbTextFont());
FontPos.top = x;
FontPos.left = y;
FontPos.right = dbScreenWidth();
FontPos.bottom = dbScreenHeight();
D3DXCreateFontIndirect(dbGetDirect3DDevice(), &FontDesc, &FontID);
dbGetDirect3DDevice()->SetRenderTarget(0,RenderSurface);
//BEGIN
dbGetDirect3DDevice()->BeginScene();
FontID->DrawText(NULL, Str, -1, &FontPos, DT_LEFT | DT_TOP, col);
dbGetDirect3DDevice()->EndScene();
//END
dbGetDirect3DDevice()->SetRenderTarget(0, BackBuffer);
if (FontID != NULL) {
FontID->Release();
FontID = NULL;
}
RenderSurface->Release();
RenderSurface = NULL;
BackBuffer->Release();
BackBuffer = NULL;
}
You'll notice its not quite the same technique as in the tutorial you linked me to, but thats because it seems the tutorial contains old and outdated information that caused errors with my build of directx. I had to look up the functions in the help file to see what structs etc it really wanted.
Oddly, it does draw text. But it draws it to the screen and not the image. d3d debug output states:
Direct3D9: (ERROR) :**** The D3DUSAGE_RENDERTARGET is not set on this surface.
Direct3D9: (ERROR) :**** You need to add D3DUSAGE_RENDERTARGET to the Usage parameter
Direct3D9: (ERROR) :**** when creating the surface. SetRenderTarget failed.
so i'm a bit buggered I think. Unless someone has some -really- clever ways around this the only possiable alternitive i can think of is to try and make a new, blank, image using the internal command dbMakeUsage(), specifying it as a render target, filling it with a transparent colour, drawing my text to it, making a SECOND gui plain and positioning it just slightly infront of my current one, texturing it with my new image and then turning transparancy on. But I dont like that. I dont like that one bit.
[07:16:59-pm] « Sephnroth » you were dreaming about lee...
[07:17:13-pm] « Mouse » stfu
[07:17:22-pm] « Mouse » he was hanging himself lol