Did you install the directx 8 or 9 SDK on your new PC?
Main Topics
Browse All TopicsI started programming a directx 3D graphics engine that runs in full screen, a couple months ago for a game I'm trying to make. I started programming and thought I finished the engine and started on the game.
A month ago I moved to a new apartment, so I burnt and transferred all my files to a new computer. It still compiles just fine but I get a D3DERR_INVALIDCALL when I call the CreateDevice function. At first I thought there was something wrong with my computer so I played with compiling and running some of the directx example files, but they all worked fine. So I must be doing something wrong in my code. Here is some of my code, keep in mind that the code is in a couple of different functions so the variable names might not line up:
// here is some header info
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <mmsystem.h>
#include <d3d8.h>
#include <d3dx8.h>
#include <dinput.h>
#include <stdio.h>
// Variables
LPDIRECT3D8 g_pD3D = 0;
LPDIRECT3DSURFACE8 g_pBackSurface = 0;
LPDIRECT3DVERTEXBUFFER8 g_pVB = 0;
LPDIRECT3DDEVICE8 g_pDevice= 0;
LPDIRECT3DINDEXBUFFER8 g_pIB=0;
LPDIRECT3DTEXTURE8 g_pTexture =0;
LPDIRECTINPUT8 g_pDI =0;
// here is where I setup the window I'm going to use.
HWND hWnd;
WNDCLASSEX wc;
static char strAppName[]= GAME_NAME;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW |CS_OWNDC;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.lpfnWndProc = WndProc;
wc.hInstance = hInstance;
wc.hbrBackground = (HBRUSH)GetStockObject( DKGRAY_BRUSH );
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hIconSm = LoadIcon( NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor( NULL, IDC_CROSS);
wc.lpszMenuName = NULL;
wc.lpszClassName = strAppName;
RegisterClassEx( &wc);
hWnd = CreateWindowEx(WS_EX_TOPMO
hWndMain = hWnd;
ShowWindow ( hWnd, iCmdShow);
UpdateWindow (hWnd);
return hWnd;
// this is my call to create the direct3d object
g_pD3D =Direct3DCreate8( D3D_SDK_VERSION);
// and this is where I call the CreateDevice function
LPDIRECT3DDEVICE8 pDevice= 0;
HRESULT r = 0;
D3DDISPLAYMODE d3ddm;
D3DPRESENT_PARAMETERS d3dpp;
r=pD3D->GetAdapterDisplayM
if ( FAILED(r) )
{
SetError("Couldnot get display adapter information");
return NULL;
}
ZeroMemory( &d3dpp, sizeof( D3DPRESENT_PARAMETERS ) );
d3dpp.BackBufferCount = 1;
d3dpp.BackBufferWidth = 800;
d3dpp.BackBufferHeight = 600;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
d3dpp.SwapEffect = D3DSWAPEFFECT_COPY_VSYNC;
d3dpp.hDeviceWindow = hWndMain;
d3dpp.Windowed = FALSE;
d3dpp.EnableAutoDepthStenc
d3dpp.AutoDepthStencilForm
d3dpp.FullScreen_RefreshRa
d3dpp.FullScreen_Presentat
d3dpp.Flags = D3DPRESENTFLAG_LOCKABLE_BA
r = pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWndMain, D3DCREATE_SOFTWARE_VERTEXP
if ( FAILED(r))
{
char *MyMessage;
if ( r == D3DERR_INVALIDCALL)
{
MyMessage =new char[]= "INVALIDCALL";
} else if ( r==D3DERR_NOTAVAILABLE) {
MyMessage =new char[]= "NOTAVAILABLE";
} else if ( r==D3DERR_OUTOFVIDEOMEMORY
MyMessage =new char[]= "OUTOFVIDEOMEMORY";
}
MessageBox(NULL,MyMessage,
SetError("Could not create the render device");
return NULL;
}
That's it. I don't know what I'm doing wrong. I've been working on this for a couple days now. I’ve been striping the code down and trying different screen settings, but all give the same error. Any input would be greatly appreciated.
Thanks,
Minott
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I installed the 9.0 SDK, but I’m trying to stick with the 8.0 libraries.
The computer has a VOODOO 3 graphics card in it and that could be a factor.
I tried using D3DDEVTYPE_HAL and D3DDEVTYPE_REF and D3DDEVTYPE_SW and none of them work.
I tried DeviceCheck on different display modes. I tried everything from R5G6B5 to A2B10G10R10. I did find that the R5G6B5 mode worked with both D3DDEVTYPE_HAL and D3DDEVTYPE_REF, but no other mode would display!!
I tried going through the Createdevice section of the Microsoft demo apps, but it’s difficult to trace back all the functions to their root to see exactly what is going on and imitate it in my code.
I tried the program on a couple of different computers and it work on all of them.
Something else to try from the Microsoft docs:
"FullScreen_RefreshRateInH
The rate at which the display adapter refreshes the screen. For windowed mode, this value must be 0. Otherwise, this value must be one of the refresh rates returned by IDirect3D9::EnumAdapterMod
D3DPRESENT_RATE_DEFAULT
The runtime chooses the presentation rate or adopts the current rate, if windowed"
You are not in windowed mode so you may need to change:
d3dpp.FullScreen_RefreshRa
to something other than 0
Good luck!
Business Accounts
Answer for Membership
by: MaroyPosted on 2004-01-11 at 11:32:04ID: 10091885
Try Changing your line:
ROCESSING, &d3dpp, &pDevice);
YPE_REF, hWndMain, D3DCREATE_SOFTWARE_VERTEXP ROCESSING, &d3dpp, &pDevice);
r = pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWndMain, D3DCREATE_SOFTWARE_VERTEXP
To
r = pD3D->CreateDevice( D3DADAPTER_DEFAULT,D3DDEVT
or when you run a directx example file try changing the dircect 3d settings,
if D3DDEVTYPE_HAL does not show up in the drop down list for
Render Device:
Then your new computer does not have HAL caps and you will have to use REF instead
The microsoft demo apps do more work in determining your video cards caps then you are
currently doing.