- // maps to a 2x3 texture rectangle with normalized coordinates (must be scaled by size after lookup)
- // +-
- // XX
- // YY
- // ZZ
- rtexture_t *projection;
- unsigned short *data, *texel;
- unsigned int sizebits = 0, stepbits = 0, res, i, j, k;
- while ((1 << sizebits) < size) sizebits++;
- while ((1 << stepbits) <= border) stepbits++;
- stepbits = min(stepbits, sizebits);
- res = size>>stepbits;
- stepbits += 16 - sizebits - 1;
- data = (unsigned short *)Mem_Alloc(texturemempool, 2*sizeof(unsigned short)*res*res*6);
- texel = data;
- for (i = 0;i < 6;i++)
- {
- unsigned int x = (i%2)<<16, y = (i/2)<<16;
- for (j = 0;j < res;j++)
- {
- for (k = 0;k < res;k++)
- {
- *texel++ = (x + ((2*k + 1)<<stepbits))/width;
- *texel++ = (y + ((2*j + 1)<<stepbits))/height;
- }
- }
- }
- projection = R_SetupTexture(rtexturepool, identifier, res, res, 1, 6, TEXF_ALWAYSPRECACHE | TEXF_FORCELINEAR | TEXF_CLAMP, TEXTYPE_PROJECTION, GLTEXTURETYPE_CUBEMAP, (unsigned char *)data, NULL);
- Mem_Free(data);
- return projection;
+ return R_SetupTexture(rtexturepool, identifier, width, height, 1, 1, R_ShadowMapTextureFlags(precision, filter), TEXTYPE_SHADOWMAP, GLTEXTURETYPE_2D, NULL, NULL);