index previous next
Detailed plan
- Rule No. 1
- General plan
- Detailed plan
Rule No.1 Don't get lost
If you ever get lost in this text, you don't know what you are doing or why you are doing something - backtrack. Get to some comfortable point and slowly go forward.
General plan
In the introduction there was something like
- Get webgl context from canvas
- Create vertex data
- Put data into GPU buffer
- Create vertex shader
- Create fragment shader
- Create shading program from vertex and fragment shader
- Plug in buffer into shading program
- Draw
Point 1. is behind us ;)
Let's expand this plan a bit.
Detailed plan
- Get webgl context from canvas
- Create vertex data
- create array with triangle's vertex data
- create float32 typed array with the same data
- Put data into GPU buffer
- create buffer
- put data into buffer
- Create vertex shader
- write vertex shader code
- embed vertex shader code into the page and get that code into string
- create vertex shader object
- put vertex shader code inside vertex shader object
- compile vertex shader
- Create fragment shader
- write fragment shader code
- embed fragment shader code into the page and get that code into string
- create fragment shader object
- put fragment shader code inside fragment shader object
- compile fragment shader
- Create shading program from vertex and fragment shader
- create program object
- attach vertex and fragment shader to the program
- link them
- use program
- Plug in buffer into shading program
- set shader parameter to take values from array
- plug in array to the shader parameter
- Draw
This plan is for you to remember - do not hurry. Take your time.
index previous next