CPP-TOOLBOX
Loading...
Searching...
No Matches
input_graphics_sound_menu Directory Reference

Files

 input_graphics_sound_menu.cpp
 
 input_graphics_sound_menu.hpp
 

Detailed Description

This is a basic menu that could used in almost any 3d program. Additionally it acts as the default menu for all cpptbx programs as a starting point.

In order to use the menu a few things need to happen, first it requires the following sounds to be defined:

std::unordered_map<SoundType, std::string> sound_type_to_file = {
{SoundType::UI_HOVER, "assets/sounds/hover.wav"},
{SoundType::UI_CLICK, "assets/sounds/click.wav"},
{SoundType::UI_SUCCESS, "assets/sounds/success.wav"},
};
SoundSystem sound_system(100, sound_type_to_file);
Definition sound_system.hpp:28

The menu requires a few systems and a single shader to render itself, so when initializing the shader cache we do this:

std::vector<ShaderType> requested_shaders = {ShaderType::ABSOLUTE_POSITION_WITH_COLORED_VERTEX};
ShaderCache shader_cache(requested_shaders);
Batcher batcher(shader_cache);
facilitates simple and robust interaction with shaders
Definition shader_cache.hpp:23

It also requires the configuration system that's in charge of a config file:

Configuration configuration("assets/config/user_cfg.ini");
Class to parse a configuration file and apply logic based on section-key pairs.
Definition config_file_parser.hpp:17

Then you can create it:

InputGraphicsSoundMenu input_graphics_sound_menu(window, batcher, sound_system, configuration);
Handles all user interface (UI) states related to input, graphics, and sound configuration.
Definition input_graphics_sound_menu.hpp:38

In order for it to render you have to call the following member function:

void process_and_queue_render_menu(Window &window, InputState &input_state, IUIRenderSuite &ui_render_suite);
Interface for UI rendering operations.
Definition ui.hpp:329
Definition input_state.hpp:198
Definition window.hpp:27

The IUIRenderSuite is an interface that when implemented renders the UI, here is an example implementation: https://github.com/cpp-toolbox/ui_render_suite_implementation

It also relies on InputState, so make sure you set that up.