game/sdlpp/sdlpp_window.cpp

34 lines
1.2 KiB
C++

#include "sdlpp_window.hpp"
namespace SDLPP {
Window::Window()
: Window( "SDL Window", 640, 480, SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED ) {}
Window::Window( const std::string &window_name )
: Window( window_name, 640, 480, SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED ) {}
Window::Window( const std::string &window_name, uint32_t width,
uint32_t height )
: Window( window_name, width, height, SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED ) {}
Window::Window( const std::string &window_name, uint32_t width, uint32_t height,
uint32_t posx, uint32_t posy ) {
window = SDL_CreateWindow( window_name.c_str(), posx, posy, width, height,
SDL_WINDOW_SHOWN );
if ( window == NULL ) {
std::cerr << "SDL could not create a window! SDL_Error: "
<< SDL_GetError() << std::endl;
throw "Couldn't create window";
}
}
void Window::setResizable( bool resizable ) {
SDL_SetWindowResizable( window, resizable ? SDL_TRUE : SDL_FALSE );
}
Window::~Window() {
SDL_DestroyWindow( window );
}
SDL_Window *Window::getWindowPtr() {
return window;
}
} // namespace SDLPP