summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom.smeding@gmail.com>2019-09-28 13:53:45 +0200
committerTom Smeding <tom.smeding@gmail.com>2019-09-28 13:53:45 +0200
commit79b50bffb05ee2c9bd84af879f574ee521bf4669 (patch)
treeb7d74271538b9ead6ab354362051a669271cbd34
parent08c6f6ea50aeadb3fae94d08b76556b5e2c88543 (diff)
Show more info in SDL view
-rw-r--r--sdl.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/sdl.cpp b/sdl.cpp
index 37b6f8e..dcc2bb9 100644
--- a/sdl.cpp
+++ b/sdl.cpp
@@ -1,4 +1,6 @@
#include <iostream>
+#include <iomanip>
+#include <sstream>
#include <SDL.h>
#include "mandel.h"
@@ -39,12 +41,25 @@ int main() {
bool need_redraw = false;
+ {
+ stringstream ss;
+ ss << "Mandel "
+ << setprecision(17)
+ << " x=" << par.cx
+ << " y=" << par.cy
+ << " w=" << par.imgw
+ << " i=" << par.maxit;
+ SDL_SetWindowTitle(window, ss.str().data());
+ }
+
SDL_Event e;
if (SDL_WaitEvent(&e) == 0) {
cerr << "SDL event wait error: " << SDL_GetError() << endl;
break;
}
+ winsurf = SDL_GetWindowSurface(window);
+
switch (e.type) {
case SDL_QUIT:
break;
@@ -114,9 +129,11 @@ int main() {
winsurf = SDL_GetWindowSurface(window);
SDL_GetWindowSize(window, &w, &h);
+ cerr << "w=" << w << " h=" << h << endl;
+ cerr << "surface: w=" << winsurf->w << " h=" << winsurf->h << endl;
+ imgdata = new uint8_t[3 * w * h];
mandelsurf = SDL_CreateRGBSurfaceFrom(imgdata, w, h, 24, 3 * w, 0x0000000ff, 0x0000ff00, 0x00ff0000, 0);
ctx = mandel_init(w, h);
- imgdata = new uint8_t[3 * w * h];
need_redraw = true;
break;
}
@@ -125,6 +142,9 @@ int main() {
if (need_redraw) {
SDL_GetWindowSize(window, &w, &h);
+ cerr << "w=" << w << " h=" << h << endl;
+ cerr << "winsurf: w=" << winsurf->w << " h=" << winsurf->h << endl;
+ cerr << "mandelsurf: w=" << mandelsurf->w << " h=" << mandelsurf->h << endl;
mandel_render(imgdata, ctx, &par);
if (SDL_MUSTLOCK(winsurf)) SDL_LockSurface(winsurf);