MiniEngine/sdl_engine_window.hpp

56 lines
908 B
C++
Raw Normal View History

2017-01-05 13:25:09 +08:00
Window::Window(int winw,int winh)
{
pimpl=new impl;
2017-01-07 09:52:56 +08:00
SDL_Window* wnd=SDL_CreateWindow("Engine",SDL_WINDOWPOS_CENTERED,SDL_WINDOWPOS_CENTERED,winw,winh,SDL_WINDOW_SHOWN);
pimpl->set(wnd);
2017-01-05 13:25:09 +08:00
}
Window::Window(const Window& inc)
{
pimpl=new impl;
*pimpl=*(inc.pimpl);
}
Window& Window::operator = (const Window& inc)
{
*pimpl=*(inc.pimpl);
return *this;
}
Window::Window(Window&& inc)
{
pimpl=inc.pimpl;
inc.pimpl=nullptr;
}
Window& Window::operator = (Window&& inc)
{
*pimpl=*(inc.pimpl);
inc.pimpl=nullptr;
return *this;
}
2017-01-05 13:25:09 +08:00
Window::~Window()
{
delete pimpl;
}
Renderer Window::getRenderer() const
2017-01-05 13:25:09 +08:00
{
return pimpl->rnd;
}
2017-01-07 09:52:56 +08:00
Rect Window::getSize()
2017-01-07 09:52:56 +08:00
{
int w,h;
SDL_GetWindowSize(pimpl->getRawWindow(),&w,&h);
Rect rect(0,0,w,h);
return rect;
}
void Window::setSize(Rect rect)
{
SDL_SetWindowSize(pimpl->getRawWindow(),rect.w,rect.h);
2017-01-07 09:52:56 +08:00
}