Skip to content

Commit

Permalink
Added initial web page
Browse files Browse the repository at this point in the history
  • Loading branch information
MikhailGorobets committed Aug 25, 2024
1 parent 4326232 commit 64f43d8
Show file tree
Hide file tree
Showing 35 changed files with 757 additions and 27 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/build-and-deploy-artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Build and Deploy Artifacts

on: [push]

jobs:
build:
runs-on: macos-14
name: MacOS -> Build

steps:
- name: Clone DiligentGraphics.github.io repository
uses: actions/checkout@v3
with:
submodules: recursive

- name: Set up build environment
if: success()
uses: DiligentGraphics/github-action/setup-build-env@v1
with:
platform: Emscripten

- name: Build artifacts
if: success()
working-directory: ${{github.workspace}}
run: |
python ./build_artifacts.py
- name: Upload artifacts
if: success()
uses: actions/upload-artifact@v4
with:
name: WebPage-DiligentGraphics.github.io
path: |
${{github.workspace}}/BuildArtefacts
retention-days: 90

deploy:
needs: Ubuntu -> Deploy
runs-on: ubuntu-latest
name: Ubuntu

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: WebPage-DiligentGraphics.github.io
path: ./build

- name: Deploy to GitHub Pages
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git checkout --orphan gh-pages
git rm -rf .
cp -r build/* .
git add .
git commit -m "Deploy to GitHub Pages"
git push -f origin gh-pages
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CMakeFiles
*.cmake
https_server.py
71 changes: 71 additions & 0 deletions build_artifacts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import os
import subprocess
import shutil

DILIGENT_ENGINE_URL = 'https://github.com/DiligentGraphics/DiligentEngine.git'
SOURCE_IMAGES = 'images'
SOURCE_TEMPLATE = 'template'
SOURCE_BUILD = 'DiligentEngine/build/Emscripten/DiligentSamples'
DESTINATION_DIR = 'BuildArtefacts'
BUILD_TARGETS = [
"Tutorial01_HelloTriangle"
]

def clone_repository(repository_url):
try:
command = ["git", "clone", "--recursive", "--depth", "1", repository_url]
subprocess.run(command, check=True)
except subprocess.CalledProcessError as e:
print(f"An error occurred while cloning the repository: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")

def configure_project():
try:
command = ["emcmake", "cmake", "-S", "./DiligentEngine", "-B", "./DiligentEngine/build/Emscripten", "-DCMAKE_BUILD_TYPE=Release", "-DDILIGENT_NO_WEBGPU=ON", "-DARCHIVER_SUPPORTED=OFF"]
subprocess.run(command, check=True)
except subprocess.CalledProcessError as e:
print(f"An error occurred while configuring the project: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")

def build_project():
try:
command = ["cmake", "--build", "./DiligentEngine/build/Emscripten", "--target", "Tutorial01_HelloTriangle"]
subprocess.run(command, check=True)
except subprocess.CalledProcessError as e:
print(f"An error occurred while building the project: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")

def upload_artefacts():
if not os.path.exists(DESTINATION_DIR):
os.makedirs(DESTINATION_DIR)

shutil.copytree(SOURCE_IMAGES, os.path.join(DESTINATION_DIR, 'images'), dirs_exist_ok=True)
for item in os.listdir(SOURCE_TEMPLATE):
source_item = os.path.join(SOURCE_TEMPLATE, item)
destination_item = os.path.join(DESTINATION_DIR, item) # Corrected the destination path

if os.path.isdir(source_item):
shutil.copytree(source_item, destination_item, dirs_exist_ok=True)
else:
shutil.copy2(source_item, destination_item)

for folder in BUILD_TARGETS:
source_folder_path_tutorials = os.path.join(SOURCE_BUILD, "Tutorials", folder)
source_folder_path_samples = os.path.join(SOURCE_BUILD, "Samples", folder)
destination_folder_path = os.path.join(DESTINATION_DIR, "wasm-modules", folder)

if os.path.exists(source_folder_path_tutorials):
shutil.copytree(source_folder_path_tutorials, destination_folder_path, dirs_exist_ok=True)
elif os.path.exists(source_folder_path_samples):
shutil.copytree(source_folder_path_samples, destination_folder_path, dirs_exist_ok=True)
else:
print(f"Folder '{folder}' not found.")

if __name__ == '__main__':
clone_repository(DILIGENT_ENGINE_URL)
configure_project()
build_project()
upload_artefacts()
Binary file added images/content/samples/Atmosphere.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/content/samples/GLTFViewer.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/content/samples/ImguiDemo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/content/samples/Shadows.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/content/search-bar/search-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/content/tutorials/Tutorial02_Cube.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/content/tutorials/Tutorial09_Quads.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/content/tutorials/Tutorial17_MSAA.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/content/tutorials/Tutorial18_Queries.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/header/diligentgraphics-icon.ico
Binary file not shown.
Binary file added images/header/diligentgraphics-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/header/github-mark-white.png
27 changes: 0 additions & 27 deletions index.html

This file was deleted.

75 changes: 75 additions & 0 deletions template/enable-threads.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// 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.
// 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.

/* Edited version of: coi-serviceworker v0.1.6 - Guido Zuidhof, licensed under MIT */
// From here: https://github.com/gzuidhof/coi-serviceworker
if(typeof window === 'undefined') {
self.addEventListener("install", () => self.skipWaiting());
self.addEventListener("activate", e => e.waitUntil(self.clients.claim()));

async function handleFetch(request) {
if(request.cache === "only-if-cached" && request.mode !== "same-origin") {
return;
}

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
request = new Request(request.url, {
cache: request.cache,
credentials: "omit",
headers: request.headers,
integrity: request.integrity,
destination: request.destination,
keepalive: request.keepalive,
method: request.method,
mode: request.mode,
redirect: request.redirect,
referrer: request.referrer,
referrerPolicy: request.referrerPolicy,
signal: request.signal,
});
}

let r = await fetch(request).catch(e => console.error(e));

if(r.status === 0) {
return r;
}

const headers = new Headers(r.headers);
headers.set("Cross-Origin-Embedder-Policy", "credentialless"); // or: require-corp
headers.set("Cross-Origin-Opener-Policy", "same-origin");

return new Response(r.body, { status: r.status, statusText: r.statusText, headers });
}

