@tolokoban/tgd
Version:
ToloGameDev library for WebGL2
75 lines • 3.62 kB
TypeScript
import type { TgdContext } from "../context";
import { TgdDataset, type TgdDatasetOptions, type TgdDatasetType } from "../dataset";
import { type TgdCodeBloc, type TgdCodeFunctions, type TgdCodeVariables } from "../shader";
import type { TgdTypeArrayForElements, WebglAttributeType } from "../types";
import type { TgdPainterFunction } from "../types/painter";
import { TgdTexture2D, TgdTextureCube } from "@tolokoban/tgd";
import { TgdUniformBufferObject, type TgdUniformBufferObjectOptions } from "./../uniform/uniform-buffer-object";
import { TgdPainter } from "./painter";
import { type TgdPainterStateOptions } from "./state";
interface DatasetOptions extends Partial<Omit<TgdDatasetOptions, "data" | "buffer">> {
attribs: Record<string, {
type: TgdDatasetType;
data: ArrayBuffer | Int8Array | Uint8Array | Int16Array | Uint16Array | Uint32Array | Float32Array | {
buffer: ArrayBuffer;
};
}>;
}
export interface TgdPainterProgramOptions {
drawMode: "POINTS" | "LINE_STRIP" | "LINE_LOOP" | "LINES" | "TRIANGLE_STRIP" | "TRIANGLE_FAN" | "TRIANGLES" | WebGL2RenderingContext["POINTS"] | WebGL2RenderingContext["LINE_STRIP"] | WebGL2RenderingContext["LINE_LOOP"] | WebGL2RenderingContext["LINES"] | WebGL2RenderingContext["TRIANGLE_STRIP"] | WebGL2RenderingContext["TRIANGLE_FAN"] | WebGL2RenderingContext["TRIANGLES"];
uniforms?: Record<string, TgdUniformBufferObject | Omit<TgdUniformBufferObjectOptions, "bindingPoint">>;
textures?: Record<string, TgdTexture2D | TgdTextureCube>;
dataset: TgdDataset | DatasetOptions | (TgdDataset | DatasetOptions)[];
varying?: TgdCodeVariables<WebglAttributeType>;
vert: Partial<{
precision: "lowp" | "mediump" | "highp";
functions: TgdCodeFunctions;
mainCode: TgdCodeBloc;
header: TgdCodeBloc;
}>;
frag: Partial<{
precision: "lowp" | "mediump" | "highp";
outputs: TgdCodeVariables<WebglAttributeType>;
functions: TgdCodeFunctions | TgdCodeBloc;
mainCode: TgdCodeBloc;
header: TgdCodeBloc;
}>;
elements?: TgdTypeArrayForElements;
state?: Partial<Omit<TgdPainterStateOptions, "children">>;
elementsCount?: number;
elementsOffset?: number;
instancesCount?: number;
onEnter?: TgdPainterFunction;
onDelete?: () => void;
}
export declare class TgdPainterProgram extends TgdPainter {
readonly context: TgdContext;
elementsCount: number;
elementsOffset: number;
instancesCount: number;
readonly textures: Record<string, TgdTexture2D | TgdTextureCube>;
private readonly uniformBlocks;
private readonly uniformBlocksToDelete;
private readonly prg;
private readonly vao;
private readonly drawMode;
private readonly painterState;
private readonly hasElements;
private readonly elementsType;
private readonly onEnter?;
private readonly onDelete?;
constructor(context: TgdContext, { onEnter, onDelete, uniforms, textures, varying, vert, frag, dataset, elements, drawMode, state, elementsCount, elementsOffset, instancesCount, }: TgdPainterProgramOptions);
setElements(elements: number[]): void;
/**
* Update the values of an attribute of a dataset and resolve the counts.
*/
setAttributeValues(dataset: TgdDataset, attribName: string, values: Float32Array): number | undefined;
delete(): void;
paint(time: number, delta: number): void;
debug(caption?: string): void;
private readonly internalPaint;
private uniformsToCode;
private resolveUniformBlock;
}
export {};
//# sourceMappingURL=program.d.ts.map