libmx2 2.2.1
C++20 multimedia and game-engine library (SDL2 / OpenGL / Vulkan)
Loading...
Searching...
No Matches
mx Namespace Reference

Classes

class  Item
 A single key/value pair read from a configuration file. More...
class  ConfigFile
 Parses and manages an INI-style configuration file. More...
class  Exception
 General-purpose exception class for the mx library. More...
class  Font
 RAII wrapper around a TTF_Font handle. More...
class  Text
 Helper for rendering text strings with SDL_Renderer. More...
class  MXCapture
 OpenCV video capture source that renders via an OpenGL sprite. More...
class  Input
 Convenience wrapper that queries controller buttons by logical name. More...
class  Joystick
 RAII wrapper for a raw SDL_Joystick device. More...
class  Controller
 RAII wrapper for SDL_GameController (standard layout mapping). More...
struct  Vertex
 Per-vertex data sent to the Vulkan vertex buffer. More...
struct  VertexHash
struct  MXMaterial
 Parsed Wavefront MTL material properties. More...
class  Mesh
 A single OpenGL sub-mesh: geometry buffers, texture bindings, and deformers. More...
class  Model
 A collection of Mesh objects loaded from an OBJ file. More...
class  mxWindow
 Main SDL2 application window. More...
class  Mixer
 SDL_mixer–based audio manager. More...
class  TeeBuf
 A std::streambuf that writes every byte to two underlying buffers. More...
class  TeeStream
 An std::ostream that writes to two output streams simultaneously. More...
class  Texture
 RAII wrapper around an SDL_Texture. More...
class  mxUtil
 Utility bag for SDL-based applications. More...
struct  QueueFamilyIndices
 Tracks Vulkan queue family assignments needed to create a device. More...
struct  SwapChainSupportDetails
 Swapchain capabilities and format/mode candidates for a physical device. More...
struct  UniformBufferObject
 Standard UBO layout uploaded to shaders each frame. More...
class  VKWindow
 Primary Vulkan rendering window and device management class. More...
class  VKAbstractModel
 Convenience wrapper that owns an MXModel plus its Vulkan textures, UBOs, and descriptor sets. More...
struct  Vec2
struct  Vec3
struct  VKVertex
 Per-vertex data uploaded to the Vulkan vertex buffer. More...
struct  VKVertexHash
 Hash functor for VKVertex, suitable for use in unordered_map. More...
struct  SubMesh
 A range of indices within the shared index buffer, with its own texture. More...
class  MXModel
 Vulkan mesh loader and GPU resource manager. More...
class  VKSprite
 Vulkan 2-D sprite with texture, custom shader, and instancing support. More...
struct  CacheKey
 Cache key combining text content and colour. More...
struct  CacheKeyHash
 Hash functor for CacheKey. More...
struct  CachedTexture
 GPU texture resources cached for a rendered text string. More...
class  VKText
 Renders SDL_ttf text into Vulkan image textures. More...
class  Wrapper
 A nullable smart wrapper around a raw pointer. More...

Concepts

concept  WrapType
 Constrains Wrapper<T> to pointer types only.

Enumerations

enum class  Input_Button {
  BTN_A = 0 , BTN_B , BTN_X , BTN_Y ,
  BTNL_L , BTN_R , BTN_D_UP , BTN_D_DOWN ,
  BTN_D_LEFT , BTN_D_RIGHT , BTN_START , BTN_BACK
}
 Logical button identifiers for a standard gamepad. More...
enum class  DeformAxis { X = 0 , Y = 1 , Z = 2 }
 Axis selector for deformation operations. More...

Functions

static bool ends_with (const std::string &s, const std::string &suf)
static std::ofstream log_file ("system.log.txt", std::ios::out)
static std::ofstream error_file ("error.log.txt", std::ios::out)
void redirect ()
 Redirect std::cout and std::cerr through the tee streams.
float generateRandomFloat (float min, float max)
 Generate a random float in the given range.
int generateRandomInt (int min, int max)
 Generate a random integer in the given range.
std::unique_ptr< char[]> compressString (const std::string &text, uLong &len)
 Compress a string using zlib.
std::string decompressString (void *data, uLong size_)
 Decompress a zlib-compressed data block.
std::vector< char > readFile (const std::string &filename)
 Read an entire file into a byte vector.
std::string readFileToString (const std::string &filename)
 Read an entire text file into a string.
static VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback (VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageType, const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData, void *pUserData)
static bool ends_with (const std::string &s, const std::string &suf)

Variables

static const int keys []
static const SDL_GameControllerButton ctrl []
TeeStream system_out (std::cout, log_file)
 Global stdout + log tee stream.
TeeStream system_err (std::cerr, error_file)
 Global stderr + log tee stream.

Enumeration Type Documentation

◆ DeformAxis

enum class mx::DeformAxis
strong

Axis selector for deformation operations.

Enumerator
X 
Y 
Z 

Definition at line 39 of file model.hpp.

◆ Input_Button

enum class mx::Input_Button
strong

Logical button identifiers for a standard gamepad.

Enumerator
BTN_A 

A / Cross button.

BTN_B 

B / Circle button.

BTN_X 

X / Square button.

BTN_Y 

Y / Triangle button.

BTNL_L 

Left shoulder button.

BTN_R 

Right shoulder button.

BTN_D_UP 

D-pad up.

BTN_D_DOWN 

