fix window resize

This commit is contained in:
jerrywwl
2019-04-08 16:42:36 +08:00
parent df13b4db14
commit c694545e12
3 changed files with 74 additions and 0 deletions
+36
View File
@@ -39,6 +39,8 @@ export class WebGLGFXWindow extends GFXWindow {
this._width = info.width;
this._height = info.height;
this._nativeWidth = this._width;
this._nativeHeight = this._height;
this._colorFmt = info.colorFmt;
this._depthStencilFmt = info.depthStencilFmt;
@@ -164,5 +166,39 @@ export class WebGLGFXWindow extends GFXWindow {
public resize (width: number, height: number) {
this._width = width;
this._height = height;
if (width > this._nativeWidth ||
height > this._nativeHeight) {
this._nativeWidth = width;
this._nativeHeight = height;
if (this._depthStencilTex) {
this._depthStencilTex.resize(width, height);
this._depthStencilTexView!.destroy();
this._depthStencilTexView!.initialize({
texture : this._depthStencilTex,
type : GFXTextureViewType.TV2D,
format : this._depthStencilFmt,
});
}
if (this._colorTex) {
this._colorTex.resize(width, height);
this._colorTexView!.destroy();
this._colorTexView!.initialize({
texture : this._colorTex,
type : GFXTextureViewType.TV2D,
format : this._colorFmt,
});
}
if (this._framebuffer && this._framebuffer.isOffscreen) {
this._framebuffer.destroy();
this._framebuffer.initialize({
renderPass: this._renderPass!,
colorViews: [ this._colorTexView! ],
depthStencilView: this._depthStencilTexView!,
});
}
}
}
}
+36
View File
@@ -39,6 +39,8 @@ export class WebGL2GFXWindow extends GFXWindow {
this._width = info.width;
this._height = info.height;
this._nativeWidth = this._width;
this._nativeHeight = this._height;
this._colorFmt = info.colorFmt;
this._depthStencilFmt = info.depthStencilFmt;
@@ -164,5 +166,39 @@ export class WebGL2GFXWindow extends GFXWindow {
public resize (width: number, height: number) {
this._width = width;
this._height = height;
if (width > this._nativeWidth ||
height > this._nativeHeight) {
this._nativeWidth = width;
this._nativeHeight = height;
if (this._depthStencilTex) {
this._depthStencilTex.resize(width, height);
this._depthStencilTexView!.destroy();
this._depthStencilTexView!.initialize({
texture : this._depthStencilTex,
type : GFXTextureViewType.TV2D,
format : this._depthStencilFmt,
});
}
if (this._colorTex) {
this._colorTex.resize(width, height);
this._colorTexView!.destroy();
this._colorTexView!.initialize({
texture : this._colorTex,
type : GFXTextureViewType.TV2D,
format : this._colorFmt,
});
}
if (this._framebuffer && this._framebuffer.isOffscreen) {
this._framebuffer.destroy();
this._framebuffer.initialize({
renderPass: this._renderPass!,
colorViews: [ this._colorTexView! ],
depthStencilView: this._depthStencilTexView!,
});
}
}
}
}
+2
View File
@@ -56,6 +56,8 @@ export abstract class GFXWindow extends GFXObject {
protected _top: number = 0;
protected _width: number = 0;
protected _height: number = 0;
protected _nativeWidth: number = 0;
protected _nativeHeight: number = 0;
protected _colorFmt: GFXFormat = GFXFormat.UNKNOWN;
protected _depthStencilFmt: GFXFormat = GFXFormat.UNKNOWN;
protected _isOffscreen: boolean = false;