/*
*  This program was created by AXELL CORPORATION.
*  Copyright (C) 2017 AXELL CORPORATION, all rights reserved.
*/
#include "gfx_sample.h"

static void ClearSurface(VGfloat r, VGfloat g, VGfloat b, VGfloat a,
                         VGint x, VGint y, VGint width, VGint height)
{
    VGfloat color[4];
    color[0] = r;
    color[1] = g;
    color[2] = b;
    color[3] = a;

    /* クリアカラーを設定 */
    vgSetfv(VG_CLEAR_COLOR, 4, color);

    /* 指定された領域をクリア */
    vgClear(x, y, width, height);
}

void ClearMain(void)
{
    VGint width = GFX_WIDTH;
    VGint height = GFX_HEIGHT;
    VGint clearwidth = width / 4;

    /* 画面を横方向に４分割し、左から赤、緑、青、白でクリアする */
    ClearSurface(1.0F, 0.0F, 0.0F, 1.0F, clearwidth * 0, 0, clearwidth, height);
    ClearSurface(0.0F, 1.0F, 0.0F, 1.0F, clearwidth * 1, 0, clearwidth, height);
    ClearSurface(0.0F, 0.0F, 1.0F, 1.0F, clearwidth * 2, 0, clearwidth, height);
    ClearSurface(1.0F, 1.0F, 1.0F, 1.0F, clearwidth * 3, 0, clearwidth, height);

    /* バッファスワップ */
    GfxSwapBuffer();
}
