Skip to content

Commit 9058ec3

Browse files
Added initial web page
1 parent 4326232 commit 9058ec3

35 files changed

+703
-27
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Build and Deploy web
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
name: Ubuntu -> Emscripten, Release
9+
10+
steps:
11+
- name: Clone DiligentGraphics.github.io repository
12+
uses: actions/checkout@v3
13+
with:
14+
submodules: recursive
15+
16+
- name: Clone DiligentEngine repository
17+
uses: actions/checkout@v3
18+
with:
19+
submodules: recursive
20+
repository: DiligentGraphics/DiligentEngine
21+
22+
- name: Set up build environment
23+
if: success()
24+
uses: DiligentGraphics/github-action/setup-build-env@v1
25+
with:
26+
platform: Emscripten
27+
28+
- name: Configure CMake
29+
if: success()
30+
uses: DiligentGraphics/github-action/configure-cmake@v1
31+
with:
32+
build-type: Release
33+
cmake_args: -DDILIGENT_NO_WEBGPU=ON
34+
35+
- name: Build
36+
if: success()
37+
uses: DiligentGraphics/github-action/build@v1
38+
with:
39+
build-args: --target=Tutorial01_HelloTriangle
40+
41+
- name: Combine artifacts
42+
if: success()
43+
run: |
44+
python
45+
46+
- name: Upload artifacts
47+
if: success()
48+
uses: actions/upload-artifact@v3
49+
with:
50+
path: |
51+
${{github.workspace}}/BuildArtefacts
52+
retention-days: 90

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CMakeFiles
2+
*.cmake
3+
https_server.py

combine_artifacts.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import os
2+
import shutil
3+
4+
5+
SOURCE_IMAGES = 'images'
6+
SOURCE_TEMPLATE = 'template'
7+
DESTINATION_DIR = 'BuildArtefacts'
8+
9+
if __name__ == '__main__':
10+
if not os.path.exists(DESTINATION_DIR):
11+
os.makedirs(DESTINATION_DIR)
12+
13+
shutil.copytree(SOURCE_IMAGES, os.path.join(DESTINATION_DIR, 'images'), dirs_exist_ok=True)
14+
print(f"Copied '{SOURCE_IMAGES}' to '{DESTINATION_DIR}'.")
15+
16+
for item in os.listdir(SOURCE_TEMPLATE):
17+
source_item = os.path.join(SOURCE_TEMPLATE, item)
18+
destination_item = os.path.join(SOURCE_TEMPLATE, item)
19+
20+
if os.path.isdir(source_item):
21+
shutil.copytree(source_item, destination_item, dirs_exist_ok=True)
22+
else:
23+
shutil.copy2(source_item, destination_item)
24+
25+
print(f"Extracted contents of '{SOURCE_TEMPLATE}' to '{DESTINATION_DIR}'.")

images/content/samples/Atmosphere.gif

1.02 MB
Loading

images/content/samples/GLTFViewer.jpg

100 KB
Loading

images/content/samples/ImguiDemo.png

9.85 KB
Loading

images/content/samples/Shadows.jpg

220 KB
Loading
766 Bytes
Loading
Loading
995 KB
Loading
Loading
Loading
Loading
Loading
1.8 MB
Loading
Loading
Loading
Loading
Loading
Loading
Loading
695 KB
Loading
Loading
Loading
Loading
Loading
Loading
29.4 KB
Binary file not shown.
229 KB
Loading

images/header/github-mark-white.png

4.72 KB
Loading

index.html

Lines changed: 0 additions & 27 deletions
This file was deleted.

