floooh / cimgui-sokol-starterkit Goto Github PK
View Code? Open in Web Editor NEWA minimal self-contained Dear ImGui starter project for Windows, Linux and macOS.
License: MIT License
A minimal self-contained Dear ImGui starter project for Windows, Linux and macOS.
License: MIT License
Hi, I tried building with sokol.c
and -ObjC
flag on macOS, and it compile demo
without errors. But I'm not sure what I'm doing actually. So let me ask a question: which is preferred, sokol.m
or -ObjC
with sokol.c
? Thank you.
How should I go about using sokol with imgui on M1 mac with C++20? I tried naively removing the cimgui wrapper, and changing the CMAkefile, but on mac, the sokol.c ends up getting compiled with objective-c which is not compatible with C++20, so not sure what to do here.
https://github.com/floooh/cimgui-sokol-starterkit#build-and-run-wasmhtml-version-via-emscripten-linux-macos
Regarding the uncertainty of the Windows build, I want to confirm it does work on Windows.
PS C:\Users\phcre\Documents\c\cimgui-sokol-starterkit\build> emcc --version
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.44 (bec42dac7873903d09d713963e34020c22a8bd2d)
PS C:\Users\phcre\Documents\c\cimgui-sokol-starterkit\build> emcmake cmake -DCMAKE_BUILD_TYPE=MinSizeRel ..
configure: cmake -DCMAKE_BUILD_TYPE=MinSizeRel .. -DCMAKE_TOOLCHAIN_FILE=C:\Users\phcre\Documents\c\emsdk\upstream\emscripten\cmake\Modules\Platform\Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR=C:/Users/phcre/Documents/c/emsdk/node/16.20.0_64bit/bin/node.exe -G Ninja
-- Configuring done (1.7s)
-- Generating done (0.0s)
-- Build files have been written to: C:/Users/phcre/Documents/c/cimgui-sokol-starterkit/build
PS C:\Users\phcre\Documents\c\cimgui-sokol-starterkit\build> cmake --build .
[11/11] Linking C executable demo.html
cache:INFO: generating system asset: symbol_lists/a460b8c467a6274ccfd29a4196fa5b9e3f688a91.json... (this will be cached in "C:\Users\phcre\Documents\c\emsdk\upstream\emscripten\cache\symbol_lists\a460b8c467a6274ccfd29a4196fa5b9e3f688a91.json" for subsequent builds)
cache:INFO: - ok
Is it some issue on my end?
C:\Development\C++\cimgui-sokol-starterkit\wasm>cmake --build .
Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
cimgui.vcxproj -> C:\Development\C++\cimgui-sokol-starterkit\wasm\Debug\libcimgui.a
sokol.vcxproj -> C:\Development\C++\cimgui-sokol-starterkit\wasm\Debug\libsokol.a
LINK : warning LNK4044: unrecognized option '/-default-obj-ext'; ignored [C:\Development\C++\cimgui-sokol-starterkit\wa
sm\demo.vcxproj]
LINK : warning LNK4044: unrecognized option '/-shell-file'; ignored [C:\Development\C++\cimgui-sokol-starterkit\wasm\de
mo.vcxproj]
LINK : warning LNK4044: unrecognized option '/sNO_FILESYSTEM=1'; ignored [C:\Development\C++\cimgui-sokol-starterkit\wa
sm\demo.vcxproj]
LINK : warning LNK4044: unrecognized option '/sASSERTIONS=0'; ignored [C:\Development\C++\cimgui-sokol-starterkit\wasm\
demo.vcxproj]
LINK : warning LNK4044: unrecognized option '/sMALLOC=emmalloc'; ignored [C:\Development\C++\cimgui-sokol-starterkit\wa
sm\demo.vcxproj]
LINK : warning LNK4044: unrecognized option '/-closure=1'; ignored [C:\Development\C++\cimgui-sokol-starterkit\wasm\dem
o.vcxproj]
LINK : fatal error LNK1104: cannot open file '.obj' [C:\Development\C++\cimgui-sokol-starterkit\wasm\demo.vcxproj]
After updating to e63a36d, the UI window doesn't render.
Building from previous commit (16c9bb1) works:
Just checkout latest commit (e63a36d) and build with CMake, i.e.:
git clone https://github.com/floooh/cimgui-sokol-starterkit.git
cd cimgui-sokol-starterkit
mkdir build && cd build
cmake ..
cmake --build .
./demo
Note that building via Xcode (i.e., configuring with-G"Xcode"
) makes no difference.
First of all, let me say I love Sokol libs and the ease of their setup and minimum footprint!
I have similar starter kit for my personal projects using Sokol and I also wrapped the shader compiler from sokol-tools-bin with a CMake script, so that I could have the shaders be built as part of the CMake build machinery.
If you're interested, I could make a PR - or do you think it would unnecessarily complicate the demo?
Hi there,
Probably a stupid question coming, I'm new to all this, so sorry in advance.
I unsuccessfully tried building with emscripten on Windows 10 (without using WSL), and I'm having trouble understanding this line in the README.md:
(this procedure should also work on Windows with
make
in the path, but is currently untested)
What do you mean by make in the path
?
Many thanks!
Hi,
I've used master branch Sokol (via fips) for a while with very few issues.
I only recently discovered this starterkit repo, and I decided to give it a go as it sounds like it could be useful for a new project I've been considering.
However, strangely, when I've tried to build and run a clean checkout of the repo, it seems to hang before a window even appears.
Breaking into it in the debugger seems to suggest it's hung on the call to _sapp.glx.QueryExtensionsString(_sapp.x11.display, _sapp.x11.screen)
in _sapp_glx_init()
.
Do you have any thoughts on what might be happening here?
Is there any additional diagnostics debugging I could turn on that might help?
Not sure if useful, but here's some gfx hardware info about my system:
$ glxinfo
name of display: :0
display: :0 screen: 0
direct rendering: Yes
server glx vendor string: SGI
server glx version string: 1.4
client glx vendor string: Mesa Project and SGI
client glx version string: 1.4
GLX version: 1.4
Extended renderer info (GLX_MESA_query_renderer):
Vendor: Intel (0x8086)
Device: Mesa Intel(R) UHD Graphics 620 (KBL GT2) (0x5917)
Version: 20.0.8
Accelerated: yes
Video memory: 3072MB
Unified memory: yes
Preferred profile: core (0x1)
Max core profile version: 4.6
Max compat profile version: 4.6
Max GLES1 profile version: 1.1
Max GLES[23] profile version: 3.2
OpenGL vendor string: Intel
OpenGL renderer string: Mesa Intel(R) UHD Graphics 620 (KBL GT2)
OpenGL core profile version string: 4.6 (Core Profile) Mesa 20.0.8
OpenGL core profile shading language version string: 4.60
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
And about my system:
CPU: Intel i7-8550U (8) @ 4.000GHz
GPU: Intel UHD Graphics 620
Resolution: 1920x1080
OS: Ubuntu 20.04.1 LTS x86_64
Kernel: 5.4.0-54-generic
Shell: bash 5.0.17
DE: GNOME 3.36.4
WM: Mutter
Thanks!
Building the project with
emcmake cmake -DCMAKE_BUILD_TYPE=MinSizeRel ..
Fails currently with the message:
configure: cmake -DCMAKE_BUILD_TYPE=MinSizeRel .. -DCMAKE_TOOLCHAIN_FILE=/opt/homebrew/Cellar/emscripten/3.1.24/libexec/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR=/opt/homebrew/opt/node/bin/node;--experimental-wasm-threads
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/cimgui-sokol-starterkit/build
sakari@Viper /tmp/cimgui-sokol-starterkit/build (main)> cmake --build .
[ 9%] Building CXX object CMakeFiles/cimgui.dir/cimgui/cimgui.cpp.o
[ 18%] Building CXX object CMakeFiles/cimgui.dir/cimgui/imgui/imgui.cpp.o
[ 27%] Building CXX object CMakeFiles/cimgui.dir/cimgui/imgui/imgui_widgets.cpp.o
[ 36%] Building CXX object CMakeFiles/cimgui.dir/cimgui/imgui/imgui_draw.cpp.o
[ 45%] Building CXX object CMakeFiles/cimgui.dir/cimgui/imgui/imgui_tables.cpp.o
[ 54%] Building CXX object CMakeFiles/cimgui.dir/cimgui/imgui/imgui_demo.cpp.o
[ 63%] Linking CXX static library libcimgui.a
[ 63%] Built target cimgui
[ 72%] Building C object CMakeFiles/sokol.dir/sokol/sokol.c.o
[ 81%] Linking CXX static library libsokol.a
[ 81%] Built target sokol
[ 90%] Building C object CMakeFiles/demo.dir/demo.c.o
[100%] Linking C executable demo.html
building:ERROR: Closure compiler run failed:
building:ERROR: /var/folders/ql/lcdkc34x02z645rm54kwhfb40000gn/T/emscripten_temp_h4fjwxem/demo.jso4.js:562:2: ERROR - [JSC_UNDEFINED_VARIABLE] variable ccall is undeclared
562| ccall("_sapp_emsc_onpaste", "void", [ "string" ], [ pasted_str ]);
^^^^^
1 error(s), 0 warning(s)
emcc: error: closure compiler failed (rc: 1): /opt/homebrew/opt/node/bin/node --max_old_space_size=8192 /opt/homebrew/Cellar/emscripten/3.1.24/libexec/node_modules/.bin/google-closure-compiler --compilation_level ADVANCED_OPTIMIZATIONS --language_in ECMASCRIPT_2020 --language_out NO_TRANSPILE --emit_use_strict=false --externs /opt/homebrew/Cellar/emscripten/3.1.24/libexec/src/closure-externs/closure-externs.js --externs /opt/homebrew/Cellar/emscripten/3.1.24/libexec/src/closure-externs/node-externs.js --externs /opt/homebrew/Cellar/emscripten/3.1.24/libexec/third_party/closure-compiler/node-externs/net.js --externs /opt/homebrew/Cellar/emscripten/3.1.24/libexec/third_party/closure-compiler/node-externs/events.js --externs /opt/homebrew/Cellar/emscripten/3.1.24/libexec/third_party/closure-compiler/node-externs/repl.js --externs /opt/homebrew/Cellar/emscripten/3.1.24/libexec/third_party/closure-compiler/node-externs/util.js --externs /opt/homebrew/Cellar/emscripten/3.1.24/libexec/third_party/closure-compiler/node-externs/dgram.js --externs /opt/homebrew/Cellar/emscripten/3.1.24/libexec/third_party/closure-compiler/node-externs/vm.js --externs /opt/homebrew/Cellar/emscripten/3.1.24/libexec/third_party/closure-compiler/node-externs/stream.js --externs /opt/homebrew/Cellar/emscripten/3.1.24/libexec/third_party/closure-compiler/node-externs/child_process.js --externs /opt/homebrew/Cellar/emscripten/3.1.24/libexec/third_party/closure-compiler/node-externs/assert.js --externs /opt/homebrew/Cellar/emscripten/3.1.24/libexec/third_party/closure-compiler/node-externs/core.js --externs /opt/homebrew/Cellar/emscripten/3.1.24/libexec/third_party/closure-compiler/node-externs/os.js --externs /opt/homebrew/Cellar/emscripten/3.1.24/libexec/third_party/closure-compiler/node-externs/readline.js --externs /opt/homebrew/Cellar/emscripten/3.1.24/libexec/third_party/closure-compiler/node-externs/punycode.js --externs /opt/homebrew/Cellar/emscripten/3.1.24/libexec/third_party/closure-compiler/node-externs/https.js --externs /opt/homebrew/Cellar/emscripten/3.1.24/libexec/third_party/closure-compiler/node-externs/domain.js --externs /opt/homebrew/Cellar/emscripten/3.1.24/libexec/third_party/closure-compiler/node-externs/dns.js --externs /opt/homebrew/Cellar/emscripten/3.1.24/libexec/third_party/closure-compiler/node-externs/tty.js --externs /opt/homebrew/Cellar/emscripten/3.1.24/libexec/third_party/closure-compiler/node-externs/querystring.js --externs /opt/homebrew/Cellar/emscripten/3.1.24/libexec/third_party/closure-compiler/node-externs/path.js --externs /opt/homebrew/Cellar/emscripten/3.1.24/libexec/third_party/closure-compiler/node-externs/string_decoder.js --externs /opt/homebrew/Cellar/emscripten/3.1.24/libexec/third_party/closure-compiler/node-externs/cluster.js --externs /opt/homebrew/Cellar/emscripten/3.1.24/libexec/third_party/closure-compiler/node-externs/zlib.js --externs /opt/homebrew/Cellar/emscripten/3.1.24/libexec/third_party/closure-compiler/node-externs/url.js --externs /opt/homebrew/Cellar/emscripten/3.1.24/libexec/third_party/closure-compiler/node-externs/tls.js --externs /opt/homebrew/Cellar/emscripten/3.1.24/libexec/third_party/closure-compiler/node-externs/process.js --externs /opt/homebrew/Cellar/emscripten/3.1.24/libexec/third_party/closure-compiler/node-externs/http.js --externs /opt/homebrew/Cellar/emscripten/3.1.24/libexec/third_party/closure-compiler/node-externs/buffer.js --externs /opt/homebrew/Cellar/emscripten/3.1.24/libexec/third_party/closure-compiler/node-externs/fs.js --js /var/folders/ql/lcdkc34x02z645rm54kwhfb40000gn/T/emscripten_temp_h4fjwxem/demo.jso4.js --js_output_file tmpxvagqmwj.cc.js the error message may be clearer with -g1 and EMCC_DEBUG=2 set
make[2]: *** [demo.html] Error 1
make[1]: *** [CMakeFiles/demo.dir/all] Error 2
make: *** [all] Error 2
Running macOS Ventura 13.0 with Emscripten stable 3.1.24.
Probably fails as there were some recent changes in Emscripten and ccall.
Line 5 of sokol.c
#define SOKOL_D3D11
doesn't build with GCC.
#define SOKOL_GLCORE33
worked fine for me.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.