* Class: Gfx3Manager
#author("2024-02-10T19:11:28+00:00","","")

The `Gfx3Manager` class is a singleton responsible for render all graphics stuff in a 3D graphics system.
** Constructors
- ''new Gfx3Manager''(): Gfx3Manager~
The constructor.~
** Methods
- ''beginDrawing''(viewIndex: number): void~
The "beginDrawing" function prepare the rendering environment for a specific view.
Warning: You need to call this method before your draw calls.~
-- ''viewIndex'': The `viewIndex` parameter is the index of the view that you want to
begin drawing. It is used to retrieve the corresponding view object from the `views` array.~
~
- ''beginPassRender''(viewIndex: number): void~
The "beginPassRender" function prepare the rendering phase.
Warning: You need to call this method before your render calls.~
-- ''viewIndex''~
~
- ''beginRender''(): void~
~
- ''changeView''(index: number, view: Gfx3View): void~
The "changeView" function change the view at a specified index in views array.~
-- ''index'': The position in the views array where the view should be changed.~
-- ''view'': The view.~
~
- ''createCubeMapFromBitmap''(bitmaps): Gfx3Texture~
The "createCubeMapFromBitmap" function creates a cube map texture from an array of bitmaps or canvas
elements.~
-- ''bitmaps'': The `bitmaps` parameter is an array of `ImageBitmap` or `HTMLCanvasElement`
objects. These objects represent the six faces of a cube map texture. Each face should have the same
size.~
~
- ''createDynamicGroup''(pipelineId: string, groupIndex: number): Gfx3DynamicGroup~
The "createDynamicGroup" function creates a dynamic group for a given pipeline and group index.~
-- ''pipelineId'': The pipelineId is a string that represents the unique identifier of
a pipeline.~
-- ''groupIndex'': The `groupIndex` parameter is the index of the uniform group in the shader.~
~
- ''createStaticGroup''(pipelineId: string, groupIndex: number): Gfx3StaticGroup~
The "createStaticGroup" function creates a static group for a given pipeline and group index.~
-- ''pipelineId'': The pipelineId is a string that represents the unique identifier of
a pipeline.~
-- ''groupIndex'': The `groupIndex` parameter is the index of the uniform group in the shader.~
~
- ''createTextureFromBitmap''(bitmap, is8bit: boolean, samplerDescriptor: GPUSamplerDescriptor): Gfx3Texture~
The "createTextureFromBitmap" function creates a GPU texture from a given bitmap image or canvas element.~
-- ''bitmap'': The `bitmap` parameter can be either an
`ImageBitmap` or an `HTMLCanvasElement`. It represents the source image from which the texture will
be created.~
-- ''is8bit'': The `is8bit` parameter is a boolean flag that indicates whether
the texture should be treated as an 8-bit texture or not.~
-- ''samplerDescriptor'': The sampler texture configuration, see https://www.w3.org/TR/webgpu/#GPUSamplerDescriptor.~
~
- ''createVertexBuffer''(size: number): VertexSubBuffer~
The "createVertexBuffer" function creates a vertex sub-buffer of a specified size and returns it.
Nota bene: A sub-buffer is just a reference offset/size pointing to the big one vertex buffer.~
-- ''size'': The `size` parameter represents the number of vertices that will be stored
in the vertex sub-buffer.~
~
- ''createView''(): Gfx3View~
The "createView" function creates a new `Gfx3View` object.~
~
- ''destroyVertexBuffer''(sub: VertexSubBuffer): void~
The "destroyVertexBuffer" function removes a given vertex sub-buffer.~
-- ''sub'': The vertex sub-buffer.~
~
- ''endDrawing''(): void~
The "endDrawing" function close the drawing phase.
Warning: You need to call this method after your draw calls.~
~
- ''endPassRender''(): void~
~
- ''endRender''(): void~
The "endRender" function ends the rendering process, submits the command encoder to the device
queue, and calculates the time taken for the rendering.
Warning: You need to call this method after your render calls.~
~
- ''getClientHeight''(): number~
The "getClientHeight" function returns the client height of the canvas.~
~
- ''getClientWidth''(): number~
The "getClientWidth" function returns the client width of the canvas.~
~
- ''getCommandEncoder''(): GPUCommandEncoder~
The "getCommandEncoder" function returns the GPUCommandEncoder.~
~
- ''getContext''(): GPUCanvasContext~
The "getContext" function returns the GPUCanvasContext object.~
~
- ''getCurrentView''(): Gfx3View~
The "getCurrentView" function returns the current view.
Nota bene: current view is set by the "beginDraw" function.~
~
- ''getDevice''(): GPUDevice~
The "getDevice" function returns the GPU device.~
~
- ''getHeight''(): number~
The "getHeight" function returns the height of the canvas.~
~
- ''getLastRenderTime''(): number~
The "getLastRenderTime" function returns the last render time.~
~
- ''getNumViews''(): number~
The "getNumViews" function returns the number of views.~
~
- ''getPassEncoder''(): GPURenderPassEncoder~
The "getPassEncoder" function returns the GPURenderPassEncoder.~
~
- ''getPipeline''(id: string): GPURenderPipeline~
The "getPipeline" function returns a GPU render pipeline based on the provided ID, throwing an error
if the pipeline is not found.~
-- ''id'': A string representing the ID of the pipeline to retrieve.~
~
- ''getVertexBuffer''(): GPUBuffer~
The "getVertexBuffer" function returns the big one vertex buffer.~
~
- ''getView''(index: number): Gfx3View~
The "getView" function returns the Gfx3View at the specified index.~
-- ''index'': The position of the view in views array.~
~
- ''getWidth''(): number~
The "getWidth" function returns the width of the canvas.~
~
- ''handleWindowResize''(): void~
The "handleWindowResize" function resizes the canvas, recreates the depth texture and view, and
updates the screen size for each view.~
~
- ''hasFilter''(): boolean~
The "hasFilter" function checks if the canvas element has an active filter.~
~
- ''initialize''(): Promise~
The "initialize" function initializes the WebGPU rendering context, checks for browser support,
requests the adapter and device, configures the canvas, creates a depth texture and vertex buffer,
and subscribes to a window resize event.~
~
- ''loadPipeline''(id: string, vertexShader: string, fragmentShader: string, pipelineDesc: GPURenderPipelineDescriptor): GPURenderPipeline~
The "loadPipeline" function creates and returns a GPU render pipeline using the provided vertex and
fragment shaders, and caches it for future use.~
-- ''id'': A unique identifier for the render pipeline.~
-- ''vertexShader'': The `vertexShader` parameter is a string that represents the code for
the vertex shader.~
-- ''fragmentShader'': The `fragmentShader` parameter is a string that represents the code
for the fragment shader.~
-- ''pipelineDesc'': The `pipelineDesc` parameter is of type
`GPURenderPipelineDescriptor` and it represents the description of the render pipeline that you want
to create. It contains various properties that define the configuration of the pipeline, such as the
vertex and fragment shaders, the color and depth formats, the primitive topology~
~
- ''releaseViews''(): void~
The "releaseViews" function delete all views.~
~
- ''removeView''(view: Gfx3View): void~
The "removeView" function removes a specified view in views array.~
-- ''view'': The view.~
~
- ''setFilter''(filter: string): void~
The "setFilter" function sets the filter property of a canvas element to the specified filter value.~
-- ''filter'': The filter parameter is a string that represents the CSS filter property.
It can be used to apply various visual effects to an element, such as blur, brightness, contrast,
grayscale, etc.~
~
- ''writeVertexBuffer''(sub: VertexSubBuffer, vertices: number[]): void~
The "writeVertexBuffer" function takes a vertex sub-buffer and write on it.~
-- ''sub'': The vertex sub-buffer.~
-- ''vertices'': The `vertices` parameter is an array of numbers representing the vertex data.~


Front page   Edit Diff History Attach Copy Rename Reload   New Page list Search Recent changes   Help   RSS of recent changes