IDirect3D9Ex* dx_Object = NULL;
/*
Applications use the methods of the IDirect3DDevice9Ex interface to render primitives, create resources, work with system-level variables, adjust gamma ramp levels, work with palettes, and create shaders. The IDirect3DDevice9Ex interface derives from the IDirect3DDevice9 interface.
*/
IDirect3DDevice9Ex* dx_Device = NULL;
/*
Describes the presentation parameters.
*/
D3DPRESENT_PARAMETERS dx_Param;
/*
The ID3DXFont interface encapsulates the textures and resources needed to render a specific font on a specific device.
*/
ID3DXFont* dx_Font = 0;
IDirect3DDevice9Ex* retDXDEVICE()
{
return dx_Device;
}
int D3DIniti(HWND hWnd)
{
if (FAILED(Direct3DCreate9Ex(D3D_SDK_VERSION, &dx_Object)))
{
exit(1);
}
/*
We created the dx_Param earlier, it is a D3DPRESENT_PARAMETERS structure. It contains many variables you can modify but in this source we are only modifying these variables.
BackBufferFormat (D3DFORMAT) is the buffer that is drawn off-screen and will be switched with the front buffer at the next frame. This is considered double buffering, which is what you need to do in GDI to ensure that it does not flicker. But GDI will still flicker because it is "slow" you could persay.
D3DFMT_A8R8G8B8 (Value: 21) is an 32-bit ARGB pixel format with alpha, using 8 bits per channel.
*/
dx_Param.BackBufferFormat = D3DFMT_A8R8G8B8;
/*
hDeviceWindow (HWND) is the form or application that determines the location and size of the back buffer on the screen.
*/
dx_Param.hDeviceWindow = hWnd;
/*
MultiSampleQuality (DWORD) is the quality level. Technically speaking DEFAULT_QUALITY is zero which also is kind of funny because zero is the lowest MultiSampleQuality. Why are we setting this? Well this is all GPU related, and microsoft is extremely vauge about this, so we will just leave this as zero.
*/
dx_Param.MultiSampleQuality = DEFAULT_QUALITY;
/*
SwapEffect (D3DSWAPEFFECT) is how the front and back buffer are to be swapped. When we disregard this, we can do multi sampling (above).
*/
dx_Param.SwapEffect = D3DSWAPEFFECT_DISCARD;
/*
Windowed (BOOL) is basically asking you if the form or application is running windowed or fullscreen. True is windowed. False is fullscreen.
*/
dx_Param.Windowed = true;
if (FAILED(dx_Object->CreateDeviceEx(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, 0, &dx_Param, 0, &dx_Device)))
{
exit(1);
}

