Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make GL optional #243

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;

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