Sign in to follow this  
Pyrogame

DX11 Drawing Text - DX11 - SlimDX/C#

Recommended Posts

Pyrogame    106
Hi, I think, that the DirectWrite API wrapper in SlimDX is not finished yet. Is this true? In DX9, this was very easy. Now, I have a DX11 device, and I know, that I need Direct2D or/and DirectWrite to draw text in DX11. What is the best method to do this? a) Create a Direct2D device, then somehow (I have to figure it out) connect it to the DX11 device and then draw the text with it? b) Use only the DirectWrite API, implement my own TextRenderer which can render to the DX11 device using some kind of textures for the glyphes (chars)? c) ... maybe there is a cool, fast, easy option ^^? In my opinion, a) feels to me like a hack... it is not a direct way. Or maybe the interop between DX11 and D2D is easy and well supported? b) in my opinion is something like: I have to render text on my own, there is an API, which simply handles my string -.-. How do you render text in your DX11 applications? What, if you want a 3D text?

Share this post


Link to post
Share on other sites
MJP    19753
You certainly don't *have* to use DirectWrite/D2D for text with D3D11. In fact the two can't really interoperate at the moment: you have to create a D3D 10.1 device in order to use D2D, which means you have to use DXGI synchronization methods in order to use that surface with a D3D11 device. Not impossible, but not simple either.

For my little simple framework I just ended up using GDI+ to render out text to a bitmap, then I load the bitmap data into a D3D11 texture. Then at runtime use my SpriteRenderer to to draw batches of quads with proper texture coordinates in order to draw glyphs. Wasn't too hard to get up and running.

Share this post


Link to post
Share on other sites
Pyrogame    106
Hmm... using GDI+ to render, because the new DX can't do this for us: a simple text rendering ^^. I'm very disapointed.

What happend to the 3d text? I can remember, that in DX9 there was some kind of mesh, which could be build up from a font and string. The result was a 3D text as a mesh.

Share this post


Link to post
Share on other sites
MJP    19753
Quote:
Original post by Pyrogame
Hmm... using GDI+ to render, because the new DX can't do this for us: a simple text rendering ^^. I'm very disapointed.


FYI, text rendering has never been part of D3D. D3DX had ID3DXFont, which was just a very basic class that was there purely for convenience (it used GDI to render text).

If you're not actually rendering the glyphs at runtime you can use whichever library you want to generate your texture. I just used GDI+ because I knew how it worked, and I wanted something I could get up and running quickly.

Quote:
Original post by Pyrogame
What happend to the 3d text? I can remember, that in DX9 there was some kind of mesh, which could be build up from a font and string. The result was a 3D text as a mesh.


You mean D3DXCreateText? They probably took it out because nobody used it. It was a cute little helper to have, but I'd imagine that if you actually need 3D text as part of your game you'll need a lot more flexibility than what that function would give you.

And if you really wanted to use that with D3D11, you could. You can just create a NULLREF D3D9 device, create the mesh, and then extract the vertex and index data. It's a simple mesh so you won't have to worry about materials or vertex declarations.

EDIT: I was talking about the native API, I forgot that this thread was originally about SlimDX. However everything I said should still apply, the names are just different.

Share this post


Link to post
Share on other sites
Pyrogame    106
Yes, i need to output dynamic text, but I can use precreated glyphs to do this. So I do not need any GDI's, I will render it using ms-paint ^^.

But like I said: I'm disapointed. Something, that was so easy in DX9, is now gone, or is complicated.

