How do I render text In DirectX 11 using the C language - directx

I've been trying to render some simple text on screen using DirectX 11, but I am unable to do It because I keep running into issues. I am using C18 and not C++. Have tried using DirectXTK , Direct2D and DirectWrite but none of these work. Does anybody have a solution for this?

Related

Is Using HTML5 canvas a good idea for Electron.JS?

I want to make an electron app that is similar to scratch in which it uses drag and drop features. I want to make these features using canvas. However, I don't know if this is a good idea as I tried searching it up and never got Electron and HTML5 Canvas in the same sentence.
I'm using canvas for rendering charts in my project and it works correctly. I have been researching a bit and I have not found any better alternative to replace it

TChart quality issue

We were using Delphi 2010 with the full VCL edition of TeeChart this worked fine
We have now updated to Delphi XE 5 with the latest version of TeeChart and the quality of the charts is now worse
Please see the image here
2 bars which were seperate are now merged into 1 bar
If I make the charts wider which is not an option it looks better but still not as good as before
Please see here
Has anyone come across any issue like this?
The projects are here for Delphi XE5 and here for Delphi 2010
The search paths may need modifying
Cheers
Paul
The issue might be because of the anti-aliasing function being turned on by default in the newer versions of TChart(!).
We had the same issue with a line series graph.
After writing to the vendor (Steema) they came up with the following solution:
Chart1.Canvas := TTeeCanvas3D.Create; //Disable GDI+ to prevent smooth drawing of the graph.
I don't get why we have to switch off drawing with GDI+ as - to my knowledge - GDI+ can also be used without anti-alias.
Anyway, our graphs now behave like the previous versions of the TChart, which is what we want.
I was also hating the "new" anti-aliased charts that are blurry and slow.
It's pretty easy to fix, when you know where to search for.
Double-click on chart, then go to 3D -> Render -> select GDI instead of GDI+
If you look "behind the scenes" into DFM file you can see the change:
Crisp and fast graph (as in 2010): DefaultCanvas = 'TTeeCanvas3D'
Blurry and slow graph (as in XE5): DefaultCanvas = 'TGDIPlusCanvas'
chart settings
Hope this helps.
Some kind of a clumsy runtime workaround was found here, that is also working:
http://www.teechart.net/support/viewtopic.php?f=3&t=15078

How to render simple 2d text in openGL with delphi?

I am trying to find a way to display a simple text on an openGL form in Delphi.
I tried this with Labels, but they were not showing up. I'm guessing that the openGL window was rendered on top of it, so I tried to call Label1.BringToFront; but this didn't work.
I also heard of a library called freetype, but I couldn't find info, how to implement it in Delphi.
What is the simplest way to render out text on an openGL form in Delphi?
The simplest way is to use opengl's wglfontbitmaps
const numberchar =128
allocate:
wglMakeCurrent(FDC, FRC);
FFontBase := glGenLists(numberchar);
SelectObject(FDC, FFont.Handle);
wglUseFontBitmaps(FDC,0,128, FFontBase);
draw(atext:ansistring);
glPushAttrib(GL_LIST_BIT);
glListBase(FFontbase);
glCallLists(Length(aText), GL_UNSIGNED_BYTE, Pansichar(aText)); list
glPopAttrib;
free:
glDeleteLists(FFontBase, numberchar);
The draw code is only partial. Best to look for tutorials for similar code.
Note this will only give you basic unscaled font. For fancy text effects, indeed, freetype is the most common route.
A good place to start with Delphi and opengl is http://www.delphigl.com/ Mostly German, but some English boards too.
An alternative (provided that you have D2010+) is to look in the direction of DirectX. D2010+ comes with a directx context component.

Three.JS model viewer feasible in phonegap?

I'm trying to make a very simple 3D model viewer in a phonegap app for use on an iPhone 4. I'm using three.js which is working fine when I make a simple website. The problem is that when I try it out on the phone the 3D object doesn't appear. Simple geometrical shapes like a cube and cylinder will load on the canvas but obj files won't.
I use an objLoader to bring in the .obj file and have all relevant files in the same directory in the app just in case. I think the problem might lie with using webGL on iOS but I'm not really sure.
Thanks very much for your help. If anyone has any suggestions for building a model viewer in phonegap for display in iOS I'd be delighted to hear them.
As very few mobile browsers support WebGL at the moment I opted to use the canvas to render the 3D models. I used a simple web 3D object viewer called JSC3D to create a model viewer in PhoneGap on iOS. It can use webGL but I just went with rendering using the 2D canvas.
I tested my app on an iPhone 4 and the result was that the model took between 2 and 5 seconds to load up and when you go to rotate the object it takes some time to redraw it depending on how complex it is. While not the most satisfactory result it did do the job. I'm going to try it out on a more advanced phone in Android and I'll let you know the result.
I suggest you try use XDK Intel if you are packaging for iphone but for android use AIDE Phonegap. Make sure you use only var renderer = new THREE.CanvasRenderer();and avoid using
Anything that has to do with WebGL for its not supported on most devices except BB Playbook and BB 10.
I think IOS render ability is better than Android, some scene renders well in IOS, but not in the Android.
Usually the movile have more render ability, than tha mobile app. I use the firefox to render the three.js obj demo, it works well. But when I use the webview in the app, it renders nothing.
I've make an Android app to render stl models. First when I use the mobile browser to render the scene, it not render the full scene, and when I remove the shadow effect, it renders. Then I try to use webview with WebGlRenderer or CanvasRenderer, no works. Last I refer to the XWalkView of crosswalk a web engine which can used as an addin of the app, to replace the webview, I also close the shadow effect, I renders well.
You can refer this answer for more info.
Here is the render result.
You definitely should not use WebGL renderer of three.js as it's not supported on iOS. Try Canvas or SVG renderer.

Can Direct3D 11 do offscreen-only rendering (no swap chain)?

Is it possible to use Direct3D 11 for rendering to textures only, i.e. without creating a swap chain and without creating any window? I have tried that and all my API calls succeed. The only problem is that the picture I am downloading from a staging texture is black.
I finally managed to capture a full stream using PIX (Parallel Nsight does not seem to work at all). PIX shows that my render target is black, too, although I clear it to blue.
Is it possible at all what I intend to do? If so, how would one do it?
Actually, the whole thing is working as intended if you initialise the device correctly.

Resources