コード例 #1
0
ファイル: ButtonRendering.cpp プロジェクト: clin4g/openwar
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);
	}
}
コード例 #2
0
ファイル: textureshape.cpp プロジェクト: Novarisk/openwar
textureglyph::textureglyph(texturetile tile, bounds2f bounds, glm::vec2 inset)
{
	outer_xy = bounds;
	inner_xy = bounds.grow(-inset.x, -inset.y);
	outer_uv = tile.outer;
	inner_uv = tile.inner;
}
コード例 #3
0
ファイル: BattleView.cpp プロジェクト: Novarisk/openwar
void BattleView::UpdateTerrainTrees(bounds2f bounds)
{
	if (_smoothTerrainSurface != nullptr && _simulator->GetGroundMap() != nullptr)
	{
		auto pos2 = std::remove_if(_billboardModel->staticBillboards.begin(), _billboardModel->staticBillboards.end(), [bounds](const Billboard& billboard) {
			return bounds.contains(billboard.position.xy());
		});
		_billboardModel->staticBillboards.erase(pos2, _billboardModel->staticBillboards.end());


		static random_generator* _randoms = nullptr;
		if (_randoms == nullptr)
			_randoms = new random_generator(997);

		int treeType = 0;
		random_iterator random(*_randoms);
		bounds2f mapbounds = _simulator->GetGroundMap()->GetBounds();
		glm::vec2 center = mapbounds.center();
		float radius = mapbounds.width() / 2;

		float d = 5 * mapbounds.width() / 1024;
		for (float x = mapbounds.min.x; x < mapbounds.max.x; x += d)
			for (float y = mapbounds.min.y; y < mapbounds.max.y; y += d)
			{
				float dx = d * (random.next() - 0.5f);
				float dy = d * (random.next() - 0.5f);
				int shape = (int)(15 * random.next()) & 15;

				glm::vec2 position = glm::vec2(x + dx, y + dy);
				if (bounds.contains(position) && glm::distance(position, center) < radius)
				{
					if (_simulator->GetHeightMap()->InterpolateHeight(position) > 0 && _simulator->GetGroundMap()->IsForest(position))
					{
						const float adjust = 0.5 - 2.0 / 64.0; // place texture 2 texels below ground
						_billboardModel->staticBillboards.push_back(Billboard(GetTerrainPosition(position, adjust * 5), 0, 5, _billboardModel->_billboardTreeShapes[shape]));
					}
				}

				++treeType;
			}
	}
}
コード例 #4
0
ファイル: ButtonRendering.cpp プロジェクト: Novarisk/openwar
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);
	}
}
コード例 #5
0
ファイル: ButtonRendering.cpp プロジェクト: Novarisk/openwar
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()));
}
コード例 #6
0
ファイル: ButtonRendering.cpp プロジェクト: Novarisk/openwar
void ButtonRendering::RenderSelected(const glm::mat4& transform, bounds2f bounds)
{
	RenderCornerButton(transform, _textureButtonSelected, bounds.grow(10), 32);
}
コード例 #7
0
ファイル: InputWidget.cpp プロジェクト: tttom64/openwar
void InputWidget::SetBounds(const bounds2f& value)
{
	_bounds = value;
	StringWidget::SetPosition(value.min);
	StringWidget::SetWidth(value.x().size());
}
コード例 #8
0
ファイル: ButtonRendering.cpp プロジェクト: clin4g/openwar
void ButtonRendering::RenderSelected(bounds2f viewport, bounds2f bounds)
{
	//RenderTextureRect(viewport, _texture_selected, bounds, bounds2(0, 0, 1, 1));
	RenderCornerButton(viewport, _textureButtonSelected, bounds.grow(10), 32);
}
コード例 #9
0
ファイル: ButtonRendering.cpp プロジェクト: clin4g/openwar
void ButtonRendering::RenderBackground(bounds2f viewport, bounds2f bounds)
{
	RenderCornerButton(viewport, _textureButtonBackground, bounds.grow(10), 32);
}