| 121 | } |
| 122 | |
| 123 | void 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 | |
| 147 | void createtexture(int tnum, int w, int h, void *pixels, int clamp, bool mipmap, bool canreduce, GLenum format) |
| 148 | { |
no test coverage detected