Class Renderer2D#

Nested Relationships#

Nested Types#

Class Documentation#

class Renderer2D#

Public Static Functions

static void Init()#

Initialize Renderer2D.

static void Shutdown()#

Shutdown Renderer2D.

static void Reset() noexcept#

Reset the Renderer2D for a new frame.

Note

This functions gets called by TRAP::Application

static void BeginScene(const Camera &camera, const Math::Mat4 &transform)#

Begin a Renderer2D scene.

Parameters:
  • camera – Main camera.

  • transformCamera transform.

static void BeginScene(const OrthographicCamera &camera)#

Begin a Renderer2D scene.

Parameters:

camera – Orthographic camera.

static void BeginScene(const EditorCamera &camera)#

Begin a Renderer2D scene.

Remark

Headless mode: This function is not available in headless mode.

Parameters:

camera – Editor camera.

static void EndScene()#

End a running Renderer2D scene.

static void SetCustomSampler(const TRAP::Ref<TRAP::Graphics::Sampler> &sampler)#

Set a custom sampler to use by the 2D renderer.

Parameters:

samplerSampler to use.

static void DrawQuad(const Transform &transform, const Math::Vec4 &color)#

Draw a colored quad.

Parameters:
  • transformTransform of the quad.

  • color – Color for the quad.

static void DrawQuad(const Transform &transform, const Ref<Texture> &texture)#

Draw a textured quad.

Parameters:
static void DrawQuad(const Transform &transform, const Math::Vec4 &color, const Ref<Texture> &texture)#

Draw a colored and textured quad.

Parameters:
  • transformTransform of the quad.

  • color – Color for the quad.

  • textureTexture for the quad.

static void DrawQuad(const Transform &transform, const TRAP::Ref<SubTexture2D> &texture)#

Draw a textured quad.

Parameters:
static void DrawQuad(const Transform &transform, const Math::Vec4 &color, const TRAP::Ref<SubTexture2D> &texture)#

Draw a colored and textured quad.

Parameters:
  • transformTransform of the quad.

  • color – Color for the quad.

  • textureTexture for the quad.

static void DrawQuad(const TRAP::Math::Mat4 &transform, const Math::Vec4 &color, const Ref<Texture> &texture, const std::array<Math::Vec2, 4> *texCoords, i32 entityID = -1)#

Draw a colored and textured quad. This is the base function for all the other DrawQuad functions.

Parameters:
static void DrawCircle(const TRAP::Math::Mat4 &transform, const Math::Vec4 &color, f32 thickness = 1.0f, f32 fade = 0.005f, i32 entityID = -1)#

Draw a colored circle with given thickness and fading. This is the base function for all the other DrawCircle functions.

Parameters:
  • transformTransform matrix for the circle.

  • color – Color for the circle.

  • thicknessOptional: Thickness for the circle.

  • fadeOptional: Fade for the circle.

  • entityIDOptional: Entity ID of the quad.

static void DrawSprite(const TRAP::Math::Mat4 &transform, const SpriteRendererComponent &sprite, i32 entityID = -1)#

Draw a sprite.

Parameters:
  • transformTransform matrix for the sprite.

  • sprite – Sprite component data.

  • entityIDEntity ID of this sprite.

static void DrawLine(const TRAP::Math::Vec3 &p0, const TRAP::Math::Vec3 &p1, const TRAP::Math::Vec4 &color, i32 entityID = -1)#

Draw a colored line from point p0 to point p1.

Parameters:
  • p0 – First point of the line.

  • p1 – Second point of the line.

  • color – Color for the line.

  • entityIDEntity ID of this line.

static void DrawRect(const TRAP::Math::Vec3 &position, const TRAP::Math::Vec2 &size, const TRAP::Math::Vec4 &color, i32 entityID = -1)#

Draw a rectangle (not filled).

Parameters:
  • position – Position of the rectangle.

  • size – Size of the rectangle.

  • color – Color for the rectangle.

  • entityIDEntity ID of this rectangle.

static void DrawRect(const TRAP::Math::Mat4 &transform, const TRAP::Math::Vec4 &color, i32 entityID = -1)#

Draw a rectangle (not filled).

Parameters:
  • transform – Transformation of the rectangle.

  • color – Color for the rectangle.

  • entityIDEntity ID of this rectangle.

static Statistics GetStats() noexcept#

Retrieve the current Renderer2D statistics.

Returns:

Renderer2D statistics.

static void ResetStats() noexcept#

Reset the Renderer2D statistics.

struct Statistics#

Public Functions

constexpr u32 GetTotalVertexCount() const noexcept#

Retrieve the current total number of vertices.

Returns:

Total vertices count.

constexpr u32 GetTotalIndexCount() const noexcept#

Retrieve the current total number of indices.

Returns:

Total indices count.

Public Members

u32 DrawCalls = 0#
u32 QuadCount = 0#
u32 CircleCount = 0#
u32 LineCount = 0#
struct Transform#

Struct to describe position, rotation and scale.

Public Members

Math::Vec3 Position = {0.0f, 0.0f, 0.0f}#
Math::Vec3 Rotation = {0.0f, 0.0f, 0.0f}#
Math::Vec3 Scale = {1.0f, 1.0f, 1.0f}#