VSGL2 - Very Simple Graphic Library 2  2.0
 All Classes Namespaces Files Functions Variables Macros Pages
Classes | Namespaces | Functions | Variables
vsgl2.h File Reference

Very Simple Graphic Library 2. More...

#include <string>
#include <sstream>
#include <SDL2/SDL.h>
#include <SDL2/SDL_net.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_mixer.h>
#include <SDL2/SDL_ttf.h>
#include "vsgl2_keycode.h"

Go to the source code of this file.

Classes

class  Color
 

Namespaces

 vsgl2
 
 vsgl2::general
 
 vsgl2::video
 
 vsgl2::audio
 
 vsgl2::io
 
 vsgl2::ttf_fonts
 
 vsgl2::utils
 

Functions

void init ()
 Use this function to initiate the library, must be called first. More...
 
void close ()
 Close and free all the resources, must be called last. More...
 
void set_window (int w, int h, string title, int fullscreen=0)
 Use this function to create a window with the specified dimensions and a title, optionally in full screen. More...
 
void set_background_color (const Color &bg)
 Use this function to change the background color. More...
 
int get_window_width ()
 Use this function to get the width of the current window. More...
 
int get_window_height ()
 Use this function to get the height of the current window. More...
 
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_line (int x1, int y1, int x2, int y2, const Color &c)
 Use to draw a line. 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_image (string image, int x, int y, int w, int h, uint8_t alpha=255)
 Use to draw an image (BMP, PNG, JPG) More...
 
void play_music (string music)
 Use to play a music in a loop (WAVE, MOD, MIDI, OGG, MP3, FLAC, and any file that you use a command to play with). It can be typically used to play a background music. More...
 
void pause_music ()
 Use to pause the music that is currently playing. More...
 
void stop_music ()
 Use to stop the music that is currently playing. More...
 
void play_sound (string sound)
 Use to play a sound (WAVE, MOD, MIDI, OGG, MP3, FLAC, and any file that you use a command to play with). It can be typically used to play a sound effect linked to an user action (pressing a button...). More...
 
bool is_pressed (int key)
 Use to check if a button is pressed. More...
 
string read_text (string font, int dim, int x, int y, Color c, uint8_t max_length=0)
 Use to read text from the user, the return key stops the input. More...
 
int get_mouse_x ()
 Use to get the mouse x coordinate. More...
 
int get_mouse_y ()
 Use to get the mouse y coordinate. More...
 
int get_mouse_wheel_x ()
 Use to get the mouse wheel horizontal value,. More...
 
int get_mouse_wheel_y ()
 Use to get the mouse wheel vertical value,. More...
 
bool mouse_left_button_pressed ()
 Use to check if the mouse left button is pressed. More...
 
bool mouse_right_button_pressed ()
 Use to check if the mouse right button is pressed. More...
 
void draw_text (string font, int dim, string text, int x, int y, Color c)
 Use this function to display a text on the screen with the desired font and dimension. More...
 
int text_width (string font, int dim, string text)
 Use this function to retrieve the width of a string, given the font, the dimension and the text. It can be useful because each character has a different size in general, so it could be very tricky to calculate the actual width of a string. More...
 
int text_height (string font, int dim, string text)
 Use this function to retrieve the height of a string, given the font, the dimension and the text. It can be useful because each character has a different size in general, so it could be very tricky to calculate the actual height of a string. More...
 
void wait_for_button_pressed ()
 Use this function to wait for any button to be pressed. More...
 
void delay (int milliseconds)
 Use this function to stop the execution for a given amount of milliseconds. More...
 
unsigned int ms_time ()
 Use this function to get the time from SDL initialization in milliseconds. More...
 
int take_screenshot (string filename)
 Use this function to take a screenshot of the window. More...
 

Variables

const int VSGL_0 = SDL_SCANCODE_0
 
const int VSGL_1 = SDL_SCANCODE_1
 
const int VSGL_2 = SDL_SCANCODE_2
 
const int VSGL_3 = SDL_SCANCODE_3
 
const int VSGL_4 = SDL_SCANCODE_4
 
const int VSGL_5 = SDL_SCANCODE_5
 
const int VSGL_6 = SDL_SCANCODE_6
 
const int VSGL_7 = SDL_SCANCODE_7
 
const int VSGL_8 = SDL_SCANCODE_8
 
const int VSGL_9 = SDL_SCANCODE_9
 
const int VSGL_A = SDL_SCANCODE_A
 
const int VSGL_B = SDL_SCANCODE_B
 
const int VSGL_C = SDL_SCANCODE_C
 
const int VSGL_D = SDL_SCANCODE_D
 
const int VSGL_E = SDL_SCANCODE_E
 
const int VSGL_F = SDL_SCANCODE_F
 
const int VSGL_G = SDL_SCANCODE_G
 
const int VSGL_H = SDL_SCANCODE_H
 
const int VSGL_I = SDL_SCANCODE_I
 
const int VSGL_J = SDL_SCANCODE_J
 
const int VSGL_K = SDL_SCANCODE_K
 
const int VSGL_L = SDL_SCANCODE_L
 
const int VSGL_M = SDL_SCANCODE_M
 
const int VSGL_N = SDL_SCANCODE_N
 
const int VSGL_O = SDL_SCANCODE_O
 
const int VSGL_P = SDL_SCANCODE_P
 
const int VSGL_Q = SDL_SCANCODE_Q
 
const int VSGL_R = SDL_SCANCODE_R
 
const int VSGL_S = SDL_SCANCODE_S
 
const int VSGL_T = SDL_SCANCODE_T
 
const int VSGL_U = SDL_SCANCODE_U
 
const int VSGL_V = SDL_SCANCODE_V
 
const int VSGL_W = SDL_SCANCODE_W
 
const int VSGL_X = SDL_SCANCODE_X
 
const int VSGL_Y = SDL_SCANCODE_Y
 
const int VSGL_Z = SDL_SCANCODE_Z
 
const int VSGL_LEFT = SDL_SCANCODE_LEFT
 
const int VSGL_RIGHT = SDL_SCANCODE_RIGHT
 
const int VSGL_UP = SDL_SCANCODE_UP
 
const int VSGL_DOWN = SDL_SCANCODE_DOWN
 
const int VSGL_ESC = SDL_SCANCODE_ESCAPE
 
const int VSGL_SPACE = SDL_SCANCODE_SPACE
 
const int FULLSCREEN = SDL_WINDOW_FULLSCREEN
 

Detailed Description

Very Simple Graphic Library 2.

Author
Alessandro Bugatti
Version
0.1
Date
Creation 2016/11/08