Skip to content

Commit

Permalink
#21 OffscreenCanvasの実装(WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
ienaga committed Feb 14, 2023
1 parent 0b55bc0 commit 8e719c3
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/renderer/RenderBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ class CommandController
// update
$devicePixelRatio = devicePixelRatio;

const player = Util.$renderPlayer;
player._$samples = samples;
player._$canvas = canvas;

const gl = canvas.getContext("webgl2", {
"stencil": true,
"premultipliedAlpha": true,
Expand All @@ -54,13 +58,11 @@ class CommandController
"preserveDrawingBuffer": true
});

const player = Util.$renderPlayer;
player._$samples = samples;
player._$canvas = canvas;

const context = new CanvasToWebGLContext(gl, samples);
player._$context = context;
player._$cacheStore._$context = context;
if (gl) {
const context = new CanvasToWebGLContext(gl, samples);
player._$context = context;
player._$cacheStore._$context = context;
}
}

/**
Expand All @@ -74,21 +76,24 @@ class CommandController
*/
setBackgroundColor (background_color = null)
{
const player = Util.$renderPlayer;
const context = Util.$renderPlayer._$context;
if (!context) {
return ;
}

if (!background_color
|| background_color === "transparent"
) {

player._$context._$setColor(0, 0, 0, 0);
context._$setColor(0, 0, 0, 0);

} else {

const color = Util.$uintToRGBA(
Util.$toColorInt(background_color)
);

player._$context._$setColor(
context._$setColor(
color.R / 255,
color.G / 255,
color.B / 255,
Expand Down

0 comments on commit 8e719c3

Please sign in to comment.