X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=bigscreen%2Fccbs_bigscreen.cpp;h=d09b1c4d36f1fae35d363aa0fe7bd01ae1ef34aa;hb=0fad64f1f8ecc79312e6d27aac1bc0b3feff84c1;hp=b32c5b1405fa71bed93d5527ee978fcf75c98bc0;hpb=16d44dda496bb6fec27aeea13decaae16fd08f7e;p=ccbs diff --git a/bigscreen/ccbs_bigscreen.cpp b/bigscreen/ccbs_bigscreen.cpp index b32c5b1..d09b1c4 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,34 @@ 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); +#if USE_FULLSCREEN + screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32, SDL_DOUBLEBUF | SDL_FULLSCREEN); + SDL_ShowCursor(SDL_DISABLE); +#else + screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32, SDL_DOUBLEBUF); +#endif + if (screen == NULL) { + fprintf(stderr, "Video initialization failed: %s\n", SDL_GetError()); + exit(1); + } try { init_freetype(); @@ -117,6 +137,8 @@ int main(int argc, char **argv) std::fprintf(stderr, "Exception: %s\n", e.what()); exit(1); } + + SDL_Quit(); return 0; }