/// import { PrimitiveType, PrimitiveTypeName } from '../enums'; import { Buffer, BufferOptions, DepthBufferOptions, ShaderOptions, ShaderProgram, ShaderProgramOptions, Texture, TextureOptions } from '../resources'; import { Color } from '../Color'; import { Device } from '../Device'; import { BufferGPU, DepthBufferGPU, ShaderGPU, ShaderProgramGPU, TextureGPU } from './resources'; import { BlendStateGPU, CullStateGPU, DepthStateGPU, OffsetStateGPU, SamplerStateGPU, ScissorStateGPU, StencilStateGPU, ViewportStateGPU } from './states'; /** * Constructor options for the {@link Device} * * @public */ export interface DeviceGPUOptions { /** * Canvas element or selector */ canvas?: string | HTMLCanvasElement; /** * Rendering context or a context type */ context?: 'gpu'; } /** * Describes the Graphics Device * * @remarks * The {@link Device} class ties all concepts of the Graphics package together. * It's a central component for rendering geometries. It holds system state variables and * is able to create resources such as buffers, shaders, textures and render targets. * * @public */ export declare class DeviceGPU extends Device { /** * The html canvas element * see {@link https://developer.mozilla.org/en/docs/Web/API/HTMLCanvasElement | HTMLCanvasElement} */ readonly canvas: HTMLCanvasElement; /** * The webgpu rendering context. */ readonly context: GPUCanvasContext; private readonly initPromise; /** * The web gpu api */ readonly device: GPUDevice; readonly adapter: GPUAdapter; readonly swapChain: GPUSwapChain; readonly msaaSampleCount = 4; protected $indexBuffer: BufferGPU; protected $vertexBuffer: BufferGPU; protected $vertexBuffers: BufferGPU[]; protected $program: ShaderProgramGPU; protected $cullState: CullStateGPU; protected $blendState: BlendStateGPU; protected $depthState: DepthStateGPU; protected $offsetState: OffsetStateGPU; protected $stencilState: StencilStateGPU; protected $scissorState: ScissorStateGPU; protected $viewportState: ViewportStateGPU; private renderCommandEncoder; private renderPassEncoder; private renderBundleEncoder; private get renderEncoder(); private commandBuffers; readonly mainTextureFormat: GPUTextureFormat; readonly mainTexture: TextureGPU; readonly mainDepthFormat: GPUTextureFormat; readonly mainDepth: DepthBufferGPU; private frameBuffer; private frameBufferOptions; /** * Constructs a {@link Device} */ constructor(options?: DeviceGPUOptions); init(): Promise; begin(): void; flush(): void; /** * Clears the color, depth and stencil buffers */ clear(color?: number | number[] | Color, depth?: number, stencil?: number): this; /** * Renders geometry using the current index buffer, indexing vertices of current vertex buffer. */ drawIndexedPrimitives(primitiveType?: PrimitiveType | PrimitiveTypeName, elementOffset?: number, elementCount?: number): this; /** * Renders multiple instances of the same geometry defined by current index buffer, indexing vertices in current vertex buffer. */ drawInstancedPrimitives(instanceCount?: number, primitiveType?: PrimitiveType | PrimitiveTypeName, offset?: number, count?: number): this; /** * Renders geometry defined by current vertex buffer and the given primitive type. */ drawPrimitives(primitiveType?: PrimitiveType | PrimitiveTypeName, offset?: number, count?: number): this; /** * If the display size of the canvas is controlled with CSS this will resize the * canvas to match the CSS dimensions in order to avoid stretched and blurry image. * * @param ratio - The pixel ratio for retina displays */ resize(pixelRatio?: number): this; reset(): this; /** * Sets or un sets multiple render targets */ setRenderTargets(...targets: Texture[]): this; /** * Sets multiple vertex buffers * * @remarks * Restricts the `vertexBuffer` property to only this set of buffers. */ set vertexBuffers(buffer: Buffer[]); /** * Gets the currently active vertex buffer */ get vertexBuffer(): Buffer; /** * Sets and activates a buffer as the currently active vertex buffer */ set vertexBuffer(buffer: Buffer); /** * Gets the currently active index buffer */ get indexBuffer(): Buffer; /** * Sets and activates a buffer as the currently active index buffer */ set indexBuffer(buffer: Buffer); /** * Gets the currently active shader program */ get program(): ShaderProgram; /** * Sets and activates a program as the currently active program */ set program(program: ShaderProgram); /** * Gets the current width of the drawing buffer */ get drawingBufferWidth(): number; /** * Gets the current height of the drawing buffer */ get drawingBufferHeight(): number; /** * Gets the aspect ratio of the drawing buffer */ get drawingBufferAspectRatio(): number; /** * Creates a new Buffer of type IndexBuffer. Overrides the type option * before it calls the Buffer constructor with given options. */ createIndexBuffer(options: BufferOptions): BufferGPU; /** * Creates a new Buffer of type VertexBuffer. Overrides the type option * before it calls the Buffer constructor with given options. */ createVertexBuffer(options: BufferOptions): BufferGPU; /** * Create a new Shader resource */ createShader(options: ShaderOptions): ShaderGPU; /** * Creates a new ShaderProgram. Calls the ShaderProgram constructor with given options. */ createProgram(options: ShaderProgramOptions): ShaderProgramGPU; /** * Creates a new Texture. Calls the Texture constructor with given options. */ createTexture(options: TextureOptions): TextureGPU; /** * Creates a new Texture that can be used as a render target. Ensures that * the depthFormat option is set and calls the Texture constructor. */ createRenderTarget(options: TextureOptions): TextureGPU; /** * Creates a new Texture of type Texture2D. Overrides the type option * before it calls the Texture constructor with given options. */ createTexture2D(options?: TextureOptions): TextureGPU; /** * Creates a new Texture of type TextureCube. Overrides the type option * before it calls the Texture constructor with given options. */ createTextureCube(options?: TextureOptions): TextureGPU; /** * Creates a new sampler state object */ createSamplerState(options?: { texture?: Texture; }): SamplerStateGPU; createDepthBuffer(options: DepthBufferOptions): DepthBufferGPU; } //# sourceMappingURL=DeviceGPU.d.ts.map