nngn
Loading...
Searching...
No Matches
nngn::GLFWBackend Class Reference

#include <glfw.h>

Inheritance diagram for nngn::GLFWBackend:
Collaboration diagram for nngn::GLFWBackend:

Classes

struct  CallbackData
 

Public Member Functions

 GLFWBackend (void)=default
 
 GLFWBackend (const Parameters &p)
 
 ~GLFWBackend (void) override
 
bool init_glfw (void) const
 
bool window_closed (void) const final
 
int swap_interval (void) const final
 
nngn::uvec2 window_size (void) const override
 
void get_keys (size_t n, int32_t *keys) const override
 
ivec2 mouse_pos (void) const override
 
void set_swap_interval (int i) override
 
void set_window_title (const char *t) final
 
void set_cursor_mode (CursorMode m) final
 
void set_size_callback (void *data, size_callback_f f) override
 
void set_key_callback (void *data, key_callback_f f) override
 
void set_mouse_button_callback (void *data, mouse_button_callback_f f) override
 
void set_mouse_move_callback (void *data, mouse_move_callback_f f) override
 
void resize (int, int) override
 
void set_camera (const Camera &c) override
 
void set_lighting (const Lighting &l) override
 
void poll_events (void) const final
 
bool render (void) override
 
- Public Member Functions inherited from nngn::Graphics
virtual bool init ()
 Fully initialize the back end.
 
virtual bool init_backend ()=0
 
virtual bool init_instance ()=0
 
virtual bool init_device ()=0
 
virtual bool init_device (std::size_t i)=0
 
virtual std::size_t n_extensions () const =0
 
virtual std::size_t n_layers () const =0
 
virtual std::size_t n_devices () const =0
 
virtual std::size_t n_device_extensions (std::size_t i) const =0
 
virtual std::size_t n_queue_families (std::size_t i) const =0
 
virtual std::size_t n_present_modes () const =0
 
virtual std::size_t n_heaps (std::size_t i) const =0
 
virtual std::size_t n_memory_types (std::size_t i, std::size_t ih) const =0
 
virtual std::size_t selected_device () const =0
 
virtual void extensions (Extension *p) const =0
 
virtual void layers (Layer *p) const =0
 
virtual void device_infos (DeviceInfo *p) const =0
 
virtual void device_extensions (std::size_t i, Extension *p) const =0
 
virtual void queue_families (std::size_t i, QueueFamily *p) const =0
 
virtual SurfaceInfo surface_info () const =0
 
virtual void present_modes (PresentMode *p) const =0
 
virtual void heaps (std::size_t i, MemoryHeap *p) const =0
 
virtual void memory_types (std::size_t i, std::size_t ih, MemoryType *p) const =0
 
virtual bool error ()=0
 
virtual Version version () const =0
 
virtual GraphicsStats stats ()=0
 
virtual bool set_n_frames (std::size_t n)=0
 
virtual bool set_n_swap_chain_images (std::size_t n)=0
 
virtual void set_camera_updated ()=0
 
virtual void set_lighting_updated ()=0
 
virtual bool set_shadow_map_size (uint32_t s)=0
 
virtual bool set_shadow_cube_size (uint32_t s)=0
 
virtual void set_automatic_exposure (bool b)=0
 
virtual void set_exposure (float e)=0
 
virtual void set_bloom_downscale (std::size_t d)=0
 
virtual void set_bloom_threshold (float t)=0
 
virtual void set_bloom_blur_size (float n)=0
 
virtual void set_bloom_blur_passes (std::size_t n)=0
 
virtual void set_bloom_amount (float a)=0
 
virtual void set_blur_downscale (std::size_t d)=0
 
virtual void set_blur_size (float n)=0
 
virtual void set_blur_passes (std::size_t n)=0
 
virtual void set_HDR_mix (float m)=0
 
virtual u32 create_pipeline (const PipelineConfiguration &conf)=0
 
virtual u32 create_buffer (const BufferConfiguration &conf)=0
 
