Esempio n. 1
0
	void updateCursorAlpha()
	{
		if (cursorVert.count() == 0)
			return;

		Vec4 color(1, 1, 1, cursorAlpha[cursorAlphaIdx] / 255.0f);

		for (size_t i = 0; i < cursorVert.count(); ++i)
			Quad::setColor(&cursorVert.vertices[i*4], color);

		cursorVertArrayDirty = true;
	}
Esempio n. 2
0
	void draw()
	{
		if (base.tex.tex == TEX::ID(0))
			return;

		bool windowskinValid = !nullOrDisposed(windowskin);
		bool contentsValid = !nullOrDisposed(contents);

		Vec2i trans = geo.pos() + sceneOffset;

		SimpleAlphaShader &shader = shState->shaders().simpleAlpha;
		shader.bind();
		shader.applyViewportProj();

		if (windowskinValid)
		{
			shader.setTranslation(trans);
			shader.setTexSize(Vec2i(base.tex.width, base.tex.height));

			TEX::bind(base.tex.tex);
			base.quad.draw();

			if (openness < 255)
				return;

			windowskin->bindTex(shader);

			TEX::setSmooth(true);
			ctrlVert.draw(0, ctrlQuads);
			TEX::setSmooth(false);
		}

		if (openness < 255)
			return;

		bool drawCursor = cursorVert.count() > 0 && windowskinValid;

		if (drawCursor || contentsValid)
		{
			/* Translate cliprect from local into screen space */
			IntRect clip = clipRect;
			clip.setPos(clip.pos() + trans);

			glState.scissorBox.push();
			glState.scissorTest.pushSet(true);

			if (rgssVer >= 3)
				glState.scissorBox.setIntersect(clip);
			else
				glState.scissorBox.setIntersect(IntRect(trans, geo.size()));

			IntRect pad = padRect;
			pad.setPos(pad.pos() + trans);

			if (drawCursor)
			{
				Vec2i contTrans = pad.pos();
				contTrans.x += cursorRect->x;
				contTrans.y += cursorRect->y;

				if (rgssVer >= 3)
					contTrans -= contentsOff;

				shader.setTranslation(contTrans);

				TEX::setSmooth(true);
				cursorVert.draw();
				TEX::setSmooth(false);
			}

			if (contentsValid)
			{
				if (rgssVer <= 2)
					glState.scissorBox.setIntersect(clip);

				Vec2i contTrans = pad.pos();
				contTrans -= contentsOff;
				shader.setTranslation(contTrans);

				TEX::setSmooth(false); // XXX
				contents->bindTex(shader);
				contentsQuad.draw();
			}

			glState.scissorBox.pop();
			glState.scissorTest.pop();
		}

		TEX::setSmooth(false); // XXX FIND out a way to eliminate
	}