Skip to main content
Version: 🚧 Nightly

Class f3d::window

Definition: window.h (line 23)

Abstract class to render in a window or an image.

A class to render things in a window or an image. An icon and windowName can be set which can be shown by a window manager.

Members​

Public types​

Enumeration type Type​

Definition: window.h (line 39)

enum Type {
NONE,
EXTERNAL,
GLX,
WGL,
COCOA,
EGL,
OSMESA,
WASM,
UNKNOWN
}

Enumeration of supported window types

  • NONE: A mock window without rendering capabilities.

  • EXTERNAL: An external window that assume the OpenGL context would have been created by another framework.

  • GLX: A window using GLX.

  • WGL: A window using WGL.

  • COCOA: A window using COCOA.

  • EGL: An offscreen window using hardware acceleration that can run headless.

  • OSMESA: An offscreen window using software rendering that is always run headless.

  • WASM: A webassembly window (when libf3d is built with emscripten).

  • UNKNOWN: An unknown window (should not happen).

Enumerator NONE​

Enumerator EXTERNAL​

Enumerator GLX​

Enumerator WGL​

Enumerator COCOA​

Enumerator EGL​

Enumerator OSMESA​

Enumerator WASM​

Enumerator UNKNOWN​

Public functions​

Function getType​

virtual Type f3d::window::getType()=0

Get the type of the window.

Return type: Type

Function isOffscreen​

virtual bool f3d::window::isOffscreen()=0

Is the window offscreen.

Return type: bool

Function getDPIScale​

virtual double f3d::window::getDPIScale()=0

Get the DPI scale value of the window. Returns 1.0 on platforms where DPI scaling is not supported.

Return type: double

Function getCamera​

virtual camera & f3d::window::getCamera()=0

Get the camera provided by the window.

Return type: camera &

Function render​

virtual bool f3d::window::render()=0

Perform a render of the window to the screen. All dynamic options are updated if needed. Return true on success, false otherwise.

Return type: bool

Function renderToImage​

virtual image f3d::window::renderToImage(bool noBackground=false)=0

Perform a render of the window to the screen and save the result in a f3d::image. of ChannelType BYTE and 3 or 4 components (RGB or RGBA). Set noBackground to true to have a transparent background. Returns the resulting f3d::image.

Parameters:

  • bool noBackground = false

Return type: image

Function getVideoFrame​

virtual std::shared_ptr< video_frame > f3d::window::getVideoFrame()=0

Get the current video frame of the window. This construct the video frame, allocates and fills the Y and UV planes with the current window content in the expected layout. Requires F3D_MODULE_FFMPEG to be enabled. Throws a video_frame::invalid_frame_exception if F3D_MODULE_FFMPEG is disabled or if the resolution is not even or positive. Returns the resulting f3d::video_frame.

Return type: std::shared_ptr< video_frame >

Function setSize​

virtual window & f3d::window::setSize(int width, int height)=0

Set the size of the window.

Parameters:

  • int width
  • int height

Return type: window &

Function getSize​

virtual std::pair< int, int > f3d::window::getSize() const =0

Get the size of the window as a (width, height) pair.

Return type: std::pair< int, int >

Function getWidth​

virtual int f3d::window::getWidth() const =0

Get the width of the window, see getSize.

Return type: int

Function getHeight​

virtual int f3d::window::getHeight() const =0

Get the height of the window, see getSize.

Return type: int

Function setPosition​

virtual window & f3d::window::setPosition(int x, int y)=0

Set the position of the window.

Parameters:

  • int x
  • int y

Return type: window &

Function getPosition​

virtual std::pair< int, int > f3d::window::getPosition() const =0

Get the position of the window as an (x, y) pair.

Return type: std::pair< int, int >

Function getLeft​

virtual int f3d::window::getLeft() const =0

Get the position of the left border of the window, see getPosition.

Return type: int

Function getTop​

virtual int f3d::window::getTop() const =0

Get the position of the top border of the window, see getPosition.

Return type: int

Function setIcon​

virtual window & f3d::window::setIcon(const unsigned char *icon, size_t iconSize)=0

Set the icon to be shown by a window manager. icon should be an unsigned char array. iconSize should be the sizeof(icon).

Parameters:

  • const unsigned char * icon
  • size_t iconSize

Return type: window &

Function setWindowName​

virtual window & f3d::window::setWindowName(std::string_view windowName)=0

Set the window name to be shown by a window manager.

Parameters:

  • std::string_view windowName

Return type: window &

Function getWorldFromDisplay​

virtual point3_t f3d::window::getWorldFromDisplay(const point3_t &displayPoint) const =0

Convert a point in display coordinate to world coordinate.

Parameters:

Return type: point3_t

Function getDisplayFromWorld​

virtual point3_t f3d::window::getDisplayFromWorld(const point3_t &worldPoint) const =0

Convert a point in world coordinate to display coordinate.

Parameters:

Return type: point3_t