Documentation / device / AbstractDevice
Interface: AbstractDevice
Defined in: libs/device/src/base_types.ts:2502
Abstract interface for the rendering device.
Extends
IEventTarget<DeviceEventMap>
Properties
[EventMapType]?
readonlyoptional[EventMapType]?:DeviceEventMap
Defined in: libs/base/dist/index.d.ts:585
Type-only event map marker.
Inherited from
IEventTarget.[EventMapType]
pool
pool:
Pool
Defined in: libs/device/src/base_types.ts:2504
Get pool object
vSync
vSync:
boolean
Defined in: libs/device/src/base_types.ts:2506
vSync
fixedFrameTime
fixedFrameTime:
number
Defined in: libs/device/src/base_types.ts:2511
The fixed per-frame time step in milliseconds, or null when using wall-clock timing. See AbstractDevice.setFixedFrameTime.
clipSpaceZeroToOne
readonlyclipSpaceZeroToOne:boolean
Defined in: libs/device/src/base_types.ts:2555
True if the device clip space maps depth to [0, 1] (zero-to-one).
Always true on WebGPU. On WebGL this becomes true when the engine runs with the reverse-Z convention and the EXT_clip_control extension has been activated; otherwise the clip space is GL style [-1, 1].
videoMemoryUsage
videoMemoryUsage:
number
Defined in: libs/device/src/base_types.ts:2983
Get the video memory usage in bytes
frameInfo
frameInfo:
FrameInfo
Defined in: libs/device/src/base_types.ts:2985
Get the current frame information
isRendering
isRendering:
boolean
Defined in: libs/device/src/base_types.ts:2987
Check if the device is running a rendering loop by calling AbstractDevice.runLoop
canvas
canvas:
HTMLCanvasElement
Defined in: libs/device/src/base_types.ts:2989
Get the canvas element for this device
type
type:
string
Defined in: libs/device/src/base_types.ts:2991
Get the device type
programBuilder
programBuilder:
ProgramBuilder
Defined in: libs/device/src/base_types.ts:2993
Get the program builder
runLoopFunction
runLoopFunction: (
device) =>void
Defined in: libs/device/src/base_types.ts:2995
Get the run loop callback function
Parameters
device
AbstractDevice
Returns
void
Methods
on()
on<
K>(type,listener,context?):void
Defined in: libs/base/dist/index.d.ts:592
Sets up a function that will be called whenever the specified event is delivered to the target
Type Parameters
K
K extends keyof DeviceEventMap
Parameters
type
K
The event type to listen for
listener
EventListener<DeviceEventMap, K>
The callback function
context?
unknown
Context object of the listener function
Returns
void
Inherited from
IEventTarget.on
once()
once<
K>(type,listener,context?):void
Defined in: libs/base/dist/index.d.ts:599
Sets up a function that will be called only once when the specified event is delivered to the target
Type Parameters
K
K extends keyof DeviceEventMap
Parameters
type
K
The event type to listen for
listener
EventListener<DeviceEventMap, K>
The callback function
context?
unknown
Context object of the listener function
Returns
void
Inherited from
IEventTarget.once
off()
off<
K>(type,listener?,context?):void
Defined in: libs/base/dist/index.d.ts:605
Removes an event listener function previously registered.
Type Parameters
K
K extends keyof DeviceEventMap
Parameters
type
K
The event type for which to remove an event listener
listener?
EventListener<DeviceEventMap>
The callback function to be removed
context?
unknown
Returns
void
Inherited from
IEventTarget.off
dispatchEvent()
dispatchEvent<
K>(type, ...args):void
Defined in: libs/base/dist/index.d.ts:611
Synchronously invoke the affected event listeners with an event object
Type Parameters
K
K extends keyof DeviceEventMap
Parameters
type
K
args
...DeviceEventMap[K]
Returns
void
false if the event was canceled, otherwise true
Inherited from
IEventTarget.dispatchEvent
setFixedFrameTime()
setFixedFrameTime(
ms):void
Defined in: libs/device/src/base_types.ts:2523
Sets a fixed per-frame time step in milliseconds for deterministic playback, or null to restore wall-clock timing. Default is null.
Parameters
ms
number
Fixed frame time in milliseconds, or null to disable.
Returns
void
Remarks
Affects frameInfo.elapsedFrame/elapsedOverall/frameTimestamp only; frame scheduling is unchanged. While enabled, FPS and CPU time statistics are derived from the synthetic clock and no longer reflect wall-clock time.
poolExists()
poolExists(
key):boolean
Defined in: libs/device/src/base_types.ts:2525
Check if a pool with given key exists
Parameters
key
string | symbol
Returns
boolean
getPool()
getPool(
key):Pool
Defined in: libs/device/src/base_types.ts:2527
Get the pool with given key, or create a new one if not exists
Parameters
key
string | symbol
Returns
getAdapterInfo()
getAdapterInfo():
any
Defined in: libs/device/src/base_types.ts:2529
Get adapter information
Returns
any
getFrameBufferSampleCount()
getFrameBufferSampleCount():
number
Defined in: libs/device/src/base_types.ts:2531
Get sample count of current frame buffer
Returns
number
isContextLost()
isContextLost():
boolean
Defined in: libs/device/src/base_types.ts:2533
Returns true if device context is lost.
Returns
boolean
getScaleX()
getScaleX():
number
Defined in: libs/device/src/base_types.ts:2535
Get the value of device pixel ratio in X axis
Returns
number
getScaleY()
getScaleY():
number
Defined in: libs/device/src/base_types.ts:2537
Get the value of device pixel ratio in Y axis
Returns
number
getDrawingBufferWidth()
getDrawingBufferWidth():
number
Defined in: libs/device/src/base_types.ts:2539
Get the width of current frame buffer
Returns
number
getDrawingBufferHeight()
getDrawingBufferHeight():
number
Defined in: libs/device/src/base_types.ts:2541
Get the height of current frame buffer
Returns
number
getBackBufferWidth()
getBackBufferWidth():
number
Defined in: libs/device/src/base_types.ts:2543
Get the width of back buffer
Returns
number
getBackBufferHeight()
getBackBufferHeight():
number
Defined in: libs/device/src/base_types.ts:2545
Get the height of back buffer
Returns
number
getDeviceCaps()
getDeviceCaps():
Immutable<DeviceCaps>
Defined in: libs/device/src/base_types.ts:2547
Get the device capabilities
Returns
Immutable<DeviceCaps>
nextFrame()
nextFrame(
callback):number
Defined in: libs/device/src/base_types.ts:2557
Schedule next frame
Parameters
callback
() => void
Returns
number
cancelNextFrame()
cancelNextFrame(
handle):void
Defined in: libs/device/src/base_types.ts:2559
Cancel schedule next frame
Parameters
handle
number
Returns
void
setFont()
setFont(
fontName):void
Defined in: libs/device/src/base_types.ts:2561
Set font for drawText function
Parameters
fontName
string
Returns
void
setTextRenderStates()
setTextRenderStates(
states):void
Defined in: libs/device/src/base_types.ts:2563
Set render states to be used when drawing text. If not set, default states will be used.
Parameters
states
Returns
void
drawText()
Call Signature
drawText(
text,x,y,color):void
Defined in: libs/device/src/base_types.ts:2571
Draw a string
Parameters
text
string
The string that will be drawn
x
number
x coordinate in pixels related to the viewport origin
y
number
y coordinate in pixels related to the viewport origin
color
string | Vector4 | Vector3
A CSS color value
Returns
void
Call Signature
drawText(
text,rect,color,options?):void
Defined in: libs/device/src/base_types.ts:2579
Draw a string inside a rectangle with layout and clipping
Parameters
text
string
The string that will be drawn
rect
Immutable<Rect>
Layout rectangle in pixels related to the viewport origin
color
string | Vector4 | Vector3
A CSS color value
options?
Text layout options
Returns
void
clearFrameBuffer()
clearFrameBuffer(
clearColor,clearDepth,clearStencil):void
Defined in: libs/device/src/base_types.ts:2604
Clears the current frame buffer.
Parameters
clearColor
Vector4 | readonly Vector4[]
Color clear value, per-target color clear values, or null to skip color clears.
clearDepth
number
If not null, the depth buffer will be cleared to this value.
clearStencil
number
If not null, the stencil buffer will be cleared to this value.
Returns
void
Remarks
Color, depth and stencil clears are independent. Passing null or undefined for one component leaves that component unchanged.
For color clears, a single Vector4 clears every current color target to the same value. Passing an array switches to per-target behavior: array element i clears color target i, and a null, undefined or missing element skips that target. Therefore [color] is equivalent to color only when the current frame buffer has exactly one color target. If the array contains more entries than the current color target count, the extra entries are ignored after reporting an error.
createGPUTimer()
createGPUTimer():
ITimer
Defined in: libs/device/src/base_types.ts:2610
Creates a GPU timer
Returns
beginTimestampQuery()
beginTimestampQuery(
label?,options?):number
Defined in: libs/device/src/base_types.ts:2617
Begin a GPU timestamp query scope.
Parameters
label?
string
options?
Returns
number
Remarks
The returned id is the only unique handle. Labels are only for grouping/debugging.
endTimestampQuery()
endTimestampQuery(
id):void
Defined in: libs/device/src/base_types.ts:2619
End a GPU timestamp query scope.
Parameters
id
number
Returns
void
pollTimestampQuery()
pollTimestampQuery(
query):TimestampQueryResult
Defined in: libs/device/src/base_types.ts:2626
Poll a timestamp query result. Returns null when the query is still pending.
Parameters
query
Returns
Remarks
Passing a numeric id is unambiguous. Passing a label resolves the latest matching scope.
resolveTimestampQuery()
resolveTimestampQuery(
query):Promise<TimestampQueryResult>
Defined in: libs/device/src/base_types.ts:2628
Resolve a timestamp query result asynchronously.
Parameters
query
Returns
Promise<TimestampQueryResult>
collectTimestampQueries()
collectTimestampQueries(
filter?):TimestampQueryResult[]
Defined in: libs/device/src/base_types.ts:2630
Collect resolved timestamp query results.
Parameters
filter?
Returns
createRenderStateSet()
createRenderStateSet():
RenderStateSet
Defined in: libs/device/src/base_types.ts:2632
Creates a render state set object
Returns
createBlendingState()
createBlendingState():
BlendingState
Defined in: libs/device/src/base_types.ts:2634
Creates a blending state object
Returns
createColorState()
createColorState():
ColorState
Defined in: libs/device/src/base_types.ts:2636
Creates a color state object
Returns
createRasterizerState()
createRasterizerState():
RasterizerState
Defined in: libs/device/src/base_types.ts:2638
Creates a rasterizer state object
Returns
createDepthState()
createDepthState():
DepthState
Defined in: libs/device/src/base_types.ts:2640
Creates a depth state object
Returns
createStencilState()
createStencilState():
StencilState
Defined in: libs/device/src/base_types.ts:2642
Creates a stencil state object
Returns
createSampler()
createSampler(
options):TextureSampler
Defined in: libs/device/src/base_types.ts:2648
Creates a texture sampler object
Parameters
options
The creation options
Returns
The created texture sampler
createTextureFromMipmapData()
createTextureFromMipmapData<
T>(data,sRGB,options?):T
Defined in: libs/device/src/base_types.ts:2655
Creates a texture from given mipmap data
Type Parameters
T
T extends BaseTexture<unknown> = BaseTexture<unknown>
Parameters
data
Mipmap data
sRGB
boolean
options?
Texture creation options
Returns
T
The created texture
createTexture2D()
createTexture2D(
format,width,height,options?):Texture2D<unknown>
Defined in: libs/device/src/base_types.ts:2668
Creates a 2d texture
Parameters
format
The texture format
width
number
Pixel width of the texture
height
number
Pixel height of the texture
options?
The creation options
Returns
Texture2D<unknown>
The created 2D texture
createTexture2DFromImage()
createTexture2DFromImage(
element,sRGB,options?):Texture2D<unknown>
Defined in: libs/device/src/base_types.ts:2680
Creates a 2d texture from a image element
Parameters
element
The image element
sRGB
boolean
options?
The creation options
Returns
Texture2D<unknown>
The created 2D texture.
createTexture2DArray()
createTexture2DArray(
format,width,height,depth,options?):Texture2DArray<unknown>
Defined in: libs/device/src/base_types.ts:2694
Creates a 2d array texture
Parameters
format
The texture format
width
number
Pixel width of the texture
height
number
Pixel height of the texture
depth
number
Array length of the texture
options?
The creation options
Returns
Texture2DArray<unknown>
The created 2D array texture.
createTexture2DArrayFromImages()
createTexture2DArrayFromImages(
elements,sRGB,options?):Texture2DArray<unknown>
Defined in: libs/device/src/base_types.ts:2708
Creates a 2d array texture from a seris of image elements
Parameters
elements
image elements
sRGB
boolean
options?
The creation options
Returns
Texture2DArray<unknown>
The created 2D array texture.
Remarks
image elements must have the same size.
createTexture3D()
createTexture3D(
format,width,height,depth,options?):Texture3D<unknown>
Defined in: libs/device/src/base_types.ts:2722
Creates a 3D texture
Parameters
format
The texture format
width
number
Pixel width of the texture
height
number
Pixel height of the texture
depth
number
Pixel depth of the texture
options?
The creation options
Returns
Texture3D<unknown>
The created 3D texture.
createCubeTexture()
createCubeTexture(
format,size,options?):TextureCube<unknown>
Defined in: libs/device/src/base_types.ts:2736
Creates a cube texture
Parameters
format
The texture format
size
number
Pixel width of the texture
options?
The creation options
Returns
TextureCube<unknown>
The created cube texture.
createTextureVideo()
createTextureVideo(
el,samplerOptions?):TextureVideo
Defined in: libs/device/src/base_types.ts:2746
Creates a video texture from a video element
Parameters
el
HTMLVideoElement
The video element
samplerOptions?
Returns
The created video texture.
copyTexture2D()
copyTexture2D(
src,srcLevel,dst,dstLevel):void
Defined in: libs/device/src/base_types.ts:2758
Copies a 2d texture to another texture.
Parameters
src
Texture that will be copied from.
srcLevel
number
Which mipmap level to be copied from.
dst
Texture that will be copied to.
dstLevel
number
Which mipmap level to be copied to.
Returns
void
Remarks
The two textures must have the same size and format
copyFramebufferToTexture2D()
copyFramebufferToTexture2D(
src,index,dst,level):void
Defined in: libs/device/src/base_types.ts:2770
Copies a color attachment of a framebuffer to a mipmap level of a texture.
Parameters
src
Framebuffer that will be copied from.
index
number
Color attachment index of the framebuffer.
dst
Texture that will be copied to.
level
number
Which mipmap level should be copied to.
Returns
void
Remarks
The color attachment and the mipmap level must have the same size and format
reverseVertexWindingOrder()
reverseVertexWindingOrder(
reverse):void
Defined in: libs/device/src/base_types.ts:2779
Set wether to reverse the winding order
Parameters
reverse
boolean
true if the winding order should be reversed.
Returns
void
Remarks
The default winding order is counter-clockwise.
isWindingOrderReversed()
isWindingOrderReversed():
boolean
Defined in: libs/device/src/base_types.ts:2783
Check if the current winding order is reversed.
Returns
boolean
createGPUProgram()
createGPUProgram(
params):GPUProgram
Defined in: libs/device/src/base_types.ts:2789
Creates a gpu program
Parameters
params
The creation options
Returns
The created program.
createBindGroup()
createBindGroup(
layout):BindGroup
Defined in: libs/device/src/base_types.ts:2795
Creates a bind group
Parameters
layout
Immutable<BindGroupLayout>
Layout of the bind group
Returns
The created bind group.
createBuffer()
createBuffer(
sizeInBytes,options):GPUDataBuffer
Defined in: libs/device/src/base_types.ts:2802
Creates a gpu buffer
Parameters
sizeInBytes
number
Size of the buffer in bytes
options
The creation options
Returns
The created buffer.
copyBuffer()
copyBuffer(
sourceBuffer,destBuffer,srcOffset,dstOffset,bytes):void
Defined in: libs/device/src/base_types.ts:2811
Copies a buffer to another buffer
Parameters
sourceBuffer
Source buffer
destBuffer
destination buffer
srcOffset
number
Source offset in bytes
dstOffset
number
Destination offset in bytes
bytes
number
How many bytes to be copy
Returns
void
createIndexBuffer()
createIndexBuffer(
data,options?):IndexBuffer
Defined in: libs/device/src/base_types.ts:2824
Creates an index buffer
Parameters
data
Uint16Array<ArrayBuffer> | Uint32Array<ArrayBuffer>
Data of the index buffer
options?
The creation options
Returns
The created index buffer.
createStructuredBuffer()
createStructuredBuffer(
structureType,options,data?):StructuredBuffer
Defined in: libs/device/src/base_types.ts:2835
Creates a structured buffer
Parameters
structureType
The structure type
options
The creation options
data?
TypedArray
Data to be filled with
Returns
The created structured buffer.
createVertexLayout()
createVertexLayout(
options):VertexLayout
Defined in: libs/device/src/base_types.ts:2845
Creates a vertex layout object.
Parameters
options
The creation options
Returns
The created vertex layout object.
createFrameBuffer()
createFrameBuffer(
colorAttachments,depthAttachment,options?):FrameBuffer
Defined in: libs/device/src/base_types.ts:2851
Creates a frame buffer
Parameters
colorAttachments
BaseTexture<unknown>[]
depthAttachment
BaseTexture<unknown>
options?
The creation options
Returns
The created framebuffer.
setViewport()
setViewport(
vp):void
Defined in: libs/device/src/base_types.ts:2861
Set viewport from an array that contains the position and size
Parameters
vp
Immutable<number[] | DeviceViewport>
The viewport position and size, if not specified, the viewport will be set to [0, 0, drawingBufferWidth, drawingBufferHeight]
Returns
void
getViewport()
getViewport():
Immutable<DeviceViewport>
Defined in: libs/device/src/base_types.ts:2863
Get current viewport as [x, y, width, height]
Returns
Immutable<DeviceViewport>
setScissor()
setScissor(
scissor):void
Defined in: libs/device/src/base_types.ts:2868
Set scissor rectangle from an array that contains the position and size
Parameters
scissor
Immutable<number[] | DeviceViewport>
The scissor rectangle position and size, if not specified, the scissor rectangle will be set to [0, 0, drawingBufferWidth,drawingBufferHeight]
Returns
void
getScissor()
getScissor():
Immutable<DeviceViewport>
Defined in: libs/device/src/base_types.ts:2872
Get current scissor rectangle
Returns
Immutable<DeviceViewport>
setProgram()
setProgram(
program):void
Defined in: libs/device/src/base_types.ts:2877
Set current GPU program
Parameters
program
GPUProgram<unknown>
The GPU program to be set
Returns
void
getProgram()
getProgram():
GPUProgram<unknown>
Defined in: libs/device/src/base_types.ts:2881
Get current GPU program
Returns
GPUProgram<unknown>
setVertexLayout()
setVertexLayout(
vertexData):void
Defined in: libs/device/src/base_types.ts:2887
Set current vertex layout
Parameters
vertexData
VertexLayout<unknown>
The vertex layout to be set
Returns
void
getVertexLayout()
getVertexLayout():
VertexLayout<unknown>
Defined in: libs/device/src/base_types.ts:2889
Get current vertex layout
Returns
VertexLayout<unknown>
setRenderStates()
setRenderStates(
renderStates):void
Defined in: libs/device/src/base_types.ts:2895
Set current render states
Parameters
renderStates
The render state set
Returns
void
getRenderStates()
getRenderStates():
RenderStateSet
Defined in: libs/device/src/base_types.ts:2897
Get current render states
Returns
setFramebuffer()
Call Signature
setFramebuffer(
rt):void
Defined in: libs/device/src/base_types.ts:2903
Sets the current framebuffer to the specified FrameBuffer object.
Parameters
rt
FrameBuffer<unknown>
The FrameBuffer object to set as the current framebuffer.
Returns
void
Call Signature
setFramebuffer(
color,depth?,sampleCount?):void
Defined in: libs/device/src/base_types.ts:2916
Sets the current framebuffer specifying complex color attachments, an optional depth attachment, MIP level, face, and sample count.
Parameters
color
BaseTexture<unknown>[]
An array of BaseTextures or objects containing a BaseTexture and optional properties. Each BaseTexture or object will serve as a color attachment. - If an object is provided, it can specify: - texture: The BaseTexture to use. - miplevel: Optional MIP level for this specific texture. default is 0. - face: Optional face index for cube map textures, specifying the cube face this texture is attached to. default is 0. - layer: Optional layer index, useful for texture arrays. default is 0.
depth?
Optional BaseTexture to serve as the depth attachment.
sampleCount?
number
Optional sample count defining the number of samples for multisampling.
Returns
void
Call Signature
setFramebuffer(
colorOrRT,depth?,sampleCount?):void
Defined in: libs/device/src/base_types.ts:2917
Parameters
colorOrRT
BaseTexture<unknown>[] | FrameBuffer<unknown>
depth?
sampleCount?
number
Returns
void
getFramebuffer()
getFramebuffer():
FrameBuffer<unknown>
Defined in: libs/device/src/base_types.ts:2923
Get current frame buffer
Returns
FrameBuffer<unknown>
setBindGroup()
setBindGroup(
index,bindGroup,dynamicOffsets?):void
Defined in: libs/device/src/base_types.ts:2931
Set current bind group
Parameters
index
number
index of the bind group
bindGroup
The bind group to be set
dynamicOffsets?
Iterable<number>
dynamic uniform buffer offsets of the bind group or null
Returns
void
getBindGroup()
getBindGroup(
index): [BindGroup,Iterable<number,any,any>]
Defined in: libs/device/src/base_types.ts:2936
Get current bind group
Parameters
index
number
index of the bind group to get
Returns
[BindGroup, Iterable<number, any, any>]
flush()
flush():
void
Defined in: libs/device/src/base_types.ts:2938
Flush the gpu command buffer
Returns
void
readPixels()
readPixels(
index,x,y,w,h,buffer):Promise<void>
Defined in: libs/device/src/base_types.ts:2953
Read pixel values from current frame buffer
Parameters
index
number
color attachment index
x
number
x position of the reading area
y
number
y position of the reading area
w
number
width of the reading area
h
number
height of the reading area
buffer
TypedArray
The output buffer
Returns
Promise<void>
Remarks
This method reads the data asynchronously to prevent GPU stall. For WebGL1 devices, the GPU stall is still inevitable.
readPixelsToBuffer()
readPixelsToBuffer(
index,x,y,w,h,buffer):void
Defined in: libs/device/src/base_types.ts:2967
Read pixel values from current frame buffer to a GPU buffer
Parameters
index
number
color attachment index
x
number
x position of the reading area
y
number
y position of the reading area
w
number
width of the reading area
h
number
height of the reading area
buffer
The output buffer
Returns
void
Remarks
This method does not support WebGL1 device
beginCapture()
beginCapture():
void
Defined in: libs/device/src/base_types.ts:2971
Begin capture draw commands
Returns
void
executeRenderBundle()
executeRenderBundle(
renderBundle):void
Defined in: libs/device/src/base_types.ts:2976
Executes render bundle
Parameters
renderBundle
unknown
RenderBundle to be execute
Returns
void
endCapture()
endCapture():
unknown
Defined in: libs/device/src/base_types.ts:2981
End capture draw commands
Returns
unknown
A RenderBundle that holds the captured draw commands
beginFrame()
beginFrame():
boolean
Defined in: libs/device/src/base_types.ts:3002
Begins a frame for rendering
Returns
boolean
Remarks
All rendering call must occur between the
See
- AbstractDevice.beginFrame and
- AbstractDevice.endFrame methods
endFrame()
endFrame():
void
Defined in: libs/device/src/base_types.ts:3009
Ends a frame for rendering
Returns
void
Remarks
All rendering call must occur between the
See
- AbstractDevice.beginFrame and
- AbstractDevice.endFrame methods
inFrame()
inFrame():
boolean
Defined in: libs/device/src/base_types.ts:3015
Whether currently inside a beginFrame()/endFrame() pair
Returns
boolean
true if currently inside a beginFrame()endFrame() pair
getVertexAttribFormat()
getVertexAttribFormat(
semantic,dataType,componentCount):VertexAttribFormat
Defined in: libs/device/src/base_types.ts:3023
Get the vertex attribute format from vertex semantic and data type
Parameters
semantic
The vertex semantic
dataType
The data type
componentCount
number
The component count
Returns
createInterleavedVertexBuffer()
createInterleavedVertexBuffer(
attribFormats,data,options?):StructuredBuffer<unknown>
Defined in: libs/device/src/base_types.ts:3036
Creates an interleaved vertex buffer
Parameters
attribFormats
The vertex attribute formats for each vertex stream in the vertex buffer
data
TypedArray
Data to be filled with
options?
The creation options
Returns
StructuredBuffer<unknown>
The created vertex buffer.
createVertexBuffer()
createVertexBuffer(
attribFormat,data,options?):StructuredBuffer<unknown>
Defined in: libs/device/src/base_types.ts:3049
Creates a non-interleaved vertex buffer
Parameters
attribFormat
The vertex attribute format
data
TypedArray
Data to be filled with
options?
The creation options
Returns
StructuredBuffer<unknown>
The created vertex buffer
draw()
draw(
primitiveType,first,count):void
Defined in: libs/device/src/base_types.ts:3061
Draw primitives
Parameters
primitiveType
The primitive type
first
number
The vertex offset (or index offset if an index buffer exists)
count
number
The vertex count (or index count if an index buffer exists) to be drawn
Returns
void
drawInstanced()
drawInstanced(
primitiveType,first,count,numInstances):void
Defined in: libs/device/src/base_types.ts:3070
Draw multiple instances of primitives
Parameters
primitiveType
The primitive type
first
number
The vertex offset (or index offset if an index buffer exists)
count
number
The vertex count (or index count if an index buffer exists) to be drawn
numInstances
number
How many instances to be drawn
Returns
void
drawIndirect()
drawIndirect(
primitiveType,indirectBuffer,indirectOffset?):void
Defined in: libs/device/src/base_types.ts:3083
Draw primitives, reading the draw arguments from a GPU buffer
Parameters
primitiveType
The primitive type
indirectBuffer
The buffer holding the draw arguments
indirectOffset?
number
Byte offset of the draw arguments within the buffer, must be a multiple of 4
Returns
void
Remarks
Requires MiscCaps.supportDrawIndirect. The buffer must be created with the 'indirect' usage and contain a tightly packed group of 4 uint32 values: vertexCount, instanceCount, firstVertex, firstInstance.
drawIndexedIndirect()
drawIndexedIndirect(
primitiveType,indirectBuffer,indirectOffset?):void
Defined in: libs/device/src/base_types.ts:3096
Draw indexed primitives, reading the draw arguments from a GPU buffer
Parameters
primitiveType
The primitive type
indirectBuffer
The buffer holding the draw arguments
indirectOffset?
number
Byte offset of the draw arguments within the buffer, must be a multiple of 4
Returns
void
Remarks
Requires MiscCaps.supportDrawIndirect. The buffer must be created with the 'indirect' usage and contain a tightly packed group of 5 uint32 values: indexCount, instanceCount, firstIndex, baseVertex, firstInstance.
compute()
compute(
workgroupCountX,workgroupCountY,workgroupCountZ):void
Defined in: libs/device/src/base_types.ts:3108
Dispatches a compute task to the GPU
Parameters
workgroupCountX
number
X dimension of the grid of workgroups to be dispatch
workgroupCountY
number
Y dimension of the grid of workgroups to be dispatch
workgroupCountZ
number
Z dimension of the grid of workgroups to be dispatch
Returns
void
runNextFrame()
runNextFrame(
f):void
Defined in: libs/device/src/base_types.ts:3114
Schedules a function to be executed at the beginning of the next frame
Parameters
f
() => void
The function to be scheduled
Returns
void
runNextFrameAsync()
runNextFrameAsync(
f):Promise<void>
Defined in: libs/device/src/base_types.ts:3120
Asyncronized version of scheduling a function to be executed at the beginning of the next frame
Parameters
f
() => void
The function to be scheduled
Returns
Promise<void>
exitLoop()
exitLoop():
void
Defined in: libs/device/src/base_types.ts:3122
Exits from current rendering loop
Returns
void
runLoop()
runLoop(
func):void
Defined in: libs/device/src/base_types.ts:3128
Begins a rendering loop
Parameters
func
(device) => void
The function to be executed at every frame
Returns
void
getGPUObjects()
getGPUObjects():
GPUObjectList
Defined in: libs/device/src/base_types.ts:3130
Get all GPU objects
Returns
getGPUObjectById()
getGPUObjectById(
uid):GPUObject<unknown>
Defined in: libs/device/src/base_types.ts:3136
Get GPU object by id
Parameters
uid
number
id of the GPU object
Returns
GPUObject<unknown>
screenXToDevice()
screenXToDevice(
val):number
Defined in: libs/device/src/base_types.ts:3145
Calculates the actual position of current frame buffer from screen position in X axis.
Parameters
val
number
The screen position in pixels
Returns
number
Remarks
If current frame buffer is the back buffer, the value will be scaled by the device pixel ratio.
deviceXToScreen()
deviceXToScreen(
val):number
Defined in: libs/device/src/base_types.ts:3154
Calculates the screen position from position of current frame buffer in X axis.
Parameters
val
number
The position of current frame buffer in pixels
Returns
number
Remarks
If current frame buffer is the back buffer, the value will be divided by the device pixel ratio.
screenYToDevice()
screenYToDevice(
val):number
Defined in: libs/device/src/base_types.ts:3163
Calculates the actual position of current frame buffer from screen position in Y axis.
Parameters
val
number
The screen position in pixels
Returns
number
Remarks
If current frame buffer is the back buffer, the value will be scaled by the device pixel ratio.
deviceYToScreen()
deviceYToScreen(
val):number
Defined in: libs/device/src/base_types.ts:3172
Calculates the screen position from position of current frame buffer in Y axis.
Parameters
val
number
The position of current frame buffer in pixels
Returns
number
Remarks
If current frame buffer is the back buffer, the value will be divided by the device pixel ratio.
buildRenderProgram()
buildRenderProgram(
options):GPUProgram<unknown>
Defined in: libs/device/src/base_types.ts:3174
Builds render program
Parameters
options
Returns
GPUProgram<unknown>
buildComputeProgram()
buildComputeProgram(
options):GPUProgram<unknown>
Defined in: libs/device/src/base_types.ts:3176
Builds compute program
Parameters
options
Returns
GPUProgram<unknown>
pushDeviceStates()
pushDeviceStates():
void
Defined in: libs/device/src/base_types.ts:3178
Pushes current FrameBuffer state
Returns
void
popDeviceStates()
popDeviceStates():
void
Defined in: libs/device/src/base_types.ts:3180
Pops last FrameBuffer state
Returns
void