Skip to content

Commit

Permalink
Merge pull request #304 from 06wj/fix/framebuffer
Browse files Browse the repository at this point in the history
Fix the display issue when the width and height of the framebuffer are decimals
  • Loading branch information
sebavan authored Apr 24, 2024
2 parents 6376155 + b4afe47 commit 8c11f4d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/backend/states/context/visualState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ export class VisualState extends BaseState {

protected getCapture(gl: WebGLRenderingContext, name: string, x: number, y: number, width: number, height: number,
textureCubeMapFace: number, textureLayer: number, type: number) {
width = Math.floor(width);
height = Math.floor(height);

const attachmentVisualState = {
attachmentName: name,
src: null as string,
Expand All @@ -256,7 +259,7 @@ export class VisualState extends BaseState {
// Copy the pixels to a working 2D canvas same size.
this.workingCanvas.width = width;
this.workingCanvas.height = height;
const imageData = this.workingContext2D.createImageData(Math.ceil(width), Math.ceil(height));
const imageData = this.workingContext2D.createImageData(width, height);
imageData.data.set(pixels);
this.workingContext2D.putImageData(imageData, 0, 0);

Expand Down
3 changes: 3 additions & 0 deletions src/backend/states/drawCalls/drawCallTextureInputState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ export class DrawCallTextureInputState {
}

protected getCapture(gl: WebGLRenderingContext, x: number, y: number, width: number, height: number, type: number, pixelated: boolean): string {
width = Math.floor(width);
height = Math.floor(height);

try {
// Check FBO status.
const status = this.context.checkFramebufferStatus(WebGlConstants.FRAMEBUFFER.value);
Expand Down

0 comments on commit 8c11f4d

Please sign in to comment.