LuciadCPillar 2026.1.02
Loading...
Searching...
No Matches
luciad::WebGpuContext Class Referencefinal

An object that contains the WebGPU context that is needed to create a Map::Renderer. More...

#include <luciad/graphics/WebGpuContext.h>

Public Member Functions

 WebGpuContext (const WebGpuContext &other)=delete
 WebGpuContext (WGPUInstance instance, WGPUDevice device, WGPUQueue queue)
 Creates a new WebGPU context.
 ~WebGpuContext ()
WGPUDevice getDevice () const
 Returns the WebGPU device.
WGPUInstance getInstance () const
 Returns the WebGPU instance.
WGPUQueue getQueue () const
 Returns the WebGPU queue.
WGPUTexture getRenderTargetDepthTexture () const
 Returns the depth texture that was set as render target, or throw if no render target was set or if no depht texture was configured.
WGPUTextureView getRenderTargetDepthTextureView () const
 Returns the depth texture view that was set as render target, or throw if no render target was set or if no depht texture was configured.
const std::string & getRenderTargetName () const
 Returns the name of the render target that was set, or throw if no render target was set.
WGPUTexture getRenderTargetTexture () const
 Returns the color texture that was set as render target, or throw if no render target was set.
WGPUTextureView getRenderTargetTextureView () const
 Returns the color texture view that was set as render target, or throw if no render target was set.
bool hasRenderTargetDepthTexture () const
 Returns if this object contains a depth texture to render to.
bool isRenderTargetClearColor () const
 Returns whether the color render target is cleared before painting, or its contents are loaded and composited over.
bool isRenderTargetClearDepth () const
 Returns whether the depth render target is cleared before painting, or its contents are loaded and depth tested against.
WebGpuContext & operator= (const WebGpuContext &other)=delete
void resetRenderTarget ()
 Resets the render target that was set in setRenderTarget.
void setRenderTarget (std::string name, WGPUTexture colorTexture, WGPUTextureView colorTextureView)
 Sets a color texture to which to render.
void setRenderTarget (std::string name, WGPUTexture colorTexture, WGPUTextureView colorTextureView, WGPUTexture depthTexture, WGPUTextureView depthTextureView, bool clearColor=true, bool clearDepth=true)
 Sets a color texture and depth texture to which to render.

Static Public Member Functions

static std::vector< WGPUFeatureName > getRequiredFeatures (WGPUAdapter adapter)
 Returns the WebGPU features that are necessary for LuciadCPillar to function properly.
static WGPULimits getRequiredLimits (WGPUAdapter adapter)
 Returns the WebGPU limits that are necessary for LuciadCPillar to function properly.

Detailed Description

An object that contains the WebGPU context that is needed to create a Map::Renderer.

Since
2026.0

Constructor & Destructor Documentation

◆ WebGpuContext() [1/2]

luciad::WebGpuContext::WebGpuContext ( WGPUInstance instance,
WGPUDevice device,
WGPUQueue queue )

Creates a new WebGPU context.

Parameters
instancea WebGPU instance
devicea WebGPU device
queuea WebGPU queue
Exceptions
luciad::LogicExceptionif the device does not satisfy the requirements imposed by getRequiredFeatures and getRequiredLimits.

◆ ~WebGpuContext()

luciad::WebGpuContext::~WebGpuContext ( )

◆ WebGpuContext() [2/2]

luciad::WebGpuContext::WebGpuContext ( const WebGpuContext & other)
delete

Member Function Documentation

◆ getDevice()

WGPUDevice luciad::WebGpuContext::getDevice ( ) const

Returns the WebGPU device.

Returns
the WebGPU device.

◆ getInstance()

WGPUInstance luciad::WebGpuContext::getInstance ( ) const

Returns the WebGPU instance.

Returns
the WebGPU instance.

◆ getQueue()

WGPUQueue luciad::WebGpuContext::getQueue ( ) const

Returns the WebGPU queue.

Returns
the WebGPU queue.

◆ getRenderTargetDepthTexture()

WGPUTexture luciad::WebGpuContext::getRenderTargetDepthTexture ( ) const

Returns the depth texture that was set as render target, or throw if no render target was set or if no depht texture was configured.

Returns
the depth texture that was set as render target, or throw if no render target was set or if no depht texture was configured.
Exceptions
luciad::RuntimeExceptionif this function is not called inbetween a setRenderTarget and resetRenderTarget call.

◆ getRenderTargetDepthTextureView()

WGPUTextureView luciad::WebGpuContext::getRenderTargetDepthTextureView ( ) const

Returns the depth texture view that was set as render target, or throw if no render target was set or if no depht texture was configured.

Returns
the depth texture view that was set as render target, or throw if no render target was set or if no depht texture was configured.
Exceptions
luciad::RuntimeExceptionif this function is not called inbetween a setRenderTarget and resetRenderTarget call.

◆ getRenderTargetName()

const std::string & luciad::WebGpuContext::getRenderTargetName ( ) const

Returns the name of the render target that was set, or throw if no render target was set.

Returns
the name of the render target that was set, or throw if no render target was set.
Exceptions
luciad::RuntimeExceptionif this function is not called inbetween a setRenderTarget and resetRenderTarget call.

◆ getRenderTargetTexture()

WGPUTexture luciad::WebGpuContext::getRenderTargetTexture ( ) const

Returns the color texture that was set as render target, or throw if no render target was set.

Returns
the color texture that was set as render target, or throw if no render target was set.
Exceptions
luciad::RuntimeExceptionif this function is not called inbetween a setRenderTarget and resetRenderTarget call.

◆ getRenderTargetTextureView()

WGPUTextureView luciad::WebGpuContext::getRenderTargetTextureView ( ) const

Returns the color texture view that was set as render target, or throw if no render target was set.

Returns
the color texture view that was set as render target, or throw if no render target was set.
Exceptions
luciad::RuntimeExceptionif this function is not called inbetween a setRenderTarget and resetRenderTarget call.

◆ getRequiredFeatures()

std::vector< WGPUFeatureName > luciad::WebGpuContext::getRequiredFeatures ( WGPUAdapter adapter)
static

Returns the WebGPU features that are necessary for LuciadCPillar to function properly.

This list of features should be passed in the device descriptor used when requesting a WebGPU device.

You may also provide a device with more features (as long as the adapter supports it), but you should never provide a device missing a feature returned by this method.

Parameters
adapterthe WebGPU adapter.
Returns
the WebGPU features required of the device for LuciadCPillar to work properly.

◆ getRequiredLimits()

WGPULimits luciad::WebGpuContext::getRequiredLimits ( WGPUAdapter adapter)
static

Returns the WebGPU limits that are necessary for LuciadCPillar to function properly.

These limits should be passed in the device descriptor used when requesting a WebGPU device.

You may also provide a device with limits that are higher (as long as the adapter supports it), but you should never provide a device with lower limits than the limits returned by this method.

Parameters
adapterthe WebGPU adapter.
Returns
the WebGPU limits required of the device for LuciadCPillar to work properly.
Since
2026.1

◆ hasRenderTargetDepthTexture()

bool luciad::WebGpuContext::hasRenderTargetDepthTexture ( ) const

Returns if this object contains a depth texture to render to.

Returns
if this object contains a depth texture to render to.

◆ isRenderTargetClearColor()

bool luciad::WebGpuContext::isRenderTargetClearColor ( ) const

Returns whether the color render target is cleared before painting, or its contents are loaded and composited over.

Defaults to true (cleared).

Returns
true if the color render target is cleared before painting, false if it is loaded and composited over.
Since
2026.1

◆ isRenderTargetClearDepth()

bool luciad::WebGpuContext::isRenderTargetClearDepth ( ) const

Returns whether the depth render target is cleared before painting, or its contents are loaded and depth tested against.

Defaults to true (cleared).

Returns
true if the depth render target is cleared before painting, false if it is loaded and depth tested against.
Since
2026.1

◆ operator=()

WebGpuContext & luciad::WebGpuContext::operator= ( const WebGpuContext & other)
delete

◆ resetRenderTarget()

void luciad::WebGpuContext::resetRenderTarget ( )

Resets the render target that was set in setRenderTarget.

◆ setRenderTarget() [1/2]

void luciad::WebGpuContext::setRenderTarget ( std::string name,
WGPUTexture colorTexture,
WGPUTextureView colorTextureView )

Sets a color texture to which to render.

This function is typically called right before Map::Renderer::paint is called. Call resetRenderTarget afterwards.

Use this function when you don't care about the contents of the depth buffer.

Parameters
namethe name of the target
colorTexturethe color texture to render to
colorTextureViewthe color texture view to render to

◆ setRenderTarget() [2/2]

void luciad::WebGpuContext::setRenderTarget ( std::string name,
WGPUTexture colorTexture,
WGPUTextureView colorTextureView,
WGPUTexture depthTexture,
WGPUTextureView depthTextureView,
bool clearColor = true,
bool clearDepth = true )

Sets a color texture and depth texture to which to render.

This function is typically called right before Map::Renderer::paint is called. Call resetRenderTarget afterwards.

Use this function when you want to use the depth buffer yourself.

By default the color and depth textures are cleared before the map is painted. Pass false for clearColor or clearDepth to instead load and reuse their existing contents. When the color is loaded, the map is alpha blended over it. When the depth is loaded, map geometry is depth tested against it and the merged depth is written back, so externally rendered geometry and the map occlude each other correctly. The provided textures must hold valid color and depth when they are loaded.

Parameters
namethe name of the target
colorTexturethe color texture to render to
colorTextureViewthe color texture view to render to
depthTexturethe depth texture to render to
depthTextureViewthe depth texture view to render to
clearColorwhether to clear the color texture before painting (true, the default) or to load and composite over its existing contents (false)
clearDepthwhether to clear the depth texture before painting (true, the default) or to load and depth test against its existing contents (false)