Jump to content

View more

Image of the Day

#ld38 #screenshotsaturday Mimosa Fizz action gif #2 https://t.co/TUzdppvfUL
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Beginning DirectX initializing a 2D or 3D environment

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
3 replies to this topic

#1 mathacka   Members   

124
Like
0Likes
Like

Posted 05 January 2013 - 09:13 PM

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?



#2 mathacka   Members   

124
Like
0Likes
Like

Posted 05 January 2013 - 10:44 PM

Ok, so I've done a bit more research. I took a look at this site and I think I'm understanding a bit more.

 

So when you initialize directX, your making an interface to hardware, and you don't know what hardware is supported and what is not. 

 

So step one is to check for some basic operations, display mode, hardware acceleration, and capabliities, then you tell the interface what you'd like to make with presentation parameters and attempt to create the device.

 

It's all making more sense now.

 

Are there any comments on anything I might be missing in these statements?



#3 Stuntdk   Members   

498
Like
0Likes
Like

Posted 06 January 2013 - 05:31 AM

I would suggest you try and follow one of the many tutorials available or get a good book on the subject.<br /><br />http://www.rastertek.com/tutdx11.html<br />http://www.braynzarsoft.net/index.php?p=DX11Lessons<br /><br />http://www.amazon.com/gp/product/1936420228/ref=as_li_qf_sp_asin_il_tl?ie=UTF8&amp;tag=braysoft-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=1936420228<br /><br />

#4 mathacka   Members   

124
Like
0Likes
Like

Posted 08 January 2013 - 01:13 AM

Thank you, I'm thinking about getting the game coding complete book!






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.