nngn
Loading...
Searching...
No Matches
nngn::Graphics Struct Referenceabstract

#include <graphics.h>

Inheritance diagram for nngn::Graphics:

Classes

struct  BufferConfiguration
 
struct  Camera
 
struct  DeviceInfo
 
struct  Extension
 
struct  Layer
 
struct  Lighting
 
struct  MemoryHeap
 
struct  MemoryType
 
struct  OpenGLParameters
 
struct  Parameters
 
struct  PipelineConfiguration
 
struct  QueueFamily
 
struct  RenderList
 
struct  SurfaceInfo
 
struct  TerminalParameters
 
struct  Version
 
struct  VulkanParameters
 

Public Types

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)
 

Public Member Functions

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 bool window_closed () const =0
 
virtual int swap_interval () const =0
 
virtual uvec2 window_size () const =0
 
virtual GraphicsStats stats ()=0
 
virtual void get_keys (size_t n, int32_t *keys) const =0
 
virtual ivec2 mouse_pos (void) const =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_swap_interval (int i)=0
 
virtual void set_window_title (const char *t)=0
 
virtual void set_cursor_mode (CursorMode m)=0
 
virtual void set_size_callback (void *data, size_callback_f f)=0
 
virtual void set_key_callback (void *data, key_callback_f f)=0
 
virtual void set_mouse_button_callback (void *data, mouse_button_callback_f f)=0
 
virtual void set_mouse_move_callback (void *data, mouse_move_callback_f f)=0
 
virtual void resize (int w, int h)=0
 
virtual void set_camera (const Camera &c)=0
 
virtual void set_lighting (const Lighting &l)=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 void poll_events () const =0
 
virtual bool render ()=0
 
virtual bool vsync ()=0
 

Static Public Member Functions

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

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
 

Member Typedef Documentation

◆ key_callback_f

using nngn::Graphics::key_callback_f = void (*)(void*, int, int, int, int)

◆ mouse_button_callback_f

using nngn::Graphics::mouse_button_callback_f = void (*)(void*, int, int, int)

◆ mouse_move_callback_f

using nngn::Graphics::mouse_move_callback_f = void (*)(void*, dvec2)

◆ size_callback_f

using nngn::Graphics::size_callback_f = void (*)(void*, uvec2)

Member Enumeration Documentation

◆ Backend

Enumerator
PSEUDOGRAPH 
TERMINAL_BACKEND 
OPENGL_BACKEND 
OPENGL_ES_BACKEND 
VULKAN_BACKEND 

◆ CursorMode

Enumerator
NORMAL 
HIDDEN 
DISABLED 

◆ LogLevel

Enumerator
DEBUG 
WARNING 
ERROR 

◆ PresentMode

Enumerator
IMMEDIATE 
MAILBOX 
FIFO 
FIFO_RELAXED 

◆ TerminalFlag

Enumerator
CLEAR 
REPOSITION 
DEDUPLICATE 
HIDE_CURSOR 
RESET_COLOR 

◆ TerminalMode

Enumerator
ASCII 
COLORED 

Member Function Documentation

◆ create()

std::unique_ptr< Graphics > nngn::Graphics::create ( Backend b,
const void * params )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_buffer()

virtual u32 nngn::Graphics::create_buffer ( const BufferConfiguration & conf)
pure virtual

◆ create_pipeline()

◆ device_extensions()

virtual void nngn::Graphics::device_extensions ( std::size_t i,
Extension * p ) const
pure virtual

◆ device_infos()

virtual void nngn::Graphics::device_infos ( DeviceInfo * p) const
pure virtual

◆ enum_str() [1/5]

const char * nngn::Graphics::enum_str ( DeviceInfo::Type t)
static
Here is the caller graph for this function:

◆ enum_str() [2/5]

const char * nngn::Graphics::enum_str ( MemoryHeap::Flag m)
static

◆ enum_str() [3/5]

const char * nngn::Graphics::enum_str ( MemoryType::Flag m)
static

◆ enum_str() [4/5]

const char * nngn::Graphics::enum_str ( PresentMode m)
static

◆ enum_str() [5/5]

