Does C2 uses WebGL framebuffer to resize canvas?

Discussion and feedback on Construct 2

Post » Tue Oct 08, 2013 11:49 pm

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?
B
99
S
35
G
29
Posts: 3,139
Reputation: 28,421

Post » Wed Oct 09, 2013 8:36 am

Looking at the js files it doesn't appear to use a framebuffer. Webgl just scales better than canvas2d when drawing a larger scale.
B
94
S
33
G
114
Posts: 5,359
Reputation: 73,779

Post » Wed Oct 09, 2013 9:18 am

@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.
B
99
S
35
G
29
Posts: 3,139
Reputation: 28,421


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 11 guests