https://github.com/fynv/v8andgui
A V8 + Dear ImGui demo showing how to embed & bind V8
https://github.com/fynv/v8andgui
Last synced: 10 months ago
JSON representation
A V8 + Dear ImGui demo showing how to embed & bind V8
- Host: GitHub
- URL: https://github.com/fynv/v8andgui
- Owner: fynv
- Created: 2023-12-22T09:37:36.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-12-29T02:29:29.000Z (over 2 years ago)
- Last Synced: 2025-07-06T03:03:08.741Z (11 months ago)
- Language: C++
- Size: 4.15 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# V8AndGUI
This is a small demo showing how to embed and bind V8 in a graphics or GUI centered application.
The main points to be shown:
* Interface description using a set of structs (definitions.hpp), which are used in DefaultModule.cpp and the wrapper classes to define the functions/objects/classes to be exported to the JavaScript space. This coding pattern is developed during the recent restructuring of a bigger project [Three.V8](https://github.com/fynv/three.v8).
* Working with async callbacks. This kind of applications normally have their own event loops. The demo shows 2 ways of making the callbacks: using the system message queue (for GUI elements) and using a separate set of message queues (ConcurrentQueue.h, AsyncCallbacks.cpp, for network requests).
I find [Dear ImGui](https://github.com/ocornut/imgui) to be helpful for providing a minimal background for showing the patterns.
The "Launcher" window is coded directly into the main program, which is used for loading code and showing debug log. The scripts can use the following APIs exported by the main program:
* Global function "print()" for printing log.
* Global object "http" for making synced/asynced http requests.
* Global object "scriptWindow" for adding UI elements to the 2nd window.
* UI element classes: "Text", "SameLine", "InputText", and "Button".