Pipeline
Pipeline
Pipeline
Lecture 3
Graphics Pipeline
Graphics Pipeline
Primitives: Points, Lines, Triangles
[Angel Ch. 2]
Abdullah Alfarrarjeh
German Jordanian University
1
Graphics Pipeline
2
The Framebuffer
• Special memory on the graphics card
4
The pipeline is implemented by
OpenGL, graphics driver and
the graphics hardware
6
Vertices (compatibility profile)
8
Transformer (compatibility profile)
9
Transformer (core profile)
10
Clipper
11
Projector
12
Projector
• In the perspective view (the default), objects which are far away are smaller than
13
those nearby.
• In the orthographic view, all objects appear at the same scale.
Rasterizer
14
Geometric Primitives
• Suppose we have 8 vertices:
p0, p1, p2, p3, p4, p5, p6, p7
16
Example: Draw Two Square Edges
(compatibility profile)
(0,1) (1,1)
• Type = GL_LINES
glBegin(GL_LINES);
glVertex3f(0.0, 0.0, -1.0);
glVertex3f(1.0, 0.0, -1.0);
glVertex3f(1.0, 1.0, -1.0);
(0,0) (1,0)
glVertex3f(0.0, 1.0, -1.0);
glEnd();
• Calls to other functions are allowed between
glBegin(type) and glEnd();
17
Geometric Primitives
(core profile)
• Specified via vertices
• Stored in a Vertex Buffer Object
(VBO)
int numVertices = 300;
float vertices[3 * numVertices];
19
Render Points and Line Segments
(core profile)
20
Main difference between the two profiles
Compatibility: Core:
Initialization:
int numVertices = 300;
float vertices[3 * numVertices];
Rendering:
glDrawArrays(type, 0, numVertices);
22
Common Bug
What is wrong?
23
Common Bug
int numVertices = 50000;
float * vertices = (float*) malloc (sizeof(float) * 3 * numVertices);
…
glBufferData(GL_ARRAY_BUFFER,
sizeof(vertices), vertices, GL_STATIC_DRAW);
glBufferData(GL_ARRAY_BUFFER,
sizeof(float) * 3 * numVertices, vertices, GL_STATIC_DRAW);
24
Polygons
• Polygons enclose an area
26
Summary
1. Graphics pipeline
2. Primitives: vertices, lines, triangles
27