nngn
Loading...
Searching...
No Matches
graphics Directory Reference

Graphics back ends.

More...

Directory dependency graph for graphics:
src/graphics

Directories

directory  opengl
 
directory  terminal
 
directory  vulkan
 

Files

file  glfw.cpp
 
file  glfw.h [code]
 
file  graphics.cpp
 
file  graphics.h [code]
 
file  lua_graphics.cpp
 
file  lua_texture.cpp
 
file  pseudo.cpp
 
file  pseudo.h [code]
 
file  shaders.cpp
 
file  stats.h [code]
 
file  texture.cpp
 
file  texture.h [code]
 

Detailed Description

Graphics back ends.

Several graphics back ends are supported, substitutable at runtime:

The following areas of the screenshots page show some of the graphics capabilities:

These are the low-level rendering operations. The higher-level layer is src/render.

Lua

The graphics back end is exposed to Lua via the nngn.graphics variable. It is only used for low-level control of the machine's graphics capabilities, however. See the documentation of src/render for how to perform higher-level rendering from Lua.

Initialization

A back end is chosen on default initialization (see src). For other cases, a specific back end can be initialized with:

nngn:set_graphics(Graphics.VULKAN_BACKEND, Graphics.vulkan_params {
version = {1, 2, 164},
debug = true,
})
Definition: audio.cpp:7

A back end can also be partially initialized to query its capabilities (see demos/graphics/list.lua):

vk = Graphics.create_backend(...)
assert(vk:init_backend())
print(vk:version())
assert(vk:init_instance())
utils.pprint(vk:extensions())
utils.pprint(vk:device_infos())
assert(vk:init_device())
utils.pprint(vk:device_info(g:selected_device()))
utils
Definition: common.lua:1
g
Definition: gamma.lua:7
assert
Definition: debug.lua:3
pprint
Definition: utils.lua:44

Common operations are:

-- Get current window size.
x, y = nngn.graphics:window_size()
-- Query statistics.
s = nngn.graphics:stats()
-- Set cursor display mode.
nngn.graphics:set_cursor_mode(Graphics.CURSOR_MODE_DISABLED)
-- Set resource limits.
nngn.graphics:resize_textures(8)
nngn.graphics:set_shadow_map_size(512, 512)
-- Control v-sync.
nngn.graphics:set_swap_interval(0)
v[1]
Definition: math.lua:19
stats
Definition: timeline.lua:5

Post-processing

Post-processing configuration is also done via the graphics back end:

nngn.graphics:set_HDR_mix(0.5)
nngn.graphics:set_exposure(2)
nngn.graphics:set_automatic_exposure(true)
nngn.graphics:set_bloom_blur_passes(4)
nngn.graphics:set_blur_size(2)