From 8ad7e539f00d9625fe0590cd3017409dfb77c3da Mon Sep 17 00:00:00 2001 From: "Min-Jae, Lee" <lee.min.jae.96@gmail.com> Date: Mon, 21 Jun 2021 18:39:06 +0900 Subject: [PATCH] Initializing WebGL2 --- index.html | 23 +++++++++++++++++++++++ script.js | 9 +++++++++ 2 files changed, 32 insertions(+) diff --git a/index.html b/index.html index e69de29..3a05f2d 100644 --- a/index.html +++ b/index.html @@ -0,0 +1,23 @@ +<!doctype html> +<html> + <head> + <meta charset="utf-8"> + <title>WebGL Tutorial</title> + <style> +html,body { + height: 100%; + margin: 0; + overflow: hidden; +} +canvas#view { + width: 100%; + height: 100%; + background: radial-gradient(gray, transparent); +} + </style> + </head> + <body> + <canvas id="view"></canvas> + <script src="script.js"></script> + </body> +</html> diff --git a/script.js b/script.js index e69de29..85a21c8 100644 --- a/script.js +++ b/script.js @@ -0,0 +1,9 @@ +document.addEventListener('DOMContentLoaded', () => { + if ('undefined' === typeof WebGL2RenderingContext) { + throw new Error('This tutorial required WebGL version 2.'); + } + const glCtx = document.querySelector('canvas#view').getContext('webgl2'); + if (!glCtx) { + throw new Error('Failed WebGL Initialization.') + } +}); -- GitLab