The Battle for Wesnoth  1.19.7+dev
Classes | Namespaces | Functions
draw.hpp File Reference

Drawing functions, for drawing things on the screen. More...

#include "sdl/rect.hpp"
#include "sdl/texture.hpp"
#include <vector>
#include <SDL2/SDL_render.h>
#include <array>
Include dependency graph for draw.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

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

Namespaces

 draw
 

Functions

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

Detailed Description

Drawing functions, for drawing things on the screen.

This includes pixel drawing for lines, rectangles and circles; fill and clear routines; and commands to render SDL surfaces and textures, in full or in part.

For the most part draw commands take coordinates in what is called "draw space", or "game-native coordinates". These are the coordinates that are used in WML, and can be thought of as pixels.

High-DPI textures and fonts will automatically use their full resolution when possible, without any extra handling required.

Definition in file draw.hpp.