import { PrimitiveType, PrimitiveTypeName } from './enums'; import { Buffer, BufferOptions, DepthBuffer, DepthBufferOptions, Shader, ShaderOptions, ShaderProgram, ShaderProgramOptions, Texture, TextureOptions } from './resources'; import { BlendState, BlendStateParams, CullState, CullStateParams, DepthState, DepthStateParams, OffsetState, OffsetStateParams, SamplerState, ScissorState, ScissorStateParams, StencilState, StencilStateParams, TextureUnitState, VertexAttribArrayState, ViewportState, ViewportStateParams } from './states'; import { Capabilities } from './Capabilities'; import { Color } from './Color'; import { Model, ModelOptions } from './model/Model'; import { ShaderEffect, ShaderEffectOptions } from './ShaderEffect'; import { SpriteBatch } from './SpriteBatch'; /** * 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 abstract class Device { /** * The html canvas element * see {@link https://developer.mozilla.org/en/docs/Web/API/HTMLCanvasElement | HTMLCanvasElement} */ readonly canvas: HTMLCanvasElement; /** * The rendering context. */ readonly context: T; /** * A collection of capabilities of the currently running graphics unit. */ capabilities: Capabilities; /** * Collection of assigned textures * * @remarks * The number of texture units is limited by {@link Capabilities.maxTextureUnits} */ readonly textures: Texture[]; /** * Collection of {@link SamplerState}. * * @remarks * The number of sampler states is limited by {@link Capabilities.maxTextureUnits} */ readonly textureUnits: TextureUnitState[]; /** * Gets a copy of the cull state parameters * Updates the cull state parameters and commits the state to the GPU */ get cullState(): CullStateParams; set cullState(v: CullStateParams); /** * Gets a copy of the blend state parameters. * Updates the blend state parameters and commits the state to the GPU. */ get blendState(): BlendStateParams; set blendState(v: BlendStateParams); /** * Gets a copy of the depth state parameters * Updates the depth state parameters and commits the state to the GPU */ get depthState(): DepthStateParams; set depthState(v: DepthStateParams); /** * Gets a copy of the offset state parameters * Updates the offset state parameters and commits the state to the GPU */ get offsetState(): OffsetStateParams; set offsetState(v: OffsetStateParams); /** * Gets a copy of the stencil state parameters * Updates the stencil state parameters and commits the state to the GPU */ get stencilState(): StencilStateParams; set stencilState(v: StencilStateParams); /** * Gets a copy of the scissor state parameters * Updates the scissor state parameters and commits the state to the GPU */ get scissorState(): ScissorStateParams; set scissorState(v: ScissorStateParams); /** * Gets a copy of the viewport state parameters * Updates the viewport state parameters and commits the state to the GPU */ get viewportState(): ViewportStateParams; set viewportState(v: ViewportStateParams); get defaultTexture(): Texture; protected abstract $indexBuffer: Buffer; protected abstract $vertexBuffer: Buffer; protected abstract $vertexBuffers: Buffer[]; protected abstract $program: ShaderProgram; protected abstract $cullState: CullState; protected abstract $blendState: BlendState; protected abstract $depthState: DepthState; protected abstract $offsetState: OffsetState; protected abstract $stencilState: StencilState; protected abstract $scissorState: ScissorState; protected abstract $viewportState: ViewportState; protected quadIndexBuffer: Buffer; protected quadVertexBuffer: Buffer; protected quadVertexBufferFlipped: Buffer; protected $vertexAttribArrayState: VertexAttribArrayState; protected registeredDepthBuffers: DepthBuffer[]; protected defaultTextureInstance: Texture; get driverInfo(): string; init(): Promise; /** * Clears the color, depth and stencil buffers */ abstract clear(color?: number | number[] | Color, depth?: number, stencil?: number): this; /** * Renders geometry using the current index buffer, indexing vertices of current vertex buffer. */ abstract drawIndexedPrimitives(primitiveType?: PrimitiveType | PrimitiveTypeName, elementOffset?: number, elementCount?: number): this; abstract drawInstancedPrimitives(instanceCount?: number, primitiveType?: PrimitiveType | PrimitiveTypeName, offset?: number, count?: number): this; /** * Renders geometry defined by current vertex buffer and the given primitive type. */ abstract drawPrimitives(primitiveType?: PrimitiveType | PrimitiveTypeName, offset?: number, count?: number): this; /** * Draws a full screen quad with the [0,0] texture coordinate starting at the bottom left. * @param flipY - if true, then the [0,0] texture coordinate starts in the top left. * */ drawQuad(flipY?: boolean): 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 */ abstract resize(pixelRatio?: number): this; /** * */ abstract reset(): this; /** * Sets or un sets a single render target */ setRenderTarget(texture: Texture): void; /** * Sets or un sets multiple render targets */ abstract 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 */ abstract get vertexBuffer(): Buffer; /** * Sets and activates a buffer as the currently active vertex buffer */ abstract set vertexBuffer(buffer: Buffer); /** * Gets the currently active index buffer */ abstract get indexBuffer(): Buffer; /** * Sets and activates a buffer as the currently active index buffer */ abstract set indexBuffer(buffer: Buffer); /** * Gets the currently active shader program */ abstract get program(): ShaderProgram; /** * Sets and activates a program as the currently active program */ abstract set program(program: ShaderProgram); /** * Gets the current width of the drawing buffer */ abstract get drawingBufferWidth(): number; /** * Gets the current height of the drawing buffer */ abstract get drawingBufferHeight(): number; /** * Gets the aspect ratio of the drawing buffer */ abstract get drawingBufferAspectRatio(): number; /** * Creates a new Buffer of type IndexBuffer. Overrides the type option * before it calls the Buffer constructor with given options. */ abstract createIndexBuffer(options: BufferOptions): Buffer; /** * Creates a new Buffer of type VertexBuffer. Overrides the type option * before it calls the Buffer constructor with given options. */ abstract createVertexBuffer(options: BufferOptions): Buffer; /** * Creates a new Shader */ abstract createShader(options: ShaderOptions): Shader; /** * */ createVertexShader(options?: Partial): Shader; /** * */ createFragmentShader(options?: Partial): Shader; /** * Creates a new ShaderProgram. Calls the ShaderProgram constructor with given options. */ abstract createProgram(options: ShaderProgramOptions): ShaderProgram; /** * Creates a new Texture. Calls the Texture constructor with given options. */ abstract createTexture(options?: TextureOptions): Texture; /** * Creates a new Texture that can be used as a render target. Ensures that * the depthFormat option is set and calls the Texture constructor. */ abstract createRenderTarget(options?: TextureOptions): Texture; /** * Creates a new Texture of type Texture2D. Overrides the type option * before it calls the Texture constructor with given options. */ abstract createTexture2D(options?: TextureOptions): Texture; /** * Creates a new Texture of type TextureCube. Overrides the type option * before it calls the Texture constructor with given options. */ abstract createTextureCube(options?: TextureOptions): Texture; /** * Creates a new sampler state object */ abstract createSamplerState(options?: { texture?: Texture; }): SamplerState; /** * Creates a depth buffer */ abstract createDepthBuffer(options: DepthBufferOptions): DepthBuffer; /** * Creates a new sprite batch. */ createSpriteBatch(): SpriteBatch; /** * Creates a vertex layout object from name */ createVertexLayout(name: string): any; /** * Creates a new model. Calls the model constructor with given options. */ createModel(options: ModelOptions): Model; createEffect(options: ShaderEffectOptions): ShaderEffect; /** * used internally when a depth buffer is created * * @internal */ registerDepthBuffer(buffer: DepthBuffer): void; /** * used internally when a depth buffer is destroyed * * @internal */ unregisterDepthBuffer(buffer: DepthBuffer): void; getSharedDepthBuffer(options: DepthBufferOptions): DepthBuffer; protected convertShaderOption(input: string | S): string | S; protected set(key: K, value: this[K]): void; } //# sourceMappingURL=Device.d.ts.map