---
title: "What is OpenGL and why needed"
subject: "Computer Graphics"
chapter: 9
key: "semester_5/computer_graphics:what-is-opengl-why-required"
source: https://www.bctengineer.com/q/semester_5/computer_graphics/what-is-opengl-why-required
site: BCT Engineering
---

# What is OpenGL and why needed

Computer Graphics · Chapter 9: Introduction to Open GL

- Asked in: 2070 Asar, 6 marks; 2069 Chaitra, 6 marks; 2072 Kartik, 5 marks; 2070 Chaitra, 3 marks; 2078 Kartik, 2 marks; 2076 Asoj, 2 marks; 2079 Baisakh, 2 marks; 2069 Asar, 2 marks (asked 8 times)
- Video: [OpenGL - introduction](https://www.youtube.com/watch?v=hPmEyAXdOdY) — Brian Will
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_5/computer_graphics/what-is-opengl-why-required
- Whole chapter: https://www.bctengineer.com/md/semester_5/computer_graphics/chapter-9

## Question

What is OpenGL? Why is OpenGL required? Explain with examples.

## Short answer

OpenGL is a cross-platform API for hardware-accelerated 2D/3D graphics, providing functions for primitives, transformations, lighting, texturing, and depth buffering. It is required for hardware independence, easy programming, high performance via GPU, and standardisation across platforms.

## Answer

**OpenGL (Open Graphics Library)** is a cross-platform, language-independent API (a library of about 250 functions) for rendering 2D and 3D graphics. It communicates with the graphics hardware (GPU) and provides functions to draw primitives, apply transformations, lighting, texturing and so on. It is used from C/C++ (and other languages), with GLUT/GLFW for windows and input.

**Why it is required**
1. **Hardware independence:** the same program runs on many platforms and graphics cards (Windows, Linux, macOS).
2. **Easy programming:** high-level calls (glVertex, glRotate, glLight) replace low-level programming of pixels and hardware.
3. **Hardware acceleration:** the commands are executed by the GPU, giving fast rendering.
4. **Rich features:** modelling and viewing transformations, hidden surface removal (depth buffer), lighting and shading, texture mapping, blending, anti-aliasing.
5. **Standard and open:** widely supported, with good documentation, and used by industry.

**Example:** drawing a coloured triangle

```c
#include <GL/glut.h>

void display(void) {
    glClear(GL_COLOR_BUFFER_BIT);      // clear the window
    glBegin(GL_TRIANGLES);
        glColor3f(1, 0, 0); glVertex2f(-0.5f, -0.5f);
        glColor3f(0, 1, 0); glVertex2f( 0.5f, -0.5f);
        glColor3f(0, 0, 1); glVertex2f( 0.0f,  0.5f);
    glEnd();
    glFlush();
}

int main(int argc, char **argv) {
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    glutCreateWindow("Triangle");
    glutDisplayFunc(display);
    glutMainLoop();
    return 0;
}
```

The output is a triangle with red, green and blue corners and colour blending in between.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What is OpenGL?
   A. A programming language for games
   B. A cross-platform, language-independent API for 2D and 3D graphics that works with graphics hardware
   C. An operating system for the GPU
   D. A window manager
   Answer: B. OpenGL is a library of about 250 functions for rendering. (Key point: Definition)

2. Why does hardware independence matter for OpenGL?
   A. Programs must be rewritten for each GPU
   B. It works only on Windows
   C. The same program runs on many platforms and graphics cards
   D. It removes the need for a GPU
   Answer: C. OpenGL hides hardware details behind a standard API. (Key point: Hardware independence)

3. How does OpenGL make programming easier?
   A. It requires writing pixel-level routines
   B. It forces assembly code
   C. It has no transformations
   D. High-level calls such as glVertex, glRotate and glLight replace low-level pixel and hardware programming
   Answer: D. The programmer calls functions rather than managing pixels. (Key point: Ease of use)

4. In the triangle example, what is drawn between glBegin(GL_TRIANGLES) and glEnd()?
   A. Three vertices with colours, blended inside the triangle
   B. A single colour fill only
   C. A line
   D. A window
   Answer: A. Red, green and blue vertices give a colour-blended triangle. (Key point: Example)

## Related in Computer Graphics

- [What is OpenGL? Callback function](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Aopengl-callback-function) — Computer Graphics, chapter 9, asked 5×

## Related in other subjects

- [What transposition is and why it is needed](https://www.bctengineer.com/question.md?key=semester_4%2Fpower_system_analysis_i%3Atransposition-what-why) — Power System Analysis I, chapter 4, asked 2×
- [Current HDP objectives and amendments needed](https://www.bctengineer.com/question.md?key=semester_7%2Fhydropower_engineering%3Ahdp-current-objectives-amendments) — Hydropower Engineering, chapter 1
