Skip to content

Commit 8c11f4d

Browse files
authored
Merge pull request #304 from 06wj/fix/framebuffer
Fix the display issue when the width and height of the framebuffer are decimals
2 parents 6376155 + b4afe47 commit 8c11f4d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/backend/states/context/visualState.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,9 @@ export class VisualState extends BaseState {
241241

242242
protected getCapture(gl: WebGLRenderingContext, name: string, x: number, y: number, width: number, height: number,
243243
textureCubeMapFace: number, textureLayer: number, type: number) {
244+
width = Math.floor(width);
245+
height = Math.floor(height);
246+
244247
const attachmentVisualState = {
245248
attachmentName: name,
246249
src: null as string,
@@ -256,7 +259,7 @@ export class VisualState extends BaseState {
256259
// Copy the pixels to a working 2D canvas same size.
257260
this.workingCanvas.width = width;
258261
this.workingCanvas.height = height;
259-
const imageData = this.workingContext2D.createImageData(Math.ceil(width), Math.ceil(height));
262+
const imageData = this.workingContext2D.createImageData(width, height);
260263
imageData.data.set(pixels);
261264
this.workingContext2D.putImageData(imageData, 0, 0);
262265

src/backend/states/drawCalls/drawCallTextureInputState.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ export class DrawCallTextureInputState {
142142
}
143143

144144
protected getCapture(gl: WebGLRenderingContext, x: number, y: number, width: number, height: number, type: number, pixelated: boolean): string {
145+
width = Math.floor(width);
146+
height = Math.floor(height);
147+
145148
try {
146149
// Check FBO status.
147150
const status = this.context.checkFramebufferStatus(WebGlConstants.FRAMEBUFFER.value);

0 commit comments

Comments
 (0)