C++ bindings are generated by tcxZZJuliaCxxWrap using CxxWrap.jl (and it's precompiled in TrussC_prebuilt_jll)
(Binding base code are mainly ported from tcxLua)
Note
This repository is not registered in public package manager, so you need pkg> add https://github.com/xxx/yyy.git (see How to add this library into your project in detail)
see tcxZZJuliaCxxWrap#binding-coverage
(and also see test cases.)
module TrussCExample
using TrussC
# tc = TrussC
function setup()
setFps(60.0f0)
end
function draw()
clear(0.12f0, 1.0f0)
# Rotating box
pushMatrix();
noFill();
translate(getWindowWidth() / 2.0f0, getWindowHeight() / 2.0f0);
rotate(Float32(getElapsedTimef() * 0.1f0), Float32(getElapsedTimef() * 0.15f0), 0.0f0);
drawBox(200.0f0);
popMatrix();
end
function keyPressed(key::Cint)
c = Char(key)
println("key: ", c, " (", key ,")")
end
function main()
@setup(setup)
@draw(draw)
@keyPressed(keyPressed)
runTrusscApp()
end
end # module TrussCExamplesee TrussCExample.jl for detail.
Julia's procedural style is much different than C++ OOP style. Please check test folder how to use types or functions in detail.
| Julia (CxxWrap) | C++ |
|---|---|
x(vec) |
vec.x |
r(red) |
red.r |
x!(vec, new_value) |
vec.x = new_value |
getWidth(fbo) |
fbo.getWidth() |
Color_red() |
Color.red |
Quaternion_identity() |
Quaternion.identity() |
begin_fbo(fbo) |
fbo.begin() |
end_fbo(fbo) |
fbo.end() |
(If you need method chaining, you can use |> operator or Chain.jl and Lazy.jl as you like.)
When you shadowed x, y by your variables, you can use TrussC.x() instead.
using TrussC
tc = TrussC
x = Vec2(1.0f0, 2.0f0) # This shadows TrussC.x
tc.x(x) # 1.0f0For other common example: tc.draw(image), tc.update(a), tc.string(e) etc...
In your project, run julia --project=@. and:
pkg> add https://github.com/funatsufumiya/TrussC_prebuilt_jll.gitpkg> add https://github.com/funatsufumiya/TrussC.jl.git
(NOTE: pkg> REPL can be shown by typing ] key on julia REPL, and type Backspace key to back to normal REPL.)
Warning
Windows CxxWrap.jl issue
If not working CxxWrap.jl on Windows, you need to try Building libcxxwrap-julia (Because prebuilt packaged dll for CxxWrap.jl is not compatible with MSVC).
Please see Windows libcxxwrap_julia_jll build of https://github.com/funatsufumiya/CxxWrapTest.jl or https://github.com/JuliaInterop/libcxxwrap-julia in detail.
If it's too hard for you to manually build libcxxwrap_julia_jll/override, You can use my prebuilt override.zip (built for libcxxwrap_julia_jll 0.14.9+0, version at 2026/05/15.)
(or, just use WSL. It's much easier.)
Not full addons supported, but some addons are supported in other libraries.
- tcxOsc
- tcxHap
Warning
They are already included in TrussC.jl, and separated DLLs now makes rendering problem (Issue #3, Issue tcxHap.jl#1)
This would be hard problem to use other addons. We need more investigation and need to find the way to use other DLLs, without recompiling TrussC_precompiled_jll (libJlTrussC) itself.
- Default values are not treated perfectly now. You may need
clear(1.0f0, 1.0f0)instaed ofclear(1.0f0). - Stataic methods (and some static constants) of types are renamed using
_(underscore).- For example
Quaternion.identity()was replaced toQuaternion_identity() - For example
Color.whitewas replaced toColor_white()(NOTE color constants are wrapped as function! not constant!)
- For example
begin,endis renamed.- For example
Fbo#begin(),Fbo#end()were replaced tobegin_fbo,end_fbo
- For example
- functions such as
x,y,r(they are needed to access such asVec3#x,Color#r) can be easily replaced by user variables.- In this case, use
TrussC.x(vec)ortc = TrussC; tc.x(vec)instaed ofx(vec).
- In this case, use
- You may need
nothingat the end ofsetupordraw, in order to indicate void function (for limitation of @cfunction bridge.)
$ julia --project=@. -e 'using Pkg; Pkg.test()'
