• 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
Chris_F

DirectX 11 + MinGW-w64

9 posts in this topic

So I'm having a hard time getting DirectX 11 and MinGW to cooperate. MinGW seems to come with some DX11 headers, but I wasn't able to get anything to compile since it couldn't even seem to find a class definition for ID3D11Device. [img]http://public.gamedev.net//public/style_emoticons/default/sleep.png[/img]

With some help online I managed to come up with this:

d3d11-mingw.h
[source]
#define __in
#define __out
#define __inout
#define __in_bcount(x)
#define __out_bcount(x)
#define __in_ecount(x)
#define __out_ecount(x)
#define __in_ecount_opt(x)
#define __out_ecount_opt(x)
#define __in_bcount_opt(x)
#define __out_bcount_opt(x)
#define __in_opt
#define __inout_opt
#define __out_opt
#define __out_ecount_part_opt(x,y)
#define __deref_out
#define __deref_out_opt
#define __RPC__deref_out

#include <d3d11.h> //from D3D SDK

#ifdef __uuidof
#undef __uuidof
#endif
#define __uuidof(x) IID_##x

#ifdef DEFINE_GUID
#undef DEFINE_GUID
#endif
#define DEFINE_GUID(id, a, b, c, d, e, f, g, h, i, j, k) const GUID id = { a,b,c, { d,e,f,g,h,i,j,k } };

