Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
esengine::BatchPlugin Class Reference

#include <BatchPlugin.hpp>

Inheritance diagram for esengine::BatchPlugin:

Public Member Functions

void init (RenderFrameContext &ctx) override
void shutdown () override
Public Member Functions inherited from esengine::RenderTypePlugin
virtual ~RenderTypePlugin ()=default
virtual bool castsShadows () const
 Whether what this plugin draws belongs in a shadow map.
virtual bool castInputs (RenderFrameContext &, ecs::Registry &, u64 &)
 For a plugin that casts: one number for everything its depth collect reads apart from the shadow views and the frame's camera, so a frame whose number, views and camera match those of the frame that drew the shadow map need not collect it again.
virtual bool castHeldInputs (u64 &) const
virtual u32 castMoverCount () const
virtual bool drawsMotion () const
virtual bool drawsScreenUI () const
 Whether this plugin can draw an entity that lives in a UI tree.
virtual void collect (RenderCollectContext &ctx)=0
virtual void scheduleSkins (RenderFrameContext &ctx, ecs::Registry &registry, SkinCache &cache)
 Make ready the programs entities will be asked for, drawing none.
virtual RenderPrewarmResult prewarm (RenderFrameContext &ctx, ecs::Registry &registry, const Entity *entities, u32 count, bool shadowPasses)
virtual RenderPrewarmResult prewarmDocument (RenderFrameContext &ctx, const MeshDocumentRecord *rows, u32 count, bool shadowPasses)
 The same readiness, asked of a PREPARED cell's own description.
virtual const char * collectScope () const
 What this plugin's collect is called in a frame profile.
virtual bool clusterInspect (u32, u32 &, u32 &) const
 What the last frames drew of the Cluster LOD mesh of the entity entityId.

Protected Member Functions

void emitQuad (TransientBufferPool &buffers, DrawList &draw_list, const ClipState &clips, const glm::vec3 &position, const glm::vec2 &size, const glm::vec2 &pivotNorm, f32 angle, const glm::vec2 &uvOffset, const glm::vec2 &uvScale, const glm::vec4 &color, const BatchDrawKey &key)
 Emits a single rotated/unrotated textured quad.
void emitNineSlice (TransientBufferPool &buffers, DrawList &draw_list, const ClipState &clips, const glm::vec3 &position, const glm::vec2 &size, const glm::vec2 &pivotNorm, f32 angle, const glm::vec2 &texSize, const glm::vec4 &border, const glm::vec2 &uvOffset, const glm::vec2 &uvScale, const glm::vec4 &color, const BatchDrawKey &key)
 Emits a 3x3 nine-slice grid of quads sharing one BatchDrawKey.
void emitRadialFill (TransientBufferPool &buffers, DrawList &draw_list, const ClipState &clips, const glm::vec3 &center, const glm::vec2 &size, f32 angle, f32 startAngle, f32 sweep, const glm::vec2 &uvOffset, const glm::vec2 &uvScale, const glm::vec4 &color, const BatchDrawKey &key)
 Emits a centered angular wedge (Radial Filled): a triangle fan from the box center out to its perimeter, swept clockwise from startAngle over sweep radians.

Protected Attributes

u32 batch_shader_id_ = 0

Detailed Description

Definition at line 29 of file BatchPlugin.hpp.

Member Function Documentation

◆ emitNineSlice()

void esengine::BatchPlugin::emitNineSlice ( TransientBufferPool & buffers,
DrawList & draw_list,
const ClipState & clips,
const glm::vec3 & position,
const glm::vec2 & size,
const glm::vec2 & pivotNorm,
f32 angle,
const glm::vec2 & texSize,
const glm::vec4 & border,
const glm::vec2 & uvOffset,
const glm::vec2 & uvScale,
const glm::vec4 & color,
const BatchDrawKey & key )
protected

Emits a 3x3 nine-slice grid of quads sharing one BatchDrawKey.

Parameters
borderSlice insets as (left, right, top, bottom) in pixels.
texSizeTexture dimensions; if either axis is <= 0 the slice UVs collapse to the outer rect.

Definition at line 60 of file BatchPlugin.cpp.

References esengine::appendQuads(), esengine::packColor(), and esengine::rotatePoint().

Referenced by esengine::SpritePlugin::collect(), and esengine::UIElementPlugin::collect().

◆ emitQuad()

void esengine::BatchPlugin::emitQuad ( TransientBufferPool & buffers,
DrawList & draw_list,
const ClipState & clips,
const glm::vec3 & position,
const glm::vec2 & size,
const glm::vec2 & pivotNorm,
f32 angle,
const glm::vec2 & uvOffset,
const glm::vec2 & uvScale,
const glm::vec4 & color,
const BatchDrawKey & key )
protected

Emits a single rotated/unrotated textured quad.

Parameters
pivotNormPivot in [0,1] within the quad; (0.5,0.5) keeps it centered on position.
keyNon-geometry attributes (stage/layer/shader/blend/texture/depth/entity/type).

Definition at line 20 of file BatchPlugin.cpp.

References esengine::appendQuad(), esengine::BATCH_QUAD_POSITIONS, esengine::BATCH_QUAD_TEX_COORDS, esengine::BatchVertex::color, esengine::packColor(), esengine::BatchVertex::position, and esengine::BatchVertex::texCoord.

Referenced by esengine::SpritePlugin::collect(), and esengine::UIElementPlugin::collect().

◆ emitRadialFill()

void esengine::BatchPlugin::emitRadialFill ( TransientBufferPool & buffers,
DrawList & draw_list,
const ClipState & clips,
const glm::vec3 & center,
const glm::vec2 & size,
f32 angle,
f32 startAngle,
f32 sweep,
const glm::vec2 & uvOffset,
const glm::vec2 & uvScale,
const glm::vec4 & color,
const BatchDrawKey & key )
protected

Emits a centered angular wedge (Radial Filled): a triangle fan from the box center out to its perimeter, swept clockwise from startAngle over sweep radians.

The wedge boundary follows the rectangle exactly — box corners crossed by the sweep become fan vertices, so edges stay straight and corners sharp (≤5 triangles, no per-frame tessellation). One BatchVertex stream, same shader as emitQuad — a radial gauge batches with every other UI quad. Radial90/180/360 differ only in the caller's sweep (fillAmount times the mode arc); the geometry is identical.

Parameters
startAngleSweep start in radians, box-local (before angle rotation).
sweepTotal swept angle in radians, [0, 2π].

Definition at line 140 of file BatchPlugin.cpp.

References esengine::appendIndexedBatch(), esengine::packColor(), and esengine::rotatePoint().

Referenced by esengine::UIElementPlugin::collect().

◆ init()

void esengine::BatchPlugin::init ( RenderFrameContext & ctx)
inlineoverridevirtual

Reimplemented from esengine::RenderTypePlugin.

Definition at line 31 of file BatchPlugin.hpp.

References batch_shader_id_, and esengine::ctx().

◆ shutdown()

void esengine::BatchPlugin::shutdown ( )
inlineoverridevirtual

Reimplemented from esengine::RenderTypePlugin.

Definition at line 32 of file BatchPlugin.hpp.

Member Data Documentation

◆ batch_shader_id_

u32 esengine::BatchPlugin::batch_shader_id_ = 0
protected

The documentation for this class was generated from the following files:
  • /home/runner/work/estella/estella/src/esengine/renderer/plugins/BatchPlugin.hpp
  • /home/runner/work/estella/estella/src/esengine/renderer/plugins/BatchPlugin.cpp