The Battle for Wesnoth  1.19.0-dev
Classes | Functions
draw Namespace Reference

Classes

class  clip_setter
 A class to manage automatic restoration of the clipping region. More...
 
class  viewport_setter
 A class to manage automatic restoration of the viewport region. More...
 
class  render_target_setter
 A class to manage automatic restoration of the render target. More...
 

Functions

void clear ()
 Clear the current render target. More...
 
void fill (const SDL_Rect &rect, uint8_t r, uint8_t g, uint8_t b, uint8_t a)
 Fill an area with the given colour. More...
 
void fill (const SDL_Rect &rect, uint8_t r, uint8_t g, uint8_t b)
 
void fill (const SDL_Rect &rect, const color_t &color)
 
void fill (uint8_t r, uint8_t g, uint8_t b, uint8_t a)
 
void fill (uint8_t r, uint8_t g, uint8_t b)
 
void fill (const color_t &color)
 
void fill (const SDL_Rect &rect)
 Fill an area. More...
 
void fill ()
 
void set_color (uint8_t r, uint8_t g, uint8_t b, uint8_t a)
 Set the drawing colour. More...
 
void set_color (uint8_t r, uint8_t g, uint8_t b)
 
void set_color (const color_t &c)
 
void set_blend_mode (SDL_BlendMode b)
 Set the blend mode used for drawing operations such as fill() and line(). More...
 
void rect (const SDL_Rect &rect)
 Draw a rectangle. More...
 
void rect (const SDL_Rect &rect, uint8_t r, uint8_t g, uint8_t b, uint8_t a)
 Draw a rectangle using the given colour. More...
 
void rect (const SDL_Rect &rect, uint8_t r, uint8_t g, uint8_t b)
 
void rect (const SDL_Rect &rect, const color_t &color)
 
void line (int from_x, int from_y, int to_x, int to_y)
 Draw a line. More...
 
void line (int from_x, int from_y, int to_x, int to_y, const color_t &c)
 Draw a line of the given colour. More...
 
void points (const std::vector< SDL_Point > &points)
 Draw a set of points. More...
 
void point (int x, int y)
 Draw a single point. More...
 
void circle (int x, int y, int r, const color_t &c, uint8_t octants=0xff)
 Draw a circle of the given colour. More...
 
void circle (int x, int y, int r, uint8_t octants=0xff)
 
void disc (int x, int y, int r, const color_t &c, uint8_t octants=0xff)
 Draw a solid disc of the given colour. More...
 
void disc (int x, int y, int r, uint8_t octants=0xff)
 
void blit (const texture &tex, const SDL_Rect &dst)
 Draws a texture, or part of a texture, at the given location. More...
 
void blit (const texture &tex)
 
void flipped (const texture &tex, const SDL_Rect &dst, bool flip_h=true, bool flip_v=false)
 Draws a texture, or part of a texture, at the given location, also mirroring/flipping the texture horizontally and/or vertically. More...
 
void flipped (const texture &tex, bool flip_h=true, bool flip_v=false)
 
void tiled (const texture &tex, const SDL_Rect &dst, bool centered=false, bool mirrored=false)
 Tile a texture to fill a region. More...
 
void tiled_highres (const texture &tex, const SDL_Rect &dst, bool centered=false, bool mirrored=false)
 Tile a texture to fill a region. More...
 
void smooth_shaded (const texture &tex, const SDL_Rect &dst, const SDL_Color &cTL, const SDL_Color &cTR, const SDL_Color &cBL, const SDL_Color &cBR, const SDL_FPoint &uvTL, const SDL_FPoint &uvTR, const SDL_FPoint &uvBL, const SDL_FPoint &uvBR)
 Draw a texture with smoothly varying colour and alpha modification, specified at the four corners of the drawing destination. More...
 
void smooth_shaded (const texture &tex, const SDL_Rect &dst, const SDL_Color &cTL, const SDL_Color &cTR, const SDL_Color &cBL, const SDL_Color &cBR)
 
void smooth_shaded (const texture &tex, const std::array< SDL_Vertex, 4 > &verts)
 
clip_setter override_clip (const SDL_Rect &clip)
 Override the clipping area. More...
 
clip_setter reduce_clip (const SDL_Rect &clip)
 Set the clipping area to the intersection of the current clipping area and the given rectangle. More...
 
void force_clip (const SDL_Rect &clip)
 Set the clipping area, without any provided way of setting it back. More...
 
::rect get_clip ()
 Get the current clipping area, in draw coordinates. More...
 
bool clip_enabled ()
 Whether clipping is enabled. More...
 
void disable_clip ()
 Disable clipping. More...
 
bool null_clip ()
 Whether the current clipping region will disallow drawing. More...
 
viewport_setter set_viewport (const SDL_Rect &viewport)
 Set the viewport. More...
 
void force_viewport (const SDL_Rect &viewport)
 Set the viewport, without any provided way of setting it back. More...
 
SDL_Rect get_viewport ()
 Get the current viewport. More...
 
render_target_setter set_render_target (const texture &t)
 Set the given texture as the active render target. More...
 

Function Documentation

◆ blit() [1/2]

void draw::blit ( const texture tex)

Definition at line 322 of file draw.cpp.

References DBG_D, renderer(), and texture::src().

◆ blit() [2/2]

void draw::blit ( const texture tex,
const SDL_Rect &  dst 
)

Draws a texture, or part of a texture, at the given location.

The portion of the texture to be drawn will be scaled to fill the target rectangle.

This version takes coordinates in game-native resolution, which may be lower than the final output resolution in high-dpi contexts or if pixel scaling is used. The texture will be copied in high-resolution if possible.

Parameters
texThe texture to be copied / drawn.
dstThe target location to copy the texture to, in low-resolution game-native drawing coordinates. If null, this fills the entire render target.

Definition at line 310 of file draw.cpp.

References DBG_D, sdl::empty_rect, renderer(), and texture::src().

Referenced by font::floating_label::draw(), gui2::canvas::draw(), gui2::image_shape::draw(), gui2::text_shape::draw(), gui::dialog_frame::draw_background(), gui::dialog_frame::draw_border(), help::help_text_area::draw_contents(), gui::button::draw_contents(), gui::scrollbar::draw_contents(), gui::tristate_button::draw_contents(), gui::textbox::draw_contents(), arrow::draw_hex(), wb::attack::draw_hex(), wb::suppose_dead::draw_hex(), display::draw_hex(), editor::editor_display::draw_hex(), game_display::draw_hex(), display::draw_label(), game_display::draw_movement_info(), display::draw_report(), gui::menu::draw_row(), gui::menu::imgsel_style::draw_row(), gui::menu::imgsel_style::draw_row_bg(), display::expose(), gui2::window::expose(), font::pango_draw_text(), image::prep_minimap_for_rendering(), halo::halo_impl::effect::render(), display::scroll(), and tiled().

◆ circle() [1/2]

void draw::circle ( int  x,
int  y,
int  r,
const color_t c,
uint8_t  octants = 0xff 
)

Draw a circle of the given colour.

Only the outline of the circle is drawn. To draw a filled circle, use draw::disc().

The octants bitfield can be used to draw only certain octants of the circle, resulting in one or more arcs.

If no colour is specified, the current drawing colour will be used.

Parameters
xThe x coordinate of the center of the circle.
yThe y coordinate of the center of the circle.
rThe radius of the circle.
cThe colour of the circle.
octantsA bitfield indicating which octants to draw, starting at twelve o'clock and moving clockwise.

Definition at line 208 of file draw.cpp.

References c, and set_color().

Referenced by gui2::round_rectangle_shape::draw(), and gui2::circle_shape::draw().

◆ circle() [2/2]

void draw::circle ( int  x,
int  y,
int  r,
uint8_t  octants = 0xff 
)

Definition at line 214 of file draw.cpp.

References d, DBG_D, and points().

◆ clear()

void draw::clear ( )

Clear the current render target.

Sets all pixel values in the current render target to (0, 0, 0, 0), that is both black and fully transparent.

To clear to a fully opaque colour in stead, use fill().

Definition at line 40 of file draw.cpp.

References b, DBG_D, fill(), and renderer().

Referenced by game_lua_kernel::intf_toggle_fog(), image::prep_minimap_for_rendering(), gui2::window::update_render_textures(), and preprocessor_scope_helper::~preprocessor_scope_helper().

◆ clip_enabled()

bool draw::clip_enabled ( )

Whether clipping is enabled.

Definition at line 538 of file draw.cpp.

References renderer().

Referenced by reduce_clip().

◆ disable_clip()

void draw::disable_clip ( )

Disable clipping.

To enable clipping, use set_clip() or force_clip().

Definition at line 546 of file draw.cpp.

References DBG_D, and renderer().

Referenced by draw::clip_setter::~clip_setter(), and draw::viewport_setter::~viewport_setter().

◆ disc() [1/2]

void draw::disc ( int  x,
int  y,
int  r,
const color_t c,
uint8_t  octants = 0xff 
)

Draw a solid disc of the given colour.

The octants bitfield can be used to draw only certain octants of the disc, resulting in one or more filled wedges.

If no colour is specified, the current drawing colour will be used.

Parameters
xThe x coordinate of the center of the circle.
yThe y coordinate of the center of the circle.
rThe radius of the circle.
cThe colour of the circle.
octantsA bitfield indicating which octants to draw, starting at twelve o'clock and moving clockwise.

Definition at line 250 of file draw.cpp.

References c, and set_color().

Referenced by gui2::round_rectangle_shape::draw(), and gui2::circle_shape::draw().

◆ disc() [2/2]

void draw::disc ( int  x,
int  y,
int  r,
uint8_t  octants = 0xff 
)

Definition at line 256 of file draw.cpp.

References d, DBG_D, and line().

◆ fill() [1/8]

void draw::fill ( )

Definition at line 94 of file draw.cpp.

References DBG_D, and renderer().

◆ fill() [2/8]

void draw::fill ( const color_t color)

Definition at line 83 of file draw.cpp.

References c, and fill().

◆ fill() [3/8]

void draw::fill ( const SDL_Rect &  rect)

Fill an area.

Uses the current drawing colour set by set_draw_color(). Coordinates are given in draw space.

If a fill area is not specified, it will fill the entire render target.

Parameters
rectThe area to fill, in drawing coordinates.

Definition at line 88 of file draw.cpp.

References DBG_D, and renderer().

◆ fill() [4/8]

void draw::fill ( const SDL_Rect &  rect,
const color_t color 
)

Definition at line 66 of file draw.cpp.

References c, and fill().

◆ fill() [5/8]

void draw::fill ( const SDL_Rect &  rect,
uint8_t  r,
uint8_t  g,
uint8_t  b 
)

Definition at line 59 of file draw.cpp.

References b, fill(), and g.

◆ fill() [6/8]

void draw::fill ( const SDL_Rect &  rect,
uint8_t  r,
uint8_t  g,
uint8_t  b,
uint8_t  a 
)

Fill an area with the given colour.

If the alpha component is not specified, it defaults to fully opaque. If not fully opaque, the fill colour will apply according to the current blend mode, by default SDL_BLENDMODE_BLEND.

If a fill area is not specified, it will fill the entire render target.

Parameters
rectThe area to fill, in drawing coordinates.
rThe red component of the fill colour, 0-255.
gThe green component of the fill colour, 0-255.
bThe blue component of the fill colour, 0-255.
aThe alpha component of the fill colour, 0-255.

Definition at line 50 of file draw.cpp.

References a, b, DBG_D, g, and renderer().

Referenced by clear(), clear_credentials(), font::floating_label::draw(), gui2::rectangle_shape::draw(), gui2::round_rectangle_shape::draw(), help::help_text_area::draw_contents(), gui::scrollbar::draw_contents(), location_palette_item::draw_contents(), gui::textbox::draw_contents(), gui::textbox::draw_cursor(), gui2::widget::draw_debug_border(), display::draw_hex(), display::draw_minimap(), display::draw_minimap_units(), gui::menu::style::draw_row_bg(), display::expose(), fill(), gui2::implementation::placer_horizontal_list::initialize(), gui2::implementation::placer_vertical_list::initialize(), editor::context_manager::new_map(), editor::context_manager::new_map_dialog(), editor::context_manager::new_scenario(), editor::context_manager::new_scenario_dialog(), image::prep_minimap_for_rendering(), display::render_map_outside_area(), shroud_map::reset(), editor::context_manager::resize_map_dialog(), display::update_render_textures(), and secure_buffer::~secure_buffer().

◆ fill() [7/8]

void draw::fill ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)

Definition at line 78 of file draw.cpp.

References b, fill(), and g.

◆ fill() [8/8]

void draw::fill ( uint8_t  r,
uint8_t  g,
uint8_t  b,
uint8_t  a 
)

Definition at line 71 of file draw.cpp.

References a, b, DBG_D, g, and renderer().

◆ flipped() [1/2]

void draw::flipped ( const texture tex,
bool  flip_h = true,
bool  flip_v = false 
)

Definition at line 358 of file draw.cpp.

References DBG_D, get_flip(), renderer(), and texture::src().

◆ flipped() [2/2]

void draw::flipped ( const texture tex,
const SDL_Rect &  dst,
bool  flip_h = true,
bool  flip_v = false 
)

Draws a texture, or part of a texture, at the given location, also mirroring/flipping the texture horizontally and/or vertically.

By default the texture will be flipped horizontally.

Parameters
texThe texture to be copied / drawn.
dstThe target location to copy the texture to, in low-resolution game-native drawing coordinates. If not given, the entire render target will be filled.
flip_hWhether to flip/mirror the texture horizontally.
flip_vWhether to flip/mirror the texture vertically.

Definition at line 340 of file draw.cpp.

References DBG_D, sdl::empty_rect, get_flip(), renderer(), and texture::src().

Referenced by gui2::image_shape::draw(), halo::halo_impl::effect::render(), and tiled().

◆ force_clip()

void draw::force_clip ( const SDL_Rect &  clip)

Set the clipping area, without any provided way of setting it back.

Parameters
clipThe clipping area, in draw-space coordinates.

Definition at line 510 of file draw.cpp.

References DBG_D, renderer(), and WRN_D.

Referenced by draw::clip_setter::clip_setter(), draw::viewport_setter::viewport_setter(), draw::clip_setter::~clip_setter(), and draw::viewport_setter::~viewport_setter().

◆ force_viewport()

void draw::force_viewport ( const SDL_Rect &  viewport)

Set the viewport, without any provided way of setting it back.

The new viewport is specified in absolute coordinates, relative to the full drawing surface.

Parameters
viewportThe viewport, in absolute draw-space coordinates. If null, the viewport is reset to the full draw area.

Definition at line 601 of file draw.cpp.

References DBG_D, renderer(), and WRN_D.

Referenced by draw::viewport_setter::viewport_setter(), and draw::viewport_setter::~viewport_setter().

◆ get_clip()

rect draw::get_clip ( )

Get the current clipping area, in draw coordinates.

The clipping area is interpreted relative to the current viewport.

If clipping is disabled, this will return the full drawing area.

Definition at line 522 of file draw.cpp.

References sdl::empty_rect, get_viewport(), and renderer().

Referenced by font::floating_label::draw(), display::draw_label(), display::draw_minimap(), display::draw_panel(), display::expose(), gui2::window::expose(), reduce_clip(), and draw::viewport_setter::viewport_setter().

◆ get_viewport()

SDL_Rect draw::get_viewport ( )

Get the current viewport.

Returns
The current viewport, in the coordinate space of the original drawing surface

Definition at line 612 of file draw.cpp.

References video::draw_area(), sdl::empty_rect, renderer(), and WRN_D.

Referenced by get_clip(), and draw::viewport_setter::viewport_setter().

◆ line() [1/2]

void draw::line ( int  from_x,
int  from_y,
int  to_x,
int  to_y 
)

Draw a line.

Uses the current drawing colour set by set_color(). Coordinates are given in draw space.

Parameters
from_xThe X coordinate of the start point, in draw space.
from_yThe Y coordinate of the start point, in draw space.
to_xThe X coordinate of the end point, in draw space.
to_yThe Y coordinate of the end point, in draw space.

Definition at line 180 of file draw.cpp.

References DBG_D, and renderer().

Referenced by schema_validation::at(), schema_validation::schema_self_validator::check_for_duplicates(), schema_validation::schema_validator::detect_derivation_cycles(), disc(), gui2::line_shape::draw(), gui2::round_rectangle_shape::draw(), draw_rect_as_lines(), schema_validation::duplicate_key_error(), schema_validation::duplicate_tag_error(), schema_validation::extra_key_error(), schema_validation::extra_tag_error(), font::pango_text::get_column_line(), font::pango_text::get_cursor_position(), gui2::text_box_base::get_cursor_position(), gui2::get_hp_tooltip(), gui2::multiline_text::get_line_end_offset(), gui2::multiline_text::handle_mouse_selection(), utils::indent(), schema_validation::inheritance_cycle_error(), schema_validation::inheritance_loop_error(), intf_describe_plugins(), intf_object_dir(), lineno_string(), schema_validation::link_cycle_error(), schema_validation::missing_key_error(), schema_validation::missing_super_error(), schema_validation::missing_tag_error(), font::pango_line_size(), font::pango_line_width(), font::pango_word_wrap(), gui2::dialogs::end_credits::pre_show(), read_ignore_patterns(), throw_wml_exception(), unit_hp(), unit_weapons(), schema_validation::wrong_path_error(), schema_validation::wrong_tag_error(), schema_validation::wrong_type_error(), schema_validation::wrong_value_error(), and preferences::manager::~manager().

◆ line() [2/2]

void draw::line ( int  from_x,
int  from_y,
int  to_x,
int  to_y,
const color_t c 
)

Draw a line of the given colour.

Parameters
from_xThe X coordinate of the start point, in draw space.
from_yThe Y coordinate of the start point, in draw space.
to_xThe X coordinate of the end point, in draw space.
to_yThe Y coordinate of the end point, in draw space.
cThe RGBA colour of the line.

Definition at line 187 of file draw.cpp.

References c, DBG_D, and renderer().

◆ null_clip()

bool draw::null_clip ( )

Whether the current clipping region will disallow drawing.

This returns true for any clipping region with negative or zero width or height.

Definition at line 555 of file draw.cpp.

References renderer().

◆ override_clip()

draw::clip_setter draw::override_clip ( const SDL_Rect &  clip)

Override the clipping area.

All draw calls will be clipped to this region.

The clipping area is specified in draw-space coordinates.

The returned object will reset the clipping area when it is destroyed, so it should be kept in scope until drawing is complete.

Parameters
clipThe clipping region in draw-space coordinates.
Returns
A clip_setter object. When this object is destroyed the clipping region will be restored to whatever it was before this call.

Definition at line 497 of file draw.cpp.

Referenced by draw_manager::expose(), gui2::window::render(), and display::screenshot().

◆ point()

void draw::point ( int  x,
int  y 
)

Draw a single point.

Definition at line 202 of file draw.cpp.

References DBG_D, and renderer().

Referenced by gui2::tree_view_node::add_child_impl(), gui2::container_base::border_space(), gui2::panel::border_space(), gui2::toggle_panel::border_space(), gui2::implementation::builder_drawing::build(), gui2::drawing::calculate_best_size(), gui2::policy::placement::table::calculate_best_size(), gui2::scrollbar_container::calculate_best_size(), gui2::size_lock::calculate_best_size(), gui2::spacer::calculate_best_size(), gui2::widget::clear_layout_size(), gui2::scrollbar_container::content_resize_request(), video::current_resolution(), game_launcher::game_launcher(), gui2::grid::child::get_best_size(), gui2::widget::get_best_size(), gui2::styled_widget::get_best_text_size(), font::pango_text::get_column_line(), gui2::get_control(), gui2::tree_view_node::get_current_size(), font::pango_text::get_cursor_position(), gui2::window::get_linked_size(), gui2::widget::get_origin(), gui2::implementation::placer_horizontal_list::get_origin(), gui2::implementation::placer_vertical_list::get_origin(), gui2::implementation::placer_horizontal_list::get_size(), gui2::implementation::placer_vertical_list::get_size(), gui2::widget::get_size(), gui2::get_window_builder(), gui2::event::sdl_event_handler::handle_event(), gui2::combobox::handle_mouse_selection(), gui2::multiline_text::handle_mouse_selection(), gui2::text_box::handle_mouse_selection(), gui2::widget::layout_initialize(), gui2::viewport::place(), gui2::tree_view_node::place(), gui2::grid::child::place(), gui2::tree_view::remove_node(), gui2::tree_view_node::replace_children(), gui2::drawing::request_reduce_height(), gui2::drawing::request_reduce_width(), gui2::styled_widget::request_reduce_width(), preferences::resolution(), gui2::scroll_label::set_label(), gui2::scroll_text::set_label(), gui2::styled_widget::set_label(), gui2::scroll_text::set_max_size(), gui2::grid::set_origin(), gui2::widget::set_visible(), gui2::event::mouse_motion::show_tooltip(), gui2::pane::signal_handler_request_placement(), gui2::event::mouse_motion::stop_hover_timer(), tiled_highres(), and gui2::listbox::update_content_size().

◆ points()

void draw::points ( const std::vector< SDL_Point > &  points)

Draw a set of points.

Definition at line 196 of file draw.cpp.

References DBG_D, and renderer().

Referenced by circle().

◆ rect() [1/4]

void draw::rect ( const SDL_Rect &  rect)

◆ rect() [2/4]

void draw::rect ( const SDL_Rect &  rect,
const color_t color 
)

Definition at line 175 of file draw.cpp.

References c, and rect().

◆ rect() [3/4]

void draw::rect ( const SDL_Rect &  rect,
uint8_t  r,
uint8_t  g,
uint8_t  b 
)

Definition at line 170 of file draw.cpp.

References b, g, and rect().

◆ rect() [4/4]

void draw::rect ( const SDL_Rect &  rect,
uint8_t  r,
uint8_t  g,
uint8_t  b,
uint8_t  a 
)

Draw a rectangle using the given colour.

Parameters
rectThe rectangle to draw, in drawing coordinates.
rThe red component of the drawing colour, 0-255.
gThe green component of the drawing colour, 0-255.
bThe blue component of the drawing colour, 0-255.
aThe alpha component of the drawing colour, 0-255.

Definition at line 159 of file draw.cpp.

References a, b, DBG_D, draw_rect_as_lines(), g, renderer(), and sdl_bad_at_rects().

◆ reduce_clip()

draw::clip_setter draw::reduce_clip ( const SDL_Rect &  clip)

◆ set_blend_mode()

void draw::set_blend_mode ( SDL_BlendMode  b)

Set the blend mode used for drawing operations such as fill() and line().

This does not affect texture drawing operations such as blit(). For those, use texture::set_blend_mode() on the texture before blitting.

Definition at line 118 of file draw.cpp.

References b, and renderer().

◆ set_color() [1/3]

void draw::set_color ( const color_t c)

Definition at line 112 of file draw.cpp.

References c, DBG_D, and renderer().

◆ set_color() [2/3]

void draw::set_color ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)

Definition at line 106 of file draw.cpp.

References b, DBG_D, g, and renderer().

◆ set_color() [3/3]

void draw::set_color ( uint8_t  r,
uint8_t  g,
uint8_t  b,
uint8_t  a 
)

Set the drawing colour.

This is the colour used by fill(), line(), points(), etc..

If the alpha component is not specified, it defaults to fully opaque.

Parameters
rThe red component of the drawing colour, 0-255.
gThe green component of the drawing colour, 0-255.
bThe blue component of the drawing colour, 0-255.
aThe alpha component of the drawing colour, 0-255.

Definition at line 100 of file draw.cpp.

References a, b, DBG_D, g, and renderer().

Referenced by circle(), disc(), gui2::rectangle_shape::draw(), and gui2::round_rectangle_shape::draw().

◆ set_render_target()

draw::render_target_setter draw::set_render_target ( const texture t)

Set the given texture as the active render target.

The current viewport will also be cached and restored along with the render target.

All draw calls will draw to this texture until the returned object goes out of scope. Do not retain the render_target_setter longer than necessary.

The provided texture must have been created with the SDL_TEXTUREACCESS_TARGET access mode.

Parameters
tThe new render target. This must be a texture created with SDL_TEXTUREACCESS_TARGET, or an empty texture. If empty, it will set the render target to Wesnoth's primary render buffer.
Returns
A render_target_setter object. When this object is destroyed the render target will be restored to whatever it was before this call.

Definition at line 661 of file draw.cpp.

References DBG_D, and t.

Referenced by display::render(), gui2::window::render(), display::render_map_outside_area(), display::screenshot(), display::scroll(), gui2::canvas::update_blur(), display::update_render_textures(), and gui2::window::update_render_textures().

◆ set_viewport()

draw::viewport_setter draw::set_viewport ( const SDL_Rect &  viewport)

Set the viewport.

Drawing operations will have their coordinates adjusted to the viewport.

The top-left corner of the viewport will be interpreted as (0,0) in draw space coordinates while the returned object is in scope.

The new viewport is specified in absolute coordinates, relative to the full drawing surface.

The returned object will reset the viewport when it is destroyed, so it should be kept in scope until viewport-relative drawing is complete.

Parameters
viewportThe new viewport region, relative to the current viewport.
Returns
A viewport_setter object. When this object is destroyed the viewport will be restored to whatever it was before this call.

Definition at line 596 of file draw.cpp.

Referenced by gui2::widget::draw_background(), gui2::widget::draw_children(), and gui2::widget::draw_foreground().

◆ smooth_shaded() [1/3]

void draw::smooth_shaded ( const texture tex,
const SDL_Rect &  dst,
const SDL_Color &  cTL,
const SDL_Color &  cTR,
const SDL_Color &  cBL,
const SDL_Color &  cBR 
)

Definition at line 450 of file draw.cpp.

References smooth_shaded().

◆ smooth_shaded() [2/3]

void draw::smooth_shaded ( const texture tex,
const SDL_Rect &  dst,
const SDL_Color &  cTL,
const SDL_Color &  cTR,
const SDL_Color &  cBL,
const SDL_Color &  cBR,
const SDL_FPoint &  uvTL,
const SDL_FPoint &  uvTR,
const SDL_FPoint &  uvBL,
const SDL_FPoint &  uvBR 
)

Draw a texture with smoothly varying colour and alpha modification, specified at the four corners of the drawing destination.

The UV texture coordinates at each corner may also be specified. If unspecified, the full texture will be drawn.

Colour modifiers multiply the output colour and alpha by their value after mapping to the range [0,1]. A value of 255 will have no effect.

Parameters
texThe texture to draw
dstWhere to draw the texture, in draw space
cTLThe colour modifier at the top-left corner
cTRThe colour modifier at the top-right corner
cBLThe colour modifier at the bottom-left corner
cBRThe colour modifier at the bottom-right corner
uvTLThe UV texture coordinate at the top-left corner
uvTRThe UV texture coordinate at the top-right corner
uvBLThe UV texture coordinate at the bottom-left corner
uvBRThe UV texture coordinate at the bottom-right corner

Definition at line 431 of file draw.cpp.

Referenced by display::draw_hex(), and smooth_shaded().

◆ smooth_shaded() [3/3]

void draw::smooth_shaded ( const texture tex,
const std::array< SDL_Vertex, 4 > &  verts 
)

Definition at line 464 of file draw.cpp.

References DBG_D, and renderer().

◆ tiled()

void draw::tiled ( const texture tex,
const SDL_Rect &  dst,
bool  centered = false,
bool  mirrored = false 
)

Tile a texture to fill a region.

This function tiles the texture in draw-space.

The texture may be aligned either with its center at the center of the region, or with its top-left corner at the top-left corner of the region.

Parameters
texThe texture to use to fill the region.
dstThe region to fill, in draw space.
centeredIf true the tiled texture will be centered. If false, it will align at the top-left.
mirroredIf true the texture will be mirrored in such a way that adjacent tiles always share a common edge. This can look better for images that are not perfect tiles.

Definition at line 369 of file draw.cpp.

References blit(), DBG_D, flipped(), texture::h(), reduce_clip(), t, and texture::w().

Referenced by gui2::image_shape::draw(), display::draw_panel(), and display::render_map_outside_area().

◆ tiled_highres()

void draw::tiled_highres ( const texture tex,
const SDL_Rect &  dst,
bool  centered = false,
bool  mirrored = false 
)

Tile a texture to fill a region.

This function tiles the texture in output space. It is otherwise identical to draw::tiled().

Definition at line 397 of file draw.cpp.

References DBG_D, get_flip(), video::get_pixel_scale(), texture::get_raw_size(), h, preferences::pixel_scale(), point(), reduce_clip(), renderer(), utf8::size(), t, and w.

Referenced by gui2::image_shape::draw().