Skip to content

Types ​

Core type aliases used throughout the ASW library.

Header: #include <asw/modules/types.h>
Namespace: asw

Type Aliases ​

TypeUnderlyingDescription
asw::Texturestd::shared_ptr<SDL_Texture>A shared pointer to an SDL texture
asw::Fontstd::shared_ptr<TTF_Font>A shared pointer to a TTF font
asw::Samplestd::shared_ptr<MIX_Audio>A shared pointer to a sound effect
asw::Musicstd::shared_ptr<MIX_Audio>A shared pointer to music
asw::RendererSDL_RendererAlias for the SDL renderer
asw::WindowSDL_WindowAlias for the SDL window

All asset types (Texture, Font, Sample, Music) use shared_ptr for automatic memory management.

BlendMode Enum ​

cpp
enum class BlendMode : SDL_BlendMode {
  None,
  Blend,
  BlendPremultiplied,
  Add,
  AddPremultiplied,
  Modulate,
  Multiply,
};
ValueDescription
NoneNo blending
BlendAlpha blending
BlendPremultipliedPre-multiplied alpha blending
AddAdditive blending
AddPremultipliedPre-multiplied additive blending
ModulateColor modulation
MultiplyMultiply blending

The underlying type of BlendMode is SDL_BlendMode, so you can cast between the two directly.

ScaleMode Enum ​

cpp
enum class ScaleMode {
  Nearest,
  Linear,
};

Sets how a texture is filtered when it is scaled. Pass it to asw::draw::set_scale_mode().

ValueDescription
NearestNearest-pixel filtering. Keeps hard pixel edges
LinearLinear filtering. Makes scaled textures smooth

The values map to SDL_SCALEMODE_NEAREST and SDL_SCALEMODE_LINEAR.

Falloff Enum ​

cpp
enum class Falloff {
  Linear,
  Smooth,
  Quadratic,
};

How a gradient or light fades from its center to its edge. Used by create_radial_gradient(), easing::falloff() and lights.

ValueDescription
LinearEven fade to the edge
SmoothSoft at the center and at the edge
QuadraticBright core that drops off quickly, closer to a real light

TextJustify Enum ​

cpp
enum class TextJustify {
  Left,
  Center,
  Right,
};

Used with asw::draw::text() and asw::game::Text to control text alignment.

FontStyle Enum ​

cpp
enum class FontStyle {
  Smooth,
  Pixel,
};

Sets how the glyphs of a font are rendered. Pass it to asw::assets::load_font().

ValueDescription
SmoothAnti-aliased glyphs rendered at the output resolution, for regular fonts. Text stays sharp when the window is scaled up or on high density displays
PixelHard-edged glyphs rendered at the logical size and scaled with nearest filtering, for pixel art fonts

Example ​

cpp
asw::Color red(255, 0, 0);
asw::Texture tex = asw::assets::load_texture("image.png");

Released under the MIT License.