Jump to content
  • Advertisement
Sign in to follow this  

INVALIDCALL with CreateDevice

This topic is 4484 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Would the D3D debug runtime component help me fix this problem? I enabled it, but I'm not sure how to use it. Anyway, in CPP: init_finish.h:
struct D3DInitialization_Destruction {
	//last 13 parameters are for D3DPRESENT_PARAMETERS
	void d3d_init (	IDirect3D9* pDObj,
			IDirect3DDevice9* pDObjDev,
			HWND hwnd,
			UINT buffW,
			UINT buffH,
			bool wind,
			D3DFORMAT buffF = D3DFMT_R8G8B8,
			UINT buffC = 1,
			bool autoDnS = FALSE,
			UINT flags = 0,

		p.BackBufferWidth = buffW;
		p.BackBufferHeight = buffH;
		p.BackBufferFormat = buffF;
		p.BackBufferCount = buffC;
		p.MultiSampleType = MST;
		p.SwapEffect = swapEffect;
		p.hDeviceWindow = hwnd;
		p.Windowed = wind;
		p.EnableAutoDepthStencil = autoDnS;
		p.AutoDepthStencilFormat = autoDnSFormat;
		p.Flags = flags;
		p.FullScreen_RefreshRateInHz = FS_RefRate;
		p.PresentationInterval = FS_PresInt;

		pDObj = Direct3DCreate9 (D3D_SDK_VERSION);
		int msg;
		msg = pDObj->CreateDevice (0, D3DDEVTYPE_HAL, hwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &p, &pDObjDev);
		if (msg == D3D_OK)
			MessageBox (hwnd, "device created!", NULL, 0);
		else if (msg == D3DERR_NOTAVAILABLE)
			MessageBox (hwnd, "NOTAVAILABLE", NULL, 0);
		else if (msg == D3DERR_INVALIDCALL)
			MessageBox (hwnd, "INVALIDCALL", NULL, 0);
		else if (msg == D3DERR_OUTOFVIDEOMEMORY)
			MessageBox (hwnd, "OUTOFVIDEOMEMORY", NULL, 0);
			MessageBox (hwnd, "unknown error", NULL, 0);
#include <assert.h>
#include <afxwin.h>
#include "d3d9.h"
#include "init_finish.h"

//inside WinMain:
IDirect3D9* DObj = NULL;
IDirect3DDevice9* DObjDev = NULL;
hafta.d3d_init (DObj, DObjDev, hwnd, 640, 480, TRUE);
I get the INVALIDCALL messagebox, but my window doesn't crash as I've seen happens to others'. I think one of the last two parameters in pDObj->CreateDevice is the problem due to the fact that hwnd works with the message boxes, and the other parameters are pretty straightforward. By the way, does any Windows message box (I also mean stuff like assert) halt a program until it goes away again?

Share this post

Link to post
Share on other sites
To use the debug runtime, start your program with the debugger ( the blue arrow if using Visual C++ ) and then after your program has terminated, check the output view. It should have a list of D3D messages.

Share this post

Link to post
Share on other sites
From a quick look at your code, I'd put money on it being the D3DFMT_R8G8B8 backbuffer format default. 24bit formats have been fairly rare for quite a while now - it's much more common to find X888 or 8888 rather than 888. Try changing that default value to D3DFMT_X8R8G8B8.

There's no guarantee that such things are supported by your hardware and you'll get an invalid-call error in that case. Look into using IDirect3D9::CheckDeviceType() to validate your height/width/format BEFORE calling CreateDevice() (or do a full enumeration using IDirect3D9::EnumAdapterModes()). For windowed mode you can save some time and grab the current properties using IDirect3D9::GetAdapterDisplayMode().


Share this post

Link to post
Share on other sites
D3DFMT_R8G8B8 isn't a valid backbuffer format in Direct3D 9 on any hardware.
Straight from the direct3d help:

These formats are the only valid formats for a back buffer or a display.

Format Back buffer Display
A2R10G10B10 x x (full-screen mode only)
A8R8G8B8 x
X8R8G8B8 x x
A1R5G5B5 x
X1R5G5B5 x x
R5G6B5 x x

Share this post

Link to post
Share on other sites
The problem was with the format (and a couple other things in D3DPRESENT_PARAMETERS). I plan on fleshing out the program a little later; I was just starting out by getting a device up and running.

Thanks guys.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!