OpenTK suited tutorial, OpenTK allows you to use OpenGL in C#
good explanation videos
good explanation slides
- https://www.slideshare.net/elnaqah/opengl-presentation
- https://www.slideshare.net/mukherjeejayant/open-gl-training
"If you can’t explain it simply, you don’t understand it well enough." - Albert Einstein
"Laziness can be the downfall of the best of us." - Always Google
- "Standartized API for rendering 2D and 3D vector graphic." https://en.wikipedia.org/wiki/OpenGL
- API = a set of functions you use to render vector graphic
- Standartized = same API and behaves the same on any platform in any programing language
- CPU tells what to render -> GPU renders it
- vendor = GPU manufacturer = NVidia, ATI, ...
- different vendor = different GPU architecture = different way of inner workings,
- each vendor implements the same set of functions (OpenGL API), inside the implmenetation each does something different but end result is the same (rendered vector graphics)
- the OpenGL API implementation is inside vendor drivers, most systems come preinstalled with (outdated?) drivers
- introduced in OpenGL 1.5 (2003)
- OpenGL Shading Language (glsl) is programing language used to describe how to adjust parts of rendering pipeline
- before OpenGL 1.5 there was only fixed pipeline, you had little control over the final image
- is similar to C, has many inbuilt functions and types
- shader = our own custom part of rendering pipeline written in shading language
- rendering pipeline has several stages (points) which you can replace with your own shaders
- each stage has some inbuilt variables
How does one render triangle on screen ?
Simplified rendering pipeline
- lets render 3 points that make up triangle
- vertex shader -> adjust vertices (or other data)
- optimization: clipping, if none are visible dont continue
- rasterization -> turn triangle into set of fragments (pixels)
- fragment shader -> adjust fragments
- show fragments on screen
vertex shader that adds 5 units on X axis to every vertex
vec3 vertex_main(vec3 in)
{
return in + vec3(5,0,0);
}
fragment shader that outputs color based on screen position
vec3 fragment_main()
{
return vec3(gl_FragCoord.x, gl_FragCoord.y, 0);
}