|
-
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.
-
May 5th, 2010, 07:52 AM
#2
Re: (Direct3D v9) BackBufferFormat and resolution help?
: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.
This is indicative of a bad pointer. Are you receiving an 0x00000005 error?
The back buffer formats are supported by your graphics card, not by "64 bit" mode. You should use the CheckDeviceType () method to determine what display modes your graphics card can support.
For resolution, you should call EnumDisplaySettings () in a loop.
Lastly, I would recommend you try playing with the samples browser that is installed with DirectX. It's installed with sample programs and code for you to try. And, make sure you use the DxDiag control panel applet to adjust your DirectX debug settings when testing.
Gort...Klaatu, Barada Nikto!
-
May 14th, 2010, 12:39 AM
#3
Re: (Direct3D v9) BackBufferFormat and resolution help?
Sorry for the late reply, and thanks again for the help!
I was indeed receiving a 0x00000005 error and found out that it was because my Direct3D device was not being created. This was because I was giving it bad parameters both for resolution and the color mode for the device, but I understand those a bit more now.
As for CheckDeviceType(), I've looked this up on MSDN and elsewhere on the internet. Am I correct in thinking that I should call it to see if a current color mode works for the device, and then handle the result accordingly, and then create the device?
Thanks for the tip on EnumDisplaySettings() by the way, I will definitely use this in the future to find possible display resolutions. I will also look into the samples browser as well as the DxDiag control panel applet. Thank you.
Tyler.
-
May 14th, 2010, 07:28 AM
#4
Re: (Direct3D v9) BackBufferFormat and resolution help?
If you know ahead of time what type of device you'd like to create, and, you're not sure the hardware supports it, it's always a good idea to check using CheckDeviceType () before attempting to create the device. By being proactive you will save time in determining what device to create.
Gort...Klaatu, Barada Nikto!
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
|