Comments (15)
duh... sorry its morning here. I see, does @ccall
supports varargs while ccall
doesnt?
ok now it's like this
@ccall libcimgui.igText("Hello %s %s"::Cstring; "world"::Cstring, "!"::Cstring)::Cvoid # Hello world !
ccall((:igText, libcimgui), Cvoid, (Cstring, Cstring, Cstring), "Hello %s %s", "world", "!") # Hello world !
ccall((:igText, libcimgui), Cvoid, (Cstring, Cstring), "test pre %s", "test") # test pre world
ccall((:igText, libcimgui), Cvoid, (Cstring, Cstring), "%s", "hello") # world
from cimgui.jl.
Got it working with, otherwise it would print fmt
as well.
@ccall libcimgui.ImPlot_Annotate_Str(1::Cdouble, 2::Cdouble, ImVec2(0, 0)::ImVec2, "%s %s"::Cstring; "a"::Cstring, "b"::Cstring)::Cvoid
Shall I make an issue to implot? or is that a generator issue?
from cimgui.jl.
Does the following vararg version of the text API work on aarch macOS?
@ccall libcimgui.igText("Hello %s %s"::CString; "world"::CString, "!"::CString)::Cvoid
from cimgui.jl.
BTW, CString
is not mandatory. You can use Ptr{Cuchar}
instead.
from cimgui.jl.
I have tried a couple of variations, in steps towards the normal CImGui.Text(text)
.
here's what happens
@ccall libcimgui.igText("Hello %s %s"::Cstring, "world"::Cstring, "!"::Cstring)::Cvoid # Hello jl_fptr_args ??N?
ccall((:igText, libcimgui), Cvoid, (Cstring, Cstring, Cstring), "Hello %s %s", "world", "!") # Hello jl_fptr_args ??N?
ccall((:igText, libcimgui), Cvoid, (Cstring, Cstring), "test pre %s", "test") # test pre jl_fptr_args
ccall((:igText, libcimgui), Cvoid, (Cstring, Cstring), "%s", "hello") # segfaults
the ??N?
would change to other random stuff (sometimes also the jl_fptr_args
part) every time I started a new julia sessions. (different location in memory?)
from cimgui.jl.
The first , in the ccall macro version should be ;
from cimgui.jl.
https://docs.julialang.org/en/v1/manual/calling-c-and-fortran-code/#Mapping-C-Functions-to-Julia
from cimgui.jl.
ccall only support a limited version of varadic arguments where each vararg should be of the same type.
from cimgui.jl.
I noticed there is also a (probably) related issue with ImPlot
annotations, as they only show as ??
.
I am toying around by redefining the implot calls using @ccall
, there is a problem. I don't understand how to unpack tuples into varargs
for example
function Annotate(x::Real, y::Real, pix_offset::ImVec2, fmt::String...)
@ccall libcimgui.ImPlot_Annotate_Str(x::Cdouble, y::Cdouble, pix_offset::ImVec2; fmt::Cstring)::Cvoid
end
complains, and
@ccall libcimgui.ImPlot_Annotate_Str(x::Cdouble, y::Cdouble, pix_offset::ImVec2; fmt::Cstring...)::Cvoid
complains as well.
Do you know if it is possible to splat into the call? I guess I could splat before the macro expansion with an eval, but eww...
from cimgui.jl.
Clang.jl has a prototype for wrapping vararg functions: https://github.com/JuliaInterop/Clang.jl/blob/9a519baa45000d2afe1262ae7463cc0795671721/gen/generator.toml#L163
But I never use that. Isn't the @ccall
macro already concise to write?
from cimgui.jl.
I meant that if I were to call
Annotate(1, 2, ImVec2(0, 0), "a", "b", "c")
in the first example typeof(fmt) == Tuple{String}
and it complains it can't convert it into a Cstring
, while in the second example it does not recognise ::Cstring...
as a valid argument type and complains that fmt
does not have one.
fmt...::Cstring...
does not work as well.
found this as well: https://discourse.julialang.org/t/why-is-ccall-syntax/72427/6
Anyhow, I tested with
function Annotate(x::Real, y::Real, pix_offset::ImVec2, fmt::String)
@ccall libcimgui.ImPlot_Annotate_Str(x::Cdouble, y::Cdouble, pix_offset::ImVec2; fmt::Cstring)::Cvoid
end
so accepting only one string, but it still shows ??
in annotations
from cimgui.jl.
Does it work if you directly use @ccall libcimgui.ImPlot_Annotate_Str(1::Cdouble, 2::Cdouble, ImVec2(0, 0)::ImVec2; "a"::Cstring, "b"::Cstring, "c"::Cstring)::Cvoid
?
from cimgui.jl.
Nope, still ??
from cimgui.jl.
According to https://github.com/cimgui/cimplot/blob/d68fa3abd4fe75312089e9332917a6c326704a58/cimplot.h#L965, the correct way to invoke the API is @ccall libcimgui.ImPlot_Annotate_Str(1::Cdouble, 2::Cdouble, ImVec2(0, 0)::ImVec2, "fmt %s %s"::Cstring; "a"::Cstring, "b"::Cstring)::Cvoid
EDIT: updated the wrong ;
position
from cimgui.jl.
This is a blocker for me on Apple Silicon. Has there been any progress?
Also, I note that CImGui.Text(text) = CImGui.TextUnformatted(text)
does work for me as a workaround
from cimgui.jl.
Related Issues (20)
- Broken after update HOT 8
- Incomplete overlap HOT 4
- UndefVarError: `igSetScrollYFloat` not defined HOT 1
- Example of integrating a GLMakie plot in a CImGui window (or conversely) HOT 6
- CImGui fails precompilation at `idGET_FLT_MAX()` HOT 1
- Columns - Horizontal Scroll demo not working in v1.79.0 HOT 3
- TagBot trigger issue HOT 8
- Example code doesn't actually run HOT 6
- Input widgets with different IDs conflict with each other? HOT 6
- How can I get ImGuiWindowClass?
- The getproperty and setproperty! method of ImNodesStyle was not provided
- On some Windows machine, got glfwCreateWindow error HOT 5
- Regenerate new wrapper libraries for fresh ImGui and ImPlot versions? HOT 1
- An error occurs when I use ImGuiTextFilter in a package
- SDL Backend Support? HOT 6
- I can not run the demo HOT 5
- ImGuiKey_KeyPadEnter not defined, when running demo HOT 2
- Upgrading Guide: 1.79 to 1.82
- Expand tests HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cimgui.jl.