Skip to main content
GameDev.net gamedev.net
🔒 Locked

Simple DX8 problem (GetAdapterDisplayMode)

Started by Sponge99 Jan 24, 2001 at 3:14 AM 2 replies 1.5k views
Original Post
Sponge99
Sponge99
I am trying to set up a simple DX8 application, based on the tuts provided by MS in their help files. I was sort of learning DX7, so this isn't all that new to me, but the tutorial doesn't seem to work...here is my code that I'm using:
#include windows.h    // removed brace things for web
#include d3d8.h
#include d3d8types.h
#include d3d.h

LPDIRECT3D8 d3d8;
D3DDISPLAYMODE d3ddm;

int WINAPI WinMain(HINSTANCE hInstance,
				   HINSTANCE hPrevInstance,
				   LPSTR lpCmdLine,
				   int nCmdShow)
{

	if (Direct3DCreate8(D3D_SDK_VERSION) == NULL)
	{
		MessageBox(NULL, "Direct3DCreate8 - Failed!", "Error", MB_OK);
		return E_FAIL;
	}
	else
		MessageBox(NULL, "Direct3DCreate8 - Passed!", "OK", MB_OK);

	if (FAILED(d3d8->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm)))
	{
		MessageBox(NULL, "GetAdapterDisplayMode - Failed!", "Error", MB_OK);
		return E_FAIL;
	}
	else
		MessageBox(NULL, "GetAdapterDisplayMode - Passed!", "OK", MB_OK);

	return 0;
}
  
But when it reaches the second DX function (GetAdapterDisplayMode) on run-time (compiles fine) it gives me an access violation error (something like 0xC000000005) and plops me in debug mode on that line. I don't get it, is their something I'm doing wrong (duh)? Well, if you can see what it is, I'd appreciate it. -Sponge99 Edited by - Sponge99 on January 24, 2001 4:16:05 AM
"Now watch as I run away in a womanly fashion." - Batman
Quantum
Quantum
You need to store the return value of Direct3DCreate8 in d3d8.
FlBlackKnight
FlBlackKnight
Yup, Quantum is right. You just tried accessing a function from a pointer without valid address. Always gives you a access violoation.
Sponge99
Sponge99
Ah, yes, both beautiful message boxes pop up now...thanks for the pointer (no pun intended). Now to figure the rest of this DX8 nonsense.....

-Sponge99
"Now watch as I run away in a womanly fashion." - Batman

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.