Skip to content

Commit

Permalink
PIXI Web GL (#2476)
Browse files Browse the repository at this point in the history
Add PIXI Web GL
  • Loading branch information
JPMeehan authored Dec 29, 2023
1 parent ddfdde4 commit 0e01b79
Show file tree
Hide file tree
Showing 38 changed files with 3,040 additions and 759 deletions.
3 changes: 1 addition & 2 deletions src/foundry/client/pixi/core/containers/quadtree.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ declare global {
* A subclass of Quadtree specifically intended for classifying the location of objects on the game canvas.
*/
class CanvasQuadtree extends Quadtree<object> {
// @ts-expect-error Override monkeypatch executed in class constructor
get bounds(): SceneDimensions["rect"];
readonly bounds: SceneDimensions["rect"];
}

namespace Quadtree {
Expand Down
66 changes: 0 additions & 66 deletions src/foundry/client/pixi/webgl/base.d.ts

This file was deleted.

60 changes: 60 additions & 0 deletions src/foundry/client/pixi/webgl/extensions/batch-renderer.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
export {};

declare global {
/**
* A batch renderer with a customizable data transfer function to packed geometries.
*/
class BatchRenderer extends PIXI.BatchRenderer {
/**
* The PackInterleavedGeometry function provided by the sampler.
*/
protected _packInterleavedGeometry: (
element: PIXI.IBatchableElement,
attributeBuffer: PIXI.ViewableBuffer,
indexBuffer: Uint16Array,
aIndex: number,
iIndex: number,
) => void;

/**
* The preRender function provided by the sampler and that is called just before a flush.
*/
protected _preRenderBatch: (...args: any[]) => void;

get uniforms(): AbstractBaseShader.Uniforms;

/**
* The number of reserved texture units that the shader generator should not use (maximum 4).
*/
protected set reservedTextureUnits(val: number);

/**
* Number of reserved texture units reserved by the batch shader that cannot be used by the batch renderer.
*/
get reservedTextureUnits(): number;

/**
* This override allows to allocate a given number of texture units reserved for a custom batched shader.
* These reserved texture units won't be used to batch textures for PIXI.Sprite or SpriteMesh.
* @override
*/
override contextChange(): void;

override start(): void;

override packInterleavedGeometry(
element: PIXI.IBatchableElement,
attributeBuffer: PIXI.ViewableBuffer,
indexBuffer: Uint16Array,
aIndex: number,
iIndex: number,
): void;

/**
* Verify if a PIXI plugin exists. Check by name.
* @param name - The name of the pixi plugin to check.
* @returns True if the plugin exists, false otherwise.
*/
static hasPlugin(name: string): boolean;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export {};

declare global {
/**
* A batch shader generator that could handle extra uniforms during initialization.
*/
class BatchShaderGenerator extends PIXI.BatchShaderGenerator {
constructor(
vertexSrc: string,
fragTemplate: string,
batchDefaultUniforms?: (maxTextures: AbstractBaseShader.UniformValue) => AbstractBaseShader.Uniforms,
);

/**
* Extra uniforms that could be handled by a custom batch shader.
*/
_batchDefaultUniforms: ((maxTextures: AbstractBaseShader.UniformValue) => AbstractBaseShader.Uniforms) | undefined;

override generateShader(maxTextures: number): PIXI.Shader;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,20 @@ declare const BLEND_MODES: {
* ```
*/
MIN_COLOR: [GLenum, GLenum, GLenum, GLenum, GLenum, GLenum];

/**
* A custom blend mode equation which chooses the minimum color for color channels and min alpha from alpha channel.
* @defaultValue
* ```typescript
* [
* WebGL2RenderingContext.ONE,
* WebGL2RenderingContext.ONE,
* WebGL2RenderingContext.ONE,
* WebGL2RenderingContext.ONE,
* WebGL2RenderingContext.MIN,
* WebGL2RenderingContext.MIN,
* ]
* ```
*/
MIN_ALL: [GLenum, GLenum, GLenum, GLenum, GLenum, GLenum];
};
3 changes: 3 additions & 0 deletions src/foundry/client/pixi/webgl/extensions/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "./batch-renderer";
import "./batch-shader-generator";
import "./blend-modes";
182 changes: 0 additions & 182 deletions src/foundry/client/pixi/webgl/filters.d.ts

This file was deleted.

22 changes: 22 additions & 0 deletions src/foundry/client/pixi/webgl/helpers/framebugger-snapshot.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export {};

declare global {
/**
* Provide the necessary methods to get a snapshot of the framebuffer into a render texture.
* Class meant to be used as a singleton.
* Created with the precious advices of dev7355608.
*/
class FramebufferSnapshot {
/**
* The RenderTexture that is the render destination for the framebuffer snapshot.
*/
framebufferTexture: PIXI.RenderTexture;

/**
* Get the framebuffer texture snapshot.
* @param renderer - The renderer for this context.
* @returns The framebuffer snapshot.
*/
getFramebufferTexture(renderer: PIXI.Renderer): PIXI.RenderTexture;
}
}
3 changes: 3 additions & 0 deletions src/foundry/client/pixi/webgl/helpers/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "./framebugger-snapshot";
import "./smooth-noise";
import "./texture-extractor";
Loading

0 comments on commit 0e01b79

Please sign in to comment.