trase
trase::BackendGL Class Reference
Inheritance diagram for trase::BackendGL:
Collaboration diagram for trase::BackendGL:

Public Member Functions

void init (const vfloat2_t &pixels, const char *name)
 Initialise this backend. More...
 
void finalise ()
 Finalise this backend. Call after all drawing finished.
 
vfloat2_t begin_frame ()
 Begin a new frame. More...
 
void end_frame ()
 End the current frame. More...
 
bool is_interactive ()
 Return true if this backend has mouse interaction.
 
bool should_close ()
 Returns true if the current window should close (e.g. More...
 
float get_time ()
 Get the current time.
 
vfloat2_t get_mouse_pos ()
 Get the current position of the mouse in pixel units.
 
bool mouse_dragging ()
 Returns true if the mouse button is clicked and the mouse is dragging.
 
vfloat2_t mouse_drag_delta ()
 Current delta position of the dragging mouse.
 
void mouse_drag_reset_delta ()
 Reset drag delta to zero.
 
void scissor (const bfloat2_t &x)
 All subsequent drawing calls will be masked to only show within the bounding box x.
 
void reset_scissor ()
 Remove a previously call to scissor()
 
void rotate (const float angle)
 Apply a rotation of angle to the current drawing transform.
 
void translate (const vfloat2_t &v)
 Apply a translation of v to the current drawing transform.
 
void reset_transform ()
 Reset the drawing transform to the identity matrix.
 
void begin_path ()
 Begin a path. More...
 
void move_to (const vfloat2_t &x)
 Extends the current path. More...
 
void line_to (const vfloat2_t &x)
 Extends the current path. More...
 
void stroke ()
 Draw a line along the completed path. More...
 
void fill ()
 Draw a line along the completed path and fill it in. More...
 
void stroke_width (const float lw)
 Set the current stroke width. More...
 
void stroke_color (const RGBA &color)
 Set the current stroke color. More...
 
void fill_color (const RGBA &color)
 Set the current fill color. More...
 
void rounded_rect (const bfloat2_t &x, const float r)
 Draw a rectangle with rounded corners. More...
 
void rect (const bfloat2_t &x)
 Draw a rectangle. More...
 
void circle (const vfloat2_t &centre, float radius)
 Draw a circle with a given centre and radius.
 
void text (const vfloat2_t &x, const char *string, const char *end)
 Draw the given text to the screen. More...
 
bfloat2_t text_bounds (const vfloat2_t &x, const char *string)
 Returns the bounding box covering the given text. More...
 
void font_size (float size)
 Sets the current font height in pixels. More...
 
void font_face (const char *face)
 Sets the current font name. More...
 
void font_blur (const float blur)
 Sets the amount of blur to apply to the drawn text. More...
 
void text_align (const int align)
 Sets the alignment of the text to its position. More...
 
- Public Member Functions inherited from trase::Backend
virtual void accept (Drawable &drawable, float time)=0
 

Static Public Member Functions

static void set_mouse_down (const vfloat2_t &mouse_pos)
 
static void set_mouse_up ()
 

Member Function Documentation

◆ begin_frame()

vfloat2_t trase::BackendGL::begin_frame ( )

Begin a new frame.

All drawing calls must be between begin_frame() and end_frame()

◆ begin_path()

void trase::BackendGL::begin_path ( )

Begin a path.

Subsequent calls to move_to() or line_to() defines the path to be drawn. The current path is completed by a call to stroke() or fill()

◆ end_frame()

void trase::BackendGL::end_frame ( )

End the current frame.

All drawing calls must be between begin_frame() and end_frame()

◆ fill()

void trase::BackendGL::fill ( )

Draw a line along the completed path and fill it in.

See also
begin_path()

◆ fill_color()

void trase::BackendGL::fill_color ( const RGBA color)

Set the current fill color.

See also
fill()

◆ font_blur()

void trase::BackendGL::font_blur ( const float  blur)

Sets the amount of blur to apply to the drawn text.

See also
text()

◆ font_face()

void trase::BackendGL::font_face ( const char *  face)

Sets the current font name.

See also
text()

◆ font_size()

void trase::BackendGL::font_size ( float  size)

Sets the current font height in pixels.

See also
text()

◆ init()

void trase::BackendGL::init ( const vfloat2_t pixels,
const char *  name 
)

Initialise this backend.

Call before any drawing

Parameters
pixelsthe size of the window in pixels
namethe name of the window

◆ line_to()

void trase::BackendGL::line_to ( const vfloat2_t x)

Extends the current path.

Draws a straight line from the current "pen" position to x

See also
begin_path()

◆ move_to()

void trase::BackendGL::move_to ( const vfloat2_t x)

Extends the current path.

Moves the current "pen" position to the position x

See also
begin_path()

◆ rect()

void trase::BackendGL::rect ( const bfloat2_t x)

Draw a rectangle.

Parameters
xthe bounding box describing the rectangle

◆ rounded_rect()

void trase::BackendGL::rounded_rect ( const bfloat2_t x,
const float  r 
)

Draw a rectangle with rounded corners.

Parameters
xthe bounding box describing the rectangle
rthe radius of the rounded corners

◆ should_close()

bool trase::BackendGL::should_close ( )

Returns true if the current window should close (e.g.

due to user interaction)

◆ stroke()

void trase::BackendGL::stroke ( )

Draw a line along the completed path.

See also
begin_path()

◆ stroke_color()

void trase::BackendGL::stroke_color ( const RGBA color)

Set the current stroke color.

See also
stroke()

◆ stroke_width()

void trase::BackendGL::stroke_width ( const float  lw)

Set the current stroke width.

See also
stroke()

◆ text()

void trase::BackendGL::text ( const vfloat2_t x,
const char *  string,
const char *  end 
)

Draw the given text to the screen.

Parameters
xthe position to draw the text
apointer to the text
endthe end of the text to draw (use nullptr to draw entire string)

◆ text_align()

void trase::BackendGL::text_align ( const int  align)

Sets the alignment of the text to its position.

See also
text()

◆ text_bounds()

bfloat2_t trase::BackendGL::text_bounds ( const vfloat2_t x,
const char *  string 
)

Returns the bounding box covering the given text.

Parameters
xthe drawing position of the text
stringpointer to the text

The documentation for this class was generated from the following files: