SANDAL2
A SDL2 Wrapper in C
Functions | Variables
SANDAL2.h File Reference

SANDAL2.h is the file to include which includes everything else. Compilation flags to use : -lSDL2 -lSDL2_ttf -lSDL2_image -lm. More...

#include "Element.h"
Include dependency graph for SANDAL2.h:

Go to the source code of this file.

Functions

int initAllSANDAL2 (int imageFlags)
 Initialisation of SANDAL2, its image and fonts (return 1 if initialisation error, 2 if image initialisation error, 3 if font initialisation error, 0 if not) using SDL2's image flags. More...
 
void closeAllSANDAL2 (void)
 Close SANDAL2, images and font.
 
int initSANDAL2 (void)
 Initialisation of SANDAL2 alone. More...
 
int initImageSANDAL2 (int imageFlags)
 Initialisation of images alone. More...
 
int initTextSANDAL2 (void)
 Initialisation of text alone. More...
 
void closeSANDAL2 (void)
 Close SDL2.
 
void closeImageSANDAL2 (void)
 Close images.
 
void closeTextSANDAL2 (void)
 Close font.
 
Uint32 createWindow (int width, int height, const char *title, int SDLFlags, int background[4], int displayCode)
 Add a window to the list of windows. More...
 
int closeWindow (void)
 close the current windows and go to the next, do not use this one in elements' or windows' binded functions, use shouldCloseWindow() instead More...
 
int shouldCloseWindow (void)
 tells that the current window should be closed, do not use this one in functions that are not binded to windows or elements, use closeWindow() instead More...
 
int closeAllWindow (void)
 close all windows More...
 
int toggleFullScreenWindow (void)
 Toggle the full screen mode of the current window. More...
 
int isFullScreenWindow (void)
 Tells whether or not the window is in full screen mode. More...
 
int updateWindow (void)
 update all the elements of the current window More...
 
int displayWindow (void)
 actualise the display of the current window More...
 
int clickWindow (SDL_MouseButtonEvent button)
 activation of click events on the current window More...
 
int unclickWindow (SDL_MouseButtonEvent button)
 activation of unclick events on the current window More...
 
int keyPressedWindow (int c)
 activation of the key pressed events on the current window More...
 
int keyReleasedWindow (int c)
 activation of the key released events on the current window More...
 
int onMouseMotionWindow (int x, int y)
 activate the mouse motion events on the current window More...
 
int onWheelWindow (int y)
 activation of the mouseWheel event on the current window More...
 
int onFocusedWindow (void)
 activation of the gaining focus event More...
 
int unFocusedWindow (void)
 activation of the losing focus event More...
 
unsigned long updateAllWindow (void)
 update all the elements of all the windows More...
 
unsigned long displayAllWindow (void)
 actualise the display of all the windows More...
 
int PollEvent (unsigned long *error)
 Get the event (if there is one) and apply the corresponding functions. More...
 
unsigned long mainLoop (unsigned short maxFPS)
 Run the standard SANDAL2 loop Do PollEvent(), call update then display and wait for a certain amount of milliseconds. More...
 

Variables

ListWindow_windows_SANDAL2
 list of windows WARNING : do not touch this variable, never ... trust me More...
 

Detailed Description

SANDAL2.h is the file to include which includes everything else. Compilation flags to use : -lSDL2 -lSDL2_ttf -lSDL2_image -lm.

Author
Baptiste PRUNIER (KLEVH)
Version
1.4.0

Function Documentation

◆ clickWindow()

int clickWindow ( SDL_MouseButtonEvent  button)

activation of click events on the current window

Parameters
button: Event informations of the button
Returns
1 if it failed, 0 if not

◆ closeAllWindow()

int closeAllWindow ( void  )

close all windows

Returns
1 if it failed, 0 if not

◆ closeWindow()

int closeWindow ( void  )

close the current windows and go to the next, do not use this one in elements' or windows' binded functions, use shouldCloseWindow() instead

Returns
1 if it failed, 0 if not

◆ createWindow()

Uint32 createWindow ( int  width,
int  height,
const char *  title,
int  SDLFlags,
int  background[4],
int  displayCode 
)

Add a window to the list of windows.

Parameters
width: width of the window
height: height of the window
title: title of the window
SDLFlags: flags of SDL2
background: color of the background
displayCode: display code of the window
Returns
0 if it failed, the window ID if not

◆ displayAllWindow()

unsigned long displayAllWindow ( void  )

actualise the display of all the windows

Returns
0 if it succeeded, a binary code telling which window failed (example : 100101 tells that the second and the fifth window failed, the first bit on the rigth only tells that there was an error), if you have more window than bits for int, you will not be able to tell which of the window failed in those which have a bigger number than the number of bit minus one

