-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
101 changed files
with
197 additions
and
4,869 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
modules/gltools/test/state-tracker/state-tracking/track-context-state.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import {createGLContext, instrumentGLContext, isBrowser} from '@luma.gl/webgl'; | ||
import '@luma.gl/debug'; | ||
|
||
const ERR_HEADLESSGL_NOT_AVAILABLE = | ||
'Failed to create WebGL context in Node.js, headless gl not available'; | ||
|
||
const ERR_HEADLESSGL_FAILED = | ||
'Failed to create WebGL context in Node.js, headless gl returned null'; | ||
|
||
const ERR_HEADLESSGL_LOAD = `\ | ||
luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL \ | ||
contexts can not be created. This may not be an error. For example, this is a \ | ||
typical configuration for isorender applications running on the server.`; | ||
|
||
const CONTEXT_DEFAULTS = { | ||
width: 1, | ||
height: 1, | ||
debug: true, | ||
throwOnFailure: false, | ||
throwOnError: false | ||
}; | ||
|
||
export function createTestContext(opts = {}) { | ||
opts = Object.assign({}, CONTEXT_DEFAULTS, opts); | ||
const context = isBrowser | ||
? createGLContext(opts) | ||
: instrumentGLContext(createHeadlessContext(opts), opts); | ||
return context; | ||
} | ||
|
||
// Create headless gl context (for running under Node.js) | ||
export function createHeadlessContext(options) { | ||
const {width, height, webgl1, webgl2} = options; | ||
|
||
function onError(message) { | ||
if (options.throwOnError) { | ||
throw new Error(message); | ||
} | ||
return null; | ||
} | ||
|
||
if (webgl2 && !webgl1) { | ||
return onError('headless-gl does not support WebGL2'); | ||
} | ||
if (!headlessGL) { | ||
return onError(ERR_HEADLESSGL_NOT_AVAILABLE); | ||
} | ||
const gl = headlessGL(width, height, options); | ||
if (!gl) { | ||
return onError(ERR_HEADLESSGL_FAILED); | ||
} | ||
return gl; | ||
} | ||
|
||
// Load headless gl dynamically, if available | ||
function headlessGL(...args) { | ||
const headless = module.require('gl'); | ||
if (!headless) { | ||
throw new Error(ERR_HEADLESSGL_LOAD); | ||
} | ||
return headless(...args); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export {default as SnapshotTestRunner} from './snapshot-test-runner'; | ||
export {default as PerformanceTestRunner} from './performance-test-runner'; | ||
export {createTestContext, createHeadlessContext} from './context'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.