In DirectX 10 you could use the font interface provided by D3DX10. In DirectX 11 you are supposed to use DirectWrite. But it looks like DirectWrite doesn't speak natively to Direct3D? Is there something basic I'm missing? How do you draw simple text with DirectX 11?
There's a SpriteFont class in the DirectXTK library that can render text to a DirectX11 device context.
Edit 2014:
As pointed out in comment, the link to RasterTek tutorials no longer functions, here is a link to Webarchive of RasterTek provided by RadioSpace.
The second point of the original answer is no longer valid either, because its now possible to share D3D11 backbuffer with Direct2D and through it draw text with DirectWrite.
Edit 2017:
RasterTek is still running: font rendering in D3D11
I know about two options
make your own font rendering engine see Rastertek DX11 tutorial
second option regarding direct write requires sharing backbuffer between d3d11 and d3d10.1 devices and using dwrite + d2d + d3d10.1 to render gui and d3d11 device to render 3d geometry and merge it all in backbuffer see the post from DieterVW on this thread
At this moment dwrite and d2d dont accept surface created with d3d11 device for rendering. But hopefully MS will make it so soon.
I recently converted a DirectX 10 application over to DirectX 11 and came across this post while searching for the same answer. The Rastertek tutorial mentioned by Zeela is good, but I continued searching and found FW1FontWrapper. After only about 30 minutes, I just finished integrating it into my project and it appears to be working great. The download section provides both x86 and x64 packages including header, library, and DLL. I am just doing a simple text output, so I can't say a lot about the API, except that for what I did (outputting frames per second), it only took about 5 lines of code (including creating/releasing the wrapper object). Based on his samples it seems to provide a lot more options than what I'm using so far.
Use DirectWrite , it support high-quality text rendering, resolution-independent outline fonts, and full Unicode text and layout support.
Related
I'm developing a video player in Qt C++ using QtAV. QtAV uses ffmpeg internally. I need to show semi transparent overlays both my watermark logo and subtitles. I'm writing the application for windows. I use OpenAL library. OpenGL and Direct2D are the choice for renderers.
If I use OpenGL renderer, it works fine in some systems. The overlay works fine. But in some other systems the whole application will be just a black window. Nothing else I can see.
If I use Direct2D, the overlay wont work. And the renderer is a bit slow. But it works on all systems, without this overlays.
I have no code to show here because its not the coding issue. Even the examples in QtAV are not working. I need to find a way to show the overlays using Direct2D renderer OR find a solid way to use OpenGL rendering on all systems without fail.
Direct2D is not well supported in QtAV. So you may need to implement your own functions to add filters in your video render. That includes text draw functions, setting transparency etc.
I already have a Direct3d device at my beck and call...
I am working on a Windows 8 modern UI application (Metro if you will)
What's the general technique of getting text drawn to the screen?
Extra points: Can I do 3d stuff with it too? This is what originally got me here as I started to do some direct2d thing then I thought, but how can I do 3d with direct2d... second of all the d2d create text functions require a handle to a window hwnd and there is no such thing (or it has been abstracted away) in windows 8 metro apps.
Anyone got any good examples or demos I can take a look at?
You should look into DirectWrite.
Regarding your second question you can render your text to a texture and then when you render that texture on screen do 3d stuff with it.
Rendering text with DirectWrite and Direct2D it's relatively simple, however, if you want something higher level, you can look into Drawing Library for Windows Store Apps, which wraps raw DirectX calls into some more GDI like.
How does one write code to make drawings in the Windows main client area of a Win32 C++ app?
I found an example online that uses the "eclipse" API but when I put it in my program, the IDE complained so it would not compile.
Assuming you mean basic drawing (primitives, rendering bitmaps, stuff like that), then GDI and GDI+ are most likely what you want. I haven't used GDI+ much, but theForger's Win32 API tutorial will show you how to work with bitmaps. Drawing primitives is more GDI+ territory, and I can really only refer you to the MSDN GDI+ documentation for details of those functions.
If you're looking for game-type graphics, on the other hand, then you might need to research DirectX or OpenGL.
By using GDI and/or GDI+ functions in the WM_PAINT handler of the form.
Here is a site with some examples.
Simple example - on one side we see camera rendered via standard software rendered "Input" on other hand (labeled "Output") rendered via some directX stuff (at least it seems to me) :
So what function is provided by windows api or DirectX api for capturing such mixed scenes?
TightVNC Server can do it, you may want to look into what they are doing. From a simple glance through their source code it looks like they are creating a virtual screen that mirrors the primary screen.
Specifically though, look into the
CreateCompatibleDC and CreateDIBSection API's
As I known, there is not a direct way to capture DirectX render area, although we can see that on the screen. Because the real render action(aka render instruction) happens in hardware layer. So the API in standard SDK cannot know the finally render result, which lead to the black square.
The only way to do this maybe put your hope on the Render layer(such as DirectX engine) itself can support output interface as well as underlying render action. So I suggest to check some documentation to find if there indeed is.
DirectX can present to a limited subsection of the window that you give it, enabling you to create small regions of DX content in larger windows.
I'm writing a plugin in firebreath, C++.
I don't have any experience with both, so my question may be very basic.
How do I place a JPEG image inside my plugin window?
Or at least, how do I do it in C++ simple program?
Thanks,
RRR
There are a couple of other questions that may help you better understand this:
How to write a web browser plugin for IE, Firefox and Chrome
Directx control in browser plugin
Basically you'll get a drawing model from FireBreath with the AttachedEvent. Depending on your platform, you will draw to that window using platform-specific drawing APIs. On Windows, for example, you would get the HWND from the PluginWindow (cast it to a PluginWindowWin) and then draw to that. Just make sure you stop drawing when DetachedEvent shows up.
For more information, you'll need to be a lot more specific; but follow those links and do some reading, then you'll know better what questions to ask.
FireBreath 1.5.2 was just released, btw! Good luck!
Good luck!
You can also use OpenGL to display images in plugin. You can get several tutorials to load jpeg image in OpenGL as texture. Same code can be ported into the Firebreath plugin using the already given OpenGL sample plugin for windows. Though OpenGL context creation will vary from one OS to the other. If you want to load jpeg images from web, you'll have to download image before converting it into opengl texture.