Ejemplo n.º 1
0
void
MagScreen::positionUpdate (const CompPoint &pos)
{
    damageRegion ();

    posX = pos.x ();
    posY = pos.y ();

    damageRegion ();
}
static void
positionUpdate (CompScreen *s,
		int        x,
		int        y)
{
    MAG_SCREEN (s);

    damageRegion (s);

    ms->posX = x;
    ms->posY = y;

    damageRegion (s);
}
static void
wizardDonePaintScreen (CompScreen *s)
{
    WIZARD_SCREEN (s);
    WIZARD_DISPLAY (s->display);

    if (ws->active || (ws->ps && ws->ps->active))
	damageRegion (s);

    if (!ws->active && ws->pollHandle)
    {
	(*wd->mpFunc->removePositionPolling) (s, ws->pollHandle);
	ws->pollHandle = 0;
    }

    if (!ws->active && ws->ps && !ws->ps->active)
    {
	finiParticles (ws->ps);
	free (ws->ps);
	ws->ps = NULL;
    }

    UNWRAP (ws, s, donePaintScreen);
    (*s->donePaintScreen) (s);
    WRAP (ws, s, donePaintScreen, wizardDonePaintScreen);
}
static void
magPreparePaintScreen (CompScreen *s,
		       int        time)
{
    MAG_SCREEN (s);
    MAG_DISPLAY (s->display);

    if (ms->adjust)
    {
	int   steps;
	float amount, chunk;

	amount = time * 0.35f * magGetSpeed (s);
	steps  = amount / (0.5f * magGetTimestep (s));

	if (!steps)
	    steps = 1;

	chunk  = amount / (float) steps;

	while (steps--)
	{
	    ms->adjust = adjustZoom (s, chunk);
	    if (ms->adjust)
		break;
	}
    }

    if (ms->zoom != 1.0)
    {
	if (!ms->pollHandle)
	{
	    (*md->mpFunc->getCurrentPosition) (s, &ms->posX, &ms->posY);
	    ms->pollHandle =
		(*md->mpFunc->addPositionPolling) (s, positionUpdate);
	}
	damageRegion (s);
    }

    UNWRAP (ms, s, preparePaintScreen);
    (*s->preparePaintScreen) (s, time);
    WRAP (ms, s, preparePaintScreen, magPreparePaintScreen);
}
Ejemplo n.º 5
0
void
MagScreen::preparePaint (int        time)
{
    if (adjust)
    {
	int   steps;
	float amount, chunk;

	amount = time * 0.35f * optionGetSpeed ();
	steps  = amount / (0.5f * optionGetTimestep ());

	if (!steps)
	    steps = 1;

	chunk  = amount / (float) steps;

	while (steps--)
	{
	    adjust = adjustZoom (chunk);
	    if (adjust)
		break;
	}
    }

    if (zoom != 1.0)
    {
	if (!poller.active ())
	{
	    CompPoint pos;
	    pos = poller.getCurrentPosition ();
	    posX = pos.x ();
	    posY = pos.y ();
	    poller.start ();
	}
	damageRegion ();
    }

    cScreen->preparePaint (time);
}
Ejemplo n.º 6
0
void
MagScreen::donePaint ()
{

    if (adjust)
	damageRegion ();

    if (!adjust && zoom == 1.0 && (width || height))
    {
	glEnable (target);

	glBindTexture (target, texture);

	glTexImage2D (target, 0, GL_RGB, 0, 0, 0,
		      GL_RGB, GL_UNSIGNED_BYTE, NULL);

	width = 0;
	height = 0;
	
	glBindTexture (target, 0);

	glDisable (target);
    }

    if (zoom == 1.0 && !adjust)
    {
	// Mag mode has ended
	cScreen->preparePaintSetEnabled (this, false);
	cScreen->donePaintSetEnabled (this, false);
	gScreen->glPaintOutputSetEnabled (this, false);

    	if (poller.active ())
    	    poller.stop ();
    }

    cScreen->donePaint ();
}
static Bool
wizardTerminate (CompDisplay    *d,
		CompAction      *action,
		CompActionState state,
		CompOption      *option,
		int             nOption)
{
    CompScreen *s;
    Window     xid;

    xid = getIntOptionNamed (option, nOption, "root", 0);

    s = findScreenAtDisplay (d, xid);
    if (s)
    {
	WIZARD_SCREEN (s);

	ws->active = FALSE;
	damageRegion (s);

	return TRUE;
    }
    return FALSE;
}
static void
magDonePaintScreen (CompScreen *s)
{
    MAG_SCREEN (s);
    MAG_DISPLAY (s->display);

    if (ms->adjust)
	damageRegion (s);

    if (!ms->adjust && ms->zoom == 1.0 && (ms->width || ms->height))
    {
	glEnable (ms->target);

	glBindTexture (ms->target, ms->texture);

	glTexImage2D (ms->target, 0, GL_RGB, 0, 0, 0,
		      GL_RGB, GL_UNSIGNED_BYTE, NULL);

	ms->width = 0;
	ms->height = 0;
	
	glBindTexture (ms->target, 0);

	glDisable (ms->target);
    }

    if (ms->zoom == 1.0 && !ms->adjust && ms->pollHandle)
    {
	(*md->mpFunc->removePositionPolling) (s, ms->pollHandle);
	ms->pollHandle = 0;
    }

    UNWRAP (ms, s, donePaintScreen);
    (*s->donePaintScreen) (s);
    WRAP (ms, s, donePaintScreen, magDonePaintScreen);
}
static void
wizardPreparePaintScreen (CompScreen *s, int time)
{
    WIZARD_SCREEN (s);
    WIZARD_DISPLAY (s->display);

    if (ws->active && !ws->pollHandle)
    {
	(*wd->mpFunc->getCurrentPosition) (s, &ws->mx, &ws->my);
	ws->pollHandle = (*wd->mpFunc->addPositionPolling) (s, positionUpdate);
    }

    if (ws->active && !ws->ps)
    {
	ws->ps = calloc(1, sizeof (ParticleSystem));
	if (!ws->ps)
	{
	    UNWRAP (ws, s, preparePaintScreen);
	    (*s->preparePaintScreen) (s, time);
	    WRAP (ws, s, preparePaintScreen, wizardPreparePaintScreen);
	    return;
	}
	loadGPoints (s, ws->ps);
	loadEmitters (s, ws->ps);
	initParticles (wizardGetHardLimit (s), wizardGetSoftLimit (s), ws->ps);
	ws->ps->darken = wizardGetDarken (s);
	ws->ps->blendMode = (wizardGetBlend (s)) ? GL_ONE :
				GL_ONE_MINUS_SRC_ALPHA;
	ws->ps->tnew = wizardGetTnew (s);
	ws->ps->told = wizardGetTold (s);
	ws->ps->gx = wizardGetGx (s);
	ws->ps->gy = wizardGetGy (s);

	glGenTextures (1, &ws->ps->tex);
	glBindTexture (GL_TEXTURE_2D, ws->ps->tex);

	glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

	glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 128, 128, 0,
			GL_RGBA, GL_UNSIGNED_BYTE, particleTex);
	glBindTexture (GL_TEXTURE_2D, 0);
    }

    if (ws->ps && ws->active && ws->ps->e)
    {
	Emitter *ei = ws->ps->e;
	GPoint *gi = ws->ps->g;
	int i;

	for (i = 0; i < ws->ps->ng; i++, gi++)
	{
	    if (gi->movement==MOVEMENT_BOUNCE || gi->movement==MOVEMENT_WRAP)
	    {
		gi->x += gi->espeed * cos (gi->eangle) * time;
		gi->y += gi->espeed * sin (gi->eangle) * time;
		if (gi->x >= s->width)
		{
		    if (gi->movement==MOVEMENT_BOUNCE)
		    {
			gi->x = 2*s->width - gi->x - 1;
			gi->eangle = M_PI - gi->eangle;
		    }
		    else if (gi->movement==MOVEMENT_WRAP)
			gi->x -= s->width;
		}
		else if (gi->x < 0)
		{
		    if (gi->movement==MOVEMENT_BOUNCE)
		    {
			gi->x *= -1;
			gi->eangle = M_PI - gi->eangle;
		    }
		    else if (gi->movement==MOVEMENT_WRAP)
			gi->x += s->width;
		}
		if (gi->y >= s->height)
		{
		    if (gi->movement==MOVEMENT_BOUNCE)
		    {
			gi->y = 2*s->height - gi->y - 1;
			gi->eangle *= -1;
		    }
		    else if (gi->movement==MOVEMENT_WRAP)
			gi->y -= s->height;
		}
		else if (gi->y < 0)
		{
		    if (gi->movement==MOVEMENT_BOUNCE)
		    {
			gi->y *= -1;
			gi->eangle *= -1;
		    }
		    else if (gi->movement==MOVEMENT_WRAP)
			gi->y += s->height;
		}
	    }
	    if (gi->movement==MOVEMENT_FOLLOWMOUSE
		&& (ws->my!=gi->y||ws->mx!=gi->x))
	    {
		gi->eangle = atan2(ws->my-gi->y, ws->mx-gi->x);
		gi->x += gi->espeed * cos(gi->eangle) * time;
		gi->y += gi->espeed * sin(gi->eangle) * time;
	    }
	}

	for (i = 0; i < ws->ps->ne; i++, ei++)
	{
	    if (ei->movement==MOVEMENT_BOUNCE || ei->movement==MOVEMENT_WRAP)
	    {
		ei->x += ei->espeed * cos (ei->eangle) * time;
		ei->y += ei->espeed * sin (ei->eangle) * time;
		if (ei->x >= s->width)
		{
		    if (ei->movement==MOVEMENT_BOUNCE)
		    {
			ei->x = 2*s->width - ei->x - 1;
			ei->eangle = M_PI - ei->eangle;
		    }
		    else if (ei->movement==MOVEMENT_WRAP)
			ei->x -= s->width;
		}
		else if (ei->x < 0)
		{
		    if (ei->movement==MOVEMENT_BOUNCE)
		    {
			ei->x *= -1;
			ei->eangle = M_PI - ei->eangle;
		    }
		    else if (ei->movement==MOVEMENT_WRAP)
			ei->x += s->width;
		}
		if (ei->y >= s->height)
		{
		    if (ei->movement==MOVEMENT_BOUNCE)
		    {
			ei->y = 2*s->height - ei->y - 1;
			ei->eangle *= -1;
		    }
		    else if (ei->movement==MOVEMENT_WRAP)
			ei->y -= s->height;
		}
		else if (ei->y < 0)
		{
		    if (ei->movement==MOVEMENT_BOUNCE)
		    {
			ei->y *= -1;
			ei->eangle *= -1;
		    }
		    else if (ei->movement==MOVEMENT_WRAP)
			ei->y += s->height;
		}
	    }
	    if (ei->movement==MOVEMENT_FOLLOWMOUSE
		&& (ws->my!=ei->y||ws->mx!=ei->x))
	    {
		ei->eangle = atan2 (ws->my-ei->y, ws->mx-ei->x);
		ei->x += ei->espeed * cos (ei->eangle) * time;
		ei->y += ei->espeed * sin (ei->eangle) * time;
	    }
	    if (ei->trigger == TRIGGER_RANDOMPERIOD
		&& ei->set_active && !((int)random ()&0xff))
		ei->active = !ei->active;
	    if (ei->active && (
		(ei->trigger == TRIGGER_PERSISTENT) ||
		(ei->trigger == TRIGGER_RANDOMSHOT && !((int)random()&0xff)) ||
		(ei->trigger == TRIGGER_RANDOMPERIOD)
		))
		genNewParticles (ws->ps, ei);
	}
    }

    if (ws->ps && ws->ps->active)
    {
	updateParticles (ws->ps, time);
	damageRegion (s);
    }

    UNWRAP (ws, s, preparePaintScreen);
    (*s->preparePaintScreen) (s, time);
    WRAP (ws, s, preparePaintScreen, wizardPreparePaintScreen);
}