NAP
Functions
nap::SDL Namespace Reference

Functions

void NAPAPI showWindow (SDL_Window *window, bool show)
 
void NAPAPI raiseWindow (SDL_Window *window)
 
void NAPAPI setFullscreen (SDL_Window *window, bool value)
 
bool NAPAPI getFullscreen (SDL_Window *window)
 
glm::ivec2 NAPAPI getWindowSize (SDL_Window *window)
 
uint32 NAPAPI getWindowFlags (SDL_Window *window)
 
glm::ivec2 NAPAPI getScreenSize (int screenIndex)
 
void NAPAPI setWindowSize (SDL_Window *window, const glm::ivec2 &size)
 
glm::ivec2 NAPAPI getDrawableWindowSize (SDL_Window *window)
 
glm::ivec2 NAPAPI getWindowPosition (SDL_Window *window)
 
void NAPAPI setWindowPosition (SDL_Window *window, const glm::ivec2 &position)
 
void NAPAPI shutdownVideo ()
 
std::string NAPAPI getSDLError ()
 
uint32_t NAPAPI getWindowId (SDL_Window *window)
 
int NAPAPI getDisplayCount ()
 
int NAPAPI getDisplayIndex (SDL_Window *window)
 
int NAPAPI getDisplayDPI (int displayIndex, float *ddpi, float *hdpi, float *vdpi)
 
int NAPAPI getDisplayDPI (SDL_Window *window, float *ddpi, float *hdpi, float *vdpi)
 
bool NAPAPI getDisplayName (int displayIndex, std::string &outName)
 
int NAPAPI getDisplayBounds (int displayIndex, glm::ivec2 &outMin, glm::ivec2 &outMax)
 
void NAPAPI hideCursor ()
 
void NAPAPI showCursor ()
 
bool NAPAPI cursorVisible ()
 
void NAPAPI toggleCursor ()
 
glm::ivec2 NAPAPI getCursorPosition ()
 
glm::ivec2 NAPAPI getGlobalCursorPosition ()
 
uint32 NAPAPI getMouseState (int *x, int *y)
 
uint32 NAPAPI getGlobalMouseState (int *x, int *y)
 
bool NAPAPI initVideo (utility::ErrorState &error)
 
void NAPAPI setWindowBordered (SDL_Window *window, bool hasBorders)
 
void NAPAPI setWindowTitle (SDL_Window *window, const std::string &name)
 

Function Documentation

◆ cursorVisible()

bool NAPAPI nap::SDL::cursorVisible ( )

Returns if the cursor is visible

Returns
if the cursor is visible

◆ getCursorPosition()

glm::ivec2 NAPAPI nap::SDL::getCursorPosition ( )

Returns the mouse cursor position relative to the focus window.

Returns
cursor position relative to the focus window

◆ getDisplayBounds()

int NAPAPI nap::SDL::getDisplayBounds ( int  displayIndex,
glm::ivec2 &  outMin,
glm::ivec2 &  outMax 
)

Gets desktop area represented by a display, with the primary display located at 0,0

Parameters
displayIndexindex of the display to get the bounds for
outMinmin position of desktop area represented by a display, with the primary display located at 0,0
outMaxmax position of desktop area represented by a display, with the primary display located at 0,0
Returns
0 on success or a negative error code on failure

◆ getDisplayCount()

int NAPAPI nap::SDL::getDisplayCount ( )

Get the number of available video displays.

Returns
A number >= 1, negative error code on failure;

◆ getDisplayDPI() [1/2]

int NAPAPI nap::SDL::getDisplayDPI ( int  displayIndex,
float *  ddpi,
float *  hdpi,
float *  vdpi 
)

Get he dots/pixels-per-inch for a display.

Parameters
displayIndexThe index of the display from which DPI information should be queried
ddpia pointer filled in with the diagonal DPI of the display; may be nullptr
hdpia pointer filled in with the horizontal DPI of the display; may be nullptr
vdpia pointer filled in with the vertical DPI of the display; may be nullptr
Returns
0 on success or a negative error code on failure

◆ getDisplayDPI() [2/2]

int NAPAPI nap::SDL::getDisplayDPI ( SDL_Window *  window,
float *  ddpi,
float *  hdpi,
float *  vdpi 
)

Get the dots/pixels-per-inch of the display that holds the given window

Parameters
windowthe window to get the dpi for
ddpia pointer filled in with the diagonal DPI of the display; may be nullptr
hdpia pointer filled in with the horizontal DPI of the display; may be nullptr
vdpia pointer filled in with the vertical DPI of the display; may be nullptr
Returns
0 on success or a negative error code on failure

◆ getDisplayIndex()

int NAPAPI nap::SDL::getDisplayIndex ( SDL_Window *  window)

Get the index of the display associated with a window.

Parameters
windowthe window to get the display index for
Returns
The index of the display containing the center of the window on success or a negative error code

◆ getDisplayName()

bool NAPAPI nap::SDL::getDisplayName ( int  displayIndex,
std::string &  outName 
)
Parameters
displayIndexindex of display to get name for
outNamedisplay name for given display index

