• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
AlexAndre_156151

"SlimDX:D3D11 & Direct2D Interop"

4 posts in this topic

I'm working on a DirectX11 engine based on SlimDX, and I've hit a major snag. I'm trying to integrate Direct2D into the engine to render 2D graphics, but I'm unable to do so. The problem is that the RenderTarget.FromDXGI method fails and throws an E_NO_INTERFACE error every time I try to create my Direct2D RenderTarget. I do everything by the book: I create a valid Device and SwapChain, get a Surface instance from SwapChain back-buffer, create a valid D2D Factory,etc. I've verified that everything is correct by stepping through with my debugger. But the method always fails! I've tried different Formats, used the BgraSupport flag to create my Device, tried every combination of settings/params possible - all to no avail. Disturbingly, everything suddenly works fine when I switch to D3D10.1 and edit a couple lines to use the Device1 interface! So it begs the question: why can't D3D11 work with Direct2D? How can any 2D graphics berendered if I can't interop with Direct2D? This is a real show-stopper, and I have [color="#366388"]countless hours of work[/color] on the line. I'm hoping someone can point me in the right direction. What's wrong, and how can D3D11 & D2D be used together? And if it's not possible, which would shock me, how the heck can I do 2D rendering at all? MSDN and the documentation for [color="#366388"]DirectX[/color] and SlimDX offer no answers. The DX docs mention only D3D10.1 / Direct2D interop, and offer no explanation ofhow we render 2D graphics now that the Font and Sprite classes are removed in 11. So can anyone help me out? I'm terribly frustrated after wasting days trying to find a solution. So I hope someone knows what I need to do. Thanks for your time and any help/advice you can provide!
0

Share this post


Link to post
Share on other sites
You can't use them together. For whatever reason, the DirectX team hasn't seen fit to enable support for D3D11. Yes it's very stupid.
0

Share this post


Link to post
Share on other sites
Thanks for posting this question for me, Alex! ;)

And thanks for answering, Mike.

But that's absolutely ridiculous... "Stupid" isn't quite the word for it I'm afraid, Mike. Damn you, Microsoft!

So where does that leave us?

A) Use a D3D11 AND a D3D10.1 Device? No way...what a waste of resources and super sloppy code...
B) Use DXUT? Nope... I'm using SlimDX, and have written my own some-what complete engine. Sloppy hack-n-splice would be the only way, and I'm not fond of that idea.
C) Hack DirectX itself? lol...

So how the heck can we render simple text and sprites without doing something really whacky, sloppy and wasteful? Am I going to be stuck writing my own 2D rendering API that can spit pixels onto my back-buffer, just to get a decent, clean 2D interface?

The only other thing I can think of is writing something that will rasterize fonts and sprites into a texture and putting them on a 3D quad with an orthographic matrix. I don't like that idea either.

So WTF, Microsoft? What do you expect us to do for 2D graphics?
0

Share this post


Link to post
Share on other sites
For me I found this library for text rendering in D3D11:
http://www.rufelt.com/fw1fontwrapper/

It uses DirectWrite (and thus Direct2D) to create the fonts. Works like a charm :)
0

Share this post


Link to post
Share on other sites
[quote name='ATC' timestamp='1308595814' post='4825599']
So where does that leave us?

A) Use a D3D11 AND a D3D10.1 Device? No way...what a waste of resources and super sloppy code...
B) Use DXUT? Nope... I'm using SlimDX, and have written my own some-what complete engine. Sloppy hack-n-splice would be the only way, and I'm not fond of that idea.
C) Hack DirectX itself? lol...

So how the heck can we render simple text and sprites without doing something really whacky, sloppy and wasteful? Am I going to be stuck writing my own 2D rendering API that can spit pixels onto my back-buffer, just to get a decent, clean 2D interface?

The only other thing I can think of is writing something that will rasterize fonts and sprites into a texture and putting them on a 3D quad with an orthographic matrix. I don't like that idea either.

So WTF, Microsoft? What do you expect us to do for 2D graphics?
[/quote]

A) I find using two devices rather elegant. I'm working on a UI library that uses Direct2D and DirectWrite with SlimDX. Direct2D alone isn't versatile enough to handle custom blending and shader effects, so my drawing model is split into Direct2D drawing and Direct3D composition all on its own Direct3D 10.1 device. Most Direct2D drawing is cached in dynamic texture atlases for speed. Ultimately, whatever is being drawn is composited onto a shared and synchronized texture. The other device simply calls OpenSharedResource<Texture2D> with the shared handle and creates a KeyedMutex for the resulting texture. Aside from the mutex lock and release each frame, the texture is used just like any other. The overhead in my code seems to be less than 0.5 milliseconds using two Direct3D 10.1 devices. I don't see why it wouldn't work between 10.1 and 11 devices.
0

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  
Followers 0