FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Quick Question

 
Post new topic   Reply to topic     Forum Index -> General
View previous topic :: View next topic  
Author Message
monkey04



Joined: 11 Jun 2004
Posts: 4

PostPosted: Fri Jun 11, 2004 4:04 pm    Post subject: Quick Question Reply with quote

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
View user's profile Send private message Send e-mail AIM Address
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Fri Jun 11, 2004 4:38 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
monkey04



Joined: 11 Jun 2004
Posts: 4

PostPosted: Fri Jun 11, 2004 4:47 pm    Post subject: Reply with quote

Unfortunately, that wasn't it Sad

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
View user's profile Send private message Send e-mail AIM Address
monkey04



Joined: 11 Jun 2004
Posts: 4

PostPosted: Fri Jun 11, 2004 5:37 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail AIM Address
monkey04



Joined: 11 Jun 2004
Posts: 4

PostPosted: Fri Jun 11, 2004 6:38 pm    Post subject: Fixed Reply with quote

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... Sad . At least its fixed now though, thanks for your time.
Back to top
View user's profile Send private message Send e-mail AIM Address
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> General All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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