You are on page 1of 19

Chapter Two

Introduction to The Rendering Process with OpenGL

1 Prepared By Haftom B. 10/31/2022


Chapter Contents
 The Role of OpenGL in the Reference Model
 Coordinate Systems
 Viewing Using a Synthetic Camera
 Output Primitives and Attributes

2 Prepared By Haftom B. 10/31/2022


2.1. OpenGL (Open Graphics Library)
 OpenGL (Open Graphics Library) is the computer industry's standard
application program interface ( API ) for defining 2-D and 3-D graphic
images.
 Most widely adopted graphics API
Easy to use, well documented
 Cross platform and cross language
 Everything is primitive (can accept only simple shapes and sizes)
 Largely built on C but can be used in most programming languages

3
Cont...
Why OpenGL?
 Device independence
 Platform independence
o SGI Irix, MAC, Linux, Windows

 Abstractions (GL, GLU, GLUT)


Open source: Hardware-independent software interface
 Support of client-server protocol Other APIs

4 Prepared By Haftom B. 10/31/2022


Features of OpenGL
 3D Transformations
 Rotations, scaleing, translation, perspective
 Color models
 Values: R, G, B, alpha.
 Lightning
 Flat shading, Gouraud shading, Phong shading
 Rendering
 Texture mapping
 Modeling
 non-uniform rational B-spline (NURB) curves, surfaces
5
Cont..
 OpenGL: the core library, it is platform (i.e. hardware system)
independent,
 glut:
 The GL Utilities Toolkit, it contains some extra routines for drawing 3-D
objects and other primitives. Using glut with OpenGL enables us to write
windows-system independent code.
 glu:
 TheOpenGL Utilities, it contains some extra routines for projections and
rendering complex 3-D objects.
 glui: Contains some extra routines for creating user-interfaces.
6
2.2 Coordinate Systems
 In graphics program, we may need to deal with a number of different
coordinate systems, and a good part of the work ( and the cause of many
headaches ) is the conversion of coordinates from one system to another.

 Here is a list of some of the coordinate systems you may encounter:

 World Coordinate System - Also known as the "universe" or sometimes


"model" coordinate system.
 This is the base reference system for the overall model, ( generally in 3D ), to
which all other model coordinates relate.

7 Prepared By Haftom B. 10/31/2022


Cont..
• Object Coordinate System - When each object is created in a modelling
program, the modeler must pick some point to be the origin of that
particular object, and the orientation of the object to a set of model axes.
• For example when modelling a desk, the modeler might choose a point in the
center of the desk top for the origin, or the point in the center of the desk at floor
level, or the bottom of one of the legs of the desk.
• When this object is moved to a point in the world coordinate system, it is really
the origin of the object ( in object coordinate system ) that is moved to the new
world coordinates, and all other points in the model are moved by an equal
amount. Note that while the origin of the object model is usually somewhere on
the model itself, it does not have to be

8 Prepared By Haftom B. 10/31/2022


Cont.…
• Viewpoint Coordinate System - Also known as the "camera" coordinate
system.
• This coordinate system is based upon the viewpoint of the observer, and changes
as they change their view.
• Moving an object "forward" in this coordinate system moves it along the
direction that the viewer happens to be looking at the time.
• Model Window Coordinate System - Not to be confused with desktop
windowing systems ( MS Windows or X Windows ), this coordinate
system refers to the subset of the overall model world that is to be
displayed on the screen.
• Depending on the viewing parameters selected, the model window may
be rectalinear or a distorted viewing frustrum of some kind.

9 Prepared By Haftom B. 10/31/2022


Cont.…
• Screen Coordinate System - This 2D coordinate system refers to the
physical coordinates of the pixels on the computer screen, based on
current screen resolution. ( E.g. 1024x768 )

• Viewport Coordinate System - This coordinate system refers to a subset of


the screen space where the model window is to be displayed.

• Typically the viewport will occupy the entire screen window, or even the entire
screen, but it is also possible to set up multiple smaller viewports within a single
screen window.

10 Prepared By Haftom B. 10/31/2022


11 Prepared By Haftom B. 10/31/2022
12 Prepared By Haftom B. 10/31/2022
Viewing Using a Synthetic Camera
 synthetic camera A type of rendering technique that seeks to replicate the
characteristics of a real camera or the human eye, rather than the perfectly
sharp neutral pictures usually produced by computer graphics.

 Graphics generated images may not be visible to camera or human eye (may
have hidden parts)

13 Prepared By Haftom B. 10/31/2022


Other Description
 Imagine you are taking a picture with your camera
 Objects in the room may be best described in a local coordinate
system unique to each object
 They also have position and orientation in the world
 Your camera also has a position and orientation, which determines
where it is looking.
 our camera has settings, such as size, field of view, and resolution,
which help define how the final picture is rendered

14 Prepared By Haftom B. 10/31/2022


Cont.….
 The synthetic camera model used in computer graphics mimics this
process, using transformations between different coordinate systems to
render an image.
 These transformations are implemented using matrices.

15 Prepared By Haftom B. 10/31/2022


2.4 Output Primitives and Attributes
 The inputs to the Graphics Rendering Pipeline are
geometric primitives such as
 Triangle,
 Point,
 Line
 Quad which is formed by one or more vertices.
 OpenGL supports three classes of geometric primitives:
 points, line segments, and closed polygons.
 They are specified via vertices.

16 Prepared By Haftom B. 10/31/2022


Cont..
 Each vertex is associated with its attributes such as the position,
color, normal and texture.
 OpenGL provides 10 primitives as shown in the next Slide.
 Sphere, 3D box and pyramid are not primitives.
 They are typically assembled using primitive triangle or quad.

17 Prepared By Haftom B. 10/31/2022


18 Prepared By Haftom B. 10/31/2022
19 Prepared By Haftom B. 10/31/2022

You might also like