GLART week 1

Introduction to OpenGL and the approach of this course. Use glBegin(), glVertex() and glEnd() to define geometry. Reading: see Red book (Third Edition) chapter 2 "Drawing Geometric Objects" pages 42-47 Assigment: 1) Get a basic OpenGL app running in Eclipse 2) Look at the code in the demo folder 3) Using the program above as a starting point, experiment with creating geometry -- fill the screen with shapes -- bonus points if they move -- bonus points if they change color What is OpenGL: "a software interface to graphics hardware" OpenGL is a low level API that communicates with the graphics hardware, or "GPU", primarily to perform 3D rendering. By providing a standard interface to many video graphics cards, OpenGL has made it easier for programmers to use 3D hardware acceleration without having to know the inner workings of the graphics hardware. While it is often used for 3D rendering, OpenGL is very versatile, and can be used for a wide range of rendering approaches. Cross Platform, cross language The OpenGL API is available in Windows, on the Mac and in Linux. Many programming languages support the API, including C, C++, Python, Visual Basic. A "state machine" OpenGL is a procedural system, meaning the API is composed of a set of loosely connected functions. API function calls change the behavior, or "state", of the OpenGL renderer, enabling or disabling features to control what the GPU renders and how it renders. OpenGL is not object oriented, though it has been integrated into object oriented languages such as C++ and Java. Low Level The OpenGL API provides very direct access to the graphics card features, without a lot of bells and whistles. It is up to the programmer to build more elaborate structures themselves. OpenGL does not include a great deal of tools or high level constructs (such as loading and displaying models or image files), but much code is available online to provide this functionality. Renderer vs. Scene Graph OpenGL is a renderer, not a scene graph. The OpenGL API passes commands to the graphics card, which performs the mathematics necessary to render geometric forms, and sends the resulting image to the screen. A scene graph provides higher level scene organization, and manages relationships between objects in space. See Xith 3D and Java 3D for examples. A Brief OpenGL History 1960 William Fetter, a graphic designer for Boeing Aircraft Co., coins the phrase "Computer Graphics" 1963 Sketchpad (aka Robot Draftsman) was a revolutionary computer program written by Ivan Sutherland as part of his PhD thesis. Ivan Sutherland's PhD work made him to be the "grandfather" of interactive computer graphics and graphical user interfaces. 1969 Special Interest Group in Graphics (SIGGRAPH) is formed 1980 In the 1980s artists and graphic designers began to see the personal computer, particularly the Commodore Amiga and Macintosh, as a serious design tool 1982 Silicon Graphics Inc. is founded by Jim Clark and Abbey Silverstone to produce 3D graphics workstations. OpenGL is a direct descendant of the IRIS GL created by SGI. 1992 The first public release of the OpenGL 1.0 spec. As part of their business strategy, SGI decided to open up their graphics API. Vendors of hardware and software joined Silicon Graphics to form the OpenGL Architecture Review Board (OpenGL ARB as itís now commonly called). Microsoft pledges support for OpenGL at the July, 1992 Win32 developers conference, concurrently with the release of the OpenGL Specification, 1.0. However, it wasnít until the release of NT 3.5 two years later that OpenGL was actually implemented on Windows. Initially performance was not very good. 1993 The PC game DOOM by Id Software is released. Widely recognized for pioneering immersive 3D graphics, but actually uses 2D maps and some tricks to render with the appearance of 3D. 1995 Toy Story, the first full-length computer-generated animation film 1996 Quake by Id Software is released, one of the first fully 3D games. 1996 The SGI OpenGL for Windows implementation. Originally called Cosmo GL, demonstrated alongside some Microsoft Direct3D demos at the 1996 SIGGRAPH conference. 2002 ATI releases the Radeon 9700 graphics card for PCs, which raises the standard for 3D rendering on a PC. 2004 OpenGL 2.0 released By 2004 OpenGL is widely available as a high performance graphics standard on PC, Mac and Linux. Geometry notes: Create geometric shapes by "connecting the dots": vertices are connected to form surfaces. -- vertex defines a point in space -- use glBegin()...glEnd() to connect vertices in different ways QUADS, LINES, POLYGON, TRIANGLES: all are converted to triangles during the rendering process -- triangle is the simplest flat surface -- complex surfaces are formed by joining many triangles together -- triangles face one way. place vertices in counter-clockwise order to create a triangle that faces forward (the "right hand rule") -- the coordinate system is cartesian: -- by default 0,0,0 is in the middle of the screen -- X values increase moving to the right (same as Java applet) -- Y values increase moving up the screen (opposite of Java applet) -- Z values increase moving towards the view point remember: smaller Z values appear smaller on screen (are farther away) -- the Y axis is inverted (0 at the bottom, opposite of Java/Processing) glVertex3f(x,y,z) Place a vertex at the given location. Vertices define positions in 3D space and are the building blocks of geometry. Vertices can specify the shape of lines, triangles, quads (squares) and polygons. A triangle is the simplest planar surface, consisting of 3 vertices connected using the GL_TRIANGLES type. glBegin(shape type), glEnd() Connect vertices to create various types of shapes using glBegin() and glEnd(). OpenGL will interpret the vertices as end point of a line (GL_LINE), or as points of triangle (GL_TRIANGLES), or as corners of a square (GL_QUADS). glColor3f(red,green,blue) Call glColor() before calling glVertex() to assign a color to the vertex. Pass the red, green and blue values as floats in the range 0-1. OpenGL often uses values between 0 and 1 to describe values in a hardware-independent fashion. OpenGL will interpolate color values across the surface between vertices to smoothly blend color from one vertex to the next. GLART is: graphics programming as an art medium for tech artists, artistic techies heavy programming (Java/Eclipse) CODE!!!!!!!! hands-on, studio class low level, under the hood, how does the computer make pictures? underneath Flash, Maya, Virtools Intro to OpenGL, 3D rendering OpenGL: a cross-platform API to the graphics processor understand how computer thinks in 3D vocabulary of 3D (and 2D) introduction to 3D math (very basic) goal: working knowledge of computer rendering programming intensive: Java/Eclipse GLART is not: not a math class, not theory of 3D mathematics will introduce ideas of math can be understood without knowing details of math aimed at artists, not engineers not game development not 3D modelling (though we'll use models in class) not Maya: no ray tracing, volumetric light and shadows, etc. not a Jitter class not a modelling class though GLART will shed light on how these systems work Grading homework matters! submit at least 8 homework assignments (out of ten) mid-term + final books Red book optional: Math for Game Programmers resources syllabus: many online, see syllabus ( nate robbins code on potatoland homework wiki (i'll set up) BOOKS: Redbook, online help sites, Math for Game Programmers (see code examples: I provide (see office hours by arrangement email me: The hello triangle code JOApp is a base class that contains basic JOGL app functionality the gl and glu objects contain OpenGL functions the opengl "display": a rectangle on screen that OpenGL draws into main() the first function that runs instantiate the application, run it. run() calls init() to initialize OpenGL starts the "game loop" JOGL's canvas calls back functions to redraw the screen init() prepare the OpenGL display also calls setup() that subclass can override (like Processing's setup()) draw() render geometry (shapes in space) like Processing's draw() called from the display() callback function (triggered by JOGL) completely redraw scene 60 times/second Related Links: Xith A Java scene graph Mesa3D A home-grown 3D graphics API, very similar to OpenGL, Java3D a Java scene graph system runs on OpenGL, but doesn't expose that layer LWJGL Lightweight Java/OpenGL binding, not affiliated with Sun aimed at gamers JOGL Java/OpenGL binding, more closely tied to Awt, Swing affiliated with Sun Java AWT - older, limited graphics system Swing - good for GUI work, not optimal for graphics Java2D - not hardware accelerated Java3D - a scene-graph, does not provide access to OpenGL Wikipedia OpenGL entry compare Direct3D and OpenGL About the Teapot