X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=bigscreen%2Fccbs_bigscreen.cpp;h=025d44bf6e435da5f4d116b12b712a9e753581d0;hb=478ab340150034e545e3ed551ff068607d49d35b;hp=b32c5b1405fa71bed93d5527ee978fcf75c98bc0;hpb=8596d4aa3654710fb225c08c4d7235b74362561e;p=ccbs diff --git a/bigscreen/ccbs_bigscreen.cpp b/bigscreen/ccbs_bigscreen.cpp index b32c5b1..025d44b 100644 --- a/bigscreen/ccbs_bigscreen.cpp +++ b/bigscreen/ccbs_bigscreen.cpp @@ -3,7 +3,8 @@ #include #include #include -#include +#include + #include "flagtrigger.h" #include "widestring.h" #include "fetch_current_tournament.h" @@ -18,6 +19,8 @@ #include "splitscreen.h" #include "rotatescreen.h" +SDL_Surface *screen = NULL; + Tournament active_tournament; std::vector active_groups; std::vector screens; @@ -83,17 +86,29 @@ void main_loop(pqxx::connection &conn) if (mainscreen && mainscreen->check_invalidated()) { mainscreen->draw(framebuf, SCREEN_WIDTH, SCREEN_HEIGHT); - ptc_update(framebuf); + 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 { - ptc_update(framebuf); + SDL_Flip(screen); conn.await_notification(0, 200000); } } int main(int argc, char **argv) { - ptc_open("CCBS bigscreen", SCREEN_WIDTH, SCREEN_HEIGHT); + SDL_Init(SDL_INIT_VIDEO); + screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32, SDL_DOUBLEBUF | SDL_FULLSCREEN); + if (screen == NULL) { + fprintf(stderr, "Video initialization failed: %s\n", SDL_GetError()); + exit(1); + } try { init_freetype(); @@ -117,6 +132,8 @@ int main(int argc, char **argv) std::fprintf(stderr, "Exception: %s\n", e.what()); exit(1); } + + SDL_Quit(); return 0; }