Edit: After some trying and stuff I have found where the problem is happening. Namely where I create the surfaces, I create the surfaces the normal way(eh ddraw tutorial way
)...
However I cant see any connection between this and the try and catch statement before this even happends... eh.. any ideas?
(im desperate!)
I am allocating a bit of memory before I execute my small directdraw library which just initializes a window and setups direct draw, and assign some function pointers and begins the main loop. Think glut but for direct draw.
But what is happening is; the resolution changes and then the program quits. However if I remove my memory allocation code it works perfectly fine. eh.. and I have tried surrounding the allocation code with a try and catch statement that outputs whatever error in a messagebox and then exits the application. However it still changes resoultion and then exits the application, without a sign of error. I even tried changing to malloc instead of new, and used an if statement, but no output(the same as before)...
Hmm... any ideas?
oh, my setup looks basically like this:>
Map map;
void render()
{
}
void createMap(Map* map)
{
try
{
map->data = new char*[8];
for(int i=0; i<8; i++)
map->data[i] = new char[8];
}catch(...){ throw("Could Not Allocate memory!"); }
}
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
// here is the allocation part happening
try
{
createMap(&map);
}catch(char* e){
MessageBox(NULL, e, "Error", MB_OK);
return 0;
}
// setup direct draw and resolution
DDInit(1024, 768, 16);
DDSetRenderFunc(render);
DDRun();
// destroy the map data
destroyMap(&map);
return 0;
}
Edit:> I changed the code and remove the allocation part. And put this instead:>
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
int x;
try
{
x++;
}catch(char* e){
MessageBox(NULL, e, "Error", MB_OK);
return 0;
}
// setup direct draw and resolution
DDInit(1024, 768, 16);
DDSetRenderFunc(render);
DDRun();
// destroy the map data
destroyMap(&map);
return 0;
}
And it gives the same result as the above example... eh.. can someone like tell me whats going on?(im going nuts)
edit again: darn source tag messing up when edititing post...
[edited by - pag on June 3, 2003 2:39:36 AM]
I am a signature virus. Please add me to your signature so that I may multiply.