2 // Copyright (C) 2008 Albert Brown
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 // Window subsystem: establish a buffer to draw in, handle input
27 #define PACKAGE_STRING "Plastic"
35 window_subsystem::window_subsystem()
37 // TODO: we're going to have to implement commandline arguments and
38 // some sort of config interface before we can un-hardcode these values
39 _screen
= SDL_SetVideoMode(640, 480, 32, SDL_DOUBLEBUF
| SDL_OPENGL
);
43 // Something went wrong
44 std::string msg
= std::string("SDL failed to set video mode: ")
46 throw std::runtime_error(msg
.c_str());
49 SDL_WM_SetCaption(PACKAGE_STRING
, PACKAGE_STRING
);
51 std::cout
<< "window_subsystem initialized." << std::endl
;
54 window_subsystem::~window_subsystem()
56 // The way SDL is designed, we can't really close the window.
57 // TODO: maybe it would be possible if we init the SDL video subsystem
58 // here (in this class). This might allow us to close and restart
59 // it aswell, although this should not be neccesary (maybe on windows).
61 std::cout
<< "window_subsystem shut down." << std::endl
;
64 void window_subsystem::tick(state
&s
)
67 while(SDL_PollEvent(&event
))
72 if(event
.key
.keysym
.sym
== SDLK_ESCAPE
)
74 std::cout
<< "Escape" << std::endl
;
79 std::cout
<< "Close button" << std::endl
;