Warn:This Readme is made by ai
Warn:You need to use a speical qemu located at:https://github.com/killjsj/qemu to have a ui called sharedbuffer
path for place custom qemu: in build version, create a folder called 'bin' in the game folder and throw all qemu build inside, in editor,create a folder called 'bin' in the project folder and throw all qemu build inside
A Godot 4.x C++ extension that captures QEMU virtual machine screen output via shared memory.
- Reads screen buffer directly from QEMU's shared memory display
- Supports multiple virtual screens
- Cross-platform (Windows, Linux)
- Real-time frame updating via threading
- RGBA format conversion for various pixel formats
- Godot 4.x with C++ support
- QEMU built with
--display sharedbuffersupport - For Windows: Visual Studio 2017+ or MinGW-w64
- For Linux: GCC with pthread support
ReadBufferFromQemu/
├── src/
│ ├── read.h # Main ReaderClass header
│ ├── read.cpp # Implementation
│ ├── utils.h # Shared memory utilities
│ ├── utils.cpp # QEMU process management
│ ├── lock.h # Cross-platform mutex
│ ├── structDefine.h # Shared memory structures
│ └── register_types.cpp # Godot extension registration
├── project/ # Godot test project
│ └── node_2d.gd # Demo usage script
└── bin/ # Compiled libraries
extends ReaderClass
var screen_sprites: Array[Sprite2D] = []
func _ready() -> void:
startMachine(['-m', '2048'])
func _process(_delta: float) -> void:
sync_connection(_delta)
var count = get_screen_count()
if count > 0 and screen_sprites.size() != count:
_setup_sprites(count)
for i in range(screen_sprites.size()):
if get_usable(i):
screen_sprites[i].texture = get_texture(i)| Method | Description |
|---|---|
startMachine(args: PackedStringArray) |
Start QEMU with given arguments |
stopMachine() |
Stop the QEMU process |
sync_connection(delta: float) |
Sync frame data to textures |
get_screen_count() -> int |
Get number of screens |
get_usable(index: int) -> bool |
Check if screen is available |
get_width(index: int) -> int |
Get screen width |
get_height(index: int) -> int |
Get screen height |
get_texture(index: int) -> ImageTexture |
Get screen texture |
scons platform=windows target=template_debugscons platform=linux target=template_debug- QEMU Connection: Spawns QEMU with
--display sharedbuffer,id=sharedbuf_N - Shared Memory: Connects to control block (
/QemuCtrl_sharedbuf_N) and data buffers - Threaded Reading: Background thread reads pixel data from shared memory
- Format Conversion: Converts various PIXMAN formats to RGBA8
- Texture Update: Main thread syncs data to Godot textures
Each virtual screen has its own:
- Shared memory mapping
- Lock (mutex) for synchronization
- Double buffering (A/B buffers)
- Independent dimensions
PIXMAN_a8r8g8b8/PIXMAN_x8r8g8b8PIXMAN_a8b8g8r8/PIXMAN_x8b8g8r8PIXMAN_b8g8r8a8/PIXMAN_b8g8r8x8PIXMAN_r8g8b8a8/PIXMAN_r8g8b8x8PIXMAN_rgba_float(96bpp/128bpp)
MIT