Exemple #1
0
	WindowVXPrivate(int x, int y, int w, int h)
	    : windowskin(0),
	      contents(0),
	      cursorRect(&tmp.rect),
	      active(true),
	      arrowsVisible(true),
	      pause(false),
	      width(w),
	      height(h),
	      geo(x, y, w, h),
	      padding(DEF_PADDING),
	      paddingBottom(padding),
	      opacity(255),
	      backOpacity(DEF_BACK_OPAC),
	      contentsOpacity(255),
	      openness(255),
	      tone(&tmp.tone),
	      ctrlVertDirty(false),
	      ctrlVertArrayDirty(false),
	      clipRectDirty(false),
	      cursorVertDirty(false),
	      cursorVertArrayDirty(false),
	      pauseAlphaIdx(0),
	      pauseQuadIdx(0),
	      cursorAlphaIdx(0)
	{
		/* 4 scroll arrows + pause */
		ctrlVert.resize(4 + 1);
		pauseVert = &ctrlVert.vertices[4*4];

		base.vertDirty = false;
		base.texSizeDirty = false;
		base.texDirty = false;

		if (w > 0 || h > 0)
		{
			base.vertDirty = true;
			base.texSizeDirty = true;
			clipRectDirty = true;
			ctrlVertDirty = true;
		}

		prepareCon = shState->prepareDraw.connect
			(sigc::mem_fun(this, &WindowVXPrivate::prepare));

		refreshCursorRectCon();
		refreshToneCon();
		updateBaseQuad();
	}
Exemple #2
0
void Bitmap::radialBlur(int angle, int divisions)
{
	GUARD_DISPOSED;

	GUARD_MEGA;

	angle     = clamp<int>(angle, 0, 359);
	divisions = clamp<int>(divisions, 2, 100);

	const int _width = width();
	const int _height = height();

	float angleStep = (float) angle / (divisions-1);
	float opacity   = 1.0f / divisions;
	float baseAngle = -((float) angle / 2);

	ColorQuadArray qArray;
	qArray.resize(5);

	std::vector<Vertex> &vert = qArray.vertices;

	int i = 0;

	/* Center */
	FloatRect texRect(0, 0, _width, _height);
	FloatRect posRect(0, 0, _width, _height);

	i += Quad::setTexPosRect(&vert[i*4], texRect, posRect);

	/* Upper */
	posRect = FloatRect(0, 0, _width, -_height);

	i += Quad::setTexPosRect(&vert[i*4], texRect, posRect);

	/* Lower */
	posRect = FloatRect(0, _height*2, _width, -_height);

	i += Quad::setTexPosRect(&vert[i*4], texRect, posRect);

	/* Left */
	posRect = FloatRect(0, 0, -_width, _height);

	i += Quad::setTexPosRect(&vert[i*4], texRect, posRect);

	/* Right */
	posRect = FloatRect(_width*2, 0, -_width, _height);

	i += Quad::setTexPosRect(&vert[i*4], texRect, posRect);

	for (int i = 0; i < 4*5; ++i)
		vert[i].color = Vec4(1, 1, 1, opacity);

	qArray.commit();

	TEXFBO newTex = shState->texPool().request(_width, _height);

	FBO::bind(newTex.fbo, FBO::Draw);

	glState.clearColor.pushSet(Vec4());
	FBO::clear();

	Transform trans;
	trans.setOrigin(Vec2(_width / 2.0f, _height / 2.0f));
	trans.setPosition(Vec2(_width / 2.0f, _height / 2.0f));

	glState.blendMode.pushSet(BlendAddition);

	SimpleMatrixShader &shader = shState->shaders().simpleMatrix;
	shader.bind();

	p->bindTexture(shader);
	TEX::setSmooth(true);

	p->pushSetViewport(shader);

	for (int i = 0; i < divisions; ++i)
	{
		trans.setRotation(baseAngle + i*angleStep);
		shader.setMatrix(trans.getMatrix());
		qArray.draw();
	}

	p->popViewport();

	TEX::setSmooth(false);

	glState.blendMode.pop();
	glState.clearColor.pop();

	shState->texPool().release(p->gl);
	p->gl = newTex;

	modified();
}
Exemple #3
0
	void rebuildCursorVert()
	{
		const IntRect rect = cursorRect->toIntRect();
		const CursorSrc &src = cursorSrc;

		cursorVertArrayDirty = true;

		if (rect.w <= 0 || rect.h <= 0)
		{
			cursorVert.clear();
			return;
		}

		const Vec2 corOff(rect.w - 4, rect.h - 4);

		const Corners<FloatRect> cornerPos =
		{
			FloatRect(        0,        0, 4, 4 ), /* Top left */
			FloatRect( corOff.x,        0, 4, 4 ), /* Top right */
			FloatRect(        0, corOff.y, 4, 4 ), /* Bottom left */
			FloatRect( corOff.x, corOff.y, 4, 4 )  /* Bottom right */
		};

		const Vec2i sideLen(rect.w - 4*2, rect.h - 4*2);

		const Sides<FloatRect> sidePos =
		{
		    FloatRect(        0,        4,         4, sideLen.y ), /* Left */
		    FloatRect( corOff.x,        4,         4, sideLen.y ), /* Right */
		    FloatRect(        4,        0, sideLen.x,         4 ), /* Top */
		    FloatRect(        4, corOff.y, sideLen.x,         4 )  /* Bottom */
		};

		const FloatRect bgPos(4, 4, sideLen.x, sideLen.y);

		bool drawSidesLR = rect.h > 8;
		bool drawSidesTB = rect.w > 8;
		bool drawBg = drawSidesLR && drawSidesTB;

		size_t quads = 0;
		quads += 4; /* 4 corners */

		if (drawSidesLR)
			quads += 2;

		if (drawSidesTB)
			quads += 2;

		if (drawBg)
			quads += 1;

		cursorVert.resize(quads);
		Vertex *vert = dataPtr(cursorVert.vertices);
		size_t i = 0;

		i += Quad::setTexPosRect(&vert[i*4], src.corners.tl, cornerPos.tl);
		i += Quad::setTexPosRect(&vert[i*4], src.corners.tr, cornerPos.tr);
		i += Quad::setTexPosRect(&vert[i*4], src.corners.bl, cornerPos.bl);
		i += Quad::setTexPosRect(&vert[i*4], src.corners.br, cornerPos.br);

		if (drawSidesLR)
		{
			i += Quad::setTexPosRect(&vert[i*4], src.border.l, sidePos.l);
			i += Quad::setTexPosRect(&vert[i*4], src.border.r, sidePos.r);
		}

		if (drawSidesTB)
		{
			i += Quad::setTexPosRect(&vert[i*4], src.border.t, sidePos.t);
			i += Quad::setTexPosRect(&vert[i*4], src.border.b, sidePos.b);
		}

		if (drawBg)
			Quad::setTexPosRect(&vert[i*4], src.bg, bgPos);
	}