简体   繁体   中英

DirectX 10.1 / C++: How to render text on sprite over ID3D10Resource* textures?

In DirectX 10/10.1, I want to render text on all four corners of the multiple displays that display a texture each made up of ID3D10Resource* prcST using D3DX10CreateTextureFromFile() in my function HRESULT OnD3D10CreateDevice( DEVICE_OBJECT* pDeviceObj, WINDOW_OBJECT* pWindowObj )

D3DX10CreateTextureFromFile ( pDeviceObj->pDevice, L"tile1.jpg", NULL, NULL, &prcST, &hr );

When I use something like below in my OnD3D10rameRender() function, that uses sprite to render text, my textures are not rendered, but only text is rendered with black backgound.( Text on black background.

Text rendered at each top-left of the 3 displays is "Some text to render"
https://plus.google.com/u/0/+AnandMuglikar/posts/XLNnBRCtTfa

hr = pDeviceObj->pSprite->Begin(0);
std::wstring left = L"Some text to render";
RECT r;
r.top = 0;
r.bottom = pWindowObj->Height;
r.left = 0;
r.right = pWindowObj->Width;
hr = pDeviceObj->pFont->DrawTextW(pDeviceObj->pSprite, left.c_str(), -1, &r, DT_LEFT | DT_TOP | DT_CALCRECT | DT_NOCLIP, D3DXCOLOR(0.0f, 1.0f, 0.0f, .5f));
hr = pDeviceObj->pSprite->Flush();
hr = pDeviceObj->pSprite->End();
pDeviceObj->pDevice->OMSetBlendState(NULL, 0, 0x0000ffff);

How to render text on sprite over alpha-blended ID3D10Resource* textures?

The 3 Edge-blending textures on 3 displays are as seen here:
https://plus.google.com/u/0/+AnandMuglikar/posts/MSVdrfFpAuW

Great job getting the text rendered on screen. Are you using a quad for the texture? Textures need an array of vertices in order to be displayed. The createtexture function only loads the image data into a texture object. You then have to pass the texture object, along with an ordered set of vertices to form a mesh that will be used to display the texture.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM