[Dev-C++] program exiting to windows(directx related)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: John D. D. <jdd...@ya...> - 2005-12-15 16:23:31
|
Hello,
I'm new to programming and have a problem with a directx example program I've been trying to complete. The source is from Beginning Game programming by Jonathan Harbour.
I tried sending the source, but I zipped it and it got blocked. I'm not sure what extensions are okay and so if you need source files please let me know and I'll send it.
Basically when it compiles fine, but when I run the program it just goes to the desktop without warning. I've put in some error checking code, but I can't figure out what's wrong.
d3ddev is a LPDIRECT3DDEVICE9
sprite_handler is a LPD3DXSPRITE
kitty is a SPRITE which is an user defined type
kitty_image is an array of LPDIRECT3DTEXTURE9
result is a HRESULT
Below is a snippet of where I think the problem is.
//start rendering
if (d3ddev->BeginScene())
{
//erase the entire background
d3ddev->StretchRect(back, NULL, backbuffer, NULL, D3DTEXF_NONE);
//start sprite handler
result = sprite_handler->Begin(D3DXSPRITE_ALPHABLEND);
if(result != S_OK)
MessageBox(hwnd, "sprite_handler begin error", "Error", MB_OK);
//Create vector to update sprite position
D3DXVECTOR3 position((float)kitty.x, (float)kitty.y, 0);
// Draw the sprite
sprite_handler->Draw(
kitty_image[kitty.curframe],
NULL,
NULL,
&position,
D3DCOLOR_XRGB(255,255,255));
//stop drawing
result = sprite_handler->End();
if(result != S_OK)
MessageBox(hwnd, "sprite_handler end error", "Error", MB_OK);
//stop rendering
d3ddev->EndScene();
}
//display the back buffer on the screen
d3ddev->Present(NULL, NULL, NULL, NULL);
Any help is appreciated and if I forgot to add anything just ask for it...
Thanks,
John
|