Skip to content

Commit

Permalink
optional gl
Browse files Browse the repository at this point in the history
  • Loading branch information
smka committed Jul 14, 2023
1 parent 8b14eeb commit 0b3a826
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions glTransitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,24 @@ import createTexture from 'gl-texture2d';
const { default: createTransition } = glTransition;

export default ({ width, height, channels }) => {
const gl = GL(width, height);
let hasInitBeenCalled = false;
let gl;

if (!gl) {
throw new Error('gl returned null, this probably means that some dependencies are not installed. See README.');
function initGL() {
hasInitBeenCalled = true;

gl = GL(width, height);

if (!gl) {
throw new Error('gl returned null, this probably means that some dependencies are not installed. See README.');
}
}

function runTransitionOnFrame({ fromFrame, toFrame, progress, transitionName, transitionParams = {} }) {
if (!hasInitBeenCalled) {
initGL();
}

function convertFrame(buf) {
// @see https://github.com/stackgl/gl-texture2d/issues/16
return ndarray(buf, [width, height, channels], [channels, width * channels, 1]);
Expand Down

0 comments on commit 0b3a826

Please sign in to comment.