Showing posts with label OpenGL. Show all posts
Showing posts with label OpenGL. Show all posts

OpenGL Tutorial


OpenGL Tutorial

OpenGL is a low-level graphics library specification. OpenGL makes available to the programmer a small set of geometric 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 primitives, together with commands that control how these objects are rendered into the frame buffer.
The OpenGL API was designed for use with the C and C++ programming languages but there are also bindings for a number of other programming languages such as Java, Tcl, Ada, and FORTRAN.
The OpenGL 1.1 Specification is maintained by Silicon Graphics and can be found at: http://www.sgi.com/Technology/openGL/glspec1.1/glspec.html.
Mesa is a free implementation of the OpenGL specification. Mesa is the actual graphics library that will be used in this course. Additional information on Mesa can be found at: http://www.ssec.wisc.edu/~brianp/Mesa.html.
The OpenGL specification is operating system and windowing system independent. It relies on the windowing system for window management, event handling, color map operations, etc . . .. In this course the tk library will be used for windowing system functions. (This library is not to be confused with Tk of Tcl/Tk.) The tk library provides the "glue" between OpenGL and X Windows.
Following are the content of this tutorial
1. Introduction to OpenGL
Rendering Pipeline
Libraries
Include Files
Setting Up Compilers

2. Simple OpenGL Program
Initialization
Creating a Window
Display Function
Reshape Function
Main Loop

3. Geometric Objects
Points, Lines and Polygons
Drawing 3-D Objects
Transformations
Scaling
Translation
Rotation Display Lists

4. Viewing
Color
Shading
Viewing Transformation
Projection
Orthographic
Perspective Manipulating the Matrix Stacks
Light
Viewport Transformation

5. Input Devices and Interaction
Menu
Mouse
Keyboard
Animation

6. Selection
Name Stacks
Picking
Hits

The OpenGL Utility Toolkit (GLUT) Programming Interface By Mark J. Kilgard


The OpenGL Utility Toolkit (GLUT) Programming Interface

By Mark J. Kilgard
The OpenGL UtilityToolkit (GLUT) is a programming interface withANSI C and FORTRAN bindings for writing window system independent OpenGL programs. The toolkit supports the following functionality:
  • Multiplewindows for OpenGL rendering.
  • Callback driven event processing.
  • Sophisticated input devices.
  • An “idle” routine and timers.
  • A simple, cascading pop-up menu facility.
  • Utility routines to generate various solid and wire frame objects.
  • Support for bitmap and stroke fonts.
  • Miscellaneous window management functions, including managing overlays.
An ANSI C implementation of GLUT for the X Window System [15] has been implemented by the author. Windows NT and OS/2 versions of GLUT are also available.
This documentation serves as both a specification and a programming guide. If you are interested in a brief introduction to programming with GLUT, look for the introductory OpenGL column [9] published in The X Journal. For a complete introduction to using GLUT, obtain the book Programming OpenGL for the XWindow System [10]. GLUT is also used by the 2nd edition of the OpenGL Programming Guide. Teachers and students interested in using GLUT in conjunction with a college-level computer graphics class should investigate Angel’s textbook Interactive Computer Graphics: A top-down approach with OpenGL [2] that uses GLUT for its OpenGL-based examples programs.
The remainder of this section describes GLUT’s design philosophy and usagemodel. The following sections specify the GLUT routines, grouped by functionality.
The final sections discuss usage advice, the FORTRAN binding, and implementation issues. AppendixA enumerates and annotates the logical programmer visible state maintained by GLUT. Appendix B presents the ANSI C GLUT API via its header file. Appendix C presents the FORTRAN GLUT API via its header file.

OpenGL Texture Mapping - Sample Chapter


OpenGL Texture Mapping - Sample Chapter

After reading this chapter, you’ll be able to do the following:
  • Understand what texture mapping can add to your scene
  • Specify texture images in compressed and uncompressed formats
  • Control how a texture image is filtered as it is applied to a fragment
  • Create and manage texture images in texture objects and, if available, control a high-performance working set of those texture objects
  • Specify how the color values in the image combine with those of the fragment to which it’s being applied
  • Supply texture coordinates to indicate how the texture image should be aligned with the objects in your scene
  • Generate texture coordinates automatically to produce effects such as contour maps and environment maps
  • Perform complex texture operations in a single pass with multitexturing (sequential texture units)
  • Use texture combiner functions to mathematically operate on texture, fragment, and constant color values
  • After texturing, process fragments with secondary colors
  • Perform transformations on texture coordinates using the texture matrix
  • Render shadowed objects, using depth textures

So far, every geometric primitive has been drawn as either a solid color or smoothly shaded between the colors at its vertices—that is, they’ve been drawn without texture mapping. If you want to draw a large brick wall without texture mapping, for example, each brick must be drawn as a separate polygon. Without texturing, a large flat wall—which is really a single rectangle—might require thousands of individual bricks, and even then the bricks may appear too smooth and regular to be realistic.
Texture mapping allows you to glue an image of a brick wall (obtained, perhaps, by scanning in a photograph of a real wall) to a polygon and to draw the entire wall as a single polygon. Texture mapping ensures that all the right things happen as the polygon is transformed and rendered. For example, when the wall is viewed in perspective, the bricks may appear smaller as the wall gets farther from the viewpoint. Other uses for texture mapping include depicting vegetation on large polygons representing the ground in flight simulation; wallpaper patterns; and textures that make polygons look like natural substances such as marble, wood, and cloth. The possibilities are endless. Although it’s most natural to think of applying textures to polygons, textures can be applied to all primitives—points, lines, polygons, bitmaps, and images. Plates 6, 8, 18–21, and 24–32 all demonstrate the use of textures.

OpenGL Simple Shading Example -Sample Chapter


OpenGL Simple Shading Example -Sample Chapter

Now that we’ve described the OpenGL Shading Language, let’s look at a simple example. In this example, we apply a brick pattern to an object. The brick pattern is calculated entirely within a fragment shader. If you’d prefer to skip ahead to the next chapter for a more in-depth discussion of the API that allows shaders to be defined and manipulated, feel free to do so.
The shader for rendering a procedural brick pattern was the first interesting shader ever executed by the OpenGL Shading Language on programmable graphics hardware. It ran for the first time in March 2002, on the 3Dlabs Wildcat VP graphics accelerator. Dave Baldwin published the first GLSL brick fragment shader in a white paper that described the language destined to become the OpenGL Shading Language. His GLSL shader was based on a RenderMan shader by Darwyn Peachey that was published in the book, Texturing and Modeling: A Procedural Approach. Steve Koren and John Kessenich adapted Dave’s shader to get it working on real hardware for the first time, and it has subsequently undergone considerable refinement for inclusion in this book.
This example, like most of the others in this book, consists of three essential components: the source code for the vertex shader, the source code for the fragment shader, and the application code that initializes and uses these shaders. This chapter focuses on the vertex and fragment shaders. The application code for using these shaders is discussed in Section 7.13, after the details of the OpenGL Shading Language API have been discussed.

OpenGL Programming Guide Second Edition


OpenGL Programming Guide Second Edition

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 or ones that depart from reality in imaginative ways. This guide explains how to program with the OpenGL graphics system to deliver the visual effect you want.
What You Should Know Before Reading This Guide
This guide assumes only that you know how to program in the C language and that you have some background in mathematics (geometry, trigonometry, linear algebra, calculus, and differential geometry). Even if you have little or no experience with computer-graphics technology, you should be able to follow most of the discussions in How to Obtain the Sample Code xxi this book. Of course, computer graphics is a huge subject, so you may want to enrich your learning experience with supplemental reading.
  • Computer Graphics: Principles and Practice by James D. Foley, Andries van Dam, Steven K. Feiner, and John F. Hughes (Reading, MA: Addison-Wesley, 1990)—This book is an encyclopedic treatment of the subject of computer graphics. It includes a wealth of information but is probably best read after you have some experience with the subject.
  • 3D Computer Graphics: A User’s Guide for Artists and Designers by Andrew S. Glassner (New York: Design Press, 1989)—This book is a nontechnical, gentle introduction to computer graphics. It focuses on the visual effects that can be achieved rather than on the techniques needed to achieve them.
Once you begin programming with OpenGL, you might want to obtain the OpenGL Reference Manual by the OpenGL Architecture Review Board (Reading, MA: Addison-Wesley Developers Press, 1996), which is designed as a companion volume to this guide. The Reference Manual provides a technical view of how OpenGL operates on data that describes a geometric object or an image to produce an image on the screen. It also contains full descriptions of each set of related OpenGL commands—the parameters used by the commands, the default values for those parameters, and what the commands accomplish. Many OpenGL implementations have this same material on-line, in the form of man pages or other help documents, and it’s probably more up-to-date. There is also a http version on the World Wide Web; consult Silicon Graphics OpenGL Web Site (http://www.sgi.com/Technology/openGL) for the latest pointer. OpenGL is really a hardware-independent specification of a programming interface, and you use a particular implementation of it on a particular kind of hardware.
This guide explains how to program with any OpenGL implementation. However, since implementations may vary slightly—in performance and in providing additional, optional features, for example—you might want to investigate whether supplementary documentation is available for the particular implementation you’re using. In addition, you might have OpenGL-related utilities, toolkits, programming and debugging support, widgets, sample programs, and demos available to you with your system.

Using OpenGL in Visual C++ By Alan Oursland


Using OpenGL in Visual C++

By Alan Oursland
With the release of NT 3.5, OpenGL became a part of the Windows operating system. Now with support for OpenGL in Windows 95 and Windows 98 and low priced graphics accelerators becoming readily available even on low end machines, the prospects of using OpenGL on any Windows machine is becoming more attractive every day. If you are interested in creating quality 2-D or 3-D graphics in Windows, or if you already know another variant of GL, keep reading. This tutorial will show you how to use OpenGL and some of its basic commands.
GL is a programming interface designed by Silicon Graphics. OpenGL is a generic version of the interface made available to a wide variety of outside vendors in the interest of standardization of the language.
OpenGL allows you to create high quality 3-D images without dealing with the heavy math usually associated with computer graphics. OpenGL handles graphics primitives, 2-D and 3-D transformations, lighting, shading, Z-buffering, hidden surface removal, and a host of other features. I'll use some of these topics in the sample programs following; others I'll leave to you to explore yourself. If you want to learn more about OpenGL you can search the MSDN website for the keyword "OpenGL".
Here is the list of topics covered in this series:
  1. Writing an OpenGL Program
  2. Simple 2-D Graphics
  3. Transformations and the Matrix Stack
  4. Simple 3-D Graphics

Java Personal OpenGL Tutorial (JPOT)


Java Personal OpenGL Tutorial (JPOT)

The first interactive OpenGL tutor POT was conceived in 1998 by Sumanta Guha, Mahesh Kumar and Ichiro Suzuki at the University of Wisconsin-Milwaukee, for use by the computer graphics students at UWM as well as the graphics community. Since POT ran only on UNIX platforms, we received many requests for versions that could run on other platforms.
Since 1999 Binh Le continued developing the tutorial and created a Java version JPot. This is the current release, and the important features are as follows:
  • JPot is platform independent.
  • The interface is improved.
  • There are more lessons.
  • A tool is provided to generate lessons automatically.
As an accademic project, JPot is free for all non-commercial uses, and we are strongly welcome other contributions for JPot. Even though we can not be responsible for any consequence of using it, we still try our best to assist you when you have problem regarding using and working on JPot.