Read the contents of a stream into an array of char
| 101 | |
| 102 | // Read the contents of a stream into an array of char |
| 103 | bool getStreamContents(sf::InputStream& stream, std::vector<char>& buffer) |
| 104 | { |
| 105 | bool success = false; |
| 106 | const std::optional size = stream.getSize(); |
| 107 | if (size > std::size_t{0}) |
| 108 | { |
| 109 | buffer.resize(*size); |
| 110 | |
| 111 | if (!stream.seek(0).has_value()) |
| 112 | { |
| 113 | sf::err() << "Failed to seek shader stream" << std::endl; |
| 114 | return false; |
| 115 | } |
| 116 | |
| 117 | const std::optional read = stream.read(buffer.data(), *size); |
| 118 | success = (read == size); |
| 119 | } |
| 120 | buffer.push_back('\0'); |
| 121 | return success; |
| 122 | } |
| 123 | |
| 124 | // Transforms an array of 2D vectors into a contiguous array of scalars |
| 125 | std::vector<float> flatten(const sf::Vector2f* vectorArray, std::size_t length) |
no test coverage detected