MCPcopy Create free account
hub / github.com/aardappel/treesheets / CreateTextureFromFile

Function CreateTextureFromFile

lobster/src/gltexture.cpp:122–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120}
121
122Texture 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
138Texture CreateBlankTexture(const int2 &size, const float4 &color, int tf) {
139 if (tf & TF_MULTISAMPLE) {

Callers 1

AddGraphicsFunction · 0.85

Calls 5

TextureClass · 0.85
lengthMethod · 0.80
LoadFileFunction · 0.70
c_strMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected