Restrospectively changing my retrospective changes…

Last week I decided that it was silly to keep using vertexAttribPointer for both the vertex positions and their colours for the squares in my second and third lessons, and for the faces of the cube in the fourth. After all, each of the squares is all one colour, so it would make more sense to use vertexAttrib4f.

Thanks to a commenter called Ray, who I’ve also been talking to on the Khronos forums, I’ve learned that the change causes problems. Vladimir Vukićević came up with a plausible diagnosis: there seems to be a problem with certain ATI graphics cards that means that if you don’t specify all attributes per-vertex, your objects don’t get drawn.

This is a pain, and is likely to cause enough problems in the future that I figured it was worth backing out the changes. Then, while I was at it, I realised that the way I was drawing the cube in lesson 4 was actually pretty bad, and there’s a much more elegant way to do it, using element array buffers — so, rather than teach people bad habits, I figured it was worth retrospectively changing that, too…

So, when we get on to lesson 5 (which is code-complete and just needs a description) then don’t be surprised if the code I refer back to is a little different to how it was last week… If you want to re-visit lesson 4 to see the changes, here’s a link to the place where the changed stuff starts.

Sorry for any confusion.

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

3 Responses to “Restrospectively changing my retrospective changes…”

  1. Petor says:

    I just had a curious look at your lesson 5 code. I appreciate, that you changed from using the vertexAttribPointer to the vertexIndex-stuff (you know what I mean..)
    Is it necessary that you list every vertex- 3 times in the vertexPositions-array? Would it not be easier to put just the 8 vertices of the cube and use the vertexIndices array to tell WebGL which vertices build one side?
    (If you explain this in the lesson, just ignore my post and be happy that I am really interested in your tutorial ;-) )

  2. Petor says:

    I just found the answer to my last question. thanks anyway.

  3. giles says:

    Petor — good question! The reason I have to list the positions three times each is because each time they have different texture coordinates. The vertex indices refer to different combinations of attributes — in this case, (position, texture coord) pairs — rather than just to positions.

    I’ll make sure I explain that properly in the writeup.

    [UPDATED] Ah, looks like you found out while I was writing that :-)

Leave a Reply

Subscribe to RSS Feed Follow Learning WebGL on Twitter