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

Remove dependency on DOM classes #7

Closed
vorg opened this issue Feb 20, 2015 · 4 comments
Closed

Remove dependency on DOM classes #7

vorg opened this issue Feb 20, 2015 · 4 comments
Assignees

Comments

@vorg
Copy link

vorg commented Feb 20, 2015

Currently createTexture2D checks if provided texture object is some kind of image data by doing following checks

if(obj instanceof HTMLCanvasElement ||
       obj instanceof HTMLImageElement ||
       obj instanceof HTMLVideoElement ||
       obj instanceof ImageData) {

that prevents us from suppling valid texture object in non browser environment like Plask.

I've run into this issue while trying to use gl-sprite-text in pex and even though i have texture wrapper passing this test:

if(obj.shape && obj.data && obj.stride) {

it breaks because of the DOM classes.

@vorg vorg changed the title Remove dependency of DOM classes Remove dependency on DOM classes Feb 20, 2015
@mikolalysenko
Copy link
Member

Yeah, this is a good idea. Maybe another option could be to use Object.toString() or perhaps we could add a test to skip that whole conditional if HTMLCanvasElement etc. are not defined in the current environment?

@hughsk @mattdesl any ideas?

@hughsk
Copy link
Member

hughsk commented Feb 20, 2015

👍

It's not pretty but this would work without changing the existing behaviour at all:

if (('undefined' != typeof HTMLCanvasElement && obj instanceof HTMLCanvasElement) ||
    ('undefined' != typeof HTMLImageElement && obj instanceof HTMLImageElement) ||
    ('undefined' != typeof HTMLVideoElement && obj instanceof HTMLVideoElement) ||
    ('undefined' != typeof ImageData && obj instanceof ImageData)) {

@mattdesl
Copy link
Member

👍 to @hughsk's solution.

also @vorg, see my thoughts on text rendering here. Feel free to add any thoughts:
stackgl/contributing#26

@gre
Copy link
Member

gre commented Nov 2, 2016

I've provided a PR that implement @hughsk suggested solution.

mikolalysenko added a commit that referenced this issue Nov 2, 2016
Fixes #7: make gl-texture2d DOM independent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants