void Mesh::RenderAAQuadAlongXNinePatch(const vec3 &bottom_left, const vec3 &top_right, const vec2i &texture_size, const vec4 &patch_info) { static const Attribute format[] = {kPosition3f, kTexCoord2f, kEND}; static const unsigned short indices[] = { 0, 2, 1, 1, 2, 3, 2, 4, 3, 3, 4, 5, 4, 6, 5, 5, 6, 7, 1, 3, 8, 8, 3, 9, 3, 5, 9, 9, 5, 10, 5, 7, 10, 10, 7, 11, 8, 9, 12, 12, 9, 13, 9, 10, 13, 13, 10, 14, 10, 11, 14, 14, 11, 15, }; auto max = vec2::Max(bottom_left.xy(), top_right.xy()); auto min = vec2::Min(bottom_left.xy(), top_right.xy()); auto p0 = vec2(texture_size) * patch_info.xy() + min; auto p1 = max - vec2(texture_size) * (mathfu::kOnes2f - patch_info.zw()); // Check if the 9 patch edges are not overwrapping. // In that case, adjust 9 patch geometry locations not to overwrap. if (p0.x() > p1.x()) { p0.x() = p1.x() = (min.x() + max.x()) / 2; } if (p0.y() > p1.y()) { p0.y() = p1.y() = (min.y() + max.y()) / 2; } // vertex format is [x, y, z] [u, v]: float z = bottom_left.z(); // clang-format off const float vertices[] = { min.x(), min.y(), z, 0.0f, 0.0f, p0.x(), min.y(), z, patch_info.x(), 0.0f, min.x(), p0.y(), z, 0.0f, patch_info.y(), p0.x(), p0.y(), z, patch_info.x(), patch_info.y(), min.x(), p1.y(), z, 0.0, patch_info.w(), p0.x(), p1.y(), z, patch_info.x(), patch_info.w(), min.x(), max.y(), z, 0.0, 1.0, p0.x(), max.y(), z, patch_info.x(), 1.0, p1.x(), min.y(), z, patch_info.z(), 0.0f, p1.x(), p0.y(), z, patch_info.z(), patch_info.y(), p1.x(), p1.y(), z, patch_info.z(), patch_info.w(), p1.x(), max.y(), z, patch_info.z(), 1.0f, max.x(), min.y(), z, 1.0f, 0.0f, max.x(), p0.y(), z, 1.0f, patch_info.y(), max.x(), p1.y(), z, 1.0f, patch_info.w(), max.x(), max.y(), z, 1.0f, 1.0f, }; // clang-format on Mesh::RenderArray(kTriangles, 6 * 9, format, sizeof(float) * 5, reinterpret_cast<const char *>(vertices), indices); }
void Graphics::setFloat4(ConstantLocation position, vec4 value) { setFloat4(position, value.x(), value.y(), value.z(), value.w()); }