MTek-GDL 0.100.4-muffintrap
Loading...
Searching...
No Matches
Functions
mgdl-draw2d.h File Reference

Functions for basic 2D drawing operations. More...

#include <mgdl/mgdl-color.h>
#include <mgdl/mgdl-types.h>

Go to the source code of this file.

Functions

Rect Rect_Create (short x, short y, short w, short h)
 Creates a rectangle struct.
 
Rect Rect_CreateV2f (vec2 position, vec2 size)
 Creates a rectangle struct.
 
void Draw2D_OrigoTo (short x, short y)
 Translates the origo to given point.
 
void Draw2D_OrigoToV2f (vec2 origo)
 
void Draw2D_RectLines (short x, short y, short x2, short y2, Color4f *color)
 Draws a box border.
 
void Draw2D_RectLinesWH (short x, short y, short w, short h, Color4f *color)
 
void Draw2D_RectLinesRec (Rect rect, Color4f *color)
 
void Draw2D_Rect (short x, short y, short x2, short y2, Color4f *color)
 Draws a filled box.
 
void Draw2D_RectR (Rect rect, Color4f *color)
 
void Draw2D_Quad (short xtl, short ytl, short xbl, short ybl, short xbr, short ybr, short xtr, short ytr, Color4f *color)
 Draws a filled quad with freely positioned corners.
 
void Draw2D_QuadV2f (vec2 tl, vec2 bl, vec2 br, vec2 tr, Color4f *color)
 
void Draw2D_Line (short int x, short int y, short int x2, short int y2, Color4f *color)
 Draws a line.
 
void Draw2D_LineV2f (vec2 start, vec2 end, Color4f *color)
 Draws a line.
 
void Draw2D_Text (short x, short y, const char *text, Color4f *color)
 Draws text using the default font.
 
void Draw2D_TextV2f (vec2 position, const char *text, Color4f *color)
 Draws text using the default font.
 

Detailed Description

Functions for basic 2D drawing operations.

2D drawing functions for debugging and ui elements and simple games. These functions expect the ortographic projection be set

Function Documentation

◆ Draw2D_Line()

void Draw2D_Line ( short int  x,
short int  y,
short int  x2,
short int  y2,
Color4f color 
)

Draws a line.

Parameters
xStart point x
yStart point y
x2End point x
y2End point y
colorColor of the line.

◆ Draw2D_LineV2f()

void Draw2D_LineV2f ( vec2  start,
vec2  end,
Color4f color 
)

Draws a line.

Parameters
startStart point
endStart point
colorColor of the line.

◆ Draw2D_OrigoTo()

void Draw2D_OrigoTo ( short  x,
short  y 
)

Translates the origo to given point.

Parameters
xOrigo x in screen units.
xOrigo y in screen units.

◆ Draw2D_Quad()

void Draw2D_Quad ( short  xtl,
short  ytl,
short  xbl,
short  ybl,
short  xbr,
short  ybr,
short  xtr,
short  ytr,
Color4f color 
)

Draws a filled quad with freely positioned corners.

Note
The points needs to be in correct relation to each other since the quad is drawn counter-clockwise.
Parameters
xtlUpper left corner x in screen units.
ytlUpper left corner y in screen units.
xblLower left corner x in screen units.
yblLower left corner y in screen units.
xbrLower right corner x in screen units.
ybrLower right corner y in screen units.
xtrUpper right corner x in screen units.
ytrUpper right corner y in screen units.
colorColor of the quad.

◆ Draw2D_Rect()

void Draw2D_Rect ( short  x,
short  y,
short  x2,
short  y2,
Color4f color 
)

Draws a filled box.

Parameters
xUpper left corner x in screen units.
yUpper left corner y in screen units.
x2Lower right corner x in screen units.
y2Lower right corner y in screen units.
colorColor of the box.

◆ Draw2D_RectLines()

void Draw2D_RectLines ( short  x,
short  y,
short  x2,
short  y2,
Color4f color 
)

Draws a box border.

The box is drawn using GL_LINES so the width is 1 pixel by default

Parameters
xUpper left corner x in screen units.
yUpper left corner y in screen units.
x2Lower right corner x in screen units.
y2Lower right corner y in screen units.
colorColor of the border

◆ Draw2D_Text()

void Draw2D_Text ( short  x,
short  y,
const char *  text,
Color4f color 
)

Draws text using the default font.

Parameters
xUpper left x of first letter.
yUpper left y of first letter.
textText to be drawn.
colorColor of the text.

◆ Draw2D_TextV2f()

void Draw2D_TextV2f ( vec2  position,
const char *  text,
Color4f color 
)

Draws text using the default font.

Parameters
positionUpper left corner of first letter
textText to be drawn.
colorColor of the text.

◆ Rect_Create()

Rect Rect_Create ( short  x,
short  y,
short  w,
short  h 
)

Creates a rectangle struct.

Parameters
xTop left corner x
yTop left corner y
wWidth of rectangle
hHeight of rectangle
Returns
Created rectangle

◆ Rect_CreateV2f()

Rect Rect_CreateV2f ( vec2  position,
vec2  size 
)

Creates a rectangle struct.

Parameters
positionTop left corner
sizeSize of rectangle: x is width, y is height
Returns
Created rectangle