const char * nngn::Graphics::enum_str ( QueueFamily::Flag f)
static
Here is the call graph for this function:

◆ error()

virtual bool nngn::Graphics::error ( )
pure virtual

◆ extensions()

virtual void nngn::Graphics::extensions ( Extension * p) const
pure virtual

◆ flags_str() [1/3]

std::string nngn::Graphics::flags_str ( MemoryHeap::Flag f)
static

◆ flags_str() [2/3]

std::string nngn::Graphics::flags_str ( MemoryType::Flag f)
static

◆ flags_str() [3/3]

std::string nngn::Graphics::flags_str ( QueueFamily::Flag f)
static
Here is the caller graph for this function:

◆ get_keys()

virtual void nngn::Graphics::get_keys ( size_t n,
int32_t * keys ) const
pure virtual

Implemented in nngn::GLFWBackend, and nngn::Pseudograph.

Here is the caller graph for this function:

◆ heaps()

virtual void nngn::Graphics::heaps ( std::size_t i,
MemoryHeap * p ) const
pure virtual

◆ init()

bool nngn::Graphics::init ( void )
inlinevirtual

Fully initialize the back end.

Calls the other initialization functions with default values.

Reimplemented in anonymous_namespace{terminal.cpp}::TerminalBackend.

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

◆ init_backend()

virtual bool nngn::Graphics::init_backend ( )
pure virtual

◆ init_device() [1/2]

virtual bool nngn::Graphics::init_device ( )
pure virtual

◆ init_device() [2/2]

virtual bool nngn::Graphics::init_device ( std::size_t i)
pure virtual

◆ init_instance()

virtual bool nngn::Graphics::init_instance ( )
pure virtual

◆ layers()

virtual void nngn::Graphics::layers ( Layer * p) const
pure virtual

◆ load_font()

virtual bool nngn::Graphics::load_font ( unsigned char c,
std::uint32_t n,
const nngn::uvec2 * size,
const std::byte * v )
pure virtual

◆ load_textures()

virtual bool nngn::Graphics::load_textures ( std::uint32_t i,
std::uint32_t n,
const std::byte * v )
pure virtual

Implemented in anonymous_namespace{vulkan.cpp}::VulkanBackend, nngn::Pseudograph, and TextureTestGraphics.

Here is the caller graph for this function:

◆ memory_types()

virtual void nngn::Graphics::memory_types ( std::size_t i,
std::size_t ih,
MemoryType * p ) const
pure virtual

◆ mouse_pos()

virtual ivec2 nngn::Graphics::mouse_pos ( void ) const
pure virtual

Implemented in nngn::GLFWBackend, and nngn::Pseudograph.

◆ n_device_extensions()

virtual std::size_t nngn::Graphics::n_device_extensions ( std::size_t i) const
pure virtual

◆ n_devices()

virtual std::size_t nngn::Graphics::n_devices ( ) const
pure virtual

◆ n_extensions()

virtual std::size_t nngn::Graphics::n_extensions ( ) const
pure virtual

◆ n_heaps()

virtual std::size_t nngn::Graphics::n_heaps ( std::size_t i) const
pure virtual

◆ n_layers()

virtual std::size_t nngn::Graphics::n_layers ( ) const
pure virtual

◆ n_memory_types()

virtual std::size_t nngn::Graphics::n_memory_types ( std::size_t i,
std::size_t ih ) const
pure virtual

◆ n_present_modes()

virtual std::size_t nngn::Graphics::n_present_modes ( ) const
pure virtual

◆ n_queue_families()

virtual std::size_t nngn::Graphics::n_queue_families ( std::size_t i) const
pure virtual

◆ poll_events()

virtual void nngn::Graphics::poll_events ( ) const
pure virtual

Implemented in nngn::GLFWBackend, and nngn::Pseudograph.

Here is the caller graph for this function:

◆ present_modes()

virtual void nngn::Graphics::present_modes ( PresentMode * p) const
pure virtual

◆ queue_families()

virtual void nngn::Graphics::queue_families ( std::size_t i,
QueueFamily * p ) const
pure virtual

◆ render()

◆ resize()

virtual void nngn::Graphics::resize ( int w,
int h )
pure virtual

◆ resize_font()

virtual bool nngn::Graphics::resize_font ( std::uint32_t s)
pure virtual

◆ resize_textures()

virtual bool nngn::Graphics::resize_textures ( std::uint32_t s)
pure virtual

Implemented in anonymous_namespace{vulkan.cpp}::VulkanBackend, and nngn::Pseudograph.

Here is the caller graph for this function:

◆ selected_device()

virtual std::size_t nngn::Graphics::selected_device ( ) const
pure virtual

◆ set_automatic_exposure()

virtual void nngn::Graphics::set_automatic_exposure ( bool b)
pure virtual

◆ set_bloom_amount()

virtual void nngn::Graphics::set_bloom_amount ( float a)
pure virtual

◆ set_bloom_blur_passes()

virtual void nngn::Graphics::set_bloom_blur_passes ( std::size_t n)
pure virtual

◆ set_bloom_blur_size()

virtual void nngn::Graphics::set_bloom_blur_size ( float n)
pure virtual

◆ set_bloom_downscale()

virtual void nngn::Graphics::set_bloom_downscale ( std::size_t d)
pure virtual

◆ set_bloom_threshold()

virtual void nngn::Graphics::set_bloom_threshold ( float t)
pure virtual

◆ set_blur_downscale()

virtual void nngn::Graphics::set_blur_downscale ( std::size_t d)
pure virtual

◆ set_blur_passes()

virtual void nngn::Graphics::set_blur_passes ( std::size_t n)
pure virtual

◆ set_blur_size()

virtual void nngn::Graphics::set_blur_size ( float n)
pure virtual

◆ set_buffer_capacity()

virtual bool nngn::Graphics::set_buffer_capacity ( u32 b,
u64 size )
pure virtual

Implemented in nngn::Pseudograph.

Here is the caller graph for this function:

◆ set_buffer_size()

virtual bool nngn::Graphics::set_buffer_size ( u32 b,
std::uint64_t size )
pure virtual

Implemented in nngn::Pseudograph.

Here is the caller graph for this function:

◆ set_camera()

◆ set_camera_updated()

◆ set_cursor_mode()

virtual void nngn::Graphics::set_cursor_mode ( CursorMode m)
pure virtual

Implemented in nngn::GLFWBackend, and nngn::Pseudograph.

Here is the caller graph for this function:

◆ set_exposure()

virtual void nngn::Graphics::set_exposure ( float e)
pure virtual

◆ set_HDR_mix()

virtual void nngn::Graphics::set_HDR_mix ( float m)
pure virtual

◆ set_key_callback()

virtual void nngn::Graphics::set_key_callback ( void * data,
key_callback_f f )
pure virtual

Implemented in nngn::GLFWBackend, and nngn::Pseudograph.

◆ set_lighting()

virtual void nngn::Graphics::set_lighting ( const Lighting & l)
pure virtual

◆ set_lighting_updated()

virtual void nngn::Graphics::set_lighting_updated ( )
pure virtual

◆ set_mouse_button_callback()

virtual void nngn::Graphics::set_mouse_button_callback ( void * data,
mouse_button_callback_f f )
pure virtual

Implemented in nngn::GLFWBackend, and nngn::Pseudograph.

◆ set_mouse_move_callback()

virtual void nngn::Graphics::set_mouse_move_callback ( void * data,
mouse_move_callback_f f )
pure virtual

Implemented in nngn::GLFWBackend, and nngn::Pseudograph.

◆ set_n_frames()

virtual bool nngn::Graphics::set_n_frames ( std::size_t n)
pure virtual

◆ set_n_swap_chain_images()

virtual bool nngn::Graphics::set_n_swap_chain_images ( std::size_t n)
pure virtual

◆ set_render_list()

virtual bool nngn::Graphics::set_render_list ( const RenderList & l)
pure virtual

◆ set_shadow_cube_size()

virtual bool nngn::Graphics::set_shadow_cube_size ( uint32_t s)
pure virtual

Implemented in nngn::Pseudograph.

Here is the caller graph for this function:

◆ set_shadow_map_size()

