Help me to make work D2D with D3D11

Started by
16 comments, last by BlackJoker 11 years, 1 month ago

Hello to all!

I have a problem with connecting D2D to D3D11. I read a lot of forum articles on that theme, but this interop a little bit hard to understand and more harder to use on practice. I tried to implement it as was saying in this article http://www.braynzarsoft.net/index.php?p=D3D11FONT#still but problem in that in the sample all the code is in 1 file and there is no OOP at all, and I make my engine from the rasterteck framework.

I think during implementation of interop D2D and D3D11 I missed something, but I can`t find the problem because program work without errors, but just no text on the screen.

I uploaded my project here, so if you wish to help me, you can look into code and say where i have a mistake because I am completely confused with this problem.

P.S. I chose to implement D2D + D3D11 because the way to cut texture into pieces seems no so good way to make text output for me, besides it hard to make localization in that way.

Please, help me.

Advertisement
Your LightShader::RenderText method doesn't appear to draw the contents of the shared texture to screen. It looks like it sets up for it but never actually does the draw call.

Telanor

Thanks, I suspect that, but I don`t understand why. As I can see I implement it just as in example. Do you know where the problem could be?

Looks like d3d11DevCon->DrawIndexed( 6, 0, 0 ); is missing on the last line of the draw call from the sample

Maybe I am stupid, but it doesn`t work. I add this call like in example, but still no text on the screen sad.png

Update

I updated my project and now it is not crashes, so you can start it without problems I hope. Pressing L button must inishiate render text, but it is not for now, unfortunately.

Updated project in my first post.

Just in case you're interested. One way of rendering text is to use SpriteFont from the DirectX Toolkit. This uses bitmaps, and includes a tool to create bitmap fonts from truetype fonts.

http://directxtk.codeplex.com/wikipage?title=SpriteFont&referringTitle=DirectXTK

There's a little disclaimer on localization, which I copy-pasted below, but it probably won't be an issue for you. If you want to check it out further the documentation is pretty good.

Localization

This implementation supports sparse fonts, so if you are localizing into languages such as Chinese, Japanese, or Korean, you can build a spritefont including only the specific characters needed by your program. This is usually a good idea for CJK languages, as a complete CJK character set is too large to fit in a Direct3D texture! (if you need full CJK support, Direct2D or DirectWrite would be a better choice). SpriteFont does not support combining characters or right-to-left (RTL) layout, so it will not work for languages with complex layout requirements such as Arabic or Thai.

PS. You might have gotten more response if you posted this in "DirectX and XNA" and tagged it with DX11 or something.

Thanks, Corvwyn, but I want to make work D2D + D3D11. Sprite fonts doesn`t seems to be good decision for me.

If I post this topic in different thread, I won`t be a rool restriction that I create 2 same topics?

I'm not a DirectX-expert and I can't read your comments or run your project(missing D3D11x.h because of Windows 8) but this line looks kinda wrong to me:


void LightShader::RenderText(std::wstring text)
{
...
d3d11_DeviceContext->IASetIndexBuffer(d2dVertBuffer, DXGI_FORMAT_R32_UINT, 0);
..
} 

Are you sure that you wanna pass your VertexBuffer to the Indexbuffer?

You are right on that. I just fix this bug, but still no text render on display to my disappointment.

Could someone build up this project and try to find out why text is not rendered?

This topic is closed to new replies.

Advertisement