This commit is contained in:
Akko
2025-08-04 18:57:35 +02:00
parent 8cf6e78a79
commit 9495868c2e
5030 changed files with 518594 additions and 17609 deletions

View File

@@ -0,0 +1,20 @@
import { ExtensionType } from '../../../extensions/Extensions';
import { Shader } from '../../../rendering/renderers/shared/shader/Shader';
import type { Graphics } from '../shared/Graphics';
import type { GraphicsAdaptor, GraphicsPipe } from '../shared/GraphicsPipe';
/**
* A GraphicsAdaptor that uses WebGL to render graphics.
* @memberof rendering
* @ignore
*/
export declare class GlGraphicsAdaptor implements GraphicsAdaptor {
/** @ignore */
static extension: {
readonly type: readonly [ExtensionType.WebGLPipesAdaptor];
readonly name: "graphics";
};
shader: Shader;
init(): void;
execute(graphicsPipe: GraphicsPipe, renderable: Graphics): void;
destroy(): void;
}

View File

@@ -0,0 +1,79 @@
'use strict';
var Extensions = require('../../../extensions/Extensions.js');
var Matrix = require('../../../maths/matrix/Matrix.js');
var maxRecommendedTextures = require('../../../rendering/batcher/gl/utils/maxRecommendedTextures.js');
var compileHighShaderToProgram = require('../../../rendering/high-shader/compileHighShaderToProgram.js');
var colorBit = require('../../../rendering/high-shader/shader-bits/colorBit.js');
var generateTextureBatchBit = require('../../../rendering/high-shader/shader-bits/generateTextureBatchBit.js');
var localUniformBit = require('../../../rendering/high-shader/shader-bits/localUniformBit.js');
var roundPixelsBit = require('../../../rendering/high-shader/shader-bits/roundPixelsBit.js');
var getBatchSamplersUniformGroup = require('../../../rendering/renderers/gl/shader/getBatchSamplersUniformGroup.js');
var Shader = require('../../../rendering/renderers/shared/shader/Shader.js');
var UniformGroup = require('../../../rendering/renderers/shared/shader/UniformGroup.js');
"use strict";
class GlGraphicsAdaptor {
init() {
const uniforms = new UniformGroup.UniformGroup({
uColor: { value: new Float32Array([1, 1, 1, 1]), type: "vec4<f32>" },
uTransformMatrix: { value: new Matrix.Matrix(), type: "mat3x3<f32>" },
uRound: { value: 0, type: "f32" }
});
const maxTextures = maxRecommendedTextures.getMaxTexturesPerBatch();
const glProgram = compileHighShaderToProgram.compileHighShaderGlProgram({
name: "graphics",
bits: [
colorBit.colorBitGl,
generateTextureBatchBit.generateTextureBatchBitGl(maxTextures),
localUniformBit.localUniformBitGl,
roundPixelsBit.roundPixelsBitGl
]
});
this.shader = new Shader.Shader({
glProgram,
resources: {
localUniforms: uniforms,
batchSamplers: getBatchSamplersUniformGroup.getBatchSamplersUniformGroup(maxTextures)
}
});
}
execute(graphicsPipe, renderable) {
const context = renderable.context;
const shader = context.customShader || this.shader;
const renderer = graphicsPipe.renderer;
const contextSystem = renderer.graphicsContext;
const {
batcher,
instructions
} = contextSystem.getContextRenderData(context);
shader.groups[0] = renderer.globalUniforms.bindGroup;
renderer.state.set(graphicsPipe.state);
renderer.shader.bind(shader);
renderer.geometry.bind(batcher.geometry, shader.glProgram);
const batches = instructions.instructions;
for (let i = 0; i < instructions.instructionSize; i++) {
const batch = batches[i];
if (batch.size) {
for (let j = 0; j < batch.textures.count; j++) {
renderer.texture.bind(batch.textures.textures[j], j);
}
renderer.geometry.draw("triangle-list", batch.size, batch.start);
}
}
}
destroy() {
this.shader.destroy(true);
this.shader = null;
}
}
/** @ignore */
GlGraphicsAdaptor.extension = {
type: [
Extensions.ExtensionType.WebGLPipesAdaptor
],
name: "graphics"
};
exports.GlGraphicsAdaptor = GlGraphicsAdaptor;
//# sourceMappingURL=GlGraphicsAdaptor.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,77 @@
import { ExtensionType } from '../../../extensions/Extensions.mjs';
import { Matrix } from '../../../maths/matrix/Matrix.mjs';
import { getMaxTexturesPerBatch } from '../../../rendering/batcher/gl/utils/maxRecommendedTextures.mjs';
import { compileHighShaderGlProgram } from '../../../rendering/high-shader/compileHighShaderToProgram.mjs';
import { colorBitGl } from '../../../rendering/high-shader/shader-bits/colorBit.mjs';
import { generateTextureBatchBitGl } from '../../../rendering/high-shader/shader-bits/generateTextureBatchBit.mjs';
import { localUniformBitGl } from '../../../rendering/high-shader/shader-bits/localUniformBit.mjs';
import { roundPixelsBitGl } from '../../../rendering/high-shader/shader-bits/roundPixelsBit.mjs';
import { getBatchSamplersUniformGroup } from '../../../rendering/renderers/gl/shader/getBatchSamplersUniformGroup.mjs';
import { Shader } from '../../../rendering/renderers/shared/shader/Shader.mjs';
import { UniformGroup } from '../../../rendering/renderers/shared/shader/UniformGroup.mjs';
"use strict";
class GlGraphicsAdaptor {
init() {
const uniforms = new UniformGroup({
uColor: { value: new Float32Array([1, 1, 1, 1]), type: "vec4<f32>" },
uTransformMatrix: { value: new Matrix(), type: "mat3x3<f32>" },
uRound: { value: 0, type: "f32" }
});
const maxTextures = getMaxTexturesPerBatch();
const glProgram = compileHighShaderGlProgram({
name: "graphics",
bits: [
colorBitGl,
generateTextureBatchBitGl(maxTextures),
localUniformBitGl,
roundPixelsBitGl
]
});
this.shader = new Shader({
glProgram,
resources: {
localUniforms: uniforms,
batchSamplers: getBatchSamplersUniformGroup(maxTextures)
}
});
}
execute(graphicsPipe, renderable) {
const context = renderable.context;
const shader = context.customShader || this.shader;
const renderer = graphicsPipe.renderer;
const contextSystem = renderer.graphicsContext;
const {
batcher,
instructions
} = contextSystem.getContextRenderData(context);
shader.groups[0] = renderer.globalUniforms.bindGroup;
renderer.state.set(graphicsPipe.state);
renderer.shader.bind(shader);
renderer.geometry.bind(batcher.geometry, shader.glProgram);
const batches = instructions.instructions;
for (let i = 0; i < instructions.instructionSize; i++) {
const batch = batches[i];
if (batch.size) {
for (let j = 0; j < batch.textures.count; j++) {
renderer.texture.bind(batch.textures.textures[j], j);
}
renderer.geometry.draw("triangle-list", batch.size, batch.start);
}
}
}
destroy() {
this.shader.destroy(true);
this.shader = null;
}
}
/** @ignore */
GlGraphicsAdaptor.extension = {
type: [
ExtensionType.WebGLPipesAdaptor
],
name: "graphics"
};
export { GlGraphicsAdaptor };
//# sourceMappingURL=GlGraphicsAdaptor.mjs.map

File diff suppressed because one or more lines are too long