CGPresentation Week2 (API, GPU&OpenGLInstallation)
CGPresentation Week2 (API, GPU&OpenGLInstallation)
Week-2
• Discrete GPU:
• A discrete GPU is a dedicated graphics card, which is completely separate from the CPU. The
graphics card have their own RAM to store image data.
Graphic AcPI
What is a graphic API?
• A graphic API is a collection of documented libraries and commands
that communicate with the computer hardware in creating 2D and
3D applications
• Graphics API is a type of API that tells graphics hardware how to draw
something on the screen.
What are the most efficient graphics APIs?
• There are only two graphics API with widespread support:
Microsoft's DirectX and ARB's OpenGL. For PC gaming, DirectX was
typically used as Windows dominated the personal computer market
• Apply configurations.
Installation of OpenGL in Visual Studio
• Select Tools option from the menu bar.
• Select
NuGet Package Manager > Package Manager Console
glVertex2f(-0.5f, -0.5f); // x, y
glVertex2f(0.5f, -0.5f);
glVertex2f(0.5f, 0.5f);
glVertex2f(-0.5f, 0.5f);
glEnd();
1 2 3
1. Application
• The application step is executed by the software on the main processor (CPU).
• In the application step, changes are made to the scene as required, for example,
by user interaction by means of input devices or during an animation.
a. Camera Transformation
• In addition to the objects, the scene also
defines a virtual camera or viewer that
indicates the position and direction of view
relative to which the scene is rendered.
• The scene is transformed so that the camera
is at the origin looking along the Z axis.
• The resulting coordinate system is called the
camera coordinate system and the
transformation is called camera • Left: Position and direction of the virtual viewer (camera),
transformation or View Transformation. as defined by the user. Right: Positioning the objects after
the camera transformation. The light gray area is the
visible volume.
2. Geometry
b. Lighting
• Often a scene contains light sources placed at different positions to
make the lighting of the objects appear more realistic.
• A general lighting is applied to all surfaces.
• It is the diffuse and thus direction-independent brightness of the scene.
• The sun is a directed light source, which can be assumed to be
infinitely far away.
2. Geometry
c. Projection
• The 3D projection step transforms the view volume into a cube with the
corner point coordinates (-1, -1, 0) and (1, 1, 1); Occasionally other target
volumes are also used.
• This step is called projection, even though it transforms a volume into
another volume, since the resulting Z coordinates are not stored in the
image, but are only used in Z-buffering in the later rastering step.
• To limit the number of displayed objects, two additional clipping planes are
used; The visual volume is therefore a truncated pyramid (frustum).
• The parallel or orthogonal projection is used, for example, for technical
representations because it has the advantage that all parallels in the object
space are also parallel in the image space, and the surfaces and volumes are
the same size regardless of the distance from the viewer.
• Maps use, for example, an orthogonal projection (so-called orthophoto), but
oblique images of a landscape cannot be used in this way - although they frustum
can technically be rendered, they seem so distorted that we cannot make any
use of them.
2. Geometry
What is Z-buffering in Projection?
• A depth buffer, also known as a z-buffer, is a type of data
buffer used in computer graphics to represent depth information of
objects in 3D space from a particular perspective.
• Depth buffers are an aid to rendering a scene to ensure that the
correct polygons properly occlude other polygons.
• Z-buffering was first described in 1974 by Wolfgang Straßer in his
PhD thesis on fast algorithms for rendering occluded objects.
2. Geometry
d. Clipping
• Any procedure that identifies those portions of a picture that are
either inside or outside of a specified region of space is referred to as
a clipping algorithm (or simply clipping)
• Everything outside the window is discarded
• Clipping algorithms can be applied in world co-ordinates, so that only
the contents of the window interior are mapped to device co-
ordinates
• Alternately, the complete world co-ordinate picture can be mapped
first to device co-ordinates, then clipped against the viewport
2. Geometry
d. Clipping
• World co-ordinate clipping removes those primitives outside the
window from further consideration, thus eliminating the processing
necessary to transform those primitives to device space.
• Viewport clipping ,can reduce calculations by allowing concatenation
of viewing and geometric transformation matrices.
• But viewport clipping does require that the transformation to device
co-ordinates be performed for all objects, including those outside the
window.
2. Geometry
Clipping Example: Line Clipping
• Line clipping against rectangles
(x1, y1)
ymax
(x0, y0)
ymin
xmin xmax
The problem: Given a set of 2D lines or polygons and a window, clip the lines or polygons to their
regions that are inside the window.
Clipping is tricky!
In: 3 vertices
Clip
Out: 6 vertices
e. Window-Viewport transformation
• In order to output the image to any target
area (viewport) of the screen, another
transformation, the Window-Viewport
transformation, must be applied.
• This is a shift, followed by scaling.
• The resulting coordinates are the device
coordinates of the output device.
• The viewport contains 6 values: height and
width of the window in pixels, the upper
left corner of the window in window
coordinates (usually 0, 0) and the minimum
and maximum values for Z (usually 0 and
1).
3. Rasterization
• Raster Images
• These are the types of images that
are produced when scanning or
photographing an object.
• Raster images are compiled using
pixels, or tiny dots, containing unique
color and tonal information that come
together to create the image.
• Since raster images are pixel based,
they are resolution dependent.
3. Rasterization
• What is Rasterization using top
left rule?
• its center lies completely inside
the triangle.
• its center lies exactly on the
triangle edge (or multiple edges
in case of corners) that is (or, in
case of corners, all are)
either top or left edge.
THANKYOU