Botcraft 1.21.11
Loading...
Searching...
No Matches
Botcraft::Renderer::Settings Class Reference

#include <Settings.hpp>

Static Public Member Functions

static bool IsEnabled ()
 
static void Enable (const bool enable=true)
 Set the renderer enabled state the for next client.
 
static void Disable ()
 Disable the rendering for all future clients.
 
static void Headless (const bool headless=true)
 Make the renderer headless (hide the display window).
 
static void ShowWindow (const bool show=true)
 Show/hide the rendering window.
 
static void HideWindow ()
 Hide the rendering window.
 
static void SetResolution (const int width, const int height)
 Try to change the resolution of the rendering window. This can be limited by specific OS constraints or a user resizing the window.
 
static std::pair< int, int > GetResolution ()
 Get the current resolution of the renderer.
 
static void TakeScreenshot (const std::string &path)
 Render and save the next rendered frame.
 
static void TakeScreenshot (const std::function< void(const std::vector< unsigned char > &pixels, const int height, const int width)> &callback)
 Render the next image and pass the raw pixels to the given callback.
 
static void EnableVsync (const bool enable=true)
 Enable/disable the vsync for the rendering loop.
 
static void DisableVsync ()
 Disable the vsync for the rendering loop.
 
static void SetMaxFramerate (const double fps)
 Set the max framerate for the rendering loop. Set to 0 for no limit.
 

Static Private Attributes

static std::atomic< bool > enabled = false
 
static std::atomic< int > height = 600
 
static std::atomic< int > width = 800
 
static std::atomic< bool > headless = false
 
static std::atomic< bool > vsync = true
 
static std::atomic< double > target_fps = 60.0
 
static std::mutex screenshot_mutex
 
static std::string screenhsot_path = ""
 
static std::function< void(const std::vector< unsigned char > &pixels, const int height, const int width)> screenshot_callback = nullptr
 

Friends

class Botcraft::Renderer::RenderingManager
 

Detailed Description

Definition at line 12 of file Settings.hpp.

Member Function Documentation

◆ Disable()

void Botcraft::Renderer::Settings::Disable ( )
static

Disable the rendering for all future clients.

Definition at line 46 of file Settings.cpp.

References CHECK_GUI, and enabled.

◆ DisableVsync()

void Botcraft::Renderer::Settings::DisableVsync ( )
static

Disable the vsync for the rendering loop.

Definition at line 102 of file Settings.cpp.

References CHECK_GUI, and vsync.

◆ Enable()

void Botcraft::Renderer::Settings::Enable ( const bool  enable = true)
static

Set the renderer enabled state the for next client.

Parameters
enableIf true, next Client will try to create a renderer

Definition at line 38 of file Settings.cpp.

References CHECK_GUI, and enabled.

◆ EnableVsync()

void Botcraft::Renderer::Settings::EnableVsync ( const bool  enable = true)
static

Enable/disable the vsync for the rendering loop.

Parameters
enableIf true, vsync will be enabled

Definition at line 96 of file Settings.cpp.

References CHECK_GUI, and vsync.

◆ GetResolution()

std::pair< int, int > Botcraft::Renderer::Settings::GetResolution ( )
static

Get the current resolution of the renderer.

Returns
A pair of int, { width, height }

Definition at line 77 of file Settings.cpp.

References height, and width.

◆ Headless()

void Botcraft::Renderer::Settings::Headless ( const bool  headless = true)
static

Make the renderer headless (hide the display window).

Parameters
headlessIf true, the window will be hidden (headless mode). Note that you still need some display device available to create the rendering context

Definition at line 52 of file Settings.cpp.

References CHECK_GUI, and headless.

◆ HideWindow()

void Botcraft::Renderer::Settings::HideWindow ( )
static

Hide the rendering window.

Definition at line 64 of file Settings.cpp.

References CHECK_GUI, and headless.

◆ IsEnabled()

bool Botcraft::Renderer::Settings::IsEnabled ( )
static

Definition at line 28 of file Settings.cpp.

References CHECK_GUI, and enabled.

Referenced by Botcraft::ManagersClient::Handle().

◆ SetMaxFramerate()

void Botcraft::Renderer::Settings::SetMaxFramerate ( const double  fps)
static

Set the max framerate for the rendering loop. Set to 0 for no limit.

Definition at line 108 of file Settings.cpp.

References CHECK_GUI, and target_fps.

◆ SetResolution()

void Botcraft::Renderer::Settings::SetResolution ( const int  width,
const int  height 
)
static

Try to change the resolution of the rendering window. This can be limited by specific OS constraints or a user resizing the window.

Definition at line 70 of file Settings.cpp.

References CHECK_GUI, height, and width.

◆ ShowWindow()

void Botcraft::Renderer::Settings::ShowWindow ( const bool  show = true)
static

Show/hide the rendering window.

Parameters
showIf true, the window will be shown, will be hidden otherwise (headless mode). Note that you still need some display device available to create the rendering context

Definition at line 58 of file Settings.cpp.

References CHECK_GUI, and headless.

◆ TakeScreenshot() [1/2]

static void Botcraft::Renderer::Settings::TakeScreenshot ( const std::function< void(const std::vector< unsigned char > &pixels, const int height, const int width)> &  callback)
static

Render the next image and pass the raw pixels to the given callback.

Pixels are in HWC order

Parameters
callbackFunction to call with the frame raw pixels. Params are pixels, height, width

◆ TakeScreenshot() [2/2]

void Botcraft::Renderer::Settings::TakeScreenshot ( const std::string &  path)
static

Render and save the next rendered frame.

Parameters
pathPath to save the PNG image to

Definition at line 82 of file Settings.cpp.

References CHECK_GUI, screenhsot_path, and screenshot_mutex.

Friends And Related Symbol Documentation

◆ Botcraft::Renderer::RenderingManager

Definition at line 51 of file Settings.hpp.

Member Data Documentation

◆ enabled

std::atomic< bool > Botcraft::Renderer::Settings::enabled = false
staticprivate

Definition at line 54 of file Settings.hpp.

Referenced by Disable(), Enable(), and IsEnabled().

◆ headless

std::atomic< bool > Botcraft::Renderer::Settings::headless = false
staticprivate

◆ height

std::atomic< int > Botcraft::Renderer::Settings::height = 600
staticprivate

◆ screenhsot_path

std::string Botcraft::Renderer::Settings::screenhsot_path = ""
staticprivate

◆ screenshot_callback

std::function< void(const std::vector< unsigned char > &pixels, const int height, const int width)> Botcraft::Renderer::Settings::screenshot_callback = nullptr
staticprivate

Definition at line 62 of file Settings.hpp.

Referenced by Botcraft::Renderer::RenderingManager::Run().

◆ screenshot_mutex

std::mutex Botcraft::Renderer::Settings::screenshot_mutex
staticprivate

◆ target_fps

std::atomic< double > Botcraft::Renderer::Settings::target_fps = 60.0
staticprivate

Definition at line 59 of file Settings.hpp.

Referenced by Botcraft::Renderer::RenderingManager::Run(), and SetMaxFramerate().

◆ vsync

std::atomic< bool > Botcraft::Renderer::Settings::vsync = true
staticprivate

◆ width

std::atomic< int > Botcraft::Renderer::Settings::width = 800
staticprivate

The documentation for this class was generated from the following files: