Skip to content

Decapitated/Godot-HTML

Repository files navigation

Build GDExtension

Godot HTML

A GDExtension, using Ultralight, to render HTML.

Versions

  • Godot 4.3+
  • Ultralight 1.4.0 Beta

Platforms

Platform x64 arm64 x32
Windows ⚠️
Linux ⚠️
Mac

✅ = Successfully ran the demo project.

⚠️ = Supported, but not tested.

❌ = Not supported.

Table of contents

CAN-DO

  • Render HTML & CSS, with JS capabilities.
  • HTML Inspector
  • Mouse & Keyboard Input
  • JS Interop
  • GDScript Support

TO-DO

  • Accelerated Views. IE. GPU based rendering.
  • ImageSource. IE. RenderTargets.
  • Make sure remote websites can't access C++ code via JS interop.
  • Live code updates. (Allow for html to update in the editor when file changed)
  • ?? More will arrise I assume ??

Ultralight Limitations

Ultralight works for most web features. Check out the missing features.

Some of the notable limitations are:

  • .webp
  • HTML5 Video/Audio

Prerequisites

Project Structure

Your project structure should look like this before running with this extension.

demo/                            # Godot project (Root)
  addons/                        # Addons
    gdhtml/                      # Godot-HTML extension
    | bin/                       # Extension libraries
    |   windows/                # Library platform
    |     x86_64/               # Platform arch
    |       gdhtml.*.dll        # Extension library
    |       Ultralight.dll      # Ultralight libraries
    |       UltralightCore.dll  # ...
    |       WebCore.dll         # ...
    |       AppCore.dll         # ...
    | inspector/                 # Ultralight inspector
    | resources/                 # Ultralight resources

Building

Clone godot-cpp

git submodule update --init --remote

Build Godot C++ bindings

cd godot-cpp
scons platform=<platform>

Build plugin

From the main folder.

scons platform=<platform>

JS Interop

JS interop is as simple as returning a Dictionary from the virtual function _on_window_ready. Then accessing it from JS using window.godot.

Checkout the example script.

Important:

  • JS Symbols are not currently supported. Convert them to a string before passing them to Godot.

Exporting Godot Project

Once you're ready to export your game/project make sure to:

Include html files in export via `Export Configuration`.
For auto imported resources, select `Keep File (No Import)`.