|
-
May 3rd, 2010, 08:29 PM
#1
(Direct3D v9) BackBufferFormat and resolution help?
I'll start off by saying that I am new to Direct3D and am about a year into C and C++. At the moment I am doing my best to learn how to use Direct3D for a game I will be creating next year and am running into a problem understanding the BackBufferFormat of D3DPRESENT_PARAMETERS. In addition to this, I am also having some difficulty understanding resolution, but I'll get to that in a moment.
To start off, I've been messing around with the different BackBufferFormat formats and am having difficulty understanding why my program crashes when it does. The code I use to set the format is:
D3DPRESENT_PARAMETERS d3dPp;
ZeroMemory(&d3dPp, sizeof(d3dPp));
d3dPp.Windowed = false;
d3dPp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dPp.hDeviceWindow = hWnd;
d3dPp.BackBufferFormat = D3DFMT_A2R10G10B10; //this varies as I test different formats
d3dPp.BackBufferHeight = SCREEN_HEIGHT;
d3dPp.BackBufferWidth = SCREEN_WIDTH;
:and the error I always get is an 'access violation reading location 0x00000000' when I am clearing the buffer before I any 3D rendering is done. The reading location being the Direct3D Device that for some reason is not being created because of the change the formats. I attempt to create the device in this code:
//create device Class using the globals and d3dPp
d3d->CreateDevice(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL, //tells Direct3D to use the HAL
hWnd, //the handle to the window to be used
D3DCREATE_SOFTWARE_VERTEXPROCESSING, //what should handle calculations
&d3dPp, //the D3DPRESENT_PARAMETERS struct
&d3dDev); //pointer to a pointer, the Direct3D Device
:and the formats I have been testing are these. D3DFMT_A8R8G8B8 (works), D3DFMT_X8R8G8B8 (works), D3DFMT_A2R10G10B10 (doesn't work), and D3DFMT_A16B16G16R16 (doesn't work). My computer is running in 64-bit mode and I believe is capable of using all of these formats. I'm not sure if just plugging in the D3DFMT is supposed to work or not. If not, can someone tell me what else needs to be changed in the code for this to work correctly?
As for my resolution problem, I was curious as to if there is a method, using only only C++, to find all possible resolutions of a monitor on the computer the program runs on? If not, is there a method?
Thank you in advance for your time.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|