#include "window.h" Window::Window( const char* title, int w, int h, int x, int y ) : closed_ {false}, focused_ {true} { window_ = SDL_CreateWindow( title, x, y, w, h, SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE ); if( window_ == NULL ) { printf( "Window could not be created: %s\n", SDL_GetError() ); } close = new WindowClose(); focus = new WindowFocus(); unfocus = new WindowUnFocus(); nop = new Nop(); } Window::~Window(){ delete close; delete focus; delete unfocus; delete nop; SDL_DestroyWindow( window_ ); } SDL_Window* Window::window(){ return window_; } void Window::toggleFullscreen(){ auto togg = SDL_TRUE; if( fullscreen_ ){ togg = SDL_FALSE; } SDL_SetWindowFullscreen( window_, togg ); printf("toggling fullscreen\n"); fullscreen_ = !fullscreen_; } Command* Window::handleEvent(SDL_Event e){ switch( e.window.event ){ case SDL_WINDOWEVENT_CLOSE: return close; case SDL_WINDOWEVENT_FOCUS_GAINED: return focus; case SDL_WINDOWEVENT_FOCUS_LOST: return unfocus; // case SDL_WINDOWEVENT_SIZE_CHANGED: // return resize; default: return nop; } } Point Window::getSize(){ Point size; SDL_GetWindowSize(window_, &size.x, &size.y); return size; }