Graphics Programming

14
OpenGl GRAPHICS PROGRAMMING

description

Graphics Programming. OpenGl. What Is OpenGl. GL stand for Graphics library. OpenGL is a software interface to graphics hardware. - PowerPoint PPT Presentation

Transcript of Graphics Programming

Page 1: Graphics Programming

OpenGl

GRAPHICS PROGRAMMING

Page 2: Graphics Programming

What Is OpenGl GL stand for Graphics library. OpenGL is a software interface to graphics hardware. This interface consists of about 150 distinct

commands that you use to specify the objects and operations needed to produce interactive three-dimensional applications.

OpenGL is independent interface that can be implemented on many different hardware platforms.

OpenGL defines a set of functions for doing computer graphics.

Page 3: Graphics Programming

What exactly can OpenGL do?

It provides 3D geometric objects, such as lines, polygons, triangle meshes, cubes , curves and surfaces.

It provides 3D modeling transformations, and viewing functions to create views of 3D scenes using the idea of a virtual camera;

It supports the manipulation of images as pixels.

Page 4: Graphics Programming

With OpenGL, you must build up your desired model (big project) from a small set of geometric primitives – points , lines, and polygons.

Page 5: Graphics Programming

OpenGl Libraries Two utility libraries have been developed

which extend of OpenGL. GLU

Is the OpenGL Utility Library , provides functions for drawing more complex primitives than those of OpenGL, such as curves and surfaces.

All GLU function names start with “glu”.

Page 6: Graphics Programming

• GLUT provides the facilities for interaction that

OpenGL lacks. It provides functions for managing windows

on the display screen, and handling input events from the mouse and keyboard.

All GLUT function names start with “glut”…

Page 7: Graphics Programming

This collection Of libraries Refereed to as” OpenGl”

OpenGL” is actually a set of three libraries: OpenGL itself,and the supporting libraries GLU and GLUT.

Application Program

GLUGLUT

OpenGL library

Unix

X Windows

Page 8: Graphics Programming

Include Files For all OpenGL applications, you want to include the gl.h

header file in every file. Almost all OpenGL applications use GLU, the aforementioned OpenGL Utility Library, which also requires inclusion of the glu.h header file. So almost every OpenGL source file begins with:

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

If you are using the OpenGL Utility Toolkit (GLUT) for managing your window manager tasks, you should include:

#include <GL/glut.h> Note that glut.h guarantees that gl.h and glu.h are properly

included for you so including these three files is redundant. To make your GLUT programs portable, include glut.h and do not include gl.h or glu.h explicitly.

Page 9: Graphics Programming

Setting Up Compilers Windows Using MS Visual C++ Most of the following files (ie. OpenGL

and GLU) will already be present if you have installed MS Visual C++ v5.0 or later. The following GLUT files will need to be copied into the specified directories.

Page 11: Graphics Programming

Compiling OpenGL/GLUT Programs Create a new project:

choose File | New from the File Menu select the Projects tab choose Win32 Console Application fill in your Project name

Page 12: Graphics Programming

A Description of an OpenGl Function

Example:

Void glNameF3 (x,y,z) ;

Page 13: Graphics Programming

• The name of the function is glNameF3 (x,y,z) ;

• The result type of the function is void; • The function has three arguments: X Y Z

Page 14: Graphics Programming

To actually use this function in your program,you have to declare variables

GLint sl= 15; GLdouble rad= 1.0; GLint st= 20; glutWireSphere (rad, sl, st); Or, you could set the arguments directly,

without declaring variables: glutWireSphere (1.0, 15, 20);