template/enable-threads.js

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// NOTE: This file creates a service worker that cross-origin-isolates the page (read more here: https://web.dev/coop-coep/) which allows us to use wasm threads.
2+
// Normally you would set the COOP and COEP headers on the server to do this, but Github Pages doesn't allow this, so this is a hack to do that.
3+
4+
/* Edited version of: coi-serviceworker v0.1.6 - Guido Zuidhof, licensed under MIT */
5+
// From here: https://github.com/gzuidhof/coi-serviceworker
6+
if(typeof window === 'undefined') {
7+
self.addEventListener("install", () => self.skipWaiting());
8+
self.addEventListener("activate", e => e.waitUntil(self.clients.claim()));
9+
10+
async function handleFetch(request) {
11+
if(request.cache === "only-if-cached" && request.mode !== "same-origin") {
12+
return;
13+
}
14+
15+
if(request.mode === "no-cors") { // We need to set `credentials` to "omit" for no-cors requests, per this comment: https://bugs.chromium.org/p/chromium/issues/detail?id=1309901#c7
16+
request = new Request(request.url, {
17+
cache: request.cache,
18+
credentials: "omit",
19+
headers: request.headers,
20+
integrity: request.integrity,
21+
destination: request.destination,
22+
keepalive: request.keepalive,
23+
method: request.method,
24+
mode: request.mode,
25+
redirect: request.redirect,
26+
referrer: request.referrer,
27+
referrerPolicy: request.referrerPolicy,
28+
signal: request.signal,
29+
});
30+
}
31+
32+
let r = await fetch(request).catch(e => console.error(e));
33+
34+
if(r.status === 0) {
35+
return r;
36+
}
37+
38+
const headers = new Headers(r.headers);
39+
headers.set("Cross-Origin-Embedder-Policy", "credentialless"); // or: require-corp
40+
headers.set("Cross-Origin-Opener-Policy", "same-origin");
41+
42+
return new Response(r.body, { status: r.status, statusText: r.statusText, headers });
43+
}
44+
45+
self.addEventListener("fetch", function(e) {
46+
e.respondWith(handleFetch(e.request)); // respondWith must be executed synchonously (but can be passed a Promise)
47+
});
48+
49+
} else {
50+
(async function() {
51+
if(window.crossOriginIsolated !== false) return;
52+
53+
let registration = await navigator.serviceWorker.register(window.document.currentScript.src).catch(e => console.error("COOP/COEP Service Worker failed to register:", e));
54+
if(registration) {
55+
console.log("COOP/COEP Service Worker registered", registration.scope);
56+
57+
registration.addEventListener("updatefound", () => {
58+
console.log("Reloading page to make use of updated COOP/COEP Service Worker.");
59+
window.location.reload();
60+
});
61+
62+
// If the registration is active, but it's not controlling the page
63+
if(registration.active && !navigator.serviceWorker.controller) {
64+
console.log("Reloading page to make use of COOP/COEP Service Worker.");
65+
window.location.reload();
66+
}
67+
}
68+
})();
69+
}
70+
71+
// Code to deregister:
72+
// let registrations = await navigator.serviceWorker.getRegistrations();
73+
// for(let registration of registrations) {
74+
// await registration.unregister();
75+
// }
76+

template/index.html

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta name="description" content="Diligent Graphics">
7+
<title>Diligent Graphics</title>
8+
<link rel="icon" href="images/header/diligentgraphics-icon.ico" type="image/x-icon">
9+
<link rel="stylesheet" href="styles.css">
10+
</head>
11+
<body>
12+
13+
<header>
14+
<a href="https://diligentgraphics.com/" target="_blank">
15+
<img src="images/header/diligentgraphics-logo.png" alt="Diligent Graphics" class="logo">
16+
</a>
17+
<a href="https://github.com/DiligentGraphics/DiligentEngine" class="github-link" target="_blank">
18+
<img src="images/header/github-mark-white.png" alt="GitHub">
19+
</a>
20+
</header>
21+
22+
<div class="container">
23+
<nav>
24+
<h2>Categories</h2>
25+
<ul>
26+
<li><a href="#tutorials">Tutorials</a></li>
27+
<li><a href="#samples">Samples</a></li>
28+
<li><a href="#known-issues">Known issues</a></li>
29+
</ul>
30+
</nav>
31+
32+
<div class="content">
33+
<div class="search-bar">
34+
<input type="text" placeholder="Search Example">
35+
<span class="search-icon"></span>
36+
</div>
37+
38+
<section id="tutorials">
39+
<h2>Tutorials</h2>
40+
<div class="grid" id="tutorialGrid">
41+
</div>
42+
</section>
43+
44+
<section id="samples">
45+
<h2>Samples</h2>
46+
<div class="grid" id="samplesGrid">
47+
</div>
48+
</section>
49+
<section id="known-issues">
50+
<h2>Known issues</h2>
51+
<ul>
52+
<li>14 - Compute Shader tutorial doesn't work on WebGL.</li>
53+
<li>18 - Queries tutorial doesn't work on WebGPU.</li>
54+
<li>19 - Render Passes tutorial doesn't work on WebGL.</li>
55+
<li>Atmosphere sample doesn't work on WebGL.</li>
56+
<li>Shadows sample has artifacts on WebGL.</li>
57+
</ul>
58+
</section>
59+
</div>
60+
</div>
61+
62+
<script src="enable-threads.js"></script>
63+
<script src="script.js"></script>
64+
65+
</body>
66+
</html>

0 commit comments

Comments
 (0)