D-pad down.

BTN_D_LEFT 

D-pad left.

BTN_D_RIGHT 

D-pad right.

BTN_START 

Start / Menu button.

BTN_BACK 

Back / Select button.

Definition at line 19 of file input.hpp.

Function Documentation

◆ compressString()

std::unique_ptr< char[]> mx::compressString ( const std::string & text,
uLong & len )

Compress a string using zlib.

Parameters
textInput string.
lenOutput: length of the compressed data.
Returns
Unique pointer to the compressed byte array.

Definition at line 31 of file util.cpp.

◆ debugCallback()

VKAPI_ATTR VkBool32 VKAPI_CALL mx::debugCallback ( VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
VkDebugUtilsMessageTypeFlagsEXT messageType,
const VkDebugUtilsMessengerCallbackDataEXT * pCallbackData,
void * pUserData )
static

Definition at line 246 of file vk.cpp.

Referenced by mx::VKWindow::createInstance().

◆ decompressString()

std::string mx::decompressString ( void * data,
uLong size_ )

Decompress a zlib-compressed data block.

Parameters
dataPointer to compressed data.
size_Size of compressed data in bytes.
Returns
Decompressed string.

Definition at line 46 of file util.cpp.

Referenced by mx::MXModel::loadMXMOD(), and mx::Model::openModel().

◆ ends_with() [1/2]

bool mx::ends_with ( const std::string & s,
const std::string & suf )
static

Definition at line 611 of file model.cpp.

Referenced by mx::MXModel::load(), mx::MXModel::loadMXMOD(), and mx::Model::openModel().

◆ ends_with() [2/2]

bool mx::ends_with ( const std::string & s,
const std::string & suf )
static

Definition at line 15 of file vk_model.cpp.

◆ error_file()

std::ofstream mx::error_file ( "error.log.txt" ,
std::ios::out  )
static

References error_file(), and log_file().

Referenced by error_file(), and redirect().

◆ generateRandomFloat()

float mx::generateRandomFloat ( float min,
float max )

Generate a random float in the given range.

Parameters
minLower bound (inclusive).
maxUpper bound (inclusive).
Returns
Random float in [min, max].

Definition at line 17 of file util.cpp.

◆ generateRandomInt()

int mx::generateRandomInt ( int min,
int max )

Generate a random integer in the given range.

Parameters
minLower bound (inclusive).
maxUpper bound (inclusive).
Returns
Random integer in [min, max].

Definition at line 24 of file util.cpp.

◆ log_file()

std::ofstream mx::log_file ( "system.log.txt" ,
std::ios::out  )
static

Referenced by error_file(), and redirect().

◆ readFile()

std::vector< char > mx::readFile ( const std::string & filename)

Read an entire file into a byte vector.

Parameters
filenamePath to the file.
Returns
Vector of bytes.

Definition at line 77 of file util.cpp.

Referenced by mx::VKWindow::createGraphicsPipeline(), mx::VKAbstractModel::createModelPipeline(), mx::VKWindow::createSpritePipeline(), mx::VKWindow::createTextPipeline(), mx::MXModel::loadMXMOD(), and mx::Model::openModel().

◆ readFileToString()

std::string mx::readFileToString ( const std::string & filename)

Read an entire text file into a string.

Parameters
filenamePath to the file.
Returns
File contents as a string.

Definition at line 90 of file util.cpp.

◆ redirect()

void mx::redirect ( )

Redirect std::cout and std::cerr through the tee streams.

After calling this function, all writes to std::cout and std::cerr are forwarded to both the terminal and the configured log file.

Definition at line 14 of file tee_stream.cpp.

References error_file(), log_file(), system_err, and system_out.

Referenced by gl::GLWindow::initGL(), gl::GLWindow::initGL(), and mx::mxWindow::mxWindow().

Variable Documentation

◆ ctrl

const SDL_GameControllerButton mx::ctrl[]
static
Initial value:
= {
SDL_CONTROLLER_BUTTON_A, SDL_CONTROLLER_BUTTON_B, SDL_CONTROLLER_BUTTON_X, SDL_CONTROLLER_BUTTON_Y,
SDL_CONTROLLER_BUTTON_LEFTSHOULDER, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER,
SDL_CONTROLLER_BUTTON_DPAD_UP, SDL_CONTROLLER_BUTTON_DPAD_DOWN,
SDL_CONTROLLER_BUTTON_DPAD_LEFT, SDL_CONTROLLER_BUTTON_DPAD_RIGHT,
SDL_CONTROLLER_BUTTON_START, SDL_CONTROLLER_BUTTON_BACK
}

Definition at line 14 of file input.cpp.

Referenced by mx::Input::getButton().

◆ keys

const int mx::keys[]
static
Initial value:
= {
SDL_SCANCODE_A, SDL_SCANCODE_S, SDL_SCANCODE_Z, SDL_SCANCODE_X,
SDL_SCANCODE_Q, SDL_SCANCODE_W, SDL_SCANCODE_UP, SDL_SCANCODE_DOWN,
SDL_SCANCODE_LEFT, SDL_SCANCODE_RIGHT, SDL_SCANCODE_RETURN, SDL_SCANCODE_ESCAPE
}

Definition at line 8 of file input.cpp.

Referenced by mx::Input::getButton(), and mx::ConfigFile::saveFile().

◆ system_err

◆ system_out