<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>http://www.fsdeveloper.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Direct2D_Gauges</id>
	<title>Direct2D Gauges - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://www.fsdeveloper.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Direct2D_Gauges"/>
	<link rel="alternate" type="text/html" href="http://www.fsdeveloper.com/wiki/index.php?title=Direct2D_Gauges&amp;action=history"/>
	<updated>2026-05-10T03:45:26Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>http://www.fsdeveloper.com/wiki/index.php?title=Direct2D_Gauges&amp;diff=8731&amp;oldid=prev</id>
		<title>Narutokun-8877: New page: {{Infobox-Applicable-FSVersion | FSXI = true | FSXA = true | FSX = true | FS2004 = false | FS2002 = false }}  Despite FSX being a DirectX 9 program and Direct2D being part of DirectX 10/11...</title>
		<link rel="alternate" type="text/html" href="http://www.fsdeveloper.com/wiki/index.php?title=Direct2D_Gauges&amp;diff=8731&amp;oldid=prev"/>
		<updated>2013-02-27T19:39:59Z</updated>

		<summary type="html">&lt;p&gt;New page: {{Infobox-Applicable-FSVersion | FSXI = true | FSXA = true | FSX = true | FS2004 = false | FS2002 = false }}  Despite FSX being a DirectX 9 program and Direct2D being part of DirectX 10/11...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Infobox-Applicable-FSVersion&lt;br /&gt;
| FSXI = true&lt;br /&gt;
| FSXA = true&lt;br /&gt;
| FSX = true&lt;br /&gt;
| FS2004 = false&lt;br /&gt;
| FS2002 = false&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Despite FSX being a DirectX 9 program and Direct2D being part of DirectX 10/11, it is possible to use it as a gauge drawing method in conjunction with GDI/GDI+(In other words, you can mix the 2) in FSX. Here is how it is done:&lt;br /&gt;
&lt;br /&gt;
First of all, define the following pointers along with any other pens/brushes/bitmaps or other D2D objects you want to use. These 2 are vital though:&lt;br /&gt;
&lt;br /&gt;
 ID2D1Factory* pD2DFactory = NULL;&lt;br /&gt;
 ID2D1DCRenderTarget* pRT = NULL;&lt;br /&gt;
&lt;br /&gt;
In your PANEL_SERVICE_CONNECT_TO_WINDOW (or gauge class constructor if using the ESP example as a template), initialize your ID2D1Factory object and your ID2D1DCRenderTarget as well as initializing any other objects:&lt;br /&gt;
&lt;br /&gt;
 //Initialize the ID2D1Factory object&lt;br /&gt;
 D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &amp;amp;pD2DFactory);&lt;br /&gt;
 //initialize the ID2D1DCRenderTarget&lt;br /&gt;
 D2D1_RENDER_TARGET_PROPERTIES props = D2D1::RenderTargetProperties(&lt;br /&gt;
 D2D1_RENDER_TARGET_TYPE_DEFAULT,&lt;br /&gt;
 D2D1::PixelFormat(&lt;br /&gt;
 	DXGI_FORMAT_B8G8R8A8_UNORM,&lt;br /&gt;
 	D2D1_ALPHA_MODE_PREMULTIPLIED),&lt;br /&gt;
 	0,&lt;br /&gt;
 	0,&lt;br /&gt;
 	D2D1_RENDER_TARGET_USAGE_GDI_COMPATIBLE,&lt;br /&gt;
 	D2D1_FEATURE_LEVEL_DEFAULT&lt;br /&gt;
 	);&lt;br /&gt;
 pD2DFactory-&amp;gt;CreateDCRenderTarget(&amp;amp;props, &amp;amp;pRT);&lt;br /&gt;
&lt;br /&gt;
Then, in your PANEL_SERVICE_POST_INSTALL call, link the ID2D1DCRenderTarget with the hDC of the gauge(it will be relinked with any gauge resize)&lt;br /&gt;
&lt;br /&gt;
 RECT rct;&lt;br /&gt;
 rct.top = 0;&lt;br /&gt;
 rct.left = 0;&lt;br /&gt;
 rct.right = tempX;//Width of the gauge&lt;br /&gt;
 rct.bottom = tempY;//Height of the gauge&lt;br /&gt;
 pRT-&amp;gt;BindDC(element-&amp;gt;hdc, &amp;amp;rct);&lt;br /&gt;
&lt;br /&gt;
Then in order to draw, place all your D2D drawing code between these 2 lines&lt;br /&gt;
&lt;br /&gt;
 pRT-&amp;gt;BeginDraw();&lt;br /&gt;
 &lt;br /&gt;
 pRT-&amp;gt;EndDraw();&lt;br /&gt;
&lt;br /&gt;
Finally, to close down Direct2D, place this in your PANEL_SERVICE_DISCONNECT or class destructor (if using the ESP GDI+ example as a template)&lt;br /&gt;
&lt;br /&gt;
 if(pRT)&lt;br /&gt;
  pRT-&amp;gt;Release();&lt;br /&gt;
 //Release the other Direct2D objects you have created as well&lt;br /&gt;
 if(pD2DFactory)&lt;br /&gt;
  pD2DFactory-&amp;gt;Release();&lt;br /&gt;
&lt;br /&gt;
Thats it. Enjoy!&lt;br /&gt;
&lt;br /&gt;
[[Category:Aircraft Design]]&lt;br /&gt;
[[Category:Panel and Gauge Design]]&lt;/div&gt;</summary>
		<author><name>Narutokun-8877</name></author>
	</entry>
</feed>