static void DrawBackground(void) { // Whole window cleared with clear color, checkerboard rendered on top of it. glClear(GL_COLOR_BUFFER_BIT); DrawCheckerBoard(); // ANIM background color rendered (blend) on top. Default is white for still // images (without ANIM chunk). glClear() can't be used for that (no blend). if (kParams.draw_anim_background_color) { glPushMatrix(); glLoadIdentity(); glColor4f(GetColorf(kParams.bg_color, 16), // BGRA from spec GetColorf(kParams.bg_color, 8), GetColorf(kParams.bg_color, 0), GetColorf(kParams.bg_color, 24)); glRecti(-1, -1, +1, +1); glPopMatrix(); } }
static void StartDisplay(void) { const int width = kParams.canvas_width; const int height = kParams.canvas_height; glutInitDisplayMode(GLUT_RGBA); glutInitWindowSize(width, height); glutCreateWindow("WebP viewer"); glutDisplayFunc(HandleDisplay); glutIdleFunc(NULL); glutKeyboardFunc(HandleKey); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glClearColor(GetColorf(kParams.bg_color, 0), GetColorf(kParams.bg_color, 8), GetColorf(kParams.bg_color, 16), GetColorf(kParams.bg_color, 24)); HandleReshape(width, height); glClear(GL_COLOR_BUFFER_BIT); DrawCheckerBoard(); }