CG Lectures Stack
CG Lectures Stack
Installation Guide:
https://www.youtube.com/watch?v=bi-NvsFKcZg
Setting Up OpenGL for Windows. OpenGL( Open Graphics Library) is a… | by Navraj khanal |
The Startup | Medium
Definition:
Computer graphics involves creating and manipulating visual content with computers. It’s how
we make pictures, animations, and interactive visual content.
Where is it used?
● Movies: Think about the amazing visuals in animated films or CGI effects.
● Virtual Reality (VR) & Augmented Reality (AR): Immersive experiences like VR
games or AR apps.
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 1 of 53
:
Activity:
Can you think of other areas where computer graphics are used?
(Some answers might include web design, mobile apps, education, automotive design, etc.)
Early Beginnings:
The field of computer graphics began in the 1960s. Back then, the graphics were pretty basic
—just simple lines and shapes.
Important Milestones:
● Sketchpad (1963): The first program that allowed users to draw on a computer
screen using a light pen. It was created by Ivan Sutherland, often called the "father of
computer graphics."
● Pixar's Toy Story (1995): The first full-length movie made entirely with computer-
generated imagery (CGI).
Interactive Timeline:
Imagine we have a timeline where we place these milestones. As we go through each one,
you see how the field evolved from simple line drawings to the realistic 3D worlds we have
today.
Activity:
Which of these technologies do you think had the biggest impact on modern computer
graphics?
(I would give you a poll or ask you to discuss, and then we would talk about the answers.)
2D Graphics:
These are flat images—think of things like icons, diagrams, or sprites in 2D video games. They
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 2 of 53
:
don’t have depth.
3D Graphics:
These images have depth and perspective. You see 3D graphics in movies like Toy Story or
games like Minecraft. They’re made up of models that can be rotated and viewed from different
angles.
Example:
Imagine showing two images: one is a simple drawing of a circle (2D), and the other is a 3D
model of a sphere. You can see how the 3D model looks more realistic because it has shadows
and can be rotated.
Activity:
Can you identify which images in the slides are 2D and which are 3D?
We’d go through a series of images together, and you’d tell me which ones are which.
Raster Graphics:
These images are made up of tiny pixels (dots of color). Common formats include JPEG, PNG,
and BMP. If you zoom in on a raster image, you’ll see it gets blurry or pixelated.
Vector Graphics:
These are made up of paths, which are defined by mathematical formulas. They can be scaled
up or down without losing quality. Formats include SVG and EPS.
Example:
Imagine I draw a simple shape, like a star, in both a raster editor (like Photoshop) and a vector
editor (like Illustrator). You’d see that when I zoom in, the raster star gets blurry, while the
vector star stays sharp.
Activity:
What do you think will happen if we scale up these images?
I’d ask you to predict and then show you the results, so you see the difference between raster
and vector graphics.
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 3 of 53
:
What’s the Graphics Pipeline?
It’s the process a computer uses to turn data into an image on the screen. It’s like an assembly
line where each stage adds something to the final image.
● Rendering: Turning the models into the final image you see.
Interactive Diagram:
Imagine a flowchart showing these stages. As we click on each stage, we learn about what
happens in that part of the pipeline.
Activity:
Can you match the stages of the pipeline with their descriptions?
I’d show you descriptions and ask you to match them with the correct stage.
Graphics Hardware
What’s a GPU?
The Graphics Processing Unit (GPU) is a special part of your computer designed to handle
complex images quickly. It’s like the brain for graphics.
Activity:
Who knows the difference between a CPU and a GPU?
We’d discuss how the CPU is the general brain of the computer, while the GPU specializes in
graphics.
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 4 of 53
:
What Are Graphics Libraries?
They’re tools that make it easier for developers to create graphics. Popular ones include
OpenGL (for 3D graphics), DirectX (used in Windows games), and WebGL (used in web
browsers).
Activity:
What do you think will happen if we change this line of code?
I’d ask you to predict, then we’d change it and see what happens—maybe the triangle moves,
changes color, or something else.
Coordinate Systems
Example:
If I tell you to plot the point (2, 3) on a graph, you’d find the spot where x=2 and y=3 intersect.
In 3D, you’d also consider the z value to place the point in space.
Activity:
Let’s plot some points together!
I’d give you coordinates, and you’d place them on a graph or use an online tool to see where
they land.
Week#2
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 5 of 53
:
What Are Color Models?
They’re ways of representing colors using numbers. The most common is RGB, where colors
are made by mixing Red, Green, and Blue light.
Other Models:
● CMYK: Used in printing, stands for Cyan, Magenta, Yellow, and Black.
● HSV: Represents color using Hue (color), Saturation (intensity), and Value
(brightness).
Interactive Demo:
Imagine using a color picker tool. As you adjust the RGB values, you see the color change on
the screen.
Activity:
What color do you get with RGB values (255, 0, 0)?
(Answer: Pure red. We’d explore different combinations to see what colors they create.)
7. Rendering Concepts
Shading, Lighting, and Texture Mapping
Shading:
How light interacts with surfaces. Different shading techniques make surfaces look flat, smooth,
or shiny.
Lighting:
Adds realism by showing how light sources affect objects. For example, a lamp casts light and
shadows.
Texture Mapping:
Applying images (textures) to 3D models, like putting a picture of wood grain on a virtual table.
Interactive Demo:
Imagine we have a 3D model of a sphere. We’d apply different shading techniques (flat,
smooth) and textures (like wood or metal) to see how they change its appearance.
Activity:
Which shading technique looks most realistic?
I’d show you examples, and you’d vote on which one you think looks the most real.
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 6 of 53
:
Rasterization
What’s Rasterization?
It’s the process of turning vector shapes into pixels on the screen. This is how most graphics
are rendered, especially in video games.
Visualization:
Imagine we have a simple shape, like a triangle. We’d use an online tool to rasterize it,
zooming in to see how it’s made up of tiny squares (pixels).
Emerging Technologies:
● Virtual Reality (VR) & Augmented Reality (AR): Immersive experiences where
graphics play a key role.
● AI in Graphics: AI can create graphics, enhance images, and even generate entire
scenes automatically.
Discussion:
Where do you think computer graphics will be most influential in the future?
We’d brainstorm ideas, like in gaming, movies, education, or even medicine.
Challenges:
● Realism vs. Performance: Balancing how real graphics look with how fast they
render.
● Computation Power: Graphics are getting more realistic, but they require more
powerful hardware.
Activity:
Any questions or predictions about the future of computer graphics?
I’d open the floor for your thoughts and questions.
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 7 of 53
:
9. Conclusion and Q&A
Recap:
We’ve covered what computer graphics are, their history, different types, how they’re created,
and where they’re going in the future.
Submission:
We’ll look at everyone’s work next time and discuss how you applied the concepts.
This concludes our interactive introduction to computer graphics! I hope you enjoyed the
session and learned a lot. Don’t hesitate to reach out if you have any questions as you explore
more about computer graphics!
Week#3
● Brief History: Discuss the evolution from early vector graphics to the modern era of
real-time 3D rendering. Mention pioneers like Ivan Sutherland (Sketchpad) and the
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 8 of 53
:
development of the OpenGL and DirectX APIs.
2. Rendering Techniques
● 2.1 Forward Rendering (Ray-Casting)
○ Concept: In ray-casting, rays are cast from the camera into the scene. The
color of the pixel is determined by the first object the ray intersects.
○ OpenGL Example:
break
○ OpenGL Example:
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 9 of 53
:
// OpenGL code snippet for setting up a basic render pipeline
glBegin(GL_TRIANGLES);
glEnd();
if (!glfwInit()) {
return -1;
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 10 of 53
:
GLFWwindow* window = glfwCreateWindow(800, 600, "OpenGL Game Window", NULL,
NULL);
if (!window) {
glfwTerminate();
return -1;
glfwMakeContextCurrent(window);
while (!glfwWindowShouldClose(window)) {
glClear(GL_COLOR_BUFFER_BIT);
// Swap buffers
glfwSwapBuffers(window);
glfwPollEvents();
glfwTerminate();
○ Role: Used for designing mechanical parts, architectural structures, and more.
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 11 of 53
:
// Function to render a simple 3D cube
void renderCube() {
glBegin(GL_QUADS);
// Front face
glEnd();
● 3.3 Visualization
○ OpenGL Example: Setting up a basic VR scene with two viewports (for left
and right eyes).
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 12 of 53
:
glViewport(0, 0, windowWidth / 2, windowHeight);
renderScene(LEFT_EYE);
renderScene(RIGHT_EYE);
4. Polygonal Representation
● Concept: 3D objects are represented as meshes made up of polygons (triangles).
GLfloat vertices[] = {
// Other vertices
};
GLuint indices[] = {
0, 1, 2, 2, 3, 0,
// Other indices
};
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 13 of 53
:
glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_INT, indices);
Week#4
5. Basic Radiometry
● Radiometric Quantities:
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
6. Geometric Concepts
● Similar Triangles:
glEnable(GL_TEXTURE_2D);
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 14 of 53
:
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glBindTexture(GL_TEXTURE_2D, textureId);
● Projection Models:
○ Orthographic Projection:
■ OpenGL Example:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
○ Perspective Projection:
■ OpenGL Example:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
7. Conclusion
● Summary: Recap of key concepts such as rendering techniques, polygonal
representation, radiometry, and projection models.
● Q&A Session: Open floor for students to ask questions or clarify doubts.
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 15 of 53
:
8. Interactive Demonstration
● Practical Example: Implement a simple 3D scene using OpenGL that includes
multiple polygons, basic lighting, and textures.
9. Homework Assignment
● Research Task: Explain the difference between forward and backward rendering, and
provide real-world examples of where each is used.
● Practical Task: Write a program in OpenGL to create a 3D scene with at least one
light source and a textured object.
Week#5
○ Standard graphics APIs like OpenGL, DirectX, and Vulkan are used for
rendering graphics in a wide range of applications.
○ GUI frameworks like Qt, GTK, and Swing are used for constructing user
interfaces in applications.
● Code Example:
#include <QApplication>
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 16 of 53
:
#include <QWidget>
#include <QOpenGLWidget>
#include <QOpenGLFunctions>
protected:
initializeOpenGLFunctions();
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 17 of 53
:
glEnd();
};
QWidget window;
window.setCentralWidget(glWidget);
window.resize(800, 600);
window.show();
return app.exec();
○ Emission refers to objects that emit light, like the sun or a lamp.
○ Scattering is how light interacts with particles, affecting its path and color.
● Code Example:
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 18 of 53
:
○ Basic ray tracing for rendering a scene with light emission and scattering.
#include <iostream>
#include <cmath>
struct Vec3 {
float x, y, z;
};
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 19 of 53
:
// A function to simulate ray-sphere intersection
bool raySphereIntersect(const Vec3& origin, const Vec3& direction, const Vec3& center, float
radius, float& t) {
float discriminant = b * b - 4 * a * c;
if (discriminant < 0) {
return false;
} else {
return true;
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 20 of 53
:
Vec3 sphereCenter(0, 0, -5);
float t;
int main() {
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 21 of 53
:
float v = (2.0f * (y + 0.5f) / height - 1.0f);
std::cout << grayscale << " " << grayscale << " " << grayscale << "\n";
return 0;
● Code Example:
○ Extend the previous OpenGL example to control the triangle's color using Qt
sliders.
#include <QSlider>
#include <QVBoxLayout>
#include <QWidget>
#include <QApplication>
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 22 of 53
:
#include <QOpenGLWidget>
#include <QOpenGLFunctions>
Q_OBJECT
private:
public:
red = r;
green = g;
blue = b;
update();
protected:
initializeOpenGLFunctions();
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 23 of 53
:
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
glEnd();
};
Q_OBJECT
public:
MainWindow() {
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 24 of 53
:
OpenGLWidget *glWidget = new OpenGLWidget();
layout->addWidget(glWidget);
redSlider->setRange(0, 100);
});
layout->addWidget(redSlider);
};
MainWindow window;
window.show();
return app.exec();
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 25 of 53
:
} CG Lectures Stack
#include "main.moc"
○ Discuss more complex topics like global illumination, path tracing, and photon
mapping.
● Hands-On Project:
Lecture 4:
1. Affine and Coordinate System Transformations
Concepts:
● Affine Transformations: Operations that preserve points, straight lines, and planes.
Examples include translation, scaling, rotation, and shearing.
Examples:
python
Copy code
# Translation matrix in 2D
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 26 of 53
:
| 1 0 dx |
| 0 1 dy |
|00 1|
● Rotation: Rotating a point (x,y)(x, y)(x,y) around the origin by angle θ\thetaθ.
python
Copy code
# Rotation matrix in 2D
| cosθ -sinθ 0 |
| sinθ cosθ 0 |
| 0 0 1|
2. Ray Tracing
Concepts:
● Simulates the way light interacts with objects by tracing the path of rays from the
camera through each pixel and into the scene.
● Calculates intersections with objects and determines the color based on material
properties and lighting.
Example:
python
Copy code
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 27 of 53
:
# Ray: P = O + tD, where O = origin, D = direction, t = distance
● Determines which objects, or parts of objects, are visible from a certain viewpoint.
● Solutions:
○ Depth Buffering: Uses a buffer to keep track of the closest depth value for
each pixel.
○ Painter’s Algorithm: Draws objects from back to front, painting over objects
behind others.
Examples:
● Depth Buffering: Store the depth value of each pixel and update it only if a new
object has a smaller depth (closer to the camera).
● Painter’s Algorithm: Sort objects by depth and render them in order from farthest to
closest.
● Forward Rendering Equation: Calculates the outgoing radiance based on the sum
of emitted and reflected radiance.
● Backward Rendering (Ray Tracing): Starts from the camera and traces rays
backward to the light sources.
Example:
● Forward Rendering:
python
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 28 of 53
:
Copy code
L_o(x, ω_o) = L_e(x, ω_o) + ∫_Ω f_r(x, ω_i, ω_o) L_i(x, ω_i) (n . ω_i) dω_i
where LoL_oLo is outgoing radiance, LeL_eLe is emitted radiance, and frf_rfr is the BRDF.
● Converts triangles into pixel values. Determines which pixels lie inside the triangle
and calculates their color values.
Example:
python
Copy code
Example:
glsl
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 29 of 53
:
Copy code
void main() {
7. Texture Mapping
Concepts:
Examples:
● Trilinear MIP-Mapping: Combines linear interpolation in both the texture and mipmap
levels.
glsl
Copy code
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR_MIPMAP_LINEAR);
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 30 of 53
:
● Data structures like BSP trees, Octrees, and KD-Trees to optimize rendering by
reducing the number of objects to consider for each pixel.
Example:
● Bounding Volume Hierarchy (BVH): Efficiently tests which objects might intersect a
ray.
python
Copy code
class BVHNode:
self.boundingBox = boundingBox
self.left = left
self.right = right
Example:
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 31 of 53
:
● Scene Graphs: Hierarchical structure to manage and render complex scenes. Each
node represents a transformation or object.
Example:
● Scene Graph:
python
Copy code
class Node:
self.transform = transform
self.children = children
Summary
Each of these concepts forms the foundation of computer graphics. Understanding
transformations, rendering equations, rasterization, and the use of shaders is critical for
developing sophisticated graphics applications. Practical application of these techniques
through examples like ray tracing, depth buffering, and texture mapping helps build an intuition
for solving visibility and rendering challenges.
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 32 of 53
:
● Task: Implement a 2D transformation pipeline that allows the user to apply a
sequence of transformations (translation, rotation, and scaling) to a shape (e.g., a
triangle or rectangle) using a graphical interface.
● Requirements:
2. Ray Tracing
● Task: Implement a simple ray tracer that renders a scene with at least one sphere and
one light source. Calculate the color of each pixel based on the intersection of rays with
the sphere and use Phong shading for lighting.
● Requirements:
● Deliverable: A rendered image of the scene and the code used to generate it, along
with a brief explanation of the shading calculations.
● Task: Create a simple 3D scene with multiple overlapping objects (e.g., cubes or
spheres). Implement both the depth buffering technique and the painter’s algorithm to
handle visibility.
● Requirements:
○ Render the scene using the depth buffer to correctly display overlapping
objects.
○ Implement the painter’s algorithm by sorting objects based on their depth and
rendering them back to front.
● Deliverable: Screenshots of the scene rendered with both techniques, along with an
explanation of how each method was implemented.
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 33 of 53
:
4. Rasterization and Shaders
● Task: Implement a basic triangle rasterizer that interpolates vertex colors across the
triangle. Additionally, write a simple fragment shader that applies a lighting effect (e.g.,
diffuse shading) to the triangle.
● Requirements:
○ Create a vertex shader to transform the triangle and a fragment shader for
color interpolation and lighting.
● Deliverable: A screenshot of the rendered triangle with smooth color transitions and
the code for both the rasterizer and shaders.
5. Texture Mapping
● Task: Map a texture image onto a 3D object (e.g., a cube). Implement both nearest-
neighbor and bilinear filtering for texture sampling. Allow the user to switch between
different filtering methods.
● Requirements:
● Deliverable: Screenshots showing the object with both texture filtering methods, and
the code used to implement texture mapping and filtering.
● Requirements:
● Deliverable: Screenshots of the scene with and without SSAA, and a brief
explanation of how anti-aliasing was implemented.
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 34 of 53
:
● Task: Implement a simple 2D scene containing multiple objects and use a spatial data
structure (e.g., QuadTree) to optimize rendering and collision detection.
● Requirements:
○ Use the QuadTree to efficiently detect collisions and only render visible
objects.
● Deliverable: A brief report on how the QuadTree improves performance, along with
code and screenshots demonstrating the optimization.
● Task: Build a simple scene graph that includes a hierarchical structure of nodes
representing a robot arm with rotating joints. Render the scene using a basic graphics
pipeline.
● Requirements:
○ Define a scene graph with nodes for each part of the robot arm.
○ Implement transformations for each node based on user input (e.g., rotate the
arm or move the base).
Submission: Submit your code, along with a document explaining each task, the approach
used, and any challenges you faced. Include screenshots or videos wherever possible to
demonstrate your implementation.
Yes, there are several online platforms and bots that can assist you with OpenGL coding. While
there's no dedicated "OpenGL bot" per se, the following platforms provide tools, compilers, and
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 35 of 53
:
real-time code assistance for OpenGL development:
1. Replit (replit.com)
● Replit is an online IDE that supports OpenGL development. You can write, run, and
debug OpenGL code directly in your browser.
● You can also collaborate in real time, making it easier to share code with others and
get assistance.
2. Add OpenGL libraries (GLEW, GLFW) if needed, and start coding your OpenGL
application.
Visit: https://replit.com
2. GitHub Copilot
● GitHub Copilot is an AI-powered coding assistant that can help you write OpenGL
code by suggesting code snippets, autocompleting lines, and even writing entire
functions based on comments.
● It's available as an extension for IDEs like Visual Studio Code and JetBrains.
3. Start coding OpenGL in C/C++, and Copilot will offer code suggestions based on your
input.
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 36 of 53
:
3. Codingame
● Codingame provides a platform for solving coding challenges, including ones related
to OpenGL or graphics programming. It's more challenge-based, but it offers a fun way
to practice OpenGL logic and algorithms.
Visit: https://www.codingame.com
● You can write and test shader code (like fragment and vertex shaders) in real-time,
view live output, and get community feedback.
Visit: https://www.shadertoy.com
● You can ask specific OpenGL-related questions and get fast responses from the
community.
These platforms and tools can be very helpful when working with OpenGL. You can choose any
of them based on your development environment or specific requirements. Let me know if you
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 37 of 53
:
need help with any specific platform or tool!
Mega Lecture 5
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 38 of 53
:
Importance of Geometric Modeling
1. Intersection Calculation
Real-Life Example:
● Calculating where a ray of light intersects a window surface in ray tracing for realistic
rendering.
Mathematics:
L(t)=P+tDL(t)=P+tD
Where:
N⋅(X−Q)=0N⋅(X−Q)=0
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 39 of 53
:
Where:
Intersection Calculation
● Applications:
Example:
#include <GL/glut.h>
#include <iostream>
void linePlaneIntersection() {
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 40 of 53
:
float linePoint[3] = {1, 2, 3};
float intersection[3] = {
linePoint[0] + t * lineDir[0],
linePoint[1] + t * lineDir[1],
linePoint[2] + t * lineDir[2]
};
cout << "Intersection: (" << intersection[0] << ", " << intersection[1] << ", " <<
intersection[2] << ")" << endl;
2. Proximity Tests
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 41 of 53
:
Real-Life Example:
● Applications:
Mathematics:
d=∣(P−A)×D∣∣D∣d=∣D∣∣(P−A)×D∣
Where:
● PP: Point.
Example:
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 42 of 53
:
void pointLineDistance() {
float cross[3] = {
};
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 43 of 53
:
● Common forms:
○ Linear: y=mx+by = mx + b
● Applications:
1.
Bézier Curves
● Properties:
● Applications:
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 44 of 53
:
Real-Life Example:
Mathematics:
B(t)=∑i=0n(ni)(1−t)n−itiPiB(t)=i=0∑n(in)(1−t)n−itiPi
Example:
void drawBezierCurve() {
glBegin(GL_LINE_STRIP);
glVertex2f(x, y);
glEnd();
2. Spline Curves
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 45 of 53
:
• A spline is a piecewise polynomial function that maintains smoothness at the
joints.
• Types:
o Cubic Splines: Smooth curves with continuous first and second derivatives.
Applications:
Real-Life Example:
Example:
void drawSpline() {
float controlPoints[4][2] = {{-1, -1}, {-0.5, 1}, {0.5, -1}, {1, 1}};
glEnable(GL_MAP1_VERTEX_3);
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 46 of 53
:
glBegin(GL_LINE_STRIP);
glEvalCoord1f((GLfloat)i / 30.0);
glEnd();
1. Bézier Surfaces
● Applications:
● Mathematics:
Real-Life Example:
Example:
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 47 of 53
:
void drawBezierSurface() {
float controlPoints[4][4][3] = {
{{-1, -1, 0}, {-0.5, -1, 0}, {0.5, -1, 0}, {1, -1, 0}},
{{-1, -0.5, 0}, {-0.5, -0.5, 0.5}, {0.5, -0.5, 0.5}, {1, -0.5, 0}},
{{-1, 0.5, 0}, {-0.5, 0.5, 0.5}, {0.5, 0.5, 0.5}, {1, 0.5, 0}},
};
glEnable(GL_MAP2_VERTEX_3);
Spline Surfaces
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 48 of 53
:
● Widely used in 3D modeling and graphics.
Why Approximation?
Bézier Approximation
● Example:
Spline Approximation
● Example:
● Definition
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 49 of 53
:
What is Animation?
Key Concepts
2. Interpolation:
3. Real-Life Examples:
Key Techniques
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 50 of 53
:
Example:
void displayAnimation() {
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glBegin(GL_TRIANGLES);
glVertex2f(-0.5, -0.5);
glVertex2f(0.5, -0.5);
glVertex2f(0.0, 0.5);
glEnd();
glPopMatrix();
glutSwapBuffers();
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 51 of 53
:
}
● Examples:
2. Gaming
4. Robotics
5. Virtual Reality
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 52 of 53
:
● Designing immersive environments with surfaces and animations.
Conclusion
Geometric modeling is the backbone of modern technology, enabling creativity and precision
across industries. Understanding its mathematical and computational principles provides the
tools to innovate in areas like CAD, gaming, animation, and robotics. Encourage students to
experiment with these concepts using OpenGL or other graphical libraries to deepen their
understanding.
● Geometric modeling bridges the gap between mathematical theory and real-world
applications.
● Understanding these techniques is crucial for fields like animation, CAD, and virtual
reality.
● Encourage further exploration of advanced modeling techniques like NURBS and real-
time rendering.
https://docs.google.com/document/u/1/d/1x2B80Az2ekRUJWLTmdmrBCAy8i-uadwWMZMv8J_IPmA/mobilebasic 6/1/25, 19 58
Page 53 of 53
: