Skip to main content

p6::Canvas

Section: Canvas

A canvas is an image that can be drawn onto.

Inherits from p6::ImageOrCanvas

Summary

Name
Canvas(ImageSize size, glpp::TextureLayout texture_layout = {glpp::InternalFormat::RGBA16, glpp::Channels::RGBA, glpp::TexelDataType::UnsignedByte})
Creates an empty canvas texture_layout is an advanced setting; it controls how the pixels are gonna be stored on the GPU.
ImageSizesize() const
Returns the size in pixels.
virtual floataspect_ratio() const override
Returns the aspect ratio (width / height)
floatinverse_aspect_ratio() const
Returns the inverse aspect ratio (height / width)
virtual const Texture &texture() const override
Returns the internal texture, that you can use to do advanced stuff with custom shaders.
const glpp::RenderTarget &render_target() const
Returns the internal render target, that you can use to do advanced stuff.
glpp::RenderTarget &render_target()
Returns the internal render target, that you can use to do advanced stuff.
voidresize(ImageSize size)
Resizes the canvas.
voiddestructive_resize(ImageSize size)
Resizes the canvas.

Details

Canvas()

Canvas(ImageSize size, glpp::TextureLayout texture_layout ={glpp::InternalFormat::RGBA16, glpp::Channels::RGBA, glpp::TexelDataType::UnsignedByte});

Creates an empty canvas texture_layout is an advanced setting; it controls how the pixels are gonna be stored on the GPU.

size()

ImageSize size() const;

Returns the size in pixels.

aspect_ratio()

float aspect_ratio() const override;

Returns the aspect ratio (width / height)

Reimplements: p6::ImageOrCanvas::aspect_ratio

inverse_aspect_ratio()

float inverse_aspect_ratio() const;

Returns the inverse aspect ratio (height / width)

texture()

const Texture & texture() const override;

Returns the internal texture, that you can use to do advanced stuff with custom shaders.

Reimplements: p6::ImageOrCanvas::texture

render_target()

const glpp::RenderTarget & render_target() const;

Returns the internal render target, that you can use to do advanced stuff.

render_target()

glpp::RenderTarget & render_target();

Returns the internal render target, that you can use to do advanced stuff.

resize()

void resize(ImageSize size);

Resizes the canvas.

destructive_resize()

void destructive_resize(ImageSize size);

Resizes the canvas.

⚠️ All of its pixel content is lost. If you don't want that you can use resize() instead.


Updated on 2024 October 24