Game Development Reference
In-Depth Information
int nCmdShow, int screenWidth, int screenHeight);
extern
C
DllExport void RenderFrame();
extern
C
DllExport int Shutdown();
extern
C
DllExport void OpenLevel( BSTR lFileName );
// Actor accessor functions
extern
C
DllExport int GetNumActors();
extern
C
DllExport void GetActorList(int *actorIdArrayPtr, int size);
extern
C
DllExport int PickActor(int *hWndPtrAddress);
extern
C
DllExport int GetActorXmlSize ( ActorId actorId );
extern
DllExport void GetActorXml ( int *actorXmlPtrAddress,
ActorId actorId );
C
// Actor XML functions
extern
C
DllExport void RemoveActor( ActorId actorId );
extern
C
DllExport void CreateActor( BSTR bstrActorResource );
extern
DllExport void ModifyActor ( BSTR bstrActorModificationXML );
Each exported function must have extern “C” _declspec(DLLexport) before
the declaration. The macro at the top of the last code segment helps keep the code
looking cleaner. As you read the remainder of this chapter, more C functions will be
added to this list as the C# editor side is explored.
The editor project settings are exactly the same as those set for the project that cre-
ated Teapot Wars, with one exception. Under Configuration Properties->General, the
Configuration Type should be set to
C
Dynamic Library (.dll)
instead of
Application
(.exe).
Wrapping Up the Editor Architecture
The editor application, logic, and view classes are thin extensions of the base classes
you
'
ve seen in earlier chapters. They can add actors to a scene, render them, and
receive events on how to modify the actors, either by moving them around or delet-
ing them. The editor doesn
t need too much more than that, at least from the game
engine itself. It does, however, need a fairly complicated user interface, a way to load
and save levels, create and modify actor properties, and package everything to be
used by the game engine. For that, we need to wrap the C++ editor implementation
with C#.
Getting that to work means the C# application needs to send information to and
retrieve information from the C++ code. This gets a little tricky, and for context, we
need to go over differences between managed and unmanaged code.
'
 
 
Search WWH ::




Custom Search