5

OpenGL Course - Winter 2001
Ken Schwarz - SGI Professional Services
  • Course material is based on "OpenGL Programming Guide" (aka "redbook") 
  •  Intended audience (preqequisites)
    • Software professionals with working familiarity with C and either IRIX or Linux
  •  Course goals: 
    • To introduce the student to software development techiques for procucing 2D and 3D graphics with OpenGL
    • To cover the fundamental techniques described in the "redbook"
  •  Course implementation: 
    • 1 hour lectures with 1 hour labs/week
    • Possible multi-week "project"  (C++ ?) 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

Section 1 - Introduction

Ob jectives for student:

  • Appreciate in general terms what OpenGL does
  • Identify different levels of rendering complexity 
  • Understand the basic structure of an OpenGL program 
  • Recognize OpenGL command syntax 
  • Identify the sequence of operations of the OpenGL rendering pipeline 
  • Understand in general terms how to animate graphics in an OpenGL program

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

What is OpenGL?

From the Programmers' Guide:

The OpenGL graphics system is a software interface to graphics hardware. (The GL stands for Graphics Library.) It allows you to create interactive programs that produce color images of moving three-dimensional objects. With OpenGL, you can control computer-graphics technology to produce realistic pictures ...


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

What is OpenGL? (cont)
  • FIRST AND FOREMOST:  A software interface to graphics hardware
  •  ~150 separate commands 
    • Object specificaton and operations on primitives
  •  Hardware-independent specification (cellphones to Reality Monsters)

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

What OpenGL is NOT
  • The OpenGL specification does not define the folowing:
    • Window interaction (GLUT!)
    • User interaction
    • High-level 3D model description

    • (low-level primitives are used)
    •  Video output

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

A few terms ...
  • Rendering

  •  the process by which a computer creates images from models
  • Model 

  • object representation made from geometric primitives (points, lines, and polygons) that are specified by their vertices. 
  • Pixel (piture element)

  •  the smallest visible element on the final rendered image
     the color infomation is encoded into memory bitplanes
  •  Bitplane

  •  An area of memory that holds 1 bit of information for each pixel on the screen
  •  Framebuffer

  • The organization of all of the bitplanes in the graphics system which determine   the color of the pixels on the screen
  •  (A graphics here ... (volume rendering))

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

Sample OpenGL Program 
  • Fig 1-1 
  • #include <whateverYouNeed.h> 
    main() { 
       InitializeAWindowPlease(); 
       glClearColor (0.0, 0.0, 0.0, 0.0); 
       glClear (GL_COLOR_BUFFER_BIT); 
       glColor3f (1.0, 1.0, 1.0); 
       glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0); 
       glBegin(GL_POLYGON); 
       glVertex3f (0.25, 0.25, 0.0); 
       glVertex3f (0.75, 0.25, 0.0); 
       glVertex3f (0.75, 0.75, 0.0); 
       glVertex3f (0.25, 0.75, 0.0); 
       glEnd(); 
       glFlush(); 
       UpdateTheWindowAndCheckForEvents(); 
    }
     

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

OpenGL Command Syntax
  • All commands begin with the "gl" prefix
  • All OpenGL-defined constants begin with "GL_"
  • Suffix defines number of parametrs and data type

  • glColor3f()
    glColor4i()
    glColor3ub()
  •  

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

OpenGL Command Syntax (cont)
    Suffix Data         Type Typical          Corresponding C-Language Type        OpenGL Type Definition 
    b                       8-bit integer                 signed char                                      GLbyte 
    s                       16-bit integer               short                                                GLshort 
    i                        32-bit integer               int or long                                         GLint, GLsizei 
    f                        32-bit floating-point      float                                                  GLfloat, GLclampf 
    d                       64-bit floating-point      double                                              GLdouble, GLclampd 
    ub                     8-bit unsigned integer   unsigned char                                   GLubyte, GLboolean 
    us                     16-bit unsigned integer  unsigned short                                 GLushort 
    ui                      32-bit unsigned integer  unsigned int or unsigned long            GLuint, GLenum, GLbitfield
     NOTE:  a "v" suffix denotes a pointer to the data 
     

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

OpenGL Command Syntax (cont)
  • Some commands may end in "v" denoting a vector to an array 
  • GLfloat color_array[] = {1.0, 0.0, 0.0}; 
    glColor3fv(color_array);