View previous topic :: View next topic |
Author |
Message |
monkey04
Joined: 11 Jun 2004 Posts: 4
|
Posted: Fri Jun 11, 2004 4:04 pm Post subject: Quick Question |
|
|
Recently, i started trying to make a quick game engine in D to create small win32 games. Today, i tried to seperate the source into various directories (WGE/wgeGraphics, WGE/wgeSound, etc). I updated the module names to directoryName.moduleName, modified the include statments etc. and everything compiles and links fine, however, when i run the program and it tries to acces a member function of one of my imported classes i get an "Access Violation" error. Thanks for any help anyone can provide. |
|
Back to top |
|
|
aldacron
Joined: 05 May 2004 Posts: 1322 Location: Seoul, South Korea
|
Posted: Fri Jun 11, 2004 4:38 pm Post subject: |
|
|
My first guess is that you didn't use new to allocate an instance of the class. It's a common mistake people make when coming from C++. See http://www.dsource.org/tutorials/index.php?show_example=80 for an example.
But that is a guess. The problem might be something else entirely. In that case, you need to post the offending code snippet for anyone to do more than guess. |
|
Back to top |
|
|
monkey04
Joined: 11 Jun 2004 Posts: 4
|
Posted: Fri Jun 11, 2004 4:47 pm Post subject: |
|
|
Unfortunately, that wasn't it
Here's the code:
Code: |
bool Paint(HWND hWnd) {
try {
wgeBeginDraw(&hWnd);
CLine lines[2];
lines[0] = new CLine(0.0f, 0.0f, 250.0f, 250.0f),
lines[1] = new CLine(0.0f, 250.0f, 250.0f, 0.0f);
lines[0].SetPen(CreatePen(PS_SOLID, 5, RGB(255, 0, 0)));
lines[1].SetPen(CreatePen(PS_SOLID, 5, RGB(0, 0, 255)));
lines[0].Draw();
lines[1].Draw();
CText text = new CText("Text and Lines Example", 50.0f, 118.0f);
text.SetForeColor(RGB(255, 125, 0));
text.SetBackColor(RGB(255, 255, 0));
text.Draw();
wgeEndDraw(&hWnd);
} catch (Object oErr) {
wgeWriteLog(APP_LOG, oErr.toString());
wgeWriteLog(USER_LOG, oErr.toString());
return false;
}
return true;
}
|
The non-member functions (wgeBeginDraw(), wgeWriteLog, and wgeEndDraw()) don't cause any problems. It's only when i try to access one of the member functions that problems happen (this includes the constructors). |
|
Back to top |
|
|
monkey04
Joined: 11 Jun 2004 Posts: 4
|
Posted: Fri Jun 11, 2004 5:37 pm Post subject: |
|
|
I guess i should add that all of this worked 100? fine before i moved the source files into seperate folders based on their modules. It might help if someone could list a quick reference to how to do this so i can see if i left something out. |
|
Back to top |
|
|
monkey04
Joined: 11 Jun 2004 Posts: 4
|
Posted: Fri Jun 11, 2004 6:38 pm Post subject: Fixed |
|
|
Ok forget it. I'm a complete idiot. I forgot that I'd changed my Vertex struct to a class, and i wasn't initializing it with new. You were right all along... . At least its fixed now though, thanks for your time. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|