VSGL2 - Very Simple Graphic Library 2  2.0
 All Classes Namespaces Files Functions Variables Macros Pages
Functions
vsgl2::video Namespace Reference

Functions

bool done ()
 Use this function to check when to stop the main loop. More...
 
void undone ()
 Use this function to reset the isDone glabal variable to its initial state (false) This can be useful when you want to use the done() function more then one time inside a program, i.e. in a video game to restart a new game. More...
 
void update ()
 Use this function to update the screen after drawing on it Typically called at the end of the main loop. More...
 
void draw_point (int x, int y, const Color &c)
 Use to draw a point at x,y coordinates. More...
 
void draw_rect (int x, int y, int w, int h, const Color &c)
 Use to draw a rectangle (only the border), use instead draw_filled_rect to draw a rectangle filled with color. More...
 
void draw_filled_rect (int x, int y, int w, int h, const Color &c)
 Use to draw a filled rectangle, use instead draw_rect to draw an empty rectangle with colored borders. More...
 
void draw_line (int x1, int y1, int x2, int y2, const Color &c)
 Use to draw a line. More...
 
void draw_image (string image, int x, int y, int w, int h, uint8_t alpha=255)
 Use to draw an image (BMP, PNG, JPG) More...
 

Function Documentation

bool done ( )

Use this function to check when to stop the main loop.

Returns
True if the user has clicked on the X to close the window or has pressed ESC to close the program
void draw_filled_rect ( int  x,
int  y,
int  w,
int  h,
const Color c 
)

Use to draw a filled rectangle, use instead draw_rect to draw an empty rectangle with colored borders.

Parameters
xThe x coordinate of the upper left corner
yThe y coordinate of the upper left corner
wThe width of the rectangle
hThe height of the rectangle
cThe color of the borders of the rectangle
void draw_image ( string  image,
int  x,
int  y,
int  w,
int  h,
uint8_t  alpha = 255 
)

Use to draw an image (BMP, PNG, JPG)

Parameters
imageThe image name, either absolute or relative
xThe x coordinate of the upper left corner of the image inside the window coordinates
yThe y coordinate of the upper left corner of the image inside the window coordinates
wThe width of the image as it will appear inside the window, not its original value
hThe height of the image as it will appear inside the window, not its original value
[alpha]The transparency value for the image: with 255 (the default), the image will look as the original, with 0 the image will become invisible
Warning
The width and the height can be set as wanted, but it is better to have the dimension of the image in the file the same as in w and h to reduce CPU load and improve performance
void draw_line ( int  x1,
int  y1,
int  x2,
int  y2,
const Color c 
)

Use to draw a line.

Parameters
x1The x coordinate of an end point
y1The y coordinate of an end point
x2The x coordinate of the other end point
y2The y coordinate of the other end point
cThe color of the line
void draw_point ( int  x,
int  y,
const Color c 
)

Use to draw a point at x,y coordinates.

Parameters
xThe x coordinate
yThe y coordinate
cThe color of the point
Warning
In the present implementation this function is very slow, so using it for drawing a large amount of points should be avoided
void draw_rect ( int  x,
int  y,
int  w,
int  h,
const Color c 
)

Use to draw a rectangle (only the border), use instead draw_filled_rect to draw a rectangle filled with color.

Parameters
xThe x coordinate of the upper left corner
yThe y coordinate of the upper left corner
wThe width of the rectangle
hThe height of the rectangle
cThe color of the rectangle
void undone ( )

Use this function to reset the isDone glabal variable to its initial state (false) This can be useful when you want to use the done() function more then one time inside a program, i.e. in a video game to restart a new game.

void update ( )

Use this function to update the screen after drawing on it Typically called at the end of the main loop.