summaryrefslogtreecommitdiff
path: root/sdl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sdl.cpp')
-rw-r--r--sdl.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/sdl.cpp b/sdl.cpp
index ea2f0f9..b854571 100644
--- a/sdl.cpp
+++ b/sdl.cpp
@@ -19,7 +19,8 @@ struct State {
SDL_Surface *mandelsurf = nullptr;
- size_t current_resolution = 4;
+ static const size_t init_render_resolution = 4;
+ size_t current_resolution = init_render_resolution;
State() {
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
@@ -47,15 +48,21 @@ struct State {
if (SDL_MUSTLOCK(winsurf)) SDL_UnlockSurface(winsurf);
}
- void update_title() {
+ string build_title() {
stringstream ss;
ss << "Mandel "
<< setprecision(17)
<< " x=" << par.cx
<< " y=" << par.cy
<< " w=" << par.imgw
- << " i=" << par.maxit;
- SDL_SetWindowTitle(window, ss.str().data());
+ << " i=" << par.maxit
+ << " par1=" << par.par1
+ << " par2=" << par.par2;
+ return ss.str();
+ }
+
+ void update_title() {
+ SDL_SetWindowTitle(window, build_title().data());
}
SDL_Event wait_event() const {
@@ -120,6 +127,11 @@ struct State {
if (par.maxit > 256) { par.maxit -= 128; return action::redraw; }
break;
+ case SDLK_w: par.par1++; return action::redraw;
+ case SDLK_s: par.par1 = max(1, par.par1) - 1; return action::redraw;
+ case SDLK_e: par.par2++; return action::redraw;
+ case SDLK_d: par.par2 = max(1, par.par2) - 1; return action::redraw;
+
case SDLK_q:
return action::quit;
}
@@ -162,10 +174,10 @@ int main() {
switch (action) {
case State::action::quit:
- return 0;
+ goto exit_app;
case State::action::redraw:
- state.current_resolution = 4;
+ state.current_resolution = State::init_render_resolution;
SDL_GetWindowSize(state.window, &state.w, &state.h);
cerr << "w=" << state.w << " h=" << state.h << endl;
@@ -186,5 +198,8 @@ int main() {
break;
}
}
+
+exit_app:
+ cout << state.build_title() << endl;
}
#endif