Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Hey guys i was wondering if anyone has come across a c++ ide that you can actively play test the updates without having to recompile all the code.

share|improve this question
    
You can't run C++ code without compilation. Not sure what you mean by "actively play test the updates"? –  bummzack Aug 15 '12 at 17:16
    
I removed your question about DirectX vs OpenGL because it's pretty much all requirements based or an option. –  Tetrad Aug 15 '12 at 17:16
    
alright thanks, and i mean; can i play the game and change values and make them change in the game without ever having to close and recompile the game. –  user1601163 Aug 15 '12 at 17:17
    
Are you looking for something like Edit And Continue in Visual Studio? msdn.microsoft.com/en-us/library/esaeyddf(v=vs.80).aspx Or are you looking for advice on how to data drive values and reload them on the fly –  Tetrad Aug 15 '12 at 17:17
4  
Sounds more like you want a game engine that has a scripting interface... –  bummzack Aug 15 '12 at 17:18

5 Answers 5

Strictly speaking, there's at least one IDE than allows changing code while debugging: it's Visual Studio (the Edit and Continue feature Tetrad mentions in comment). Looks like GDB (GCC's debugger) has a similar feature as well.

However I've never seen this feature used in a real game project. The reason for this is probably that the changes allowed by Edit and Continue are too limited to be practical. You might be able to change one or two variables, but there's no way you'll be able to add a complete function, for instance.

The usual way of having code that can be changed at runtime is to build a scripting engine on top of the C++ code (Lua, UnrealScript, Boo, etc.). It's typically used for gameplay code that is subject to frequent changes and isn't performance-critical .

A less frequent way is to compile this kind of code in separate DLLs. This allows to recompile and reload them when the code changes, see for instance this question on GDSE or this blog for more details. This is probably more experimental, but I personally like the idea of keeping the whole code base in one language.

share|improve this answer
    
Another way would be use normal virtual machine for either parts of the game (e.g. Unity3D engine) or the complete game (XNA). –  Soonts Aug 18 '12 at 1:23

Easiest solution without recompiling ALL of the code, aside from VS's awesome edit/continue, is to keep the part your working on in a separate library,(DLL, etc depending on your platform), and just rebuild that part. Include a command in your primary/host app to unload and reload the library in question. You'll still have to recompile the lib, but not the host app.

Of course, whether this will work depends on the OS and how you reference the library, but its another option beyond IDE-specific features.

Or: if what you're really looking for is runtime tweaking/debugging, I'd look at integrating IronPython, Lua, etc, and exposing the objects in question to the script engine. This is easier in .NET than C++, but I've seen it done both ways.

If you're using an Entity/Component architecture, there are precedents for providing an "Object Inspector" window/CLI to dump component field values (to a grid or stdout), and let you change those values on the fly via a simple REPL. ID's console is a good example of this. In an older project, I redirected stdin/stdout to a stream that was read per-frame and displayed on screen. It was kind of neat in that, anywhere in the code, I could write to stdout and the text would be executed as script.

share|improve this answer

Ch (formerly Cint) allows you to do this.

You could also probably hook something up with Clang and the LLVM JIT, which I believe is what Ch is doing.

Technically you must always recompile, but it's definitely possible for that compilation to be automatic and for the changes to be made to a running program in some limited circumstances.

It'll never be perfect or even close to how a dynamic language can do this, though. C++ assumes a lot about how things are laid out in memory. Changing the fields of a struct for instance would require not only updating the code, but also updating all the copies of that struct in memory. Since C/C++ supports unions and other means of "hiding" objects in memory (void pointers, buffers, etc.) it is impossible for the compiler to do this, and so runtime changes of code will generally require restarting any application.

It's worth pointing out you can do something similar yourself. Allow your game engine to serialize/deserialize its game state on demand. Move all the logic you're expecting to be changing frequently to a DLL, which you should load dynamically. You are then capable of saving your game state to a buffer or disk, unloading the current logic DLL, loading in a new one, and restoring your game state. You can then also hook up your own editor that allows you to seamlessly compile some C++ source and do the reload dance with the click of a single "Test Changes" button.

Engines like Unity do something similar for C#, and it appears that Unreal Engine 4 will do it for C++. I know a couple smaller game-specific engines that have done similar things. Takes some work to set up, but can be worth it if you're using C++ as your primary game logic language instead of a scripting language.

share|improve this answer

An alternative suggestion is to expose the necessary API's to a scripting language such as LUA (World of Warcraft) which allows you to update things on the fly without recompiling your core code as often.

share|improve this answer

I recall reading of a technique where the game engine tracked changes to a C source file and parsed the numeric values - that let the developers tweak the constants without recompile. I can't remember what they called this technique so I can't easily find the article.

However, this sounds to me like too much of a hassle when you could, for example, move the constants to a LUA file and use that instead.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.