import { PrimitiveType, PrimitiveTypeName } from '../enums'; import { Buffer, BufferOptions, DepthBuffer, DepthBufferOptions, FrameBufferOptions, ShaderOptions, ShaderProgram, ShaderProgramOptions, Texture, TextureOptions } from '../resources'; import { Color } from '../Color'; import { Device } from '../Device'; import { Model, ModelOptions } from '../model/Model'; import { ShaderEffect, ShaderEffectOptions } from '../ShaderEffect'; import { SpriteBatch } from '../SpriteBatch'; import { BlendStateGL, CullStateGL, DepthStateGL, OffsetStateGL, SamplerStateGL, ScissorStateGL, StencilStateGL, ViewportStateGL } from './states'; import { BufferGL, DepthBufferGL, FrameBufferGL, ShaderGL, ShaderProgramGL, TextureGL } from './resources'; /** * Constructor options for the {@link Device} * * @public */ export interface DeviceGLOptions { /** * Canvas element or selector */ canvas?: string | HTMLCanvasElement; /** * Rendering context or a context type */ context?: 'webgl' | 'webgl2' | 'experimental-webgl' | WebGLRenderingContext | WebGL2RenderingContext; /** * Context attributes */ contextAttributes?: WebGLContextAttributes & { xrCompatible?: boolean; }; } /** * @public */ export declare const DefaultContextAttributes: Readonly; /** * 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 DeviceGL extends Device { /** * The html canvas element * see {@link https://developer.mozilla.org/en/docs/Web/API/HTMLCanvasElement | HTMLCanvasElement} */ canvas: HTMLCanvasElement; /** * The webgl rendering context. * * @remarks * see * {@link https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext | WebGLRenderingContext} * and * {@link https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext | WebGL2RenderingContext} */ context: WebGLRenderingContext | WebGL2RenderingContext; get isWebGL2(): boolean; protected $program: ShaderProgramGL; protected $indexBuffer: BufferGL; protected $vertexBuffer: BufferGL; protected $vertexBuffers: BufferGL[]; protected $cullState: CullStateGL; protected $blendState: BlendStateGL; protected $depthState: DepthStateGL; protected $offsetState: OffsetStateGL; protected $stencilState: StencilStateGL; protected $scissorState: ScissorStateGL; protected $viewportState: ViewportStateGL; protected currentFrameBuffer: FrameBufferGL; protected reusableFrameBuffer: FrameBufferGL; protected reusableFrameBufferOptions: FrameBufferOptions; get backBuffer(): FrameBufferGL; set backBuffer(value: FrameBufferGL); private customFrameBuffer; get driverInfo(): string; /** * Constructs a {@link Device} */ constructor(options?: DeviceGLOptions); /** * 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 a single render target */ setRenderTarget(texture: Texture): void; /** * Sets or un sets multiple render targets */ setRenderTargets(...targets: Texture[]): this; /** * Gets the currently active frame buffer */ get frameBuffer(): FrameBufferGL; /** * Sets and activates a frame buffer as the currently active frame buffer */ set frameBuffer(buffer: FrameBufferGL); /** * 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; /** * 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; /** * Creates a new Buffer of type IndexBuffer. Overrides the type option * before it calls the Buffer constructor with given options. */ createIndexBuffer(options: BufferOptions): BufferGL; /** * Creates a new Buffer of type VertexBuffer. Overrides the type option * before it calls the Buffer constructor with given options. */ createVertexBuffer(options: BufferOptions): BufferGL; /** * Create a new Shader resource */ createShader(options: ShaderOptions): ShaderGL; /** * Creates a new ShaderProgram. Calls the ShaderProgram constructor with given options. */ createProgram(options: ShaderProgramOptions): ShaderProgramGL; /** * Creates a new Texture. Calls the Texture constructor with given options. */ createTexture(options: TextureOptions): TextureGL; /** * 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): TextureGL; /** * Creates a new Texture of type Texture2D. Overrides the type option * before it calls the Texture constructor with given options. */ createTexture2D(options?: TextureOptions): TextureGL; /** * Creates a new Texture of type TextureCube. Overrides the type option * before it calls the Texture constructor with given options. */ createTextureCube(options?: TextureOptions): TextureGL; /** * Creates a new sampler state object */ createSamplerState(options?: { texture?: Texture; }): SamplerStateGL; createDepthBuffer(options: DepthBufferOptions): DepthBufferGL; /** * 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; unsetSamplersUsedAsAttachments(): void; } //# sourceMappingURL=DeviceGL.d.ts.map