예제 #1
0
파일: mask.c 프로젝트: tinyserver/siege
void SG_EXPORT sgMaskDrawDBG(SGMask* mask, SGint x, SGint y, SGbool transparent)
{
	if(mask == NULL)
		return;
	SGuint i, j;

	sgDrawBegin(SG_POINTS);
		for(i = 0; i < mask->width; i++)
		{
			for(j = 0; j < mask->height; j++)
			{
				if(!transparent)
					sgDrawColor1f(mask->field[i][j] ? 1.0 : 0.0);
				if(mask->field[i][j] || !transparent)
					sgDrawVertex2f(x - mask->xoffset + i, y - mask->yoffset + j);
			}
		}
	sgDrawEnd();
}
예제 #2
0
파일: atlas.c 프로젝트: SIEGE/siege
int main(void)
{
    sgInit(0);

    sgWindowOpen(WIDTH, HEIGHT, 32, 0);
    sgWindowSetTitle("SIEGE Atlas Demo");

    SGAtlas* atlas = sgAtlasCreate(ASIZE, ASIZE, 32);

    SGAtlasArea* area;

    size_t i;
    size_t num = 0;
    for(i = 0; i < NUMTEST; i++)
    {
        area = sgAtlasAreaReserve(atlas, BORDER + 12 + rand() % 5, BORDER + 12 + rand() % 5, SG_FALSE);
        if(area)
        {
            fillArea(atlas, area);
            num++;
        }
    }
    printf("Successfully inserted: %u/%u items\n", (unsigned int)num, NUMTEST);

    while(sgLoop(NULL))
    {
        sgDrawColor1f(1.0);
        sgAtlasDrawDBG(atlas, (WIDTH - ASIZE) / 2, (HEIGHT - ASIZE) / 2, 0, SG_FALSE);

        sgDrawColor3f(0.0, 1.0, 0.0);
        sgAtlasDrawDBG(atlas, (WIDTH - ASIZE) / 2, (HEIGHT - ASIZE) / 2, 0, SG_TRUE);

        sgWindowSwapBuffers();
        sgDrawClear();
    }

    sgAtlasDestroy(atlas);

    sgDeinit();

    return 0;
}