• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Yours3!f

implementing scripting

17 posts in this topic

Hi,

 

so I'm trying to implement scripting using runtime-compiled c++ code. Now my problem is that when I load the DLL, it's functions see different memory than the exe's code (so getting a singleton results in a new singleton, rather than getting the exe's singleton).

So I suppose I should implement some sort of interface, so that I can call the exe's functions, and the exe's code is hidden from the gameplay code. This would enable anyone to create a gameplay c++ code or DLL and load it in the exe. I suppose this interface is needed with different script languages like lua too, so there should be a 'usual' way to handle this.
How is this usually handled?

0

Share this post


Link to post
Share on other sites

Your .EXE is capable of exporting symbols just as your .DLL is.  Just as your (and almost every other) .DLL relies on external symbols from other .DLL files, they may also rely on external symbols from your .EXE.

 

So make your .EXE export whatever symbols you need the .DLL to access the same way you would export symbols from any .DLL, and make the .DLL import those symbols from the .EXE the same way it would import from any .DLL.

 

 

L. Spiro

2

Share this post


Link to post
Share on other sites

Your .EXE is capable of exporting symbols just as your .DLL is.  Just as your (and almost every other) .DLL relies on external symbols from other .DLL files, they may also rely on external symbols from your .EXE.

 

So make your .EXE export whatever symbols you need the .DLL to access the same way you would export symbols from any .DLL, and make the .DLL import those symbols from the .EXE the same way it would import from any .DLL.

 

 

L. Spiro

 

 

thank you for the reply!

well, I thought it would work the other way around too, but I would be interested in the actual howto on the interface design and such. Or there isn't much magic there, just export some functions and that's it?

0

Share this post


Link to post
Share on other sites

There is no magic.  It works the same way as any DLL linking to any function in any other DLL.  EXE’s and DLL’s are almost the same thing.

 

 

L. Spiro

2

Share this post


Link to post
Share on other sites

There is no magic.  It works the same way as any DLL linking to any function in any other DLL.  EXE’s and DLL’s are almost the same thing.

 

 

L. Spiro

 

well, okay thank you :)

0

Share this post


Link to post
Share on other sites

For communication between DLL's and EXE's using C++ a commonly used technique is to have virtual interfaces to systems, as this way you can pass around a pointer to a structure which holds the pointers to the interface of each sub system. This is the technique we used in Runtime Compiled C++ and it's also how the CryENGINE passes around interfaces using gEnv.

 

For a look at what a system table looks like see this file.

 

Exporting classes without using virtual interfaces is not simple in general, for an overview have a look at this post on codeproject. Using a virtual interface makes things alot easier - they don't have to be pure virtual but this does help to eliminate mistakes. Make sure to define a virtual destructor to prevent the memory created in one module being freed in another.

 

Feel free to use any of the code in RCC++, we use a liberal Zlib license and you can just use which-ever parts you need.

Thank you,
I'm actually using the rtcc++ (win32 alternate file watcher api, remember?), and I'm now at the implementation stage. I skipped the actual example (simpleexample) code, because it was a bit huge (the consoleexample wasn't though) tongue.png

I've actually read the codeproject article while googling, and I started to do something like that, but this seems a bit more organized.
So I guess I'll look into the SimpleExample now...

Edited by Yours3!f
0

Share this post


Link to post
Share on other sites

Hi - I thought there might be a connection, but wasn't sure since you'd used different profile names! Thanks once again for the alternate file watcher ;)

 

The SimpleExample is a bit big - keep meaning to change the name to PulseDemo as that's what it morphed into. The sample does show how to pass in a pointer to an interface structure so you can interact with your game engine.

 

In my case with the game Avoyd I'm working on, I'm actually implementing most of the engine using RCC++ as a trial of how that can be made to work better. The new features described in the blog help with that, though I need to get more documentation up on the wiki to help.

0

Share this post


Link to post
Share on other sites

Hi - I thought there might be a connection, but wasn't sure since you'd used different profile names! Thanks once again for the alternate file watcher ;)

 

The SimpleExample is a bit big - keep meaning to change the name to PulseDemo as that's what it morphed into. The sample does show how to pass in a pointer to an interface structure so you can interact with your game engine.

 

In my case with the game Avoyd I'm working on, I'm actually implementing most of the engine using RCC++ as a trial of how that can be made to work better. The new features described in the blog help with that, though I need to get more documentation up on the wiki to help.

 

Yeah, I use a couple of them :)

I actually took my time today, and looked at it, and got it right. As I noticed I still need to export one function at least to set the system table, but that is fine.

 

I'm working on one too, though it doesn't have a website yet (only youtube channel), I intend to use the scripting to do gameplay, not the whole engine. More docs/wiki would be awesome!

0

Share this post


Link to post
Share on other sites

Interesting, wasn't aware about RCC++, just knowing internal studios roll those kind of thing in proprietary engines.

Cool idea to roll a separate framework for this.

In Coffee The Engine, I based the whole thing on component/plugin oriented design, working nice and should scale well.

