Shading Languages
1. OpenGL
OpenGL is a graphics API Specification, not a library! It defines an abstract rendering device and a set of functions to operate on it. Its immediate mode, with drawing commands and no concept of permanent objects. The implementation is provided by the graphics driver. It is a state machine for maximum efficiency.
To write an openGL program, we need to setup a render window, setup and initialize a viewport, model transformation & file IO. Finally, you must define a frame generation function to define what happens in each frame.
1.1 Context
Contexts represent an instance of OpenGL. Each process can have multiple contexts, which share resources. Just one context can be current for a given thread, and all OpenGL commands affect the current context. Contexts are created using platform-specific APIs (e.g. GLUT, GLFW, SDL).
1.2 Resources
Resources acts as sources of inputs and sinks for outputs. This can be primitives, buffers, and texture images.
1.3 Object Model
OpenGL is object oriented, where object instances are identified by ID. Each command has an object currently bound to the target.
Buffer objects store an array of unformatted memory allocated by the OpenGL context (i.e. the GPU). These are regular OpenGL objects that can store vertex data, pixel data, etc. To set up internal state, it must be bound to the context. Can be both immutable & mutable.
1.4 Primitive Types
Primitive Types include, LINES, LINE_STRIP, TRIANGLES, TRIANGLE_STRIP, POINTS, etc. Each primitive type has its own rules for rasterization.
1.5 Shaders
Shader Objects are part of a pipeline, compiled during runtime from GLSL code. A program object is a set of shaders linked together. Each program object has its own set of attributes and uniforms.