

You saw when we made the deviceContext, we asked for a debug compatible context with the flag D3D11_CREATE_DEVICE_DEBUG. Great! Next we’re going to activate the debug layer in our deviceContext. Our command line build script would now look like this: cl main.cpp /link user32.lib d3d11.libĪlso make sure you include assert at the top of main.cpp #include We’re going to link to d3d11.lib for it to work. We then release the original device and device context.Īwesome! Now we can check if this compiles. We use QueryInterface to get the type of ID3D11Device1 from our device. It looks like this: ID3D11Device1* d3d11Device ID3D11DeviceContext1* d3d11DeviceContext // Get 1.1 interface of D3D11 Device and Context hResult = baseDevice->QueryInterface(_uuidof(ID3D11Device1), (void**)&d3d11Device) assert(SUCCEEDED(hResult)) baseDevice->Release() hResult = baseDeviceContext->QueryInterface(_uuidof(ID3D11DeviceContext1), (void**)&d3d11DeviceContext) assert(SUCCEEDED(hResult)) baseDeviceContext->Release() Since we would rather have these, we query the device we just created to get a newer one. There are newer versions of ID3D11DeviceContext and ID3D11DeviceContext aptly called ID3D11Device1 and ID3D11DeviceContext1 which have more functionality. We want Direct11 features, hardware rendering, a device with BGRA support and in a debug build we want to create a debug device to find errors in our program.
DIRECTX 11 WINDOWS
Let's get started! The first thing for any Windows program is the windows entry point which we’re going to stick into a main.cpp file: #include int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int /*nShowCmd*/)

DirectX 11 API is less of a state machine, and more function calls that you can reason, making the experience of graphics program more enjoyable. This can lead to bugs that can be hard to find. OpenGL is a giant state machine where you bind textures, vertex arrays, and options like blend modes which stay bound until you specifically unbind them or unset them. The other advantage over OpenGL is that DirectX is a lot easier to reason about. You don’t want half your users (or worse!) to load your game up and find a blank screen. This interface governs the relationship between multimedia hardware. You want it to work on as many machines as possible with the least hiccups. DX11 is shorthand for DirectX 11, and it is the latest generation of what is known as an application programming interface. DirectX has advantages over OpenGL in that it is more reliable on Windows computers - this is an advantage when it comes time to ship your game. DirectX 11 is the native graphics API for Windows. In this article, I’m going to walk through creating a DirectX 11 context to use with your games.
