A bundle of retrospective changes

I’ve got quite a large list of things I wanted to fix in the lessons, but I’ve just made it three items shorter…

  1. murphy pointed out that modern browsers have built-in JSON libraries, so lesson 14 doesn’t need to import one. So that’s gone.
  2. The code that loaded textures was pretty ugly, creating separate globals for the image and the texture itself. I felt that the image should be a field of the texture object — so now it is, in all lessons back to #5.
  3. Finally, doug pointed out that my JavaScript objects in lesson 9 all had separate copies of their methods — that is, for each object, there was a completely different copy of the function stored in memory. The correct thing to do is to use a prototype, so now I do. Hopefully my explanation of JavaScript’s object model is finally correct…

One more thing: the demo for lesson 15 is now live — take a look and tell me what you think!

You can leave a response, or trackback from your own site.

4 Responses to “A bundle of retrospective changes”

  1. murphy says:

    About Lesson 15: Well, Safari doesn’t like it. Still, it won’t auto-convert float to int, and says: “ERROR: 0:33: ‘!=’ : wrong operand types no operation ‘!=’ exists that takes a left-hand operand of type ‘float’ and a right operand of type ‘const int’ (or there is no acceptable conversion)”. The OpenGL specification says that floats are autocasted to int, as far as I understand it. Does anybody know why Safari doesn’t comply?

  2. giles says:

    Thanks, murphy — I thought I’d got all of the floats — your warnings about them in the past have made me careful, but obviously not careful enough. I’ve fixed it, could you let me know if it works now?

    Re: SL differences between browsers — as I understand it, right now all browsers just dump the SL straight to the OpenGL library with no pre-processing, so we’re at the mercy of the hardware vendors’ drivers, which must have differing support for type conversions.

    I saw something the other day (perhaps on the mailing list, but I’m not sure) that suggested that the implementors are well aware of the problem and will fix it before the official release of WebGL implementations, but that it’s not at the top of their queue right now — presumably because it pretty much works most of the time.

  3. Paul Brunt says:

    @giles I have the same issue with floats, nearly every time I make a change to a shader ;-)
    Have you considered doing a book based on the tutorials? It’d be really nice to have a desktop(literal) reference for webgl. As for lesson 15 coming on great. It may be hard for newcomers to 3D to see the spec map with the current values(with texture on at least) it’s very subtle. Had you considered cranking them up for illistration? 10,10,10 for spec colour really makes the effect obvious.

  4. giles says:

    Hi Paul — glad to hear it’s not just me struggling with floats in the SL!

    You’re the second person to suggest I write a book, it sounds like I should look into it — thanks!

    Re: the specular highlight — that’s a good idea, 10 might be a bit high as a default, but I’ll bump the starting point up a bit and make sure that I suggest in the text (and demo in the video) that people try going that high for a really clear view of what’s going on.

Leave a Reply

Subscribe to RSS Feed Follow Learning WebGL on Twitter