Not sure how it's similar though, will take a look later on.

0

Share this post


Link to post
Share on other sites

For communication between DLL's and EXE's using C++ a commonly used technique is to have virtual interfaces to systems, as this way you can pass around a pointer to a structure which holds the pointers to the interface of each sub system. This is the technique we used in Runtime Compiled C++ and it's also how the CryENGINE passes around interfaces using gEnv.

 

For a look at what a system table looks like see this file.

 

Exporting classes without using virtual interfaces is not simple in general, for an overview have a look at this post on codeproject. Using a virtual interface makes things alot easier - they don't have to be pure virtual but this does help to eliminate mistakes. Make sure to define a virtual destructor to prevent the memory created in one module being freed in another.

 

Feel free to use any of the code in RCC++, we use a liberal Zlib license and you can just use which-ever parts you need.

I just knew about Runtime Compiled C++ and must say, wow, amazing idea.

0

Share this post


Link to post
Share on other sites

Interesting, wasn't aware about RCC++, just knowing internal studios roll those kind of thing in proprietary engines.

Cool idea to roll a separate framework for this.

In Coffee The Engine, I based the whole thing on component/plugin oriented design, working nice and should scale well.

Not sure how it's similar though, will take a look later on.

 

The approach in RCC++ is somewhat different from what I'm aware other teams have used in the past, as rather than simply allowing shared libraries (DLLs on Windows) to be reloaded dynamically RCC++ detects changes in files and compiles the minimal set of source files needed into a shared library then links this in. This gives a quicker turn around at the cost of some developer effort in code markup using macros.

 


I just knew about Runtime Compiled C++ and must say, wow, amazing idea.

 

Thanks :)

0

Share this post


Link to post
Share on other sites

The approach in RCC++ is somewhat different from what I'm aware other teams have used in the past, as rather than simply allowing shared libraries (DLLs on Windows) to be reloaded dynamically RCC++ detects changes in files and compiles the minimal set of source files needed into a shared library then links this in. This gives a quicker turn around at the cost of some developer effort in code markup using macros.

 

Having instant reload of shared libraries isn't that simple, it's already the same job of having interfaces/macros and lot of tricky stuff... Depends if this is just some plugin system with init/exit method (as standard plugin systems) or full Objects creation/refresh handling (which is what "Runtime C++" means) I guess. Thats not the same, sure you know it, but I wanted to make it clear for others.

 

. Having full source files change detection is nice, but you loose IDE ability to have output/error reporting (double click to go to the error), not sure about debugging abilities, if some part is failing, what happens?

. Automatically separate the whole project in libs: I thought about it as well, but in Coffee's component based system it makes no point, it's already clearly separated. Rebuilding a simple component takes 1s, and build system already figure out which files need to be rebuilt.

. Coffee already have assets changes detection, that's why I may have extended it to source files as well, but I choose to only take built DLLs into account for the upper reasons.

 

RCC++ is a nice idea, but it seems hard to integrate it into an existing engine (with the usual existing custom build system, reflection and so on...), but for starting a new project from scratch it seriously looks like a great idea.

But, indeed, that's the future and some nice reason to stick to only one langage for the whole thing...

0

Share this post


Link to post
Share on other sites


Having full source files change detection is nice, but you loose IDE ability to have output/error reporting (double click to go to the error), not sure about debugging abilities, if some part is failing, what happens?

 

All output is piped through a logging interface, and if you copy this to either stdio (on Linux/Mac OS X) or OutputDebugString (Windows) you get full double click to go to error support as well. Debugging is also handled similarly, with the added benefit of the game not stopping due to error catching (though this has issues with gdb which I need to sort out). See http://runtimecompiledcplusplus.blogspot.fr/2011/09/crash-protection.html

 


but it seems hard to integrate it into an existing engine

It's intended initial use is for scripting style additions to an engine. For this purpose it should be easier to add than adding something like lua or python. The problem at the moment is the lack of documentation, which I do hope to fix.

0

Share this post


Link to post
Share on other sites

Okay, so you attach VS to the main exe, then use usual things, great!

Tried SEH years ago but I failed to enable it on whole project (unwinding problems or don't remember).

This looks good, will definitively follow your project.

0

Share this post


Link to post
Share on other sites

Okay, so you attach VS to the main exe, then use usual things, great!

Tried SEH years ago but I failed to enable it on whole project (unwinding problems or don't remember).

This looks good, will definitively follow your project.

 

You can use our system outside of RCC++ with only a small amount of effort - have a look at RuntimeProtector.h and the implementation functions in RuntimeObjectSystem_Platform*.cpp

 

[Edit] Note that this will likely interfere with any crash handler like Breakpad, but since it's primarily intended for development I'd simply turn it off in shipping code if you use Breadpad in shipping code. I intend to look into a solution at some point.

Edited by dougbinks
0

Share this post


Link to post
Share on other sites

Looks good, will see how to integrate RCC++ later on (will start with this part) and will see if I can use more as well, since it'll save lot of headache in future platform support.

Thanks.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0