Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Zipster

DirectX 8.0 Graphics Problem

This topic is 6389 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

I have the following code:
  
char* D3DInit(LPDIRECT3D8 lpD3D, LPDIRECT3DDEVICE8 lpD3DD, HWND hWnd)
{	
	if(FAILED(lpD3D = Direct3DCreate8(D3D_SDK_VERSION)))
		return "Unable to create D3D object";

	D3DDISPLAYMODE d3ddm;
	if(FAILED(lpD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm)))
		return 0;
	
	D3DPRESENT_PARAMETERS d3dpp; 
	ZeroMemory(&d3dpp, sizeof(d3dpp));
	d3dpp.Windowed   = true;
	d3dpp.SwapEffect = D3DSWAPEFFECT_COPY;
	d3dpp.BackBufferFormat = d3ddm.Format;

	if(FAILED(lpD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
                                  D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                                  &d3dpp, &lpD3DD)))
		return "Unable to create device";

	return NULL;
}

void D3DShutdown(LPDIRECT3D8 lpD3D, LPDIRECT3DDEVICE8 lpD3DD)
{
    if( lpD3DD != NULL)
        lpD3DD->Release();
    if( lpD3D != NULL)
        lpD3D->Release();
}

void D3DRender(LPDIRECT3D8 lpD3D, LPDIRECT3DDEVICE8 lpD3DD)
{
	//lpD3DD->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_RGBA(0,0,63,0), 0, 0 );


}
  
When i execute my code (dont worry about WinMain() such. I have already determined that there is nothing wrong there) AS is above (Clear() commented out), it runs fine, and i get a blank window. ok. thats good. So now what happens when i uncomment Clear(). Crash. The program runs, sets the mode, but once Clear() is executed it just leaves the application nice and smoothly. its really confusing me as to why its doing this, especially since its copied straight from an online tuturial. Any ideas? I''ll post the other code if you need it, but i dont think youll find anything there. Its just standard Win32 code! Creating windows, etc.

Share this post


Link to post
Share on other sites
Advertisement
Ok, I found the error. It seems that my D3D pointers were getting messed up when I was passing them as paramters through the funcitons. When i made them global variables and didn''t pass them throught the functions it worked. The wierd thing is I don''t know why the variables passing didn''t work! LPDIRECT3D8 and such are pointers by nature, so what did i do wrong? Passing that by a pointer won''t do because member functions of the interfaces can''t use a pointer to the interface (**IDirect3D8, which won''t work for member functions)

So how could I successfully pass the variables through the functions?

Share this post


Link to post
Share on other sites
This could be really silly, but maybe you need to pass the pointers by reference instead of by value?

- This could have messed things up?

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!