self.addEventListener("fetch", function(e) {
e.respondWith(handleFetch(e.request)); // respondWith must be executed synchonously (but can be passed a Promise)
});

} else {
(async function() {
if(window.crossOriginIsolated !== false) return;

let registration = await navigator.serviceWorker.register(window.document.currentScript.src).catch(e => console.error("COOP/COEP Service Worker failed to register:", e));
if(registration) {
console.log("COOP/COEP Service Worker registered", registration.scope);

registration.addEventListener("updatefound", () => {
console.log("Reloading page to make use of updated COOP/COEP Service Worker.");
window.location.reload();
});

// If the registration is active, but it's not controlling the page
if(registration.active && !navigator.serviceWorker.controller) {
console.log("Reloading page to make use of COOP/COEP Service Worker.");
window.location.reload();
}
}
})();
}

// Code to deregister:
// let registrations = await navigator.serviceWorker.getRegistrations();
// for(let registration of registrations) {
// await registration.unregister();
// }
66 changes: 66 additions & 0 deletions template/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Diligent Graphics">
<title>Diligent Graphics</title>
<link rel="icon" href="images/header/diligentgraphics-icon.ico" type="image/x-icon">
<link rel="stylesheet" href="styles.css">
</head>
<body>

<header>
<a href="https://diligentgraphics.com/" target="_blank">
<img src="images/header/diligentgraphics-logo.png" alt="Diligent Graphics" class="logo">
</a>
<a href="https://github.com/DiligentGraphics/DiligentEngine" class="github-link" target="_blank">
<img src="images/header/github-mark-white.png" alt="GitHub">
</a>
</header>

<div class="container">
<nav>
<h2>Categories</h2>
<ul>
<li><a href="#tutorials">Tutorials</a></li>
<li><a href="#samples">Samples</a></li>
<li><a href="#known-issues">Known issues</a></li>
</ul>
</nav>

<div class="content">
<div class="search-bar">
<input type="text" placeholder="Search Example">
<span class="search-icon"></span>
</div>

<section id="tutorials">
<h2>Tutorials</h2>
<div class="grid" id="tutorialGrid">
</div>
</section>

<section id="samples">
<h2>Samples</h2>
<div class="grid" id="samplesGrid">
</div>
</section>
<section id="known-issues">
<h2>Known issues</h2>
<ul>
<li>14 - Compute Shader tutorial doesn't work on WebGL.</li>
<li>18 - Queries tutorial doesn't work on WebGPU.</li>
<li>19 - Render Passes tutorial doesn't work on WebGL.</li>
<li>Atmosphere sample doesn't work on WebGL.</li>
<li>Shadows sample has artifacts on WebGL.</li>
</ul>
</section>
</div>
</div>

<script src="enable-threads.js"></script>
<script src="script.js"></script>

</body>
</html>
Loading

0 comments on commit 64f43d8

Please sign in to comment.