MCPcopy
hub / github.com/regl-project/regl / parseMipMapFromObject

Function parseMipMapFromObject

lib/texture.js:918–967  ·  view source on GitHub ↗
(mipmap, options)

Source from the content-addressed store, hash-verified

916 }
917
918 function parseMipMapFromObject (mipmap, options) {
919 var imgData = null
920 if (isPixelData(options)) {
921 imgData = mipmap.images[0] = allocImage()
922 copyFlags(imgData, mipmap)
923 parseImage(imgData, options)
924 mipmap.mipmask = 1
925 } else {
926 parseFlags(mipmap, options)
927 if (Array.isArray(options.mipmap)) {
928 var mipData = options.mipmap
929 for (var i = 0; i < mipData.length; ++i) {
930 imgData = mipmap.images[i] = allocImage()
931 copyFlags(imgData, mipmap)
932 imgData.width >>= i
933 imgData.height >>= i
934 parseImage(imgData, mipData[i])
935 mipmap.mipmask |= (1 << i)
936 }
937 } else {
938 imgData = mipmap.images[0] = allocImage()
939 copyFlags(imgData, mipmap)
940 parseImage(imgData, options)
941 mipmap.mipmask = 1
942 }
943 }
944 copyFlags(mipmap, mipmap.images[0])
945
946 // For textures of the compressed format WEBGL_compressed_texture_s3tc
947 // we must have that
948 //
949 // "When level equals zero width and height must be a multiple of 4.
950 // When level is greater than 0 width and height must be 0, 1, 2 or a multiple of 4. "
951 //
952 // but we do not yet support having multiple mipmap levels for compressed textures,
953 // so we only test for level zero.
954
955 if (
956 mipmap.compressed &&
957 (
958 mipmap.internalformat === GL_COMPRESSED_RGB_S3TC_DXT1_EXT ||
959 mipmap.internalformat === GL_COMPRESSED_RGBA_S3TC_DXT1_EXT ||
960 mipmap.internalformat === GL_COMPRESSED_RGBA_S3TC_DXT3_EXT ||
961 mipmap.internalformat === GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
962 )
963 ) {
964 check(mipmap.width % 4 === 0 && mipmap.height % 4 === 0,
965 'for compressed texture formats, mipmap level 0 must have width and height that are a multiple of 4')
966 }
967 }
968
969 function setMipMap (mipmap, target) {
970 var images = mipmap.images

Callers 2

reglTexture2DFunction · 0.85
reglTextureCubeFunction · 0.85

Calls 6

isPixelDataFunction · 0.85
allocImageFunction · 0.85
copyFlagsFunction · 0.85
parseImageFunction · 0.85
parseFlagsFunction · 0.85
checkFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…