-
-
Notifications
You must be signed in to change notification settings - Fork 0
WritingScripts
๐ง Note: For advanced scripting features (UI, 3D, live editing), see Roadmap.md for future plans!
This guide explains how to write scripts for Graphite using C++ and the provided interfaces.
Scripts must implement the ScriptInterface with these methods:
-
Init()โ Initialization code -
Update()โ Per-frame logic -
Draw()โ Drawing code -
Destroy()โ Cleanup
Example:
#define BUILDING_SCRIPT_DLL
#include <Graphite/ScriptInterface.h>
#include <Graphite/Math.h>
class Script : ScriptInterface {
void Init() {
// Initialization
}
void Update() {
// Frame logic
}
void Draw() {
// Drawing
}
void Destroy() {
// Cleanup
}
};
extern "C" ScriptInterface* SCRIPT_API GetScript() {
Script* script = new Script();
return (ScriptInterface*)script;
}
extern "C" void SCRIPT_API DeleteScript(ScriptInterface* script) {
Script* temp_script = (Script*)script;
delete temp_script;
}Create and draw points:
Graphite::Math::Point p({0.5f, 0.5f}, {1.0f, 0.0f, 0.0f});
p.drawPoint();-
Always implement all four methods
-
Use sandbox mode for safer editing
-
Use verbose mode for debugging
-
For edition use sandbox mode it prevents segment fault and program crashes at runtime edition.
-
Sandbox mode runs the
Graphite -v <path>on fork. If program breaks it doesn't stop whole program just check if script is changed. -
Always end all threads in script in
Destroy()function. -
When script is stable use normal mode for performance.
-
See
Examples.mdfor more sample scripts
For advanced scripting, see the API Reference and Tutorials.
Graphite Wiki ยฉ 2025 Daynlight & Contributors
Licensed under the Apache License 2.0
- ๐ Home
- ๐ ๏ธ Installation
- ๐งโ๐ป Usage
- ๐ Tutorials
- ๐งโ๐ฌ Examples
- ๐ WritingScripts
- ๐ฆ PackageManager
- ๐งฎ Math
- ๐๏ธ APIReference
- ๐ผ๏ธ RenderingEngine
- ๐๏ธ Architecture
- ๐ Roadmap
- ๐ Versions
- ๐ ChangeLog
- ๐ถ Planning
- ๐ค Community
- ๐ Credits
- ๐ Troubleshooting
- โ FAQ