p3nGu1nZz commited on
Commit
41fe030
1 Parent(s): d998663

🥒 Rendering so fresh, it's zucchini crisp!

Browse files
Files changed (4) hide show
  1. index.js +6 -2
  2. style.css +6 -0
  3. wgpu-config.js +2 -2
  4. wgpu-state.js +3 -3
index.js CHANGED
@@ -1,5 +1,3 @@
1
- // index.js
2
-
3
  import { mat4 } from 'https://webgpufundamentals.org/3rdparty/wgpu-matrix.module.js';
4
  import { initializeWebGPU } from './wgpu-device.js';
5
  import { createState } from './wgpu-state.js';
@@ -13,7 +11,13 @@ import { config } from './wgpu-config.js';
13
  import { CANVAS, CTX, COLORS, RENDER_PASS_DESCRIPTOR } from './wgpu-constants.js';
14
  import { CreateBuffers } from './wgpu-buffer.js';
15
 
 
 
 
 
 
16
  const state = createState(config);
 
17
 
18
  async function Main() {
19
  const adapter = await navigator.gpu?.requestAdapter();
 
 
 
1
  import { mat4 } from 'https://webgpufundamentals.org/3rdparty/wgpu-matrix.module.js';
2
  import { initializeWebGPU } from './wgpu-device.js';
3
  import { createState } from './wgpu-state.js';
 
11
  import { CANVAS, CTX, COLORS, RENDER_PASS_DESCRIPTOR } from './wgpu-constants.js';
12
  import { CreateBuffers } from './wgpu-buffer.js';
13
 
14
+ const canvas = document.createElement('canvas');
15
+ canvas.width = config.canvas.width;
16
+ canvas.height = config.canvas.height;
17
+ document.body.appendChild(canvas);
18
+
19
  const state = createState(config);
20
+ state.canvas = canvas;
21
 
22
  async function Main() {
23
  const adapter = await navigator.gpu?.requestAdapter();
style.css CHANGED
@@ -7,6 +7,12 @@ body {
7
  font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;
8
  }
9
 
 
 
 
 
 
 
10
  h1 {
11
  font-size: 10em;
12
  margin-top: 0;
 
7
  font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;
8
  }
9
 
10
+ canvas {
11
+ display: block;
12
+ width: 100vw;
13
+ height: 100vh;
14
+ }
15
+
16
  h1 {
17
  font-size: 10em;
18
  margin-top: 0;
wgpu-config.js CHANGED
@@ -1,5 +1,3 @@
1
- // wgpu-config.js
2
-
3
  export const config = {
4
  glyphsAcrossTexture: 16,
5
  glyphWidth: 32,
@@ -8,6 +6,8 @@ export const config = {
8
  vertsPerGlyph: 6,
9
  floatsPerVertex: 8,
10
  uniformBufferSize: 64,
 
 
11
  canvas: {
12
  width: 512,
13
  height: 256
 
 
 
1
  export const config = {
2
  glyphsAcrossTexture: 16,
3
  glyphWidth: 32,
 
6
  vertsPerGlyph: 6,
7
  floatsPerVertex: 8,
8
  uniformBufferSize: 64,
9
+ floatsInUniformBuffer: 16,
10
+ matrixSize: 16,
11
  canvas: {
12
  width: 512,
13
  height: 256
wgpu-state.js CHANGED
@@ -14,15 +14,15 @@ export function createState(config) {
14
  shaderCode: null,
15
  },
16
  matrices: {
17
- uniformValues: new Float32Array(config.uniformBufferSize / 4),
18
- matrix: new Float32Array(16),
19
  },
20
  glyphs: {
21
  numGlyphs: 0,
22
  width: 0,
23
  height: 0,
24
  },
25
- canvas: document.querySelector('canvas'),
26
  timing: {
27
  time: 0,
28
  fixedDeltaTime: 0,
 
14
  shaderCode: null,
15
  },
16
  matrices: {
17
+ uniformValues: new Float32Array(config.floatsInUniformBuffer),
18
+ matrix: new Float32Array(config.matrixSize),
19
  },
20
  glyphs: {
21
  numGlyphs: 0,
22
  width: 0,
23
  height: 0,
24
  },
25
+ canvas: document.querySelector('canvas') || document.body.appendChild(document.createElement('canvas')),
26
  timing: {
27
  time: 0,
28
  fixedDeltaTime: 0,