Thank you for your comments so far. :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Similar Content

    • By isu diss
       I'm trying to code Rayleigh part of Nishita's model (Display Method of the Sky Color Taking into Account Multiple Scattering). I get black screen no colors. Can anyone find the issue for me?
       
      #define InnerRadius 6320000 #define OutterRadius 6420000 #define PI 3.141592653 #define Isteps 20 #define Ksteps 10 static float3 RayleighCoeffs = float3(6.55e-6, 1.73e-5, 2.30e-5); RWTexture2D<float4> SkyColors : register (u0); cbuffer CSCONSTANTBUF : register( b0 ) { float fHeight; float3 vSunDir; } float Density(float Height) { return exp(-Height/8340); } float RaySphereIntersection(float3 RayOrigin, float3 RayDirection, float3 SphereOrigin, float Radius) { float t1, t0; float3 L = SphereOrigin - RayOrigin; float tCA = dot(L, RayDirection); if (tCA < 0) return -1; float lenL = length(L); float D2 = (lenL*lenL) - (tCA*tCA); float Radius2 = (Radius*Radius); if (D2<=Radius2) { float tHC = sqrt(Radius2 - D2); t0 = tCA-tHC; t1 = tCA+tHC; } else return -1; return t1; } float RayleighPhaseFunction(float cosTheta) { return ((3/(16*PI))*(1+cosTheta*cosTheta)); } float OpticalDepth(float3 StartPosition, float3 EndPosition) { float3 Direction = normalize(EndPosition - StartPosition); float RayLength = RaySphereIntersection(StartPosition, Direction, float3(0, 0, 0), OutterRadius); float SampleLength = RayLength / Isteps; float3 tmpPos = StartPosition + 0.5 * SampleLength * Direction; float tmp; for (int i=0; i<Isteps; i++) { tmp += Density(length(tmpPos)-InnerRadius); tmpPos += SampleLength * Direction; } return tmp*SampleLength; } static float fExposure = -2; float3 HDR( float3 LDR) { return 1.0f - exp( fExposure * LDR ); } [numthreads(32, 32, 1)] //disptach 8, 8, 1 it's 256 by 256 image void ComputeSky(uint3 DTID : SV_DispatchThreadID) { float X = ((2 * DTID.x) / 255) - 1; float Y = 1 - ((2 * DTID.y) / 255); float r = sqrt(((X*X)+(Y*Y))); float Theta = r * (PI); float Phi = atan2(Y, X); static float3 Eye = float3(0, 10, 0); float ViewOD = 0, SunOD = 0, tmpDensity = 0; float3 Attenuation = 0, tmp = 0, Irgb = 0; //if (r<=1) { float3 ViewDir = normalize(float3(sin(Theta)*cos(Phi), cos(Theta),sin(Theta)*sin(Phi) )); float ViewRayLength = RaySphereIntersection(Eye, ViewDir, float3(0, 0, 0), OutterRadius); float SampleLength = ViewRayLength / Ksteps; //vSunDir = normalize(vSunDir); float cosTheta = dot(normalize(vSunDir), ViewDir); float3 tmpPos = Eye + 0.5 * SampleLength * ViewDir; for(int k=0; k<Ksteps; k++) { float SunRayLength = RaySphereIntersection(tmpPos, vSunDir, float3(0, 0, 0), OutterRadius); float3 TopAtmosphere = tmpPos + SunRayLength*vSunDir; ViewOD = OpticalDepth(Eye, tmpPos); SunOD = OpticalDepth(tmpPos, TopAtmosphere); tmpDensity = Density(length(tmpPos)-InnerRadius); Attenuation = exp(-RayleighCoeffs*(ViewOD+SunOD)); tmp += tmpDensity*Attenuation; tmpPos += SampleLength * ViewDir; } Irgb = RayleighCoeffs*RayleighPhaseFunction(cosTheta)*tmp*SampleLength; SkyColors[DTID.xy] = float4(Irgb, 1); } }  
    • By amadeus12
      I made my obj parser
      and It also calculate tagent space for normalmap.
      it seems calculation is wrong..
      any good suggestion for this?
      I can't upload my pics so I link my question.
      https://gamedev.stackexchange.com/questions/147199/how-to-debug-calculating-tangent-space
      and I uploaded my code here


      ObjLoader.cpp
      ObjLoader.h
    • By Alessandro Pozzer
      Hi guys, 

      I dont know if this is the right section, but I did not know where to post this. 
      I am implementing a day night cycle on my game engine and I was wondering if there was a nice way to interpolate properly between warm colors, such as orange (sunset) and dark blue (night) color. I am using HSL format.
      Thank  you.
    • By thefoxbard
      I am aiming to learn Windows Forms with the purpose of creating some game-related tools, but since I know absolutely nothing about Windows Forms yet, I wonder:
      Is it possible to render a Direct3D 11 viewport inside a Windows Form Application? I see a lot of game editors that have a region of the window reserved for displaying and manipulating a 3D or 2D scene. That's what I am aiming for.
      Otherwise, would you suggest another library to create a GUI for game-related tools?
       
      EDIT:
      I've found a tutorial here in gamedev that shows a solution:
      Though it's for D3D9, I'm not sure if it would work for D3D11?
       
    • By Cyndanera
      in directx I need to know how would I play the animation in directx rendering frames for each part of the model moving parts - like the bones, how would would that work?
      I'm new to writing a animation player, for a model parser.
      I'm asking so I understand how to do this, I'm new to loading a model and playing\moving the bones to effect the mesh.
  • Popular Now