Vertex Data in WebGL
- Review of Homework 5
- Can you give me an overall UML diagram of this system?
- What is happening in the vertex and fragment shaders?
- What is the purpose of d in the vertex shader?
- What is a mat4, vec4?
- We will move on to discuss how we can form other projection matrices soon.
- We will also discuss sending over transformation matricies.
- In the canvas
- The canvas perhaps should not add the event handler?
- In the Program
- How are shapes represented?
- Does this seem efficient?
- In the widget
- Notice responsibility for establishing and displaying a VBO is moved here.
- bufferData(target, usage)
- or bufferData(target, size, usage)
- or bufferData(target, srdData, usage)
- There are others.
- target is ARRAY_BUFFER or ELMENT_ARRAY_BUFFER
- size is the size in bytes
- srcData is the data that will be copied
- null will not copy any data but will init buffer
- Usage
- gl.STATIC_DRAW : write once read many
- gl.DYNAMIC_DRAW: write some read many
- gl.STREAM_DRW: write once read once.
- There are others.
- Look at Display
- bindBuffer
- gl.ARRAY_BUFFER : attributes
- gl.ELEMENT_ARRAY_BUFFER: indices
- There are other buffers available.
- vertexAttribPointer(index, size, type, normalized, stride, offset)
- Binds the current buffer to an attribute.
- Index is the index of a vertex attribute.
- (The mapping between the attribute and the variable in the shader)
- Size is the number of components per attribute
- An integer between 1 and 4 inclusive
- type is one of the following
- gl.BYTE - 8 bit
- gl.SHORT - 16 bit
- gl.UNSIGNED_BYTE - 8 bit
- gl.UNSIGNED_SHORT - 16 bit
- g.FLOAT - 32 bit
- normalized
- true if the data should be normalized.
- Byte and Short [-1, 1]
- Unsigned [0,1]
- float: parameter has not effect.
- stride
- Offset in bytes between the beginning of consecutive vertex attributes.
- 0 -> each is next to each other.
- 4 -> a float between each set
- offset - size in bytes to the first component.
- We will spend quite a bit of time looking at this today.
- For completeness look at drawArrays.
- Do you understand this program?