CGP Reviewer
CGP Reviewer
Core Concepts
Raster: An array of pixels arranged in a grid on a screen. Pixels use RGB values
between 0 and 1 to specify colors. Examples:
• Red: (1, 0, 0)
• Green: (0, 1, 0)
• Blue: (0, 0, 1)
Buffer & Framebuffer: A buffer temporarily stores data. The framebuffer stores pixel
data, including color, depth, and sometimes stencil buffers.
1. Application Stage:
o Creates the window for graphics.
o Loads data into the GPU (e.g., textures, vertex shaders).
o Sends vertex data via vertex buffer objects (VBOs) and stores
associations in vertex array objects (VAOs).
2. Geometry Processing:
o The vertex shader computes the final positions of points (vertices).
o Transformations:
▪ Model Transformation: Adjusts an object's position, size, and
orientation.
▪ View Transformation: Transforms world coordinates to camera
view coordinates.
▪ Projection Transformation: Clips points outside the viewing
region.
3. Rasterization:
o Converts geometric shapes into pixels.
o Assembles primitives (points, lines, triangles) and creates fragments for
each pixel.
4. Pixel Processing:
o The fragment shader determines the final color of each pixel using:
▪ Base color, interpolated vertex colors.
▪ Textures and lighting effects.
Handout 2
Important Terminologies:
• GPU (Graphics Processing Unit): Handles rendering tasks more efficiently than a
CPU, primarily using shaders to perform calculations.
• Shader: A program executed on the GPU to manage specific tasks like rendering pixels
and vertices.
• APIs and Shader Languages:
o DirectX & HLSL: Used on Microsoft platforms.
o Metal & Metal Shading Language: For Apple devices.
o OpenGL & GLSL: Cross-platform library, widely used for graphics rendering.
Graphics Pipeline in OpenGL
1. Application Stage: Initializing the window, sending data to the GPU, and managing
attribute data through vertex buffer objects (VBOs) and vertex array objects (VAOs).
2. Geometry Processing: Determining the position of vertices through vertex shaders and
transformations (model, view, and projection).
3. Rasterization: Grouping vertices into geometric primitives (lines, triangles) and creating
fragments (data for pixel colors).
4. Pixel Processing: Determining the final color of each pixel using fragment shaders,
texture mapping, and lighting calculations.
Pygame Overview
Pygame Features
• Discrete Events: Captured when a key is pressed or released (e.g., keydown, keyup
events).
• Continuous Events: Actions (like moving an object) that persist while a key is held
down.