mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 07:42:38 +08:00
fix copressed texture creation on webgl2
This commit is contained in:
@@ -971,10 +971,10 @@ export function WebGL2CmdFuncCreateTexture (device: WebGL2GFXDevice, gpuTexture:
|
||||
h = Math.max(1, h >> 1);
|
||||
}
|
||||
} else {
|
||||
const view: ArrayBufferView = { buffer: new ArrayBuffer(0), byteLength: 0, byteOffset: 0 };
|
||||
for (let i = 0; i < gpuTexture.mipLevel; ++i) {
|
||||
const imgSize = GFXFormatSize(gpuTexture.format, w, h, 1);
|
||||
gl.compressedTexImage2D(WebGL2RenderingContext.TEXTURE_2D, i, gpuTexture.glInternelFmt, w, h, 0, imgSize, 0);
|
||||
const view: ArrayBufferView = { buffer: new ArrayBuffer(imgSize), byteLength: imgSize, byteOffset: 0 };
|
||||
gl.compressedTexImage2D(WebGL2RenderingContext.TEXTURE_2D, i, gpuTexture.glInternelFmt, w, h, 0, view);
|
||||
w = Math.max(1, w >> 1);
|
||||
h = Math.max(1, h >> 1);
|
||||
}
|
||||
@@ -1034,14 +1034,13 @@ export function WebGL2CmdFuncCreateTexture (device: WebGL2GFXDevice, gpuTexture:
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const view: ArrayBufferView = { buffer: new ArrayBuffer(0), byteLength: 0, byteOffset: 0 };
|
||||
|
||||
for (let f = 0; f < 6; ++f) {
|
||||
let w = gpuTexture.width;
|
||||
let h = gpuTexture.height;
|
||||
for (let i = 0; i < gpuTexture.mipLevel; ++i) {
|
||||
const imgSize = GFXFormatSize(gpuTexture.format, w, h, 1);
|
||||
gl.compressedTexImage2D(WebGL2RenderingContext.TEXTURE_CUBE_MAP_POSITIVE_X + f, i, gpuTexture.glInternelFmt, w, h, 0, imgSize, 0);
|
||||
const view: ArrayBufferView = { buffer: new ArrayBuffer(imgSize), byteLength: imgSize, byteOffset: 0 };
|
||||
gl.compressedTexImage2D(WebGL2RenderingContext.TEXTURE_CUBE_MAP_POSITIVE_X + f, i, gpuTexture.glInternelFmt, w, h, 0, view);
|
||||
w = Math.max(1, w >> 1);
|
||||
h = Math.max(1, h >> 1);
|
||||
}
|
||||
@@ -1118,10 +1117,10 @@ export function WebGL2CmdFuncResizeTexture (device: WebGL2GFXDevice, gpuTexture:
|
||||
h = Math.max(1, h >> 1);
|
||||
}
|
||||
} else {
|
||||
const view: ArrayBufferView = { buffer: new ArrayBuffer(0), byteLength: 0, byteOffset: 0 };
|
||||
for (let i = 0; i < gpuTexture.mipLevel; ++i) {
|
||||
const imgSize = GFXFormatSize(gpuTexture.format, w, h, 1);
|
||||
gl.compressedTexImage2D(WebGL2RenderingContext.TEXTURE_2D, i, gpuTexture.glInternelFmt, w, h, 0, imgSize, 0);
|
||||
const view: ArrayBufferView = { buffer: new ArrayBuffer(imgSize), byteLength: imgSize, byteOffset: 0 };
|
||||
gl.compressedTexImage2D(WebGL2RenderingContext.TEXTURE_2D, i, gpuTexture.glInternelFmt, w, h, 0, view);
|
||||
w = Math.max(1, w >> 1);
|
||||
h = Math.max(1, h >> 1);
|
||||
}
|
||||
@@ -1162,14 +1161,13 @@ export function WebGL2CmdFuncResizeTexture (device: WebGL2GFXDevice, gpuTexture:
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const view: ArrayBufferView = { buffer: new ArrayBuffer(0), byteLength: 0, byteOffset: 0 };
|
||||
|
||||
for (let f = 0; f < 6; ++f) {
|
||||
let w = gpuTexture.width;
|
||||
let h = gpuTexture.height;
|
||||
for (let i = 0; i < gpuTexture.mipLevel; ++i) {
|
||||
const imgSize = GFXFormatSize(gpuTexture.format, w, h, 1);
|
||||
gl.compressedTexImage2D(WebGL2RenderingContext.TEXTURE_CUBE_MAP_POSITIVE_X + f, i, gpuTexture.glInternelFmt, w, h, 0, imgSize, 0);
|
||||
const view: ArrayBufferView = { buffer: new ArrayBuffer(imgSize), byteLength: imgSize, byteOffset: 0 };
|
||||
gl.compressedTexImage2D(WebGL2RenderingContext.TEXTURE_CUBE_MAP_POSITIVE_X + f, i, gpuTexture.glInternelFmt, w, h, 0, view);
|
||||
w = Math.max(1, w >> 1);
|
||||
h = Math.max(1, h >> 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user