Ejemplo n.º 1
0
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();
}
Ejemplo n.º 2
0
Archivo: atlas.c Proyecto: 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;
}