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 
39  void NAPAPI setFullscreen(SDL_Window* window, bool value);
40 
44  bool NAPAPI getFullscreen(SDL_Window* window);
45 
51  glm::ivec2 NAPAPI getWindowSize(SDL_Window* window);
52 
57  uint32 NAPAPI getWindowFlags(SDL_Window* window);
58 
63  glm::ivec2 NAPAPI getScreenSize(int screenIndex);
64 
70  void NAPAPI setWindowSize(SDL_Window* window, const glm::ivec2& size);
71 
77  glm::ivec2 NAPAPI getDrawableWindowSize(SDL_Window* window);
78 
84  glm::ivec2 NAPAPI getWindowPosition(SDL_Window* window);
85 
91  void NAPAPI setWindowPosition(SDL_Window* window, const glm::ivec2& position);
92 
96  void NAPAPI shutdownVideo();
97 
101  std::string NAPAPI getSDLError();
102 
107  uint32_t NAPAPI getWindowId(SDL_Window* window);
108 
113  int NAPAPI getDisplayCount();
114 
120  int NAPAPI getDisplayIndex(SDL_Window* window);
121 
130  int NAPAPI getDisplayDPI(int displayIndex, float* ddpi, float* hdpi, float* vdpi);
131 
140  int NAPAPI getDisplayDPI(SDL_Window* window, float* ddpi, float* hdpi, float* vdpi);
141 
146  bool NAPAPI getDisplayName(int displayIndex, std::string& outName);
147 
155  int NAPAPI getDisplayBounds(int displayIndex, glm::ivec2& outMin, glm::ivec2& outMax);
156 
160  void NAPAPI hideCursor();
161 
165  void NAPAPI showCursor();
166 
171  bool NAPAPI cursorVisible();
172 
176  void NAPAPI toggleCursor();
177 
182  glm::ivec2 NAPAPI getCursorPosition();
183 
189  glm::ivec2 NAPAPI getGlobalCursorPosition();
190 
197  uint32 NAPAPI getMouseState(int* x, int* y);
198 
206  uint32 NAPAPI getGlobalMouseState(int* x, int* y);
207 
213  bool NAPAPI initVideo(utility::ErrorState& error);
214 
220  void NAPAPI setWindowBordered(SDL_Window* window, bool hasBorders);
221 
227  void NAPAPI setWindowTitle(SDL_Window* window, const std::string& name);
228  }
229 }
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::setFullscreen
void NAPAPI setFullscreen(SDL_Window *window, bool value)
nap::SDL::showCursor
void NAPAPI showCursor()
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)