◆ getDrawableWindowSize()

glm::ivec2 NAPAPI nap::SDL::getDrawableWindowSize ( SDL_Window *  window)

Returns the actual size in pixels of a window, which can be different from the represented window size. This is the case with High DPI screens on OSX

Returns
the actual size in pixels of a window

◆ getFullscreen()

bool NAPAPI nap::SDL::getFullscreen ( SDL_Window *  window)

Returns if the window is full screen (Desktop)

◆ getGlobalCursorPosition()

glm::ivec2 NAPAPI nap::SDL::getGlobalCursorPosition ( )

Get the position of the cursor, in relation to the desktop. This works just like getCursorPosition(), but the coordinates will be reported relative to the top-left of the desktop. Current position of the cursor, in relation to the desktop

◆ getGlobalMouseState()

uint32 NAPAPI nap::SDL::getGlobalMouseState ( int *  x,
int *  y 
)

Get the current state of the mouse, in relation to the desktop. This works just like getMouseState(), but the coordinates will be reported relative to the top-left of the desktop.

Parameters
xthe current x coordinate, relative to the desktop. Can be nullptr
ythe current y coordinate, relative to the desktop. Can be nullptr
Returns
The current button state as a bitmask, which can be tested using the SDL_BUTTON(X) macros.

◆ getMouseState()

uint32 NAPAPI nap::SDL::getMouseState ( int *  x,
int *  y 
)

Get the current state of the mouse relative to the focus window.

Parameters
xthe current x coordinate. Can be nullptr
ythe current y coordinate. Can be nullptr
Returns
The current button state as a bitmask, which can be tested using the SDL_BUTTON(X) macros.

◆ getScreenSize()

glm::ivec2 NAPAPI nap::SDL::getScreenSize ( int  screenIndex)
Parameters
screenIndexthe number of the display
Returns
the screen resolution in pixels, on failure return value is -1

◆ getSDLError()

std::string NAPAPI nap::SDL::getSDLError ( )

@ return the last SDL error as a string

◆ getWindowFlags()

uint32 NAPAPI nap::SDL::getWindowFlags ( SDL_Window *  window)
Parameters
windowthe window to get the flags for
Returns
flags associated with the given window

◆ getWindowId()

uint32_t NAPAPI nap::SDL::getWindowId ( SDL_Window *  window)
Returns
the id associated with a specific SDL window
Parameters
windowthe SDL window to get the id for

◆ getWindowPosition()

glm::ivec2 NAPAPI nap::SDL::getWindowPosition ( SDL_Window *  window)

returns the window position as pixel coordinates

Parameters
windowthe window to get the position for
Returns
the window position in pixels

◆ getWindowSize()

glm::ivec2 NAPAPI nap::SDL::getWindowSize ( SDL_Window *  window)

Returns the size of an SDL window

Parameters
windowthe window to retrieve the size for
Returns
the window size

◆ hideCursor()

void NAPAPI nap::SDL::hideCursor ( )

Hides the mouse cursor

◆ initVideo()

bool NAPAPI nap::SDL::initVideo ( utility::ErrorState error)

Initializes SDL video system. Call this before creating any windows or render contexts!

Returns
if the system initialized correctly or not

◆ raiseWindow()

void NAPAPI nap::SDL::raiseWindow ( SDL_Window *  window)

Makes sure the window is on top and receives input focus.

Parameters
windowthe window to raise

◆ setFullscreen()

void NAPAPI nap::SDL::setFullscreen ( SDL_Window *  window,
bool  value 
)

Sets the window to be full screen in desktop mode

Parameters
windowthe window to enable / disable
valueif the window is full screen

◆ setWindowBordered()

void NAPAPI nap::SDL::setWindowBordered ( SDL_Window *  window,
bool  hasBorders 
)

Controls if the window has any borders.

Parameters
windowthe window to set
hasBordersif the window should have borders

◆ setWindowPosition()

void NAPAPI nap::SDL::setWindowPosition ( SDL_Window *  window,
const glm::ivec2 &  position 
)

Set the position of a window on screen.

Parameters
windowthe window to set the position for
positionthe window location in pixels

◆ setWindowSize()

void NAPAPI nap::SDL::setWindowSize ( SDL_Window *  window,
const glm::ivec2 &  size 
)

resizes an SDL window

Parameters
windowthe window to resize
sizethe new window size

◆ setWindowTitle()

void NAPAPI nap::SDL::setWindowTitle ( SDL_Window *  window,
const std::string &  name 
)

Sets the window title.

Parameters
windowthe window to set the title for
namethe new window name

◆ showCursor()

void NAPAPI nap::SDL::showCursor ( )

Shows the mouse cursor

◆ showWindow()

void NAPAPI nap::SDL::showWindow ( SDL_Window *  window,
bool  show 
)

Makes a window visible.

Parameters
windowpointer to the window to make visible.
showif the window is shown or hidden

◆ shutdownVideo()

void NAPAPI nap::SDL::shutdownVideo ( )

Shutdown SDL

◆ toggleCursor()

void NAPAPI nap::SDL::toggleCursor ( )

Toggles cursor visibility on / off