13.003 Computational Geometry and Visualization

OpenGL


OpenGL is an API (or Application Programming Interface) for producing high-quality 2D and 3D graphic images, including such advanced features as hidden surface removal, texture mapping, transparency, and motion blur. OpenGL is independent of display hardware, operating system, and window system.

Although originally developed by Silicon Graphics, Inc. (SGI), OpenGL is now under the control of the independent Architecture Review Board, including members from from ATI, Compaq, Evans & Sutherland, Hewlett-Packard, IBM, Intel, Intergraph, INVIDIA Microsoft, and Silicon Graphics.

OpenGL is supported on all UNIX workstations, and shipped standard with every Windows NT and Windows 95 PC. It runs on every major operating system including Mac OS, OS/2, UNIX, Windows 95, Windows NT, Linux, OPENStep, Python, and BeOS; it also works with every major windowing system, including Presentation Manager, Win32, and X/Window System.

OpenGL is callable from Ada, C, C++, Fortran, and Java and offers complete independence from network protocols and topologies.

Example

Just to provide the flavor of OpenGL, the following example program draws a white square centered in a black window:

#include <GL/gl.h>
#include <GL/glu.h>

main()
{
  /* open the window here ... */

  glClearColor(0.0, 0.0, 0.0, 0.0);   /* set clear color to black */
  glClear(GL_COLOR_BUFFER_BIT);       /* erase window to black */

  gluOrtho2d(-1.0, 1.0, -1.0, 1.0);   /* 2d orthographic projection */

  glColor3f(1.0, 1.0, 1.0);           /* set drawing color to white */

  glBegin(GL_POLYGON);                /* start a new polygon */
  glVertex2f(-0.5, -0.5);             /* vertices of polygon ... */
  glVertex2f(-0.5,  0.5);
  glVertex2f( 0.5,  0.5);
  glVertex2f( 0.5, -0.5);
  glEnd();                            /* end of polygon */

  glFlush();                          /* actually draw on screen */

  /* keep the window on the screen */
}

On to "OpenGL Geometric Primitives"
Back to "Introduction to graphics with OpenGL"
Back to "Lectures on OpenGL and Computer Graphics"