Hi, I'm having a hard time understanding the minimum requirements I need to initialize Direct2D and Direct3D. It seems when I look at another init() function I get a different way to do it, here's one I picked off the internet:
// this function initializes and prepares Direct3D for use
void InitD3D(HWND hWnd)
{
// create a struct to hold information about the swap chain
DXGI_SWAP_CHAIN_DESC scd;
// clear out the struct for use
ZeroMemory(&scd, sizeof(DXGI_SWAP_CHAIN_DESC));
// fill the swap chain description struct
scd.BufferCount = 1; // one back buffer
scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; // use 32-bit color
scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; // how swap chain is to be used
scd.OutputWindow = hWnd; // the window to be used
scd.SampleDesc.Count = 4; // how many multisamples
scd.Windowed = TRUE; // windowed/full-screen mode
// create a device, device context and swap chain using the information in the scd struct
D3D11CreateDeviceAndSwapChain(NULL,
D3D_DRIVER_TYPE_HARDWARE,
NULL,
NULL,
NULL,
NULL,
D3D11_SDK_VERSION,
&scd,
&swapchain,
&dev,
NULL,
&devcon);
}
Then in another one it begins with this and uses a ton of code!
bool D3DClass::Initialize(int screenWidth, int screenHeight, bool vsync, HWND hwnd, bool fullscreen,
float screenDepth, float screenNear)
{
HRESULT result;
IDXGIFactory* factory;
IDXGIAdapter* adapter;
IDXGIOutput* adapterOutput;
unsigned int numModes, i, numerator, denominator, stringLength;
DXGI_MODE_DESC* displayModeList;
DXGI_ADAPTER_DESC adapterDesc;
int error;
DXGI_SWAP_CHAIN_DESC swapChainDesc;
ID3D10Texture2D* backBufferPtr;
D3D10_TEXTURE2D_DESC depthBufferDesc;
D3D10_DEPTH_STENCIL_DESC depthStencilDesc;
D3D10_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc;
D3D10_VIEWPORT viewport;
float fieldOfView, screenAspect;
D3D10_RASTERIZER_DESC rasterDesc;
What is it that I'm missing, I have a ton of books, but I can't seem to understand DirectX?
Also, Direct2D uses presentation perameters more often, what's the difference?