A Blitz3D+ program can run in a web browser, so anyone can play it from a link without installing anything. Blitz3D+ compiles the program to WebAssembly, draws with WebGPU, and writes a web build: one web page that holds the whole program, which any web host can serve.
The IDE compiles the program for the web and opens it in your default browser. Click the page to start it: browsers only start sound, full screen and mouse capture after a click. Close the tab, or end the program as usual, to stop it. The IDE serves the program to your browser from this computer until you run another program in the browser or close the IDE.
castle.html, writes it, and offers to open it in the browser.index.html and upload it in a zip file as an HTML5 game.The page contains everything the program needs, compressed: the Blitz3D+ web runtime, your compiled program, and every file in your program's folder, such as models, images and sounds. Keep a program's files in its folder, or in folders below it, as you would for an executable. Your .bb source files are left out, so publishing a game does not publish its code. Several games' pages can share a folder on your site, and Chrome and Edge also open a page straight from your computer, without a web host.
For a very large game, tick Create a folder instead in the save dialog. The IDE then writes a folder of separate files, named after your program, which needs less memory while it loads and starts sooner: its page downloads first the files your program loads by name and what the worlds it loads need at the start, and the rest while the game runs. A single page cannot, since everything in it arrives at once. Upload the folder's contents; for itch.io, zip them with index.html at the top. The folder's page fetches each file as a part of program.b3dpak, which most web hosts allow; on one that does not, it downloads the whole file first, as before.
To update a published game, create its web build again and upload it over the old one. Players who come back get the new version without refreshing the page themselves, on any web host. Browsers keep a game's files between visits, and unless the web host says otherwise, they guess from each file's date how long it stays current. So a folder's program.json names a version of each of its other files, which changes whenever the file does; the page asks the host for program.json on every visit, and loads the web runtime, your program and the rest by those versions. A returning player therefore never gets your new program with a web runtime the browser kept from the old one, and a page kept from the old version opens the new one. A single-file page is one file, which browsers keep whole, so a returning player may see the old version of it for a while.
If you can change your host's settings, have it send Cache-Control: no-cache with a single-file page, and with a folder's index.html and program.b3dpak: browsers then check them on every visit, and download them only when they have changed. A folder's page asks for the web runtime, your program and each part of program.b3dpak at addresses of their own, ending in ?v= or ?file= and a code that changes whenever the file does, so the host can let browsers keep those for good with Cache-Control: public, max-age=31536000, immutable. On nginx, for a game in the folder /play/game/:
map $arg_file$arg_v $game_cache_control {
"" "no-cache";
default "public, max-age=31536000, immutable";
}
server {
...
location /play/game/ {
add_header Cache-Control $game_cache_control;
}
}
From the command line, blitzcc --target web -o game.html game.bb writes the page game.html, and blitzcc --target web -o site game.bb writes the folder site; add --run to open either one too. blitzcc --serve game.html or blitzcc --serve site opens a web build created earlier.
Players need a browser with WebGPU and WebAssembly JavaScript Promise Integration: Chrome or Edge 137 or later, Firefox 153 or later on Windows or an Apple-silicon Mac, or Safari 27. The page explains what is missing on other browsers. Browsers only allow WebGPU on pages served over HTTPS, which web hosts provide.
In the browser, 3D graphics are see-through wherever your program draws nothing, so the 3D can float over a web page of your own. Turn off the camera's background with CameraClsMode camera,False,True, and draw no 2D before RenderWorld. See-through entities let the page show through them, and added ones (EntityBlend 3) light it up. Then put the web build in your page in an iframe, adding ?transparent=1 to its address, which leaves out the build's own black background and title bar:
<iframe src="game.html?transparent=1&autostart=1" width="640" height="480"
style="border: 0"></iframe>
Without ?transparent=1, the page shows black there, as Windows does. The iframe still takes the mouse clicks over its whole area. Reading the screen (ReadPixel, CopyRect, screenshots) gives black where the page shows through.
.b3shader files with HLSL source) are translated for the browser by tools that the Mac version has, and that the online IDE's server runs on Linux: a web build created on a Mac, or in the online IDE while you are signed in, includes them. The Windows version cannot translate them yet, so in a web build created on Windows they do not load in the browser, and creating the build warns you. A shader that uses more textures or samplers than browsers allow is left out, and creating the web build warns you about it.DesktopWidth and DesktopHeight still report the screen's size. Menu shortcuts cannot use keys the browser keeps for itself, such as Ctrl+W. The Native UI commands (LoadNativeUI and the rest) are Windows-only.RequestFile, RequestFiles and RequestDir show a dialog in the page over the program's own files, the ones its web build carries and the ones it has written, since a web page cannot give a program the computer's folders. When opening, the player can add files from the computer, and a file the program saves can be downloaded to the computer.WaitJob, Flip or Delay still works, but a job that runs until your program cancels it needs threads, which web builds do not have yet.Flip always waits for the display, and a program pauses while its tab is in the background.