0% found this document useful (0 votes)
5 views49 pages

ETI 5104 - Lecture 3 - Graphics Software

The document provides an overview of computer graphics software, detailing its types including raster, vector, 3D, CAD, simulation, and real-time graphics software, along with their applications and examples. It also discusses the graphics rendering pipeline, essential algorithms, and the history and architecture of OpenGL, a widely-used graphics API. Additionally, it covers basic OpenGL syntax, functions, and attributes, as well as practical programming examples and compilation instructions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views49 pages

ETI 5104 - Lecture 3 - Graphics Software

The document provides an overview of computer graphics software, detailing its types including raster, vector, 3D, CAD, simulation, and real-time graphics software, along with their applications and examples. It also discusses the graphics rendering pipeline, essential algorithms, and the history and architecture of OpenGL, a widely-used graphics API. Additionally, it covers basic OpenGL syntax, functions, and attributes, as well as practical programming examples and compilation instructions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 49

Computer Graphics Software

Introduction to Graphics Software


◼ What is Computer Graphics Software?
◼ Programs used to create and manipulate digital images and

animations.
◼ Importance in Design, Simulation, and Communication:
◼ Design: Graphic software is used to create visual representations of

systems, components, and concepts, which aid in conceptualization


and prototyping.
◼ Simulation: Used in telecommunications for simulating network

behaviour, signal propagation, and error analysis.


◼ Communication: Visualization tools allow engineers and scientists

to communicate complex ideas effectively.


◼ Real-Life Analogy: Graphics Software = Digital Toolbox: Just like an
architect uses a variety of tools to draw blueprints, an engineer uses
graphics software to draft, simulate, and visualize designs.
Types of Computer Graphics Software
1. Raster Graphics Software
◼ Deals with images made of pixels. Each pixel is a tiny dot of
colour, and together they form an image.
◼ Examples:
◼ Adobe Photoshop – A professional tool for editing

photographs and creating raster-based graphics.


◼ GIMP – A free, open-source alternative to Photoshop.

◼ Applications: Image editing, digital photography, and textures in


animation and gaming.
◼ Real-Life Analogy: Imagine a mosaic made up of tiny coloured
tiles. Each tile corresponds to a pixel, and when combined, they
create the complete image.
Types of Computer Graphics Software
2. Vector Graphics Software
◼ Uses mathematical equations to create shapes like lines, curves, and
polygons. Unlike raster images, vector graphics are resolution-
independent.
◼ Examples:
◼ Adobe Illustrator – Used for creating logos, diagrams, and

illustrations.
◼ CorelDRAW – Another vector graphics editor used in design and

marketing.
◼ Applications: Logo design, UI design, and any graphic that needs to
be scaled without losing quality.
◼ Real-Life Analogy: A vector image is like a blueprint for a building. The
blueprint contains precise instructions on how to create the design, and
you can scale it up or down without losing detail.
Types of Computer Graphics Software
3. 3D Graphics Software
◼ Software designed to create 3D models and animations. They allow
manipulation of three-dimensional objects in a virtual environment.
◼ Examples:
◼ Blender – Open-source software for 3D modeling, animation, and

rendering.
◼ Autodesk Maya – Industry-standard software for creating 3D models

and animations in films and games.


◼ 3ds Max – Similar to Maya, but more focused on modeling and

rendering for engineering and architectural design.


◼ Applications: Animation, simulations, gaming, and product design.
◼ Real-Life Analogy: Think of 3D graphics software as a sculptor
shaping a clay model. Instead of chiseling away at physical material,
the software allows you to manipulate the model virtually.
Types of Computer Graphics Software
4. CAD (Computer-Aided Design) Software
◼ Used for creating 2D and 3D models, especially in engineering,
architecture, and product design.
◼ Examples:
◼ AutoCAD – A comprehensive tool used by engineers for drafting

2D and 3D designs.
◼ SolidWorks – Primarily used for 3D modeling in product design,

especially in mechanical engineering.


◼ Applications: Network design, product design, circuit boards,
architectural drawings and infrastructure planning.
◼ Real-Life Analogy: CAD software is like a digital drafting table.
Engineers use it to create detailed blueprints and prototypes of
physical structures or systems.
Types of Computer Graphics Software
5. Simulation Software
◼ Software used for simulating real-world systems, behaviours, or
phenomena, often with a focus on engineering or
telecommunications.
◼ Examples:
◼ MATLAB – Used for numerical computing and simulation,

especially in telecom signal processing.


◼ Simulink – Works in tandem with MATLAB to simulate dynamic

systems and networks.


◼ NS3 – A network simulator used to simulate communication

networks (especially useful in telecom).


◼ Applications: Network simulation, signal processing, fluid dynamics,
telecommunications system modeling.
Types of Computer Graphics Software
6. Real-Time Graphics Software (e.g., OpenGL, DirectX)
◼ These are APIs (Application Programming Interfaces) used to
render graphics in real-time applications such as video games or
simulations.
◼ Examples:
◼ OpenGL – Open-source API for rendering 2D and 3D

graphics.
◼ DirectX – A Microsoft API for handling multimedia tasks,

including real-time graphics rendering.


◼ Applications: Video games, virtual reality, real-time simulations.
◼ Real-Life Analogy: OpenGL and DirectX are like the engines of
a car. Without the engine, you can't move the vehicle (or render
graphics in real-time).
Graphics Software in Telecom
1. Network Design and Simulation
◼ Using AutoCAD to design fiber optic cable layouts or signal distribution
networks.
2. Telecom System Visualization
◼ 3D modeling software and simulation tools are used to visualize
telecom systems and infrastructure. E.g. Visualizing cellular tower
coverage or simulating network congestion.
3. Signal Propagation and Interference Visualization
◼ Blender or MATLAB can be used to simulate how signals propagate in

different environments, visualizing signal strength and interference.


4. Real-Time Communication Simulation
◼ Real-time simulation tools like NS3 or MATLAB are critical in testing

how telecom systems perform under various real-world conditions.


Graphics Rendering Pipeline
◼ Rendering: conversion from scene to image

◼ Scene is represented as a model composed of primitives.


Model is generated by a program or input by a user.
◼ Image is drawn on an output device: monitor, printer,
memory, file, video frame. Device independence.
◼ Typically rendering process is divided into steps called the
graphics pipeline.
Graphics Rendering Pipeline
◼ Cartesian reference frames used in constructing and
displaying a scene
◼ Modeling / local / master coordinates (MCS) used to define
the shapes of individual objects, such as trees or furniture
◼ A Scene is constructed by placing the objects into appropriate
locations within a scene reference frame called world
coordinates (WCS)
◼ The overall WC description is processed through various
routines onto one or more output-device reference frames for
display in a process called the viewing pipeline
◼ WC positions are first converted to viewing coordinates
corresponding to the view we want of a scene, based on the
position and orientation of a hypothetical camera.
Graphics Rendering Pipeline
◼ Then object locations are transformed to a two-dimensional
(2D) projection of the scene, which corresponds to what we
will see on the output device.
◼ The scene is then stored in normalized coordinates /
normalized device coordinates, where each coordinate
value is in the range from −1 to 1 or 0 to 1, depending on the
system
◼ Visible surfaces are identified and picture parts outside the
bounds for the view are eliminated.
◼ The picture is scan-converted into the refresh buffer of a
raster system for display. The coordinate systems for display
devices are generally called device coordinates, or screen
coordinates in the case of a video monitor.
Forward projection pipeline
Algorithms
◼ A number of basic algorithms are needed:
◼ Transformation: Convert representations of models/primitives
from one coordinate system to another
◼ Clipping/Hidden surface removal: remove primitives and part of
primitives that are not visible on the display
◼ Rasterization: Convert a projected screen space primitive to a set
of pixels.
◼ Picking: select a 3D object by clicking an input device over a
pixel location.
◼ Shading and illumination: Simulate the interaction of light with a
scene.
◼ Animation: Simulate movement by rendering a sequence of
frames.
Early History of APIs
◼ The primary goal of standardized graphics
software is portability
◼ The first graphics API was
◼ Graphical Kernel System (GKS)
◼ 2D but contained good workstation model
◼ GKS adopted as IS0 and later ANSI standard
(1984)
◼ GKS not easily extended to 3D (GKS-3D)
◼ Far behind hardware development
PHIGS and X
◼ Programmers Hierarchical Graphics System
(PHIGS)
◼ Arose from CAD community in 1988
◼ Database model with retained graphics (structures)
◼ X Window System
◼ DEC/MIT effort
◼ Client-server architecture with graphics
◼ PEX combined the two
◼ Not easy to use (all the defects of each)
◼ Phigs+, GL, OpenGL, Direct3D: 3D pipeline
OpenGL
◼ Silicon Graphics, Inc. (SGI) developed graphics
workstations with a set of routines called GL (Graphics
Library),
◼ The success of GL lead to OpenGL (1992), a platform-
independent API that was
◼ Easy to use

◼ Close enough to the hardware to get excellent

performance
◼ Focus on rendering

◼ Omitted windowing and input to avoid window

system dependencies
◼ Alternative to OpenGL: Vulkan
OpenGL Libraries
◼ OpenGL core library
◼ OpenGL32 on Windows
◼ GL on most unix/linux systems (libGL.a)
◼ OpenGL Utility Library (GLU)
◼ Provides functionality in OpenGL core but avoids
having to rewrite code
◼ Links with window system
◼ GLX for X window systems
◼ WGL for Windows
◼ AGL for Macintosh
Basic OpenGL Syntax
◼ Function names are prefixed with gl for core
library, glu for GLU, glut for GLUT library
◼ glBegin, glClear, gluOrtho2D,glutInit
◼ Constants
◼ GL_2D, GL_RGB, GLUT_SINGLE
◼ Data types
◼ GLbyte, GLshort, GLint, GLfloat, GLdouble
GLUT
◼ OpenGL Utility Toolkit (GLUT)
◼ Provides functionality common to all window
systems
◼ Open a window
◼ Get input from mouse and keyboard
◼ Menus
◼ Event-driven
◼ Code is portable but GLUT lacks the functionality
of a good toolkit for a specific platform
◼ No slide bars
OpenGL Architecture

Immediate Mode geometry


pipeline
Per Vertex
Polynomial Operations &
Evaluator Primitive
Assembly

Display Per Fragment Frame


CPU List
Rasterization
Operations Buffer

Texture
Memory
Pixel
Operations
OpenGL Functions
◼ Primitives
◼ Points
◼ Line Segments
◼ Polygons
◼ Attributes
◼ Transformations
◼ Viewing
◼ Modeling
◼ Control (GLUT)
◼ Input (GLUT)
◼ Query
OpenGL State

◼ OpenGL is a state machine


◼ OpenGL functions are of two types
◼ Primitive generating
◼ Can cause output if primitive is visible
◼ How vertices are processed and appearance of
primitive are controlled by the state
◼ State changing
◼ Transformation functions
◼ Attribute functions
Lack of Object Orientation

◼ OpenGL is not object oriented so that there


are multiple functions for a given logical
function
◼ glVertex3f
◼ glVertex2i
◼ glVertex3dv
◼ Underlying storage mode is the same
◼ Easy to create overloaded functions in C++
but issue is efficiency
OpenGL function format

function name
dimensions

glVertex3f(x,y,z)

x,y,z are floats


belongs to GL library

glVertex3fv(p)

p is a pointer to an array
OpenGL Command Formats

glVertex3fv( v )

Number of Data Type Vector


components b - byte
ub - unsigned byte omit “v” for
2 - (x,y)
3 - (x,y,z)
s - short scalar form
us - unsigned short
4 - (x,y,z,w)
i - int
ui - unsigned int glVertex2f( x, y )
f - float
d - double
OpenGL #defines

◼ Most constants are defined in the include


files gl.h, glu.h and glut.h
◼ Note #include <GL/glut.h> should
automatically include the others
◼ Examples
◼ glBegin(GL_POLYGON)
◼ glClear(GL_COLOR_BUFFER_BIT)
◼ include files also define OpenGL data
types: GLfloat, GLdouble,….
A Simple Program

Generate a square on a solid background


simple.c
#include <GL/glut.h>
void mydisplay(){
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON);
glVertex2f(-0.5, -0.5);
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, 0.5);
glVertex2f(0.5, -0.5);
glEnd();
glFlush();
}
int main(int argc, char** argv){
glutCreateWindow("simple");
glutDisplayFunc(mydisplay);
glutMainLoop();
}
Event Loop
◼ Note that the program defines a display
callback function named mydisplay
◼ Every glut program must have a display callback
◼ The display callback is executed whenever
OpenGL decides the display must be refreshed,
for example when the window is opened
◼ The main function ends with the program
entering an event loop
Compilation on Windows
◼ Visual C++
◼ Get glut.h, glut32.lib and glut32.dll from web
◼ Create a console application
◼ Add opengl32.lib, glut32.lib to project settings
(under link tab)
◼ Borland C similar
◼ Cygwin (linux under Windows)
◼ Can use gcc and similar makefile to linux
◼ Use –lopengl32 –lglu32 –lglut32 flags
Polygon Issues
◼ OpenGL will only display polygons correctly that are
◼ Simple: edges cannot cross
◼ Convex: All points on line segment between two points in a
polygon are also in the polygon
◼ Flat: all vertices are in the same plane
◼ User program can check if above true
◼ OpenGL will produce output if these conditions are violated but it
may not be what is desired
◼ Triangles satisfy all conditions

nonconvex polygon
nonsimple polygon
Attributes
◼ Attributes are part of the OpenGL state and
determine the appearance of objects
◼ Color (points, lines, polygons)
◼ Size and width (points, lines)
◼ Stipple pattern (lines, polygons)
◼ Polygon mode
◼ Display as filled: solid color or stipple pattern
◼ Display edges
◼ Display vertices
RGB color
◼ Each color component is stored separately in the
frame buffer
◼ Usually 8 bits per component in buffer
◼ Note in glColor3f the color values range from 0.0
(none) to 1.0 (all), whereas in glColor3ub the
values range from 0 to 255
Color and State
◼ The color as set by glColor becomes part of the
state and will be used until changed
◼ Colors and other attributes are not part of the
object but are assigned when the object is
rendered
◼ We can create conceptual vertex colors by code such
as
glColor
glVertex
glColor
glVertex
Viewports
◼ Do not have to use the entire window for
the image: glViewport(x,y,w,h)
◼ Values in pixels (screen coordinates)
Geometric Primitive Types
Header files
• #include <windows.h>
• #include <GL/gl.h>
• #include <GL/glu.h>

With GLUT we don’t need glu.h and gl.h


• #include <GL/glut.h>

• Include header files for the C++ program


• #include <stdio.h>

• #include <stdlib.h>
• #include <math.h>
DISPLAY WINDOW MANAGEMENT USING
GLUT

◼ To initialize glut------glutInit(&argc, argv)


◼ Window caption----glutCreateWindow("My
first opengl program")
◼ To specify what the display window will
contain you can use a method for example “
line_segment”
◼ Use glutDisplayFunc(line_segment) to call the
method in the main program
COMPLETE THE OPERATIONS
• To complete the processing operations, use the
following function------glutMainLoop()---the very
last function of the program.
• Initial image position----
glutInitWindowposition(100,200)
• Initial window size-----
glutInitWindowSize(200,300)
• Other window options like buffering and choice
of color modes
• glutDisplayMode(GLUT_SINGLE|GLUT_RGB)
A complete OpenGL program
◼ Set background colour ---
glClearColor(1.0,1.0,1.0,1.0)

◼ Putting the display window on the screen


use---glClear(GL_COLOR_BUFFER_BIT)

◼ Choosing colour schemes for objects---


glColor3f(1.0,0.0,0.0)
CONT…

◼ If we want to display 2D object, we tell the


OpenGL how we want to project our picture
onto the display window as generating 2D is
a special case of 3D viewing

◼ glMatrixMode(GL_PROJECTION)

◼ gluOrtho2D(0.0,200.0,0.0,150.0)
IMPLEMENTATION

◼ // Include Header files


◼ #include<windows.h>
◼ #include<GL/glut.h>
◼ #include<stdio.h>
◼ #include <stdlib.h>
◼ #include <math.h>
/*Initial set up */

◼ void init (void)


◼ {
◼ glClearColor (1.0, 1.0, 1.0, 0.0); // Set
display-//window color to white.
◼ glMatrixMode (GL_PROJECTION); // Set
//projection parameters.
◼ gluOrtho2D (0.0, 200.0, 0.0, 150.0);
◼ }
/*Creating a line*/
• void lineSegment (void)
• {
• glClear (GL_COLOR_BUFFER_BIT); // Clear display
window.
• glColor3f (1.0, 0.0, 0.0); // Set line segment color to
red.
• glBegin (GL_LINES);
• glVertex2i (180, 15); // Specify line-segment geometry.
• glVertex2i (10, 145);
• glEnd ( );
• glFlush ( ); // Process all OpenGL routines as quickly
as possible.
• }
/*The main function*/
• void main (int argc, char** argv)
• {
• glutInit (&argc, argv); // Initialize GLUT.
• glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); // Set
display mode.
• glutInitWindowPosition (50, 100); // Set top-left display-
window position.
• glutInitWindowSize (400, 300); // Set display-window width
and height.
• glutCreateWindow ("An Example OpenGL Program"); //
Create display window.
• init ( ); // Execute initialization procedure.
• glutDisplayFunc (lineSegment); // Send graphics to display
window.
• glutMainLoop ( ); // Display everything and wait.
• }
/*More procedures*/
• void line_segment(void)
• {
• glClear(GL_COLOR_BUFFER_BIT);
• glColor3f(0.0,0.0,1.0);
• glBegin(GL_LINE_STRIP);
• glVertex2i(180,15);
• glVertex2i(10,145);
• glVertex2i(100,15);
• glVertex2i(10,185);
• glEnd();
• glFlush();
• }
Cont…
• void line_segment(void)
• {
• glClear(GL_COLOR_BUFFER_BIT);
• glColor3f(0.0,0.0,1.0);
• glBegin(GL_LINE_LOOP);
• glVertex2i(180,15);
• glVertex2i(10,145);
• glVertex2i(100,15);
• glVertex2i(10,185);
• glEnd();
• glFlush();
• }
OpenGL Example
◼ Here’s an example that renders a colored triangle (Note
that this doesn’t include any ‘setup’ code)

glBegin(GL_TRIANGLES);
glColor3f(1.0, 0.0, 0.0); // red
glVertex3f(-4.0, -2.0, 0.0);
glColor3f(0.0, 1.0, 0.0); // green
glVertex3f(4.0, -2.0, 0.0);
glColor3f(0.0, 0.0, 1.0); // blue
glVertex3f(0.0, 5.0, 0.0);
glEnd();

You might also like