# Full compatibility with C++ Builder

**URL:** <https://forum.castle-engine.io/t/full-compatibility-with-c-builder/1009>\
**Category:** News\
**Created:** [December 1, 2023, 4:45pm UTC](https://forum.castle-engine.io/t/full-compatibility-with-c-builder/1009 "2023-12-01T16:45:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)\
**Post date:** [December 1, 2023, 4:45pm UTC](https://forum.castle-engine.io/t/full-compatibility-with-c-builder/1009/1 "2023-12-01T16:45:06Z")

</div>

| [![C++ Builder application using Castle Game Engine (TCastleControl) within FMX (FireMonkey)](https://forum.castle-engine.io/uploads/default/original/2X/7/7d6aa5904ba4e67f5aa6608cbdea4160594dabc0.png)](https://castle-engine.io/wp/wp-content/uploads/2023/11/screenshot.png "C++ Builder application using Castle Game Engine (TCastleControl) within FMX (FireMonkey)") |
| [![C++ Builder application using Castle Game Engine (TCastleWindow) with views, scenes, viewports](https://forum.castle-engine.io/uploads/default/original/2X/a/a88db0e5d9d1e04b7549523d8f4941cb7c46e068.png)](https://castle-engine.io/wp/wp-content/uploads/2023/11/screenshot-1.png "C++ Builder application using Castle Game Engine (TCastleWindow) with views, scenes, viewports") |

This is probably a bit surprising news, coming from a game engine written in Pascal 🙂 Don’t worry, there are improvements relevant for Pascal too, at the bottom of this post!

That said, I do love playing with new toys, and a toy I played with recently was _C++ Builder_. [C++ Builder](https://www.embarcadero.com/products/cbuilder) is Embarcadero C++ compiler and IDE, closely integrated with Delphi and so Pascal. I played with exposing our engine classes to C++ developers. It turns out it is really trivial to expose full Castle Game Engine API (with all classes and features) to C++ developers this way!

For example, you can now write code like below to operate on `TCastleScene` from C++:

```
__fastcall void TViewMain::ClickMove(TObject* Sender)
{
    Scene1->Translation = Scene1->Translation + Vector3(0, 1, 0);
}

\_\_fastcall void TViewMain::ClickBunny(TObject\* Sender)  
{  
Scene1-\>Url = “castle-data:/Bunny.gltf”;  
}
```

The end result is that our engine API is 100% available for C++ developers. This includes

- using our classes like `TCastleWindow` or `TCastleControl` to initialize the window or control (on FMX or VCL form),

- using our [views](https://castle-engine.io/views) (`TCastleView` descendants) to manage bigger projects,

- using `TCastleViewport`, `TCastleScene` and other [viewport features](https://castle-engine.io/viewport_and_scenes) to render 3D and 2D content,

- using `TCastleButton` and other [engine user-interface controls](https://castle-engine.io/user_interface),

- loading components (view contents, or smaller things) designed in [CGE editor](https://castle-engine.io/editor).

All the related classes are just available to you as C++ classes. The Pascal units are available as C++ header files. Properties, methods, global routines, enums etc. — just everything works and is exposed in C++ using concepts analogous to Pascal. This is the amazing power of _C++ Builder_.

The examples are in the [latest engine official download](https://castle-engine.io/download), in particular:

- [Example delphi/cpp\_builder/fmx](https://github.com/castle-engine/castle-engine/tree/master/examples/delphi/cpp_builder/fmx) shows using TCastleControl inside FMX form,

- [Example delphi/cpp\_builder/window](https://github.com/castle-engine/castle-engine/tree/master/examples/delphi/cpp_builder/window) shows using TCastleWindow, with views, loading a design, operating on `TCastleScene` and more. It faithfully recreates in C++ one of recent CGE Pascal examples from the [ITDevCon 2023 conference](https://github.com/castle-engine/conference-itdevcon-2023/).

Follow the installation procedure inside, in particular please note you have to [build and install Delphi packages](https://github.com/castle-engine/castle-engine/tree/master/packages/delphi). This generates the C++ header files _and_ the object files to be linked.

Don’t worry, we’re still a Pascal game engine 🙂 And we continue to [love and promote Pascal](https://castle-engine.io/why_pascal). The beauty of this integration is that it doesn’t require any maintenance, our Delphi and Pascal code is just completely automatically available for C++ developers with equivalent capabilities. So, going forward, we are fully committed to supporting both Pascal and C++ developers this way.

I am excited to see where this will take us 🙂 If you have C++ Builder, and wonder about using Castle Game Engine with C++ this way, please go ahead and be sure to [report any issues or success stories](https://castle-engine.io/talk.php)!

Please note that right now the CGE documentation remains Pascal-oriented. I hope that the above two C++ Builder examples (in `examples/delphi/cpp_builder/`) are enough to give you an example how Pascal concepts map to C++. If it’s unclear how to access anything from C++, [let us know (ask on forum, Discord…)](https://castle-engine.io/talk.php).

While doing this, we polished by the way some engine pieces useful for Delphi (Pascal):

- We introduce a new `castle_engine_window` Delphi runtime package. This includes units that work with our `TCastleWindow` component. While you don’t have to use this runtime package to build Pascal CGE applications using `TCastleWindow` (instead, new projects by default will just link to CGE Pascal units, without using the package) but it’s an important stepping stone to make Delphi aware of all our classes and go with GetIt.

- We now automatically cooperate with default Delphi and C++ Builder convention to put exe files in a project subdirectory like `Win32/Debug/`, `Win32/Release/`, `Win64/Debug/` and so on. We will detect this situation and access `data` directory automatically correctly, so that your applications using [data directory](https://castle-engine.io/manual_data_directory.php) will work correctly out-of-the-box in this case.

- We have explicitly switched our [XML vendor in Delphi](https://docwiki.embarcadero.com/RADStudio/Sydney/en/Using_the_Document_Object_Model) to [OmniXML](https://github.com/mremec/omnixml/), for all platforms. This is a fast cross-platform XML vendor. We use it on all platforms with Delphi now (not MSXML on Windows) to have most consistent cross-platform behavior.

### Share this:

- [Facebook](https://castle-engine.io/wp/2023/12/01/full-compatibility-with-c-builder/?share=facebook "Click to share on Facebook")
- [Twitter](https://castle-engine.io/wp/2023/12/01/full-compatibility-with-c-builder/?share=twitter "Click to share on Twitter")
- [LinkedIn](https://castle-engine.io/wp/2023/12/01/full-compatibility-with-c-builder/?share=linkedin "Click to share on LinkedIn")
- [Reddit](https://castle-engine.io/wp/2023/12/01/full-compatibility-with-c-builder/?share=reddit "Click to share on Reddit")
- Email
-