virtual bool set_buffer_capacity (u32 b, u64 size)=0
 
virtual bool set_buffer_size (u32 b, std::uint64_t size)=0
 
virtual bool write_to_buffer (u32 b, u64 offset, u64 n, u64 size, void *data, void f(void *, void *, u64, u64))=0
 
template<typename F >
bool write_to_buffer (u32 b, u64 offset, u64 n, u64 size, F &&f)
 
bool update_buffers (u32 vbo, u32 ebo, u64 voff, u64 eoff, u64 vn, u64 vsize, u64 en, u64 esize, void *data, auto &&vgen, auto &&egen)
 
virtual bool resize_textures (std::uint32_t s)=0
 
virtual bool load_textures (std::uint32_t i, std::uint32_t n, const std::byte *v)=0
 
virtual bool resize_font (std::uint32_t s)=0
 
virtual bool load_font (unsigned char c, std::uint32_t n, const nngn::uvec2 *size, const std::byte *v)=0
 
virtual bool set_render_list (const RenderList &l)=0
 
virtual bool vsync ()=0
 

Protected Member Functions

bool create_window (void)
 

Protected Attributes

int m_swap_interval = 1
 
GLFWwindow * w = nullptr
 
Parameters params = {}
 
Camera camera = {}
 
Lighting lighting = {}
 

Private Attributes

struct nngn::GLFWBackend::CallbackData callback_data = {}
 

Additional Inherited Members

- Public Types inherited from nngn::Graphics
enum class  Backend : u8 {
  PSEUDOGRAPH , TERMINAL_BACKEND , OPENGL_BACKEND , OPENGL_ES_BACKEND ,
  VULKAN_BACKEND
}
 
enum class  LogLevel { DEBUG , WARNING , ERROR }
 
enum class  PresentMode { IMMEDIATE , MAILBOX , FIFO , FIFO_RELAXED }
 
enum class  TerminalFlag : u8 {
  CLEAR = 1u << 0 , REPOSITION = 1u << 1 , DEDUPLICATE = 1u << 2 , HIDE_CURSOR = 1u << 3 ,
  RESET_COLOR = 1u << 4
}
 
enum class  TerminalMode { ASCII , COLORED }
 
enum class  CursorMode { NORMAL , HIDDEN , DISABLED }
 
using size_callback_f = void (*)(void*, uvec2)
 
using key_callback_f = void (*)(void*, int, int, int, int)
 
using mouse_button_callback_f = void (*)(void*, int, int, int)
 
using mouse_move_callback_f = void (*)(void*, dvec2)
 
- Static Public Member Functions inherited from nngn::Graphics
static std::unique_ptr< Graphicscreate (Backend b, const void *params)
 
static const char * enum_str (DeviceInfo::Type t)
 
static const char * enum_str (QueueFamily::Flag f)
 
static const char * enum_str (PresentMode m)
 
static const char * enum_str (MemoryHeap::Flag m)
 
static const char * enum_str (MemoryType::Flag m)
 
static std::string flags_str (QueueFamily::Flag f)
 
static std::string flags_str (MemoryHeap::Flag f)
 
static std::string flags_str (MemoryType::Flag f)
 
- Static Public Attributes inherited from nngn::Graphics
static constexpr u32 TEXTURE_EXTENT = NNGN_TEXTURE_EXTENT
 
static constexpr u32 TEXTURE_EXTENT_LOG2 = std::countr_zero(TEXTURE_EXTENT)
 
static constexpr u32 TEXTURE_SIZE = NNGN_TEXTURE_SIZE
 
static constexpr u32 TEXTURE_MIP_LEVELS = Math::mip_levels(TEXTURE_EXTENT)
 
static constexpr u32 SHADOW_MAP_INITIAL_SIZE = 1024
 
static constexpr u32 SHADOW_CUBE_INITIAL_SIZE = 512
 
static constexpr float DEFAULT_EXPOSURE = 1.0f
 
static constexpr float DEFAULT_BLOOM_THRESHOLD = 0.75f
 