virtual bool nngn::Graphics::set_shadow_map_size ( uint32_t s)
pure virtual

Implemented in nngn::Pseudograph.

Here is the caller graph for this function:

◆ set_size_callback()

virtual void nngn::Graphics::set_size_callback ( void * data,
size_callback_f f )
pure virtual

◆ set_swap_interval()

virtual void nngn::Graphics::set_swap_interval ( int i)
pure virtual

◆ set_window_title()

virtual void nngn::Graphics::set_window_title ( const char * t)
pure virtual

Implemented in nngn::GLFWBackend, and nngn::Pseudograph.

◆ stats()

◆ surface_info()

virtual SurfaceInfo nngn::Graphics::surface_info ( ) const
pure virtual

◆ swap_interval()

virtual int nngn::Graphics::swap_interval ( ) const
pure virtual

Implemented in anonymous_namespace{terminal.cpp}::TerminalBackend, nngn::GLFWBackend, and nngn::Pseudograph.

Here is the caller graph for this function:

◆ update_buffers()

bool nngn::Graphics::update_buffers ( u32 vbo,
u32 ebo,
u64 voff,
u64 eoff,
u64 vn,
u64 vsize,
u64 en,
u64 esize,
void * data,
auto && vgen,
auto && egen )
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ version()

◆ vsync()

◆ window_closed()

virtual bool nngn::Graphics::window_closed ( ) const
pure virtual

Implemented in nngn::GLFWBackend, and nngn::Pseudograph.

◆ window_size()

virtual uvec2 nngn::Graphics::window_size ( ) const
pure virtual

◆ write_to_buffer() [1/2]

template<typename F >
bool nngn::Graphics::write_to_buffer ( u32 b,
u64 offset,
u64 n,
u64 size,
F && f )
Here is the call graph for this function:

◆ write_to_buffer() [2/2]

virtual bool nngn::Graphics::write_to_buffer ( u32 b,
u64 offset,
u64 n,
u64 size,
void * data,
void fvoid *, void *, u64, u64 )
pure virtual

Implemented in nngn::Pseudograph.

Here is the caller graph for this function:

Member Data Documentation

◆ DEFAULT_BLOOM_BLUR_PASSES

std::size_t nngn::Graphics::DEFAULT_BLOOM_BLUR_PASSES = 10
static

◆ DEFAULT_BLOOM_BLUR_SIZE

float nngn::Graphics::DEFAULT_BLOOM_BLUR_SIZE = 1.0f
static

◆ DEFAULT_BLOOM_DOWNSCALE

std::size_t nngn::Graphics::DEFAULT_BLOOM_DOWNSCALE = 8
staticconstexpr

◆ DEFAULT_BLOOM_THRESHOLD

float nngn::Graphics::DEFAULT_BLOOM_THRESHOLD = 0.75f
static

◆ DEFAULT_BLUR_DOWNSCALE

std::size_t nngn::Graphics::DEFAULT_BLUR_DOWNSCALE = 2
static

◆ DEFAULT_EXPOSURE

float nngn::Graphics::DEFAULT_EXPOSURE = 1.0f
staticconstexpr

◆ SHADOW_CUBE_INITIAL_SIZE

u32 nngn::Graphics::SHADOW_CUBE_INITIAL_SIZE = 512
static

◆ SHADOW_MAP_INITIAL_SIZE

u32 nngn::Graphics::SHADOW_MAP_INITIAL_SIZE = 1024
static

◆ TEXTURE_EXTENT

u32 nngn::Graphics::TEXTURE_EXTENT = NNGN_TEXTURE_EXTENT
staticconstexpr

◆ TEXTURE_EXTENT_LOG2

u32 nngn::Graphics::TEXTURE_EXTENT_LOG2 = std::countr_zero(TEXTURE_EXTENT)
static

◆ TEXTURE_MIP_LEVELS

u32 nngn::Graphics::TEXTURE_MIP_LEVELS = Math::mip_levels(TEXTURE_EXTENT)
static

◆ TEXTURE_SIZE

u32 nngn::Graphics::TEXTURE_SIZE = NNGN_TEXTURE_SIZE
static

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