|
-
March 28th, 2010, 09:11 AM
#1
My selfmade game keeps crashing
Well hello,
I created myself a game. I runs alright with Debugger, but without debugger, it crashes immediately.
I tried to find the error, with cout. After each function or something I type a line like "cout << "DIRECTX::LoadTexture()\n";" or something similiar.
Anyway, here is a piece of code.
Code:
IDAdd = GUI::AddChild("Button", "Add Message", 100, 20, 698, 117, WS_VISIBLE | WS_CHILD | BS_BITMAP | BS_FLAT);
IDEdit = GUI::AddChild("Edit", "", 695, 20, 2, 117, WS_VISIBLE | WS_CHILD | WS_BORDER);
IDList = GUI::AddChild("Listbox", "", 796, 125, 2, 2, WS_VISIBLE | WS_CHILD | WS_BORDER | WS_TABSTOP | WS_VSCROLL | LBS_DISABLENOSCROLL);
cout<< "GUI::AddChild() Done\n";
SendMessage(Childs[IDAdd], BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)(HANDLE)LoadImage(NULL, "Images/AddMessage.bmp", IMAGE_BITMAP, 100, 20, LR_LOADFROMFILE));
SendMessage(Childs[IDEdit], WM_SETFONT, (WPARAM)CreateFontA(15, 0, 0, 0, 0, FALSE, 0, 0, 0, 0, 0, 0, 0, "Comic Sans MS"), FALSE);
SendMessage(Childs[IDList], WM_SETFONT, (WPARAM)CreateFontA(15, 0, 0, 0, 0, FALSE, 0, 0, 0, 0, 0, 0, 0, "Comic Sans MS"), FALSE);
cout << "SendMessage() Done\n";
Oldproc = (PROC)SetWindowLongPtr(Childs[1], GWL_WNDPROC, (DWORD)EditProc);
cout << "Oldproc\n";
assert(Oldproc);
SetFocus(MainWnd);
cout << "SetFocus() Done\n";
cout << "DIRECTX:\n";
DirectX = new DIRECTX(MainWnd); // Creating DirectX
cout << "DirectX = new DIRECTX(MainWnd);\n";
The output was:
 Originally Posted by Output
GUI::AddChild() Done
SendMessage() Done
Oldproc
SetFocus() Done
DIRECTX:
Its really weird. Because it crashes at the part where DIRECTX: is initialized.
But the weird part is this:
Code:
DIRECTX::DIRECTX(HWND Window) {
cout << "DIRECTX::DIRECTX\n";
DIRECTX::counter = 0;
cout << "DIRECTX::counter\n";
DIRECTX::DXWindow = Window;
cout << "DIRECTX::DXWindow\n";
DIRECTX::Interface = 0;
cout << "DIRECTX::Interace\n";
DIRECTX::Device = 0;
DIRECTX::Sprite = 0;
DIRECTX::InitInterface();
cout << "DIRECTX::InitInterface();\n";
DIRECTX::InitDevice();
cout << "DIRECTX::InitDevice();\n";
DIRECTX::InitSprite();
cout << "DIRECTX::InitSprite();\n";
}
This is the Constructor of DIRECTX. But it immidiatly crashes after coming in the constructor, it doesn't even cout DIRECTX: IRECTX() T___T.
I'm so ****ing stuck, does ANYBODY had this problem before? I really need to fix it, I'm so frustrated.
-
March 29th, 2010, 03:22 AM
#2
Re: My selfmade game keeps crashing
Oldproc = (PROC)SetWindowLongPtr(Childs[1], GWL_WNDPROC, (DWORD)EditProc);
What do you have in EditProc()? Can't you avoid changing the default function for your controls? Are you calling Oldproc() for messages you don't handle in EditProc()?
-
March 29th, 2010, 03:40 AM
#3
Re: My selfmade game keeps crashing
The way the app crashes in the constructor of DIRECTX indicates there is some memory corruption in your program, prior to that call.
-
March 29th, 2010, 04:26 AM
#4
Re: My selfmade game keeps crashing
 Originally Posted by olivthill2
What do you have in EditProc()? Can't you avoid changing the default function for your controls? Are you calling Oldproc() for messages you don't handle in EditProc()?
Hmm, that might be really good possible. Thanks alot, ill try it out when I'm at home!
 Originally Posted by cilu
The way the app crashes in the constructor of DIRECTX indicates there is some memory corruption in your program, prior to that call.
But how? Because the constructor seems to crash before even doing anything o_O. It crashes before setting counter to 0.
-
March 29th, 2010, 05:04 AM
#5
Re: My selfmade game keeps crashing
The constructor of the parentclass of your DIRECTX class could be crashing. No way to know for sure with the info given, you'll have to find that out for yourself.
-
March 29th, 2010, 07:54 AM
#6
Re: My selfmade game keeps crashing
 Originally Posted by OReubens
The constructor of the parentclass of your DIRECTX class could be crashing. No way to know for sure with the info given, you'll have to find that out for yourself.
Yes i already know that. But there it wouldn't be possible for the constructor to crash without doing anything yet.
-
March 29th, 2010, 08:20 AM
#7
Re: My selfmade game keeps crashing
 Originally Posted by Pynolathgeen
Yes i already know that. But there it wouldn't be possible for the constructor to crash without doing anything yet.
Yes it can.
I runs alright with Debugger, but without debugger, it crashes immediately.
The debugger creates a lot of extra space around allocated memory, and without this your app crashes. It sounds like memory corruption in some way. It's probably not your constructor that is crashing. Btw, how are you so sure it's the constructor ?
-
March 29th, 2010, 09:40 AM
#8
Re: My selfmade game keeps crashing
 Originally Posted by Skizmo
Yes it can.
The debugger creates a lot of extra space around allocated memory, and without this your app crashes. It sounds like memory corruption in some way. It's probably not your constructor that is crashing. Btw, how are you so sure it's the constructor ?
Well, I put a small line like "Cout << "function: DIRECTX()\n";" after each function and it stopped working after saying "Directx:", the line before the constructor is called...
-
March 29th, 2010, 09:42 AM
#9
Re: My selfmade game keeps crashing
YES! I GOT IT. THANKS ALOT olivthill2! It was indeed the EditProc. I tries to call OldProc, but Oldproc is not a WindowProc =P. THANKS!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|