MCPcopy Create free account
hub / github.com/assaultcube/AC / uploadtexture

Function uploadtexture

source/src/texture.cpp:123–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121}
122
123void uploadtexture(GLenum target, GLenum internal, int tw, int th, GLenum format, GLenum type, void *pixels, int pw, int ph, bool mipmap)
124{
125 int bpp = formatsize(format);
126 uchar *buf = NULL;
127 if(pw!=tw || ph!=th)
128 {
129 buf = new uchar[tw*th*bpp];
130 scaletexture((uchar *)pixels, pw, ph, bpp, buf, tw, th);
131 }
132 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
133 for(int level = 0;; level++)
134 {
135 uchar *src = buf ? buf : (uchar *)pixels;
136 glTexImage2D(target, level, internal, tw, th, 0, format, type, src);
137 if(!mipmap || max(tw, th) <= 1) break;
138 int srcw = tw, srch = th;
139 if(tw > 1) tw /= 2;
140 if(th > 1) th /= 2;
141 if(!buf) buf = new uchar[tw*th*bpp];
142 scaletexture(src, srcw, srch, bpp, buf, tw, th);
143 }
144 if(buf) delete[] buf;
145}
146
147void createtexture(int tnum, int w, int h, void *pixels, int clamp, bool mipmap, bool canreduce, GLenum format)
148{

Callers 1

createtextureFunction · 0.85

Calls 3

formatsizeFunction · 0.85
scaletextureFunction · 0.85
maxFunction · 0.85

Tested by

no test coverage detected