1 / 18

Graphics Programming

Graphics Programming. OpenGl. Introduction. OpenGL is a low-level graphics library specification. It makes available to the programmer a small set of geomteric primitives - points, lines, polygons, images, and bitmaps.

camden
Télécharger la présentation

Graphics Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Graphics Programming OpenGl

  2. Introduction • OpenGL is a low-level graphics library specification. It makes available to the programmer a small set of geomteric primitives - points, lines, polygons, images, and bitmaps. • OpenGL provides a set of commands that allow the specification of geometric objects in two or three dimensions, using the provided primatives, together with commands that control how these objects are rendered (drawn).

  3. 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 hardware-independent interface that can be implemented on many different hardware platforms. • The portability of OpenGl led to its rapid acceptance as a standard for computer graphics programming.

  4. What Is OpenGl • OpenGL itself isn’t a programming language, or a software library. • It’s the specification of an Application Programming Interface (API) for computer graphics programming. In other words, OpenGL defines a set of functions for doing computer graphics.

  5. 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.

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

  7. OpenGl Libraries • Two utility libraries have been developed which extend the low-level functionality 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”.

  8. 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”.

  9. 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 GLUT GLU OpenGL library X Windows Unix

  10. The X window system is a computer software system and network protocol that provides a basis for graphical user interfaces (GUIs) and rich input device capability for networked computers.

  11. The OpenGl Model Application Model Application Program Graphic System(OpenGl) Mouse,… Display Screen User

  12. 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 includegl.h or glu.h explicitly.

  13. 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.

  14. libraries (place in the lib\ subdirectory of Visual C++) • opengl32.lib • glu32.lib • glut32.lib • include files (place in the include\GL\ subdirectory of Visual C++) • gl.h • glu.h • glut.h • dynamically-linked libraries (place in the \Windows\System subdirectory • opengl32.dll • glu32.dll • glut32.dll

  15. 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

  16. A Description of an OpenGl Function • Example: the definition of the GLUT function which draws a sphere. void glutWireSphere ( GLdoubleradius, GLintslices, GLintstacks );

  17. • The name of the function is glutWireSphere(); • • The result type of the function is void; • • The function has three arguments: • – radius, of type GLdouble • – slices, of type GLint • – stacks, of type GLint

  18. To actually use this function in your program,you have to declare variables • GLintsl= 15; • GLdoublerad= 1.0; • GLintst= 20; • glutWireSphere (rad, sl, st); • Or, you could set the arguments directly, without declaring variables: • glutWireSphere (1.0, 15, 20);

More Related