Exemple #1
0
void ButtonRendering::RenderTextureRect(bounds2f viewport, texture* texture, bounds2f b, bounds2f t, float alpha)
{
	vertexbuffer<texture_vertex> shape;
	shape._mode = GL_TRIANGLE_STRIP;
	shape._vertices.push_back(texture_vertex(b.p11(), t.p12()));
	shape._vertices.push_back(texture_vertex(b.p12(), t.p11()));
	shape._vertices.push_back(texture_vertex(b.p21(), t.p22()));
	shape._vertices.push_back(texture_vertex(b.p22(), t.p21()));

	if (alpha == 1)
	{
		texture_uniforms uniforms;
		uniforms._transform = sprite_transform(viewport).transform();
		uniforms._texture = texture;

		_renderers->_texture_renderer->render(shape, uniforms);
	}
	else
	{
		texture_alpha_uniforms uniforms;
		uniforms._transform = sprite_transform(viewport).transform();
		uniforms._texture = texture;
		uniforms._alpha = alpha;

		_renderers->_alpha_texture_renderer->render(shape, uniforms);
	}
}
Exemple #2
0
static void AddRect(vertexbuffer<texture_vertex>& shape, bounds2f bounds, bounds2f texture)
{
	shape._vertices.push_back(texture_vertex(bounds.p11(), glm::vec2(0, 1) - texture.p11()));
	shape._vertices.push_back(texture_vertex(bounds.p12(), glm::vec2(0, 1) - texture.p12()));
	shape._vertices.push_back(texture_vertex(bounds.p22(), glm::vec2(0, 1) - texture.p22()));

	shape._vertices.push_back(texture_vertex(bounds.p22(), glm::vec2(0, 1) - texture.p22()));
	shape._vertices.push_back(texture_vertex(bounds.p21(), glm::vec2(0, 1) - texture.p21()));
	shape._vertices.push_back(texture_vertex(bounds.p11(), glm::vec2(0, 1) - texture.p11()));
}
Exemple #3
0
void ButtonRendering::RenderTextureRect(const glm::mat4& transform, texture* texturex, bounds2f b, bounds2f t, float alpha)
{
	vertexbuffer<texture_vertex> shape;
	shape._mode = GL_TRIANGLE_STRIP;
	shape._vertices.push_back(texture_vertex(b.p11(), t.p12()));
	shape._vertices.push_back(texture_vertex(b.p12(), t.p11()));
	shape._vertices.push_back(texture_vertex(b.p21(), t.p22()));
	shape._vertices.push_back(texture_vertex(b.p22(), t.p21()));

	if (alpha == 1)
	{
		_renderers->_texture_renderer->get_uniform<glm::mat4>("transform").set_value(transform);
		_renderers->_texture_renderer->get_uniform<const texture*>("texture").set_value(texturex);
		_renderers->_texture_renderer->render(shape);
	}
	else
	{
		_renderers->_alpha_texture_renderer->get_uniform<glm::mat4>("transform").set_value(transform);
		_renderers->_alpha_texture_renderer->get_uniform<const texture*>("texture").set_value(texturex);
		_renderers->_alpha_texture_renderer->get_uniform<float>("alpha").set_value(alpha);
		_renderers->_alpha_texture_renderer->render(shape);
	}
}