NAP
sdlhelpers.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 
5 #pragma once
6 
7 // External Includes
8 #include <string>
9 #include <glm/glm.hpp>
10 #include <utility/dllexport.h>
11 #include <nap/numeric.h>
12 #include <utility/errorstate.h>
13 
14 // SDL Forward declares
15 struct SDL_Window;
16 
17 namespace nap
18 {
19  namespace SDL
20  {
26  void NAPAPI showWindow(SDL_Window* window, bool show);
27 
32  void NAPAPI raiseWindow(SDL_Window* window);
33 
40  bool NAPAPI setFullscreen(SDL_Window* window, bool value);
41 
45  bool NAPAPI getFullscreen(SDL_Window* window);
46 
52  glm::ivec2 NAPAPI getWindowSize(SDL_Window* window);
53 
58  uint32 NAPAPI getWindowFlags(SDL_Window* window);
59 
64  glm::ivec2 NAPAPI getScreenSize(int screenIndex);
65 
71  void NAPAPI setWindowSize(SDL_Window* window, const glm::ivec2& size);
72 
78  glm::ivec2 NAPAPI getDrawableWindowSize(SDL_Window* window);
79 
85  glm::ivec2 NAPAPI getWindowPosition(SDL_Window* window);
86 
92  void NAPAPI setWindowPosition(SDL_Window* window, const glm::ivec2& position);
93 
97  void NAPAPI shutdownVideo();
98 
102  std::string NAPAPI getSDLError();
103 
108  uint32_t NAPAPI getWindowId(SDL_Window* window);
109 
114  int NAPAPI getDisplayCount();
115 
121  int NAPAPI getDisplayIndex(SDL_Window* window);
122 
131  int NAPAPI getDisplayDPI(int displayIndex, float* ddpi, float* hdpi, float* vdpi);
132 
141  int NAPAPI getDisplayDPI(SDL_Window* window, float* ddpi, float* hdpi, float* vdpi);
142 
147  bool NAPAPI getDisplayName(int displayIndex, std::string& outName);
148 
156  int NAPAPI getDisplayBounds(int displayIndex, glm::ivec2& outMin, glm::ivec2& outMax);
157 
161  void NAPAPI hideCursor();
162 
166  void NAPAPI showCursor();
167 
172  bool NAPAPI cursorVisible();
173 
177  void NAPAPI toggleCursor();
178 
183  glm::ivec2 NAPAPI getCursorPosition();
184 
190  glm::ivec2 NAPAPI getGlobalCursorPosition();
191 
198  uint32 NAPAPI getMouseState(int* x, int* y);
199 
207  uint32 NAPAPI getGlobalMouseState(int* x, int* y);
208 
214  bool NAPAPI initVideo(utility::ErrorState& error);
215 
221  void NAPAPI setWindowBordered(SDL_Window* window, bool hasBorders);
222 
228  void NAPAPI setWindowTitle(SDL_Window* window, const std::string& name);
229  }
230 }
nap::SDL::getDisplayIndex
int NAPAPI getDisplayIndex(SDL_Window *window)
nap::SDL::initVideo
bool NAPAPI initVideo(utility::ErrorState &error)
nap::SDL::getCursorPosition
glm::ivec2 NAPAPI getCursorPosition()
nap::SDL::getGlobalMouseState
uint32 NAPAPI getGlobalMouseState(int *x, int *y)
nap::SDL::getWindowId
uint32_t NAPAPI getWindowId(SDL_Window *window)
nap::SDL::toggleCursor
void NAPAPI toggleCursor()
nap::SDL::hideCursor
void NAPAPI hideCursor()
nap::SDL::cursorVisible
bool NAPAPI cursorVisible()
nap::SDL::showWindow
void NAPAPI showWindow(SDL_Window *window, bool show)
nap::SDL::showCursor
void NAPAPI showCursor()
nap::SDL::setFullscreen
bool NAPAPI setFullscreen(SDL_Window *window, bool value)
nap::utility::ErrorState
Definition: errorstate.h:19
nap::SDL::getDisplayCount
int NAPAPI getDisplayCount()
nap::SDL::setWindowPosition
void NAPAPI setWindowPosition(SDL_Window *window, const glm::ivec2 &position)
nap::SDL::getDisplayBounds
int NAPAPI getDisplayBounds(int displayIndex, glm::ivec2 &outMin, glm::ivec2 &outMax)
nap::SDL::setWindowBordered
void NAPAPI setWindowBordered(SDL_Window *window, bool hasBorders)
nap::uint32
uint32_t uint32
Definition: numeric.h:20
nap::SDL::getFullscreen
bool NAPAPI getFullscreen(SDL_Window *window)
nap::SDL::getWindowSize
glm::ivec2 NAPAPI getWindowSize(SDL_Window *window)
nap::SDL::getDrawableWindowSize
glm::ivec2 NAPAPI getDrawableWindowSize(SDL_Window *window)
nap::SDL::setWindowTitle
void NAPAPI setWindowTitle(SDL_Window *window, const std::string &name)
nap
Definition: templateapp.h:17
nap::SDL::getGlobalCursorPosition
glm::ivec2 NAPAPI getGlobalCursorPosition()
nap::SDL::getWindowFlags
uint32 NAPAPI getWindowFlags(SDL_Window *window)
nap::SDL::getMouseState
uint32 NAPAPI getMouseState(int *x, int *y)
nap::SDL::getWindowPosition
glm::ivec2 NAPAPI getWindowPosition(SDL_Window *window)
nap::SDL::getDisplayName
bool NAPAPI getDisplayName(int displayIndex, std::string &outName)
nap::SDL::shutdownVideo
void NAPAPI shutdownVideo()
nap::SDL::getDisplayDPI
int NAPAPI getDisplayDPI(int displayIndex, float *ddpi, float *hdpi, float *vdpi)
nap::SDL::setWindowSize
void NAPAPI setWindowSize(SDL_Window *window, const glm::ivec2 &size)
nap::SDL::getScreenSize
glm::ivec2 NAPAPI getScreenSize(int screenIndex)
nap::SDL::getSDLError
std::string NAPAPI getSDLError()
nap::SDL::raiseWindow
void NAPAPI raiseWindow(SDL_Window *window)