- memset(framebuf, 0, 800*600*4);
-
- pqxx::work t(conn, "trx");
-
- // fetch all songs
- pqxx::result res( t.exec("SELECT * FROM songs WHERE title LIKE 'M%'") );
- unsigned y = 0;
- for (pqxx::result::const_iterator i = res.begin(); i != res.end(); ++i) {
- my_draw_text(i["title"].as(widestring()), framebuf, 0, y, 1, 255, 255, 255, font);
- y += 20;
-// std::fprintf(stderr, "%s\n", i["title"].c_str());
+ if (mainscreen && mainscreen->check_invalidated()) {
+ if (screen->pitch == screen_width * 4) {
+ SDL_LockSurface(screen);
+ mainscreen->draw((unsigned char *)screen->pixels, screen_width, screen_height);
+ SDL_UnlockSurface(screen);
+ } else {
+ mainscreen->draw(framebuf, screen_width, screen_height);
+ SDL_LockSurface(screen);
+ for (unsigned y = 0; y < screen_height; ++y) {
+ unsigned char *sptr = framebuf + y * screen_width * 4;
+ unsigned char *dptr = (unsigned char *)screen->pixels + y * screen->pitch;
+ memcpy(dptr, sptr, screen_width * 4);
+ }
+ SDL_UnlockSurface(screen);
+ }
+ SDL_Flip(screen);
+ conn.await_notification(0, 10000);
+ } else {
+ SDL_Flip(screen);
+ conn.await_notification(0, 200000);