static constexpr float DEFAULT_BLOOM_BLUR_SIZE = 1.0f
 
static constexpr std::size_t DEFAULT_BLOOM_DOWNSCALE = 8
 
static constexpr std::size_t DEFAULT_BLUR_DOWNSCALE = 2
 
static constexpr std::size_t DEFAULT_BLOOM_BLUR_PASSES = 10
 

Constructor & Destructor Documentation

◆ GLFWBackend() [1/2]

nngn::GLFWBackend::GLFWBackend ( void )
default

◆ GLFWBackend() [2/2]

nngn::GLFWBackend::GLFWBackend ( const Parameters & p)
inlineexplicit

◆ ~GLFWBackend()

nngn::GLFWBackend::~GLFWBackend ( void )
override

Member Function Documentation

◆ create_window()

bool nngn::GLFWBackend::create_window ( void )
protected
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_keys()

void nngn::GLFWBackend::get_keys ( size_t n,
int32_t * keys ) const
overridevirtual

Implements nngn::Graphics.

◆ init_glfw()

bool nngn::GLFWBackend::init_glfw ( void ) const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mouse_pos()

ivec2 nngn::GLFWBackend::mouse_pos ( void ) const
overridevirtual

Implements nngn::Graphics.

◆ poll_events()

void nngn::GLFWBackend::poll_events ( void ) const
finalvirtual

Implements nngn::Graphics.

◆ render()

bool nngn::GLFWBackend::render ( void )
overridevirtual

◆ resize()

void nngn::GLFWBackend::resize ( int ,
int  )
inlineoverridevirtual

◆ set_camera()

void nngn::GLFWBackend::set_camera ( const Camera & c)
inlineoverridevirtual

◆ set_cursor_mode()

void nngn::GLFWBackend::set_cursor_mode ( CursorMode m)
finalvirtual

Implements nngn::Graphics.

◆ set_key_callback()

void nngn::GLFWBackend::set_key_callback ( void * data,
key_callback_f f )
overridevirtual

Implements nngn::Graphics.

Here is the call graph for this function:

◆ set_lighting()

void nngn::GLFWBackend::set_lighting ( const Lighting & l)
inlineoverridevirtual

◆ set_mouse_button_callback()

void nngn::GLFWBackend::set_mouse_button_callback ( void * data,
mouse_button_callback_f f )
overridevirtual

Implements nngn::Graphics.

Here is the call graph for this function:

◆ set_mouse_move_callback()

void nngn::GLFWBackend::set_mouse_move_callback ( void * data,
mouse_move_callback_f f )
overridevirtual

Implements nngn::Graphics.

Here is the call graph for this function:

◆ set_size_callback()

void nngn::GLFWBackend::set_size_callback ( void * data,
size_callback_f f )
overridevirtual

Implements nngn::Graphics.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_swap_interval()

void nngn::GLFWBackend::set_swap_interval ( int i)
overridevirtual

◆ set_window_title()

void nngn::GLFWBackend::set_window_title ( const char * t)
finalvirtual

Implements nngn::Graphics.

◆ swap_interval()

int nngn::GLFWBackend::swap_interval ( void ) const
inlinefinalvirtual

Implements nngn::Graphics.

◆ window_closed()

bool nngn::GLFWBackend::window_closed ( void ) const
finalvirtual

Implements nngn::Graphics.

◆ window_size()

uvec2 nngn::GLFWBackend::window_size ( void ) const
overridevirtual

Implements nngn::Graphics.

Member Data Documentation

◆ callback_data

struct nngn::GLFWBackend::CallbackData nngn::GLFWBackend::callback_data = {}
private

◆ camera

Camera nngn::GLFWBackend::camera = {}
protected

◆ lighting

Lighting nngn::GLFWBackend::lighting = {}
protected

◆ m_swap_interval

int nngn::GLFWBackend::m_swap_interval = 1
protected

◆ params

Parameters nngn::GLFWBackend::params = {}
protected

◆ w

GLFWwindow* nngn::GLFWBackend::w = nullptr
protected

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