| 120 | } |
| 121 | |
| 122 | Texture CreateTextureFromFile(string_view name, int tf) { |
| 123 | tf &= ~TF_FLOAT; // Not supported yet. |
| 124 | string fbuf; |
| 125 | if (LoadFile(name, &fbuf) < 0) |
| 126 | return Texture(); |
| 127 | int2 dim; |
| 128 | int comp; |
| 129 | auto buf = stbi_load_from_memory((uchar *)fbuf.c_str(), (int)fbuf.length(), &dim.x, &dim.y, |
| 130 | &comp, 4); |
| 131 | if (!buf) |
| 132 | return Texture(); |
| 133 | auto tex = CreateTexture(buf, dim.data(), tf); |
| 134 | stbi_image_free(buf); |
| 135 | return tex; |
| 136 | } |
| 137 | |
| 138 | Texture CreateBlankTexture(const int2 &size, const float4 &color, int tf) { |
| 139 | if (tf & TF_MULTISAMPLE) { |