/Niels
unhandled exception

Did you try single stepping to figure out the exact line of the exception?
/Niels
how everybody doing? I hope better than me....
I need some help here =
any time that I tried to create a surface, the compiler gave me this error=
First-chance exception in game01.exe: 0xC0000005: Access Violation.
and here the code with the problem=
ZeroMemory(&ddsd2,sizeof(ddsd2));
ddsd2.dwSize = sizeof(DDSURFACEDESC2);
ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd2.dwWidth = bm.bmWidth;
ddsd2.dwHeight = bm.bmHeight;
if(dd->CreateSurface(&ddsd2,&superficie,NULL) !=DD_OK)
return NULL;
any help will be appreciate
thanks
_José
Are you just declaring a variable of type "LPDIRECTDRAW"? It is just a pointer - it only holds the memory location of the real variable. So you need to call a function like DirectDrawCreate before you can use it.
If you are calling a function to create the object, maybe that code is failing first? Then the pointer wouldn't point to anything.
The following program will cause the same error:
// Changed these to quotes so they'd
// appear here. Change them back when
// you copy the program.
#include "windows.h"
// Just a simple class
class CMyClass
{
public:
void DoSomething() { m_nData = 5; };
protected:
int m_nData;
};
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
// Create a pointer -
// doesn't point to anything yet.
CMyClass* pNothing;
// Call a member function -
// fails here
pNothing->DoSomething();
// Create an object
pNothing = new CMyClass;
// This will work fine
pNothing->DoSomething();
// Delete the object
delete pNothing;
return 0;
}
Memory access violations are caused by trying to read or write memory you don't have permission to use (because it wasn't allocated). That's why it's called an "access" violation. And that's why the sample program crashes when it tries to set the member variable's value.
Step through your code and see if your LPDIRECTDRAW is NULL after it's been created. If it is, then your creation code is the problem.
P.S. What would happen if they used speech synthesis technology for cryptic compiler/runtime error messages? (instead of text)
[This message has been edited by null_pointer (edited November 17, 1999).]