AMD #146

Open
wants to merge 28 commits into
from

Projects

None yet

2 participants

@greggman
Contributor

See #143

This PR adds basic WebGL2 support (it runs, adds WebGL2 VAO support, otherwise lots of features still TBD), and switches the module system to use AMD and the builder to use Webpack+Babel so you can use ES6 features and compile down to ES5/IE

The chrome extension works in both release and debug mode and embed.js seems to work in both release and debug mode. Also tested firefox in release. Safari I can't test as the extension no longer works even without these changes, see #145

A few caveats: Because the debug mode uses require.js there are issues with using debug mode on pages that use require.js themselves. There is a workaround. Non-debug mode does not have that issue. See readme.md

Another issue is in debug mode things are finicky in that it's possible window.onload could fire
before getContext has been wrapped. At the moment it seems to be working but just in case, for those cases you can (debug mode with embed.js only) you can wait for gliready instead of load. In other words assuming you have some code like this

window.onload = runMyApp;

You'd change it to

window.addEventListener('gliready', runMyApp);

Again, only when using embed.js in debug mode. In non debug mode there's no issue. Also mentioned in readme

greggman added some commits Dec 27, 2016
@greggman greggman add "webgl2" to the list of types of contexts to check for f1d95da
@greggman greggman add WebGL2 resource types 7aadf7e
@greggman greggman Add GL constants 9fdefc7
@greggman greggman Add VertexArray class 0a07160
@greggman greggman Update Info for WebGL2 a215312
@greggman greggman add util.isWebGL2 function a1d8d56
@greggman greggman Add util.addSimpleElem function 5264c0d
@greggman greggman add VertexArray tab and view 12d3712
@greggman greggman add WebGL2 resource to TraceLine.js 565c57f
@greggman greggman Use VertexArrayTab 514975b
@greggman greggman update build to use VertexArray scripts 56ced7d
@greggman greggman remove unused context names 0caf031
@greggman greggman set WebGL version for support contexts cdaf91e
@greggman greggman fix generateMipmap error issue
AFAIK if you're not uploading any data then there's no reason to call generateMipmap?
95f4795
@greggman greggman fix texture formats 4239332
@greggman greggman store VAO's element buffer on object because otherwise setExtraParame…
…ter copies the Buffer object
f801022
@greggman greggman move util.addSimpleElem to ui.appendElement ec44980
@greggman greggman make VertexArrayView use ui.appendElement and show ELEMENT_ARRAY_BUFFER 42382c5
@greggman greggman add a few more constants 74765c1
@greggman greggman add stuff for calculating number of bytes for WebGL2 textures 3cf789d
@greggman greggman add more enums to getParameter FunctionInfo a928565
@greggman greggman Use AMD
This commit switches to AMD for the module system and uses webpack/babel
to build lib/gli.all.js. This means you can use ES6 code in the source
and it should be converted to ES5. It also means there's no need to
add files to both the loaded and the buildscript as webpack can
figure out the files.

The chrome extension works in both release and debug mode
and embed.js seems to work in both release and debug mode.
Also tested firefox in release. Safari I can't test
as the extension no longer works even without these changes.

A few caveats: Because the debug mode uses require.js
there *may* be issues with using debug mode on pages
that use require.js themselves. Non-debug mode should
not have that issue.

Another issue is in debug mode things are finicky
in that it's possible window.onload could fire
before `getContext` has been wrapped. At the moment
it seems to be working but just in case, for those
cases you can (debug mode with embed.js only) you
can wait for `gliready` instead of load. In other words
assuming you have some code like this

    window.onload = runMyApp;

You'd change it to

    window.addEventListener('gliready', runMyApp);

Again, only when using embed.js in debug mode.
408c57c
@greggman greggman Set TracePreview canvas size to match original canvas size e0aa38f
@greggman greggman Remove unused module reference 22ea20c
@greggman greggman add back in missing "experimental-webgl" 5cb0685
@greggman greggman remove unused code 7a53a17
@greggman greggman detail using require.js base pages when debugging the inspector 016dcbc
@benvanik
Owner

Still reading through this, but it looks fantastic Gregg!

core/ui/tabs/trace/TraceListing.js
@@ -100,7 +111,7 @@
if (call.error) {
el.className += " trace-call-error";
- var errorString = gli.info.enumToString(call.error);
+ var errorString = infos.enumToString(call.error);
@benvanik
Owner

Would you like to merge this soon, or are you planning to continue updating this PR? There were a few TODO's in there (like the vertex array not refreshing) but if you're planning on adding more to this PR that's fine.

@greggman
Contributor

I'd like to merge this if that's ok. I don't think there's any loss in functionality and the AMD changes are pretty big and would make it harder to merge other changes later if someone happened to work on the non AMD version.

I have another PR waiting and more coming.

As for the TODOs I scanned over them and I don't see any I wrote. They're all copied from code I cribbed. I think the refresh comment you're referring to is copied from BuffersTab.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment