Does C2 uses WebGL framebuffer to resize canvas?

0 favourites
  • 3 posts
From the Asset Store
Simple resize and rotate events for any sprite, quick and easy event sheet that you can use for your own projects.
  • I'm curious, I have a question what happens if C2 uses webGL to resize canvas from small to big in fullscreen to get smoother gameplay using this:

    var canvas;

    var gl;

    function resizeCanvas() {

       // only change the size of the canvas if the size it's being displayed

       // has changed.

       if (canvas.width != canvas.clientWidth ||

           canvas.height != canvas.clientHeight) {

         // Change the size of the canvas to match the size it's being displayed

         canvas.width = canvas.clientWidth;

         canvas.height = canvas.clientHeight;

       }

    }

    function main() {

       canvas = document.getElementById("c");

       gl = canvas.getContext("experimental-webgl");

       resizeCanvas();

       ...

       // at render time

       gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);

    }

    window.addEventListener('load', main);

    window.addEventListener('resize' resizeCanvas);

    I took this code from stack overflow, if is not related to webGL framebuffer to canvas, then silly me.

    When I see C2 game is using traditional canvas when I try to resize from fullscreen window to small, the performance changes like 45 fps to 60 fps in debugger.

    I thought about the bigger the canvas, the worse the performance, I think webGL uses a framebuffer the size and then interpolate it to a larger canvas. It's about my theory.

    Is it possible?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Looking at the js files it doesn't appear to use a framebuffer. Webgl just scales better than canvas2d when drawing a larger scale.

  • R0J0hound according to my tests, you say WebGL scales better than canvas2d but the performance doesn't improve, you have some experiments uses less than 60 fps, in average, 30 fps, try to resize from fullscreen to small window, you prolly get 40-50 fps.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)