◆ displayWindow()

int displayWindow ( void  )

actualise the display of the current window

Returns
1 if it failed, 0 if not

◆ initAllSANDAL2()

int initAllSANDAL2 ( int  imageFlags)

Initialisation of SANDAL2, its image and fonts (return 1 if initialisation error, 2 if image initialisation error, 3 if font initialisation error, 0 if not) using SDL2's image flags.

Parameters
imageFlags: SDL2's image flags
Returns
0 if success, 1 if failed

◆ initImageSANDAL2()

int initImageSANDAL2 ( int  imageFlags)

Initialisation of images alone.

Parameters
imageFlags: SDL2's image flags
Returns
0 if success, 1 if failed

◆ initSANDAL2()

int initSANDAL2 ( void  )

Initialisation of SANDAL2 alone.

Returns
0 if success, 1 if failed

◆ initTextSANDAL2()

int initTextSANDAL2 ( void  )

Initialisation of text alone.

Returns
0 if success, 1 if failed

◆ isFullScreenWindow()

int isFullScreenWindow ( void  )

Tells whether or not the window is in full screen mode.

Returns
1 if the current window is in full screen mode, 0 if not or if there is no current window

◆ keyPressedWindow()

int keyPressedWindow ( int  c)

activation of the key pressed events on the current window

Parameters
c: key which was pressed
Returns
1 if it failed, 0 if not

◆ keyReleasedWindow()

int keyReleasedWindow ( int  c)

activation of the key released events on the current window

Parameters
c: key which was released
Returns
1 if it failed, 0 if not

◆ mainLoop()

unsigned long mainLoop ( unsigned short  maxFPS)

Run the standard SANDAL2 loop Do PollEvent(), call update then display and wait for a certain amount of milliseconds.

Parameters
maxFPSnumber of maximum frame per seconds, it will tries to go that quick and will compensate if an iteration is longer than expected. If it is greater than 1000, it will be ignored and will be set to 60 instead.
Returns
the error flag (0 if it succeeded, a binary code telling which window failed (example : 100101 tells that the second and the fifth window failed, the first bit on the rigth only tells that there was an error), if you have more window than bits for int, you will not be able to tell which of the window failed in those which have a bigger number than the number of bit minus one) set by PollEvent

◆ onFocusedWindow()

int onFocusedWindow ( void  )

activation of the gaining focus event

Returns
1 if it faied, 0 if not

◆ onMouseMotionWindow()

int onMouseMotionWindow ( int  x,
int  y 
)

activate the mouse motion events on the current window

Parameters
x: new x coordinate of the mouse
y: new y coordinate of the mouse
Returns
1 if it failed, 0 if not

◆ onWheelWindow()

int onWheelWindow ( int  y)

activation of the mouseWheel event on the current window

Parameters
y: direction of the wheel
Returns
1 if it failed, 0 if not

◆ PollEvent()

int PollEvent ( unsigned long *  error)

Get the event (if there is one) and apply the corresponding functions.

Parameters
errorwhere to store the error flag (0 if it succeeded, a binary code telling which window failed (example : 100101 tells that the second and the fifth window failed, the first bit on the rigth only tells that there was an error), if you have more window than bits for int, you will not be able to tell which of the window failed in those which have a bigger number than the number of bit minus one)
Returns
1 if the user asked to close the window, 0 if not

◆ shouldCloseWindow()

int shouldCloseWindow ( void  )

tells that the current window should be closed, do not use this one in functions that are not binded to windows or elements, use closeWindow() instead

Returns
1 if it failed, 0 if not

◆ toggleFullScreenWindow()

int toggleFullScreenWindow ( void  )

Toggle the full screen mode of the current window.

Returns
0 if succeeded, 1 if not

◆ unclickWindow()

int unclickWindow ( SDL_MouseButtonEvent  button)

activation of unclick events on the current window

Parameters
button: Event informations of the button
Returns
1 if it failed, 0 if not

◆ unFocusedWindow()

int unFocusedWindow ( void  )

activation of the losing focus event

Returns
1 if it failed, 0 if not

◆ updateAllWindow()

unsigned long updateAllWindow ( void  )

update all the elements of all the windows

Returns
1 if it failed, 0 if not

◆ updateWindow()

int updateWindow ( void  )

update all the elements of the current window

Returns
1 if it failed, 0 if not

Variable Documentation

◆ _windows_SANDAL2

ListWindow* _windows_SANDAL2

list of windows WARNING : do not touch this variable, never ... trust me

list of windows WARNING : do not touch this variable, never ... trust me

List of the windows WARNING : do not touch it ... trust me.