10 Introduction To Opengl

Computer Graphics · Unit 10 · 3 hrs

Introduction to OpenGL

Exam-focused notes for Introduction to OpenGL (Computer Graphics, CSC214): what the TU syllabus asks and how it has actually been tested, with 4 solved past questions from this unit.

Introduction to OpenGL in short

This final chapter moves from the theory of the earlier chapters to a concrete graphics API: OpenGL, the industry-standard library used to actually issue the drawing, colour and lighting commands a graphics program needs.

Introduction to OpenGL: notes

Introduction, Callback functions, Color commands, Drawings pixels, lines, polygons using OpenGL, Viewing and Lighting

OpenGL ("Open Graphics Library") is a software interface, an application programming interface (API), that lets a program communicate with the underlying graphics hardware to render 2D and 3D graphics, without the program having to know the details of any particular graphics card. It exposes a common set of commands, drawing polygons, assigning colours, moving and rotating objects, zooming, that work the same way across different applications and different hardware platforms. OpenGL itself is a fairly low-level, procedural library; the OpenGL Utility Toolkit (GLUT) sits on top of it to simplify window management and to provide ready-made complex shapes such as a sphere, a torus, and the well-known teapot, so a program does not need to build every 3D primitive from individual vertices.

Several factors explain why OpenGL became the standard: it was the first graphics API designed to be vendor-independent, working the same way regardless of which company made the graphics card; it is free to use, with no licensing cost; it is designed to offload work onto the graphics card itself wherever possible, for performance; and, being based on a state-machine, procedural model rather than tied to any one language's object system, it can be, and has been, bound to a wide variety of programming languages including C, C++ and Java.

What this unit covers

  • Introduction, Callback functions, Color commands, Drawings pixels, lines, polygons using OpenGL, Viewing and Lighting

Introduction, Callback functions, Color commands, Drawings pixels, lines, polygons using OpenGL, Viewing and Lighting

2081 · 5 marks

Explain any two functions in OpenGL. Write the basic commands to draw the pixel and polygon in OpenGL. [5]

These are fundamental OpenGL functions used to delimit the vertices of a primitive or group of primitives. - glBegin(mode) marks the start of a vertex list for a geometric primitive. - glEnd() marks the end of the vertex list. The mode parameter specifies what kind of primitive to draw. Common mo...

Open this answer on its own page →

2080 · 5 marks

Write short notes on a. OpenGL b. Flynn's Classification [5]

Show solved answer

Short Notes


a. OpenGL (2.5 marks)

OpenGL (Open Graphics Library) is a software interface (API) that allows a programmer to communicate with graphics hardware for rendering 2D and 3D graphics. It provides a common set of commands that can be used to manage graphics across different applications and multiple platforms.

Key Features:

  • Vendor-independent: It was the first vendor-independent API for development of graphics applications.
  • Free to use: There is no need to license it.
  • Hardware accelerated: Designed to use the graphics card where possible to improve performance.
  • Language flexible: Originally based on a state machine, procedural model; thus it can be used with a wide variety of programming languages.

Common OpenGL Commands:

  • Drawing polygons
  • Assigning colors to shapes
  • Zooming in and out
  • Rotating objects

Color Models:

OpenGL supports two color models:

  1. RGBA mode - color specified by Red, Green, Blue intensities and an optional Alpha (transparency) value. Values range from 0.0 (absent) to 1.0 (saturated).
  2. Color Index mode

GLUT (OpenGL Utility Toolkit):

GLUT aids in the development of more complicated 3D objects such as a sphere, a torus, and a teapot. It uses callback functions - functions that the GLUT library calls when it needs to process an event (e.g., glutKeyboardFunc for key press events).


b. Flynn's Classification (2.5 marks)

Flynn's Classification (proposed by Michael J. Flynn, 1966) classifies computer architectures based on the number of concurrent instruction streams and data streams.

CategoryFull FormDescription
SISDSingle Instruction, Single DataOne instruction stream operates on one data stream. Traditional uniprocessor (von Neumann).
SIMDSingle Instruction, Multiple DataOne instruction stream operates on multiple data streams simultaneously. Used in vector processors and GPUs.
MISDMultiple Instruction, Single DataMultiple instruction streams operate on a single data stream. Rare in practice; used in fault-tolerant systems.
MIMDMultiple Instruction, Multiple DataMultiple instruction streams operate on multiple data streams. Used in multiprocessors and distributed systems.

Diagram:

                    Data Streams
                  Single    Multiple
Instruction  Single | SISD  |  SIMD |
Streams     Multiple| MISD  |  MIMD |

Summary:

  • SISD - conventional computers
  • SIMD - parallel array processors
  • MISD - pipeline processors (debated)
  • MIMD - modern multicore and distributed systems (most common today)

Flynn's classification is widely used as a fundamental framework for understanding and comparing parallel computer architectures.

Open this answer on its own page →

2077 · 5 marks

Write a procedure to draw a line in OpenGL? Describe Painter’s algorithm. [5]

--- In OpenGL, the term line refers to a line segment. Lines are specified in terms of the vertices at their endpoints. OpenGL also supports connected series of line segments and closed connected series of segments. Primitive Description ------ GLLINES Each pair of vertices defines an independent...

Open this answer on its own page →

2075 · 5 marks

Give some basic color model. Give the basic command to draw the pixel and polygon in OpenGL. [5]

Color models are mathematical systems for describing colors using numerical values. The basic color models are: - An additive color model used in display devices (monitors, screens). - Colors are formed by combining red, green, and blue light. - Each component ranges from 0 to 1 (or 0 to 255). - ...

Open this answer on its own page →