<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.xna.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Direct3D</title><link>http://forums.xna.com/forums/27.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 0.0)</generator><item><title>Re: Native Direct3D and .Net Framework Graphics on the same control problem</title><link>http://forums.xna.com/forums/thread/198205.aspx</link><pubDate>Fri, 10 Jul 2009 06:47:39 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:198205</guid><dc:creator>GregDude</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/198205.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=27&amp;PostID=198205</wfw:commentRss><description>I had several work a rounds but ended up just drawing the few extra GUI elements I needed using D3D.&lt;br /&gt;</description></item><item><title>Re: Native Direct3D and .Net Framework Graphics on the same control problem</title><link>http://forums.xna.com/forums/thread/197127.aspx</link><pubDate>Tue, 07 Jul 2009 05:10:52 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:197127</guid><dc:creator>legalize</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/197127.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=27&amp;PostID=197127</wfw:commentRss><description>&lt;p&gt;You don&amp;#39;t say anything about how dynamic this GUI stuff is that you&amp;#39;re trying to draw with .NET, but if its relatively static I would just draw it to an image and then use D3D to combine it with the 3D stuff by treating it as a simple quad textured with the image drawn by .NET.&lt;/p&gt;
&lt;p&gt;Either that, or do the reverse: draw the D3D stuff into a plain surface which you copy into a .NET image and have .NET do the compositing.&lt;/p&gt;
&lt;p&gt;I wouldn&amp;#39;t try to mix presentation from both APIs.  Either have D3D do the presentation (which means rendering .NET into an image and having D3D do the composition in the back buffer using a textured quad), or have .NET do the presentation (which means rendering D3D into a plain surface and having .NET do the composition in an image).&lt;/p&gt;</description></item><item><title>Re: Native Direct3D and .Net Framework Graphics on the same control problem</title><link>http://forums.xna.com/forums/thread/197064.aspx</link><pubDate>Tue, 07 Jul 2009 01:07:27 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:197064</guid><dc:creator>GregDude</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/197064.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=27&amp;PostID=197064</wfw:commentRss><description>Thanks for the info legalize.&amp;nbsp; I&amp;#39;m not actually wanting to draw to the backbuffer with GDI.&amp;nbsp; I want to over-draw the fontbuffer.&lt;br /&gt;
&lt;br /&gt;
The application consists of two parts, the native code accessing Direct3D to draw some polygons and the managed code using .Net Framework to overlay some GUI.&amp;nbsp; The two parts don&amp;#39;t really communicate with each other or access each others data.&lt;br /&gt;
&lt;br /&gt;
There may be some way to achieve what I&amp;#39;m after using transparent overlayed windows.&amp;nbsp; I would need to take care to prevent the GUI overdraw from triggering another repaint of the background, since it is the repaint that triggers the whole redraw in the first place.&amp;nbsp; There are all kind of work arounds including rendering to textures and repainting with those textures, drawing some GUI elements in D3D itself, etc. but my current method is so convenient and keeps native and managed parts of the app separate.&lt;br /&gt;</description></item><item><title>Re: Native Direct3D and .Net Framework Graphics on the same control problem</title><link>http://forums.xna.com/forums/thread/194430.aspx</link><pubDate>Mon, 29 Jun 2009 03:11:51 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:194430</guid><dc:creator>legalize</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/194430.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=27&amp;PostID=194430</wfw:commentRss><description>Mixing GDI and Direct3D is supported, but its somewhat painful.  You have to make sure your back buffer is compatible with GDI and you have to use IDirect3DSurface9::GetDC to obtain a compatible DC for drawing on the back buffer surface.  The restrictions imposed by this model are documented on the reference page for IDirect3DSurface9::GetDC.&lt;br /&gt;
&lt;br /&gt;
In Vista, GDI is implemented completely in software.  This will continue with Windows 7 and beyond.  If you need to mix GDI like operations with Direct3D, you should look at the DirectWrite and Direct2D APIs introduced for Windows 7.  (They will be back-filled on Vista, once Windows 7 is released.)</description></item><item><title>Re: Native Direct3D and .Net Framework Graphics on the same control problem</title><link>http://forums.xna.com/forums/thread/190138.aspx</link><pubDate>Mon, 15 Jun 2009 11:29:20 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:190138</guid><dc:creator>GregDude</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/190138.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=27&amp;PostID=190138</wfw:commentRss><description>Thanks for replying Nick.&amp;nbsp; I am coming to realize the two don&amp;#39;t get along very well.&amp;nbsp; It appears the GDI does some kind of internal buffering and layering which is out of sync with raw updates to the window.&amp;nbsp; If it wasn&amp;#39;t for this buffering or compositing, there should be no reason they can&amp;#39;t work, perhaps as long as they are synchronized in some way.&lt;br /&gt;
I have just found however that this issue occurs only on Vista, not XP or Windows 7.&amp;nbsp; I can make Vista work by setting the .exe properties Compatibility to &amp;#39;Disable desktop composition&amp;#39;.&lt;br /&gt;
&lt;br /&gt;
By the way, this application is a GUI game development tool which uses some windows to render scenes using the native game engine.&amp;nbsp; You can imagine it is desirable to overlay the native rendering with managed GUI and not mix code since they aren&amp;#39;t really related anyway.&lt;br /&gt;</description></item><item><title>Re: Native Direct3D and .Net Framework Graphics on the same control problem</title><link>http://forums.xna.com/forums/thread/190097.aspx</link><pubDate>Mon, 15 Jun 2009 05:41:05 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:190097</guid><dc:creator>Nick Gravelyn</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/190097.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=27&amp;PostID=190097</wfw:commentRss><description>Honestly I would have expected both to be broken. At the end of the day, you shouldn&amp;#39;t be combining GDI with Direct3D on the same surface; they are two different graphics APIs which were likely never designed to be used on the same surface at the same time. You should just render your selection rectangle using Direct3D, as well as any further 2D graphics you render on top of the scene.</description></item><item><title>Native Direct3D and .Net Framework Graphics on the same control problem</title><link>http://forums.xna.com/forums/thread/190087.aspx</link><pubDate>Mon, 15 Jun 2009 05:08:03 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:190087</guid><dc:creator>GregDude</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/190087.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=27&amp;PostID=190087</wfw:commentRss><description>I am encountering and issue where drawing a control using both Direct3D and .Net Framework Graphics causes conflict.&lt;br /&gt;
Strangely enough this only occurs with Windows Vista.&amp;nbsp; Windows XP works fine.&amp;nbsp; Pleaes see the attached screen shots.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://img37.imageshack.us/img37/1390/editorrectangle.jpg" target="_blank"&gt;screen shots&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
This is the execution process:&lt;br /&gt;
MouseMove calls Invalidate() on the control.&lt;br /&gt;
Paint event is called.&lt;br /&gt;
Inside MyOnPaint(), I &lt;br /&gt;
1) Render 3D scene using native Direct3D, using the HWND from the control.&lt;br /&gt;
2) Draw a selection rectangle using Graphics::DrawRectangle()&lt;br /&gt;
&lt;br /&gt;
Any Graphics::Draw functions overlay the Direct3D scene with visible bounding rectangles and trails.&lt;br /&gt;
The only way I can get the image to look correct is surround the Graphics::DrawRectangle with:&lt;br /&gt;
&lt;br /&gt;
Point screenPoint = win-&amp;gt;PointToScreen(Point(0,0));&lt;br /&gt;
graphics-&amp;gt;CopyFromScreen(screenPoint.X, screenPoint.Y, 0,0, win-&amp;gt;Size);&lt;br /&gt;
graphics-&amp;gt;DrawRectangle(pen, rectangle);&lt;br /&gt;
graphics-&amp;gt;Flush(Drawing::Drawing2D::FlushIntention::Sync);&lt;br /&gt;
&lt;br /&gt;
It appears the GDI or Graphics code buffers the draw commands and applies them at some point.&lt;br /&gt;
This flush and sync code seems to synchronize them.&amp;nbsp; The Graphics functions still leave white bounding boxes.&lt;br /&gt;
&lt;br /&gt;
Another alternative for me is to render the selection rectangle with&lt;br /&gt;
ControlPaint::DrawReversibleFrame(rectangle, Color::Transparent, FrameStyle::Dashed);&lt;br /&gt;
However I still need to flush and sync which drops the effective frame rate from say 200fps to 15fps.</description></item></channel></rss>