Created
February 11, 2020 18:31
-
-
Save aaronmaldonado-dev/e482af6211e348ff7d5e85041fff0131 to your computer and use it in GitHub Desktop.
Sekam Dex, WebGL tutorial - Step No. 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>WEBGL - 06</title> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css"> | |
<style> | |
#gl { | |
position: absolute; | |
height: 100%; | |
width: 100%; | |
left: 0; | |
top: 0; | |
} | |
#gl canvas { | |
position: absolute; | |
height: 100%; | |
width: 100%; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="gl"></div> | |
<script> | |
class Playground { | |
constructor() { | |
this.gl = this.createContext(); | |
} | |
createContext() { | |
const container = document.getElementById('gl'); | |
const canvas = document.createElement('canvas'); | |
let screenHeight = window.innerHeight; | |
let screenWidth = window.innerWidth; | |
canvas.height = screenHeight; | |
canvas.width = screenWidth; | |
container.appendChild(canvas); | |
return canvas.getContext('webgl'); | |
} | |
} | |
let playground = new Playground(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment