0% found this document useful (0 votes)
9 views6 pages

cg p 1 odd pages

The document provides an overview of OpenGL, a widely used 3D graphics API, and instructions for installing it on the Ubuntu operating system. It discusses the OpenGL Utility Toolkit (GLUT), which simplifies OpenGL programming by handling system-level I/O and window management. Additionally, a basic program example is included to demonstrate the use of OpenGL primitives for rendering graphics.

Uploaded by

blackcrusher7
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)
9 views6 pages

cg p 1 odd pages

The document provides an overview of OpenGL, a widely used 3D graphics API, and instructions for installing it on the Ubuntu operating system. It discusses the OpenGL Utility Toolkit (GLUT), which simplifies OpenGL programming by handling system-level I/O and window management. Additionally, a basic program example is included to demonstrate the use of OpenGL primitives for rendering graphics.

Uploaded by

blackcrusher7
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/ 6

Title: Install and explore the OpenGL

Aim: To study briefly about OpenGL and to install OpenGL on the UBUNTU
Operating System.

Theory:

OpenGL is the most extensively documented 3D graphics API(Application


Program Interface) to date. Information regarding OpenGL is all over the Web
and in print. It is impossible to exhaustively list all sources of OpenGL
information. OpenGL programs are typically written in C and C++. One can
also program OpenGL from Delphi (a Pascal-like language), Basic, Fortran,
Ada, and other languages. To compile and link OpenGL programs, one will
need OpenGL header files. To run OpenGL programs one may need shared or
dynamically loaded OpenGL libraries, or a vendor-specific OpenGL Installable
Client Driver (ICD).
GLUT: The OpenGL Utility Toolkit (GLUT) is a library of utilities for
OpenGL programs, which primarily perform system-level I/O with the host
operating system. Functions performed include window definition, window
control, and monitoring of keyboard and mouse input. Routines for drawing a
number of geometric primitives (both in solid and wireframe mode) are also
provided, including cubes, spheres, and cylinders. GLUT even has some limited
support for creating pop-up menus. The two aims of GLUT are to allow the
creation of rather portable code between operating systems (GLUT is
cross-platform) and to make learning OpenGL easier. All GLUT functions start
with the glut prefix (for example, glutPostRedisplay marks the current window
as needing to be redrawn)
Setting up GLUT - main()
GLUT provides high-level utilities to simplify OpenGL programming,
especially in interacting with the Operating System (such as creating a window,
handling key and mouse inputs). The following GLUT functions were used in
the above program:
●​ glutInit: initializes GLUT, must be called before other GL/GLUT
functions. It takes the same arguments as the main().
void glutInit(int argc, char *argv[])
●​ glutCreateWindow: creates a window with the given title.
glutCreateWindow(char *title)
//Basic program to display output using basic OpenGL primitives
#include<GL/glut.h>
#include<iostream>
using namespace std;
void initialize()
{
glClearColor(1, 1, 1, 1);
glClear(GL_COLOR_BUFFER_BIT);

gluOrtho2D(0, 600, 0, 600);


}
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glFlush();
}
void mainMenu(int choice) {
switch(choice) {
​ case 1: // Pixel
​ glPointSize(10);
​ glColor3f(1,1,0);
​ glBegin(GL_POINTS);
​ glVertex2i(100,100);
​ glEnd();
​ break;
​ case 2: // Line
​ glLineWidth(3);
​ glColor3f(1,0,0);
​ glBegin(GL_LINES);
glVertex2i(10,10);
glVertex2i(300,10);
glEnd();
​ break;
​ case 3: // Triangle
​ glColor3f(0,0,1);
​ glBegin(GL_TRIANGLES);
​ ​ glVertex2i(50,50);
Output

You might also like