Skip to content

Commit

Permalink
make GL optional
Browse files Browse the repository at this point in the history
  • Loading branch information
artoonie committed Apr 14, 2023
1 parent c77c302 commit 6e11cd0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ See [examples](https://github.com/mifi/editly/tree/master/examples)
- (Linux) may require some extra steps. See [headless-gl](https://github.com/stackgl/headless-gl#system-dependencies).
- **Editly is now ESM only**

Note: While OpenGL is required for transitions, you may disable transitions and circumvent the need for OpenGL by setting all transition durations to zero. This is particularly useful on platforms that do not support installing Xvfb, like Google Cloud Functions.

## Installing

`npm i -g editly`
Expand Down
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;

const 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 6e11cd0

Please sign in to comment.