CApi
The CAPI plugin enables access to Tellusim API from the C programming language. Its primary purpose is to provide a C interface for generating bindings in languages such as C# and Rust, though it can also be used independently as a standalone C API. The plugin includes a comprehensive 3D math library, enabling efficient and portable use of Tellusim functionality across multiple platforms and language environments.
info
The plugins/binding/capi/include
directory contains C-compatible headers.
The plugins/binding/capi/source
directory contains C++ to C bindings.
The target C binding library is libTellusimC
, which depends on libTellusim
.
// create app
TSApp app = tsApp_new(argc, argv);
if(!tsApp_create(app, TS_PlatformUnknown, TS_AppVersion)) return false;
// create window
TSWindow window = tsWindow_new_Pu(tsApp_getPlatform(app), tsApp_getDevice(app));
if(!window) return false;
tsWindow_setSize(window, tsApp_getWidth(app), tsApp_getHeight(app), 0);
tsWindow_setCloseClickedCallback(window, close_clicked_func, window);
tsWindow_setKeyboardPressedCallback(window, keyboard_pressed_func, window);
// create and show the window
TSString title = tsString_format("%s Tellusim::CAPI", tsWindow_getPlatformName(window));
if(!tsWindow_create_cSWF(window, title, TS_WindowDefaultFlags | TS_WindowFlagVerticalSync) || !tsWindow_setHidden(window, 0)) return false;