Graphics Pipeline, OpenGL

Tom Kelliher, CS 320

Feb. 4, 2000

Administrivia

Announcements

Assignment

From Last Time

Synthetic camera, history of graphics.

Outline

  1. Modeling-Rendering Paradigm.

  2. Graphics Architectures.

  3. OpenGL intro: Sierpinski gasket program.

Coming Up

More OpenGL programming.

Modeling-Rendering Paradigm

Alternative to synthetic camera.

Modeler, interface file, renderer.

  1. Modeler:
    1. Concerned with design and placement of objects.

    2. Highly interactive process.

    3. Possibly more than one modeler, tailored to each application.

  2. Interface file:
    1. Output from modeler, input to renderer.

    2. Basic description of scene.

  3. Renderer:
    1. Adds lighting, viewer perspective, material properties (additional components of interface file).

    2. Computationally intensive.

    3. PIXAR's Renderman.

Graphics Architectures

Early Systems

Host, DA converter, CRT.

Display Processors

Host, display processor and display list, CRT.

  1. Separate processor.

  2. Host sends primitives along, stored in display list.

  3. Display processor deals with refresh, re-generation.

Graphics Pipelines

Consider a pipeline for computing large numbers of .

Properties of pipelines:

  1. Depth --- latency.

  2. Throughput.

Steps in a graphics pipeline:

  1. Transformation --- between series of coordinate systems. Matrix multiplications.

  2. Clipping --- cut scene down to field of view. Example: Excel.

  3. Projection --- Project 3-D objects into 2-D. Matrix multiplication.

  4. Rasterization --- Convert 2-D primitives to pixels.

Sierpinski Gasket Program

  1. The pentagon and the algorithm.

  2. Initialization. Color models, buffers, clear color.

  3. Callbacks. Function types, especially the mouse callback.

  4. Matrix manipulation.

  5. The purpose of GLUT. The main loop.

  6. Online/web man pages. Downcasing.

/* Sierpinski Pentagon GL program */


/* This program illustrates simple use of mouse with OpenGL
to start and stop program execution */

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

/* define a point data type */

typedef struct { float x,y;} point;

/* A pentagon */
point vertices[5]={{50,0},{0,250},{250,500},{500,250},{450,0}};

int j;
point new, old={75,50}; /* A random point */

void clear(void)
{
        glClear(GL_COLOR_BUFFER_BIT);
}

void display(void)

/* computes and plots a single new point */

{
        long random();
        int i;
        j=random()%5; /* pick a vertex at random */


/* Compute point halfway between vertex and old point */

        new.x = (old.x+vertices[j].x)/2; 
        new.y = (old.y+vertices[j].y)/2;
        
/* plot point */

        glBegin(GL_POINTS);
                glVertex2f(new.x, new.y);
        glEnd();


/* replace old point by new */

        old.x=new.x;
        old.y=new.y;
        

        glFlush();
}


void mouse(int btn, int state, int x, int y)
{
if(btn==GLUT_LEFT_BUTTON&state==GLUT_DOWN)  glutIdleFunc(display);
if(btn==GLUT_MIDDLE_BUTTON&state==GLUT_DOWN)   glutIdleFunc(NULL);
if(btn==GLUT_RIGHT_BUTTON&state==GLUT_DOWN)   exit();
}

int main(int argc, char** argv)
{


        glutInit(&argc,argv);
        glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
        glutInitWindowSize(500,500);
        glutInitWindowPosition(0,0);
        glutCreateWindow("Sierpinski Gasket");

        glutIdleFunc (display);
        glutMouseFunc (mouse);  
        glClearColor(1.0, 1.0, 1.0, 0.0); /* white background */
        glColor3f(1.0, 0.0, 0.0);
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(0.0, 500.0, 0.0, 500.0, -1.0, 1.0);
        glMatrixMode(GL_MODELVIEW);
        glutDisplayFunc(clear);


        glutMainLoop();

}



Thomas P. Kelliher
Fri Feb 4 12:25:36 EST 2000
Tom Kelliher