DEFINE_GUID(IID_ID3D11DeviceChild,0x1841e5c8,0x16b0,0x489b,0xbc,0xc8,0x44,0xcf,0xb0,0xd5,0xde,0xae);
DEFINE_GUID(IID_ID3D11DepthStencilState,0x03823efb,0x8d8f,0x4e1c,0x9a,0xa2,0xf6,0x4b,0xb2,0xcb,0xfd,0xf1);
DEFINE_GUID(IID_ID3D11BlendState,0x75b68faa,0x347d,0x4159,0x8f,0x45,0xa0,0x64,0x0f,0x01,0xcd,0x9a);
DEFINE_GUID(IID_ID3D11RasterizerState,0x9bb4ab81,0xab1a,0x4d8f,0xb5,0x06,0xfc,0x04,0x20,0x0b,0x6e,0xe7);
DEFINE_GUID(IID_ID3D11Resource,0xdc8e63f3,0xd12b,0x4952,0xb4,0x7b,0x5e,0x45,0x02,0x6a,0x86,0x2d);
DEFINE_GUID(IID_ID3D11Buffer,0x48570b85,0xd1ee,0x4fcd,0xa2,0x50,0xeb,0x35,0x07,0x22,0xb0,0x37);
DEFINE_GUID(IID_ID3D11Texture1D,0xf8fb5c27,0xc6b3,0x4f75,0xa4,0xc8,0x43,0x9a,0xf2,0xef,0x56,0x4c);
DEFINE_GUID(IID_ID3D11Texture2D,0x6f15aaf2,0xd208,0x4e89,0x9a,0xb4,0x48,0x95,0x35,0xd3,0x4f,0x9c);
DEFINE_GUID(IID_ID3D11Texture3D,0x037e866e,0xf56d,0x4357,0xa8,0xaf,0x9d,0xab,0xbe,0x6e,0x25,0x0e);
DEFINE_GUID(IID_ID3D11View,0x839d1216,0xbb2e,0x412b,0xb7,0xf4,0xa9,0xdb,0xeb,0xe0,0x8e,0xd1);
DEFINE_GUID(IID_ID3D11ShaderResourceView,0xb0e06fe0,0x8192,0x4e1a,0xb1,0xca,0x36,0xd7,0x41,0x47,0x10,0xb2);
DEFINE_GUID(IID_ID3D11RenderTargetView,0xdfdba067,0x0b8d,0x4865,0x87,0x5b,0xd7,0xb4,0x51,0x6c,0xc1,0x64);
DEFINE_GUID(IID_ID3D11DepthStencilView,0x9fdac92a,0x1876,0x48c3,0xaf,0xad,0x25,0xb9,0x4f,0x84,0xa9,0xb6);
DEFINE_GUID(IID_ID3D11UnorderedAccessView,0x28acf509,0x7f5c,0x48f6,0x86,0x11,0xf3,0x16,0x01,0x0a,0x63,0x80);
DEFINE_GUID(IID_ID3D11VertexShader,0x3b301d64,0xd678,0x4289,0x88,0x97,0x22,0xf8,0x92,0x8b,0x72,0xf3);
DEFINE_GUID(IID_ID3D11HullShader,0x8e5c6061,0x628a,0x4c8e,0x82,0x64,0xbb,0xe4,0x5c,0xb3,0xd5,0xdd);
DEFINE_GUID(IID_ID3D11DomainShader,0xf582c508,0x0f36,0x490c,0x99,0x77,0x31,0xee,0xce,0x26,0x8c,0xfa);
DEFINE_GUID(IID_ID3D11GeometryShader,0x38325b96,0xeffb,0x4022,0xba,0x02,0x2e,0x79,0x5b,0x70,0x27,0x5c);
DEFINE_GUID(IID_ID3D11PixelShader,0xea82e40d,0x51dc,0x4f33,0x93,0xd4,0xdb,0x7c,0x91,0x25,0xae,0x8c);
DEFINE_GUID(IID_ID3D11ComputeShader,0x4f5b196e,0xc2bd,0x495e,0xbd,0x01,0x1f,0xde,0xd3,0x8e,0x49,0x69);
DEFINE_GUID(IID_ID3D11InputLayout,0xe4819ddc,0x4cf0,0x4025,0xbd,0x26,0x5d,0xe8,0x2a,0x3e,0x07,0xb7);
DEFINE_GUID(IID_ID3D11SamplerState,0xda6fea51,0x564c,0x4487,0x98,0x10,0xf0,0xd0,0xf9,0xb4,0xe3,0xa5);
DEFINE_GUID(IID_ID3D11Asynchronous,0x4b35d0cd,0x1e15,0x4258,0x9c,0x98,0x1b,0x13,0x33,0xf6,0xdd,0x3b);
DEFINE_GUID(IID_ID3D11Query,0xd6c00747,0x87b7,0x425e,0xb8,0x4d,0x44,0xd1,0x08,0x56,0x0a,0xfd);
DEFINE_GUID(IID_ID3D11Predicate,0x9eb576dd,0x9f77,0x4d86,0x81,0xaa,0x8b,0xab,0x5f,0xe4,0x90,0xe2);
DEFINE_GUID(IID_ID3D11Counter,0x6e8c49fb,0xa371,0x4770,0xb4,0x40,0x29,0x08,0x60,0x22,0xb7,0x41);
DEFINE_GUID(IID_ID3D11ClassInstance,0xa6cd7faa,0xb0b7,0x4a2f,0x94,0x36,0x86,0x62,0xa6,0x57,0x97,0xcb);
DEFINE_GUID(IID_ID3D11ClassLinkage,0xddf57cba,0x9543,0x46e4,0xa1,0x2b,0xf2,0x07,0xa0,0xfe,0x7f,0xed);
DEFINE_GUID(IID_ID3D11CommandList,0xa24bc4d1,0x769e,0x43f7,0x80,0x13,0x98,0xff,0x56,0x6c,0x18,0xe2);
DEFINE_GUID(IID_ID3D11DeviceContext,0xc0bfa96c,0xe089,0x44fb,0x8e,0xaf,0x26,0xf8,0x79,0x61,0x90,0xda);
DEFINE_GUID(IID_ID3D11Device,0xdb6f6ddb,0xac77,0x4e88,0x82,0x53,0x81,0x9d,0xf9,0xbb,0xf1,0x40);
[/source]

Using this, I managed to compile a simple 32-bit hello world DirectX 11 program which sets up a device and swap chain and back buffer. However, if I compile it as 64-bits, it crashes when I call:

[code]
DXGI_SWAP_CHAIN_DESC scd;
ZeroMemory(&scd, sizeof(DXGI_SWAP_CHAIN_DESC));

scd.BufferCount = 1;
scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
scd.OutputWindow = hWnd;
scd.SampleDesc.Count = 4;
scd.Windowed = true;

D3D11CreateDeviceAndSwapChain(NULL,
D3D_DRIVER_TYPE_HARDWARE,
NULL, 0,
NULL, 0,
D3D11_SDK_VERSION,
&scd, &swapchain,
&dev, NULL,
&devcon); //crash
[/code]

Any ideas on how I can get these two to work together better? I [b]really[/d] don't want to have to deal with VC++. [img]http://public.gamedev.net//public/style_emoticons/default/dry.png[/img]
0

Share this post


Link to post
Share on other sites
I don't think that you can leave 11th argument NULL.
Also - have you checked that debug logging with DirectX Control Panel doesn't display some obvious error message?

But you [b]really[/b] should try using VC++. It's nice IDE, especially when you need to debug code.
0

Share this post


Link to post
Share on other sites
[quote name='Chris_F' timestamp='1327639527' post='4906660']
[b]really[/d] don't want to have to deal with VC++. [img]http://public.gamedev.net//public/style_emoticons/default/dry.png[/img]
[/quote]

smart move.. and very nice results. congrats.
-5

Share this post


Link to post
Share on other sites
[quote name='Martins Mozeiko' timestamp='1327651891' post='4906685']
I don't think that you can leave 11th argument NULL.
[/quote]

That wasn't the issue.

[quote]
But you [b]really[/b] should try using VC++. It's nice IDE, especially when you need to debug code.
[/quote]

So, I should drop the compiler I'm used to, the one that is free with outstanding support for C++11 and virtually no bugs, and switch to VC++ Express, a non-optimizing compiler with few C++11 features and several bugs that I've personally encountered? I'm not exactly excited about the thought of that.

Edit: OK, I stand corrected, it's supposedly a "fully optimizing" compiler, but I believe GCC still wins by far when it comes to the performance of the code generated by it's auto vectorization.

[quote name='kunos' timestamp='1327652181' post='4906688']
smart move.. and very nice results. congrats.
[/quote]

Wow. You are incredibly ignorant and arrogant. Thanks for the help buddy.
0

Share this post


Link to post
Share on other sites
I'd personally just use the one that is known to work.  In the case of D3D11 that's MSVC (as an added bonus you'll have the best debugger in the business available to you too).

I think your performance concerns are somewhat unfounded.  A huge chunk of your runtime performance is going to be going on stuff running on your GPU, and the compiler used for you C/C++ code is completely irrelevant where that's concerned.  Where stuff does run on the CPU, proper and sensible data and code structures will give you much better results than any amount of compiler-side micro-optimizations.
0

Share this post


Link to post
Share on other sites
[quote]
But you [b]really[/b] should try using VC++. It's nice IDE, especially when you need to debug code.
[/quote]

If the original poster wants to discuss DX11 + MinGW64, then by all means, let him have his topic. There's plenty of room for DX11 + VS2010 threads as well.

[quote name='Chris_F' timestamp='1327657618' post='4906700']
So, I should drop the compiler I'm used to, the one that is free with outstanding support for C++11 and virtually no bugs, and switch to VC++ Express, a non-optimizing compiler with few C++11 features and several bugs that I've personally encountered? I'm not exactly excited about the thought of that.

Edit: OK, I stand corrected, it's supposedly a "fully optimizing" compiler, but I believe GCC still wins by far when it comes to the performance of the code generated by it's auto vectorization.
[/quote]

Let's not throw in comments based on FUD. GCC is not virtually bug-free: there are [url="http://gcc.gnu.org/bugzilla/buglist.cgi?product=gcc&component=c%2B%2B&resolution=---"]842 outstanding unfixed bugs[/url] in the GCC C++ compiler frontend alone. Visual Studio is not bug-free either.

Believing "GCC wins by far in performance" does not make it a correct statement either. It might. Or it might not. Instead of believing, it is better to profile, but unfortunately, there are not that many great sources available that would accurately profile these compilers. Two sources I found[list]
[*]http://www.g-truc.net/post-0372.html : VC2010 beats GCC by a large margin.
[*]http://www.willus.com/ccomp_benchmark2.shtml?p1 : GCC beats VC2010 in 6 out of 10 tests.
[/list]
I do not mean to derail, now please let's stick to the original topic.
1

Share this post


Link to post
Share on other sites
[quote name='Chris_F' timestamp='1327657618' post='4906700'] virtually no bugs[/quote]

You are being silly:
[url="http://gcc.gnu.org/bugzilla/buglist.cgi?product=gcc&component=c%2B%2B&resolution=---"]http://gcc.gnu.org/b...&resolution=---[/url]
[url="http://gcc.gnu.org/bugzilla/buglist.cgi?product=gcc&component=c&resolution=---"]http://gcc.gnu.org/b...&resolution=---[/url]
[url="http://gcc.gnu.org/bugzilla/buglist.cgi?product=gcc&component=libstdc%2B%2B&resolution=---"]http://gcc.gnu.org/b...&resolution=---[/url]
[url="http://gcc.gnu.org/bugzilla/buglist.cgi?product=gcc&component=preprocessor&resolution=---"]http://gcc.gnu.org/b...&resolution=---[/url]

Every software has a bugs. And GCC is no exception from that. I develop with both - gcc and msvc compilers. And both have bugs. Different ones, of course, but they have bugs. Actually in my experience GCC has far more bugs (and worse ones) than MSVC.
0

Share this post


Link to post
Share on other sites
Well, I have yet to encounter any serious bug myself in the latest GCC, and with the rate at which new versions and bug fixes are released, I wouldn't expect it to be much of a problem if I did. Visual Studio? Well, if you find a bug (which I have, several), you can wait a couple [i]years[/i] and [i]hope[/i] their next product comes with a fix. And that doesn't even address the overwhelming lack of support for C++11.

In any case I shouldn't have to defend my personal preference for what is a great compiler. Visual Studio isn't even available on the other platforms I use, and MinGW makes working in Windows easy and consistent. There is really no reason somebody shouldn't be able to compile D3D11 applications with it.
-2

Share this post


Link to post
Share on other sites
[quote name='Chris_F' timestamp='1327683716' post='4906786']
Visual Studio isn't even available on the other platforms I use
[/quote]

Nor is D3D11. Problem goes away.
0

Share this post


Link to post
Share on other sites
Hi I have the solution to your problem.

I done the same thing a few months back.
What I had to do was download the official windows dx sdk and put the defines as you have done above.
I then had to get the directx dll files and use this
[url="http://sourceforge.net/apps/trac/mingw-w64/wiki/gendef"]http://sourceforge.n...w64/wiki/gendef[/url]
And then from that I created library files to link with.

Lucky for you ruben seems to have added this to his latest personal build.

[url="http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/rubenvb/4.7.0-1/"]http://sourceforge.n...ubenvb/4.7.0-1/[/url]
Get the gcc build

Sample Program Follows

[url="http://pastebin.com/QKwyL7Ph"]http://pastebin.com/QKwyL7Ph[/url]

Best of luck.. post back if you run into any problems [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

EDIT:



forgot to post compile and link parameters..

compile

-municode
-mwindows

-link

-ld3d11
-ld3dx11_43
-lgdi32

Also
http://orwellengine.blogspot.com/

Devcpp for mingw64 if you want a nice old style low memory consumption ide.
Although I use programmers notepad myself
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