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); } }
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; }
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; } } }
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); } }
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())); }
void ButtonRendering::RenderSelected(const glm::mat4& transform, bounds2f bounds) { RenderCornerButton(transform, _textureButtonSelected, bounds.grow(10), 32); }
void InputWidget::SetBounds(const bounds2f& value) { _bounds = value; StringWidget::SetPosition(value.min); StringWidget::SetWidth(value.x().size()); }
void ButtonRendering::RenderSelected(bounds2f viewport, bounds2f bounds) { //RenderTextureRect(viewport, _texture_selected, bounds, bounds2(0, 0, 1, 1)); RenderCornerButton(viewport, _textureButtonSelected, bounds.grow(10), 32); }
void ButtonRendering::RenderBackground(bounds2f viewport, bounds2f bounds) { RenderCornerButton(viewport, _textureButtonBackground, bounds.grow(10), 32); }