Spaces:
Running
Running
Enhanced vertex data function
Browse files
index.js
CHANGED
@@ -75,8 +75,8 @@ function GenerateIndices(maxGlyphs) {
|
|
75 |
}
|
76 |
|
77 |
function GenerateVertexDataAndTexture(glyphCanvas) {
|
78 |
-
const
|
79 |
-
state.device.queue.writeBuffer(state.vertexBuffer, 0, vertexData);
|
80 |
|
81 |
state.texture = createTextureFromSource(state.device, glyphCanvas, { mips: true });
|
82 |
state.sampler = state.device.createSampler({
|
@@ -101,9 +101,10 @@ function GenerateVertexDataAndTexture(glyphCanvas) {
|
|
101 |
],
|
102 |
});
|
103 |
|
104 |
-
state
|
105 |
-
state.
|
106 |
-
state.
|
|
|
107 |
}
|
108 |
|
109 |
function GameLoop(context) {
|
|
|
75 |
}
|
76 |
|
77 |
function GenerateVertexDataAndTexture(glyphCanvas) {
|
78 |
+
const glyphData = generateGlyphVerticesForText('Hello\nworld!\nText in\nWebGPU!', COLORS, config, glyphCanvas);
|
79 |
+
state.device.queue.writeBuffer(state.vertexBuffer, 0, glyphData.vertexData);
|
80 |
|
81 |
state.texture = createTextureFromSource(state.device, glyphCanvas, { mips: true });
|
82 |
state.sampler = state.device.createSampler({
|
|
|
101 |
],
|
102 |
});
|
103 |
|
104 |
+
// Update state with glyph details
|
105 |
+
state.numGlyphs = glyphData.numGlyphs;
|
106 |
+
state.width = glyphData.width;
|
107 |
+
state.height = glyphData.height;
|
108 |
}
|
109 |
|
110 |
function GameLoop(context) {
|