# Homeworks

There will be about a dozen homeworks.

 Due Questions Solution Sep 2 Homework 1 Solution1.pdf Sep 9 Homework 2 Solution2.pdf Sep 16 Homework 3 Solution3.pdf Sep 26 Homework 4 Solution4.pdf Oct 17 Homework 5

# Lectures and labs day-by-day

 AngelCG06.ppt: Programming in OpenGL III Demo, discuss, and modify shape_test.c. New features: OpenGL datatypes like GLfloat Allocate and enable depth (aka Z) buffer Perspective view Several utility polyhedra sphere, cone, cube, torus, dodecahedron, teapot, octahedron, icosahedron wire or solid Light source and color Enabling and disabling lighting Reshape callback Push and pop transformation matrix Rotate, scale, translate transformations Using viewport to draw into a small region of the window. Anything outside the viewport is clipped. AngelCG07.ppt: Input and Interaction Demo, discuss, and modify gasket2.c . Features: Array of vertices passed to glVertex2fv Array of triangles Recursively creating the graphic object glBegin and glVertex2fv are in different routines. It's the order in which they are executed that matters, not their order in the source file. Parallel (ortho) projection. Demo, discuss, and modify gasket3.c . Features: 3D. Spec colors in an array. Reshape callback. It handles rectangular windows, keeping the tetrahedra undistorted, with the same aspect ratio, centered in the window.. Portrait and landscape mode are separate cases. glPostRedisplay

Reading: Angel, chapter 2, excluding 2.11
Announcements:

1. In Homework 2, the nonphysical aspect of the graphics pipeline is the idea that objects do not interact with each other, i.e., that object A's brightness/color/etc is not affected by object B. Therefore, OK to hand in homework 2 tomorrow.
2. Homework 3 available, due Sep 16.
3. Prof Roysam is looking for graphics students in various roles from undergrad projects on up. See his website and talk to him. Working for him would make a good term project for this course.
 8 Wed Sep 10 Topics: Chance to talk to Jixu. Reading: Announcements: 9 Fri Sep 12
 Topics: AngelCG07.ppt: Input and interaction Demo, discuss, and modify paint.c . Features: keyboard callback write the key at a position stored in a global and update that mouse callback accumulating info, such as triangle vertices, from successive callbacks converting coords from what is passed to mouse callback (origin is top left corner) to what is used by openGL window (origin is bottom left corner) picking a region of window by analyzing coords of mouse click. immediate mode: on redisplay, if it's not explicitly redrawn, it's not there any more. colors as unsigned bytes. using globals to pass data to/from callback routines. menus create add entry add submenu attach to mouse button menu callback arg is the int key associated with that menu entry pushing and popping attributes writing text setting position writing char updating position by width of char

2. Good news: Profs Barb Cutler (CS), Tom Zimmie (Civil), and I just won a National Science Foundation Cyber-Enabled Discovery and Innovation award for $670K, Fundamental Terrain Representations and Operations, which, "unifies the fields of computational geometry, computer graphics, and civil engineering hydrology, resulting in a transformational ability to predict how erosion occurs, specifically in levee failure by overtopping, and, after a failure, to reverse-simulate what happened...." Details. 3. talk today at 3 in JEC 3117 by Shivkumar Kalyanaraman an ECSE prof on leave at Telecom Research Innovation Center (TRIC), IBM India Research Laboratory, Delhi ''Spoken Web: Towards a Telco-hosted Voice-based Web created from Ordinary Cell Phones''. I'll end class a few minutes early so people can attend this.  10 Tues Sep 16 Topics: passivemotion.c. Changes the image depending on where the mouse is, using a mouse passive motion callback. This shows how to answer Friday's question about causing something to happen when you mouse over a menu at the top of the window passivemotion2.c. Extends passivemotion to redraw only when something changes. This prevents the image tearing caused by redrawing during the refresh. It's also more efficient. single_double.c. Shows: The difference between single and double buffering. Creating two graphics windows in one program. Note the order: Set the display mode. Create the window. Register the callbacks. Repeat for each window. Call MainLoop. Mouse input. Changing the idle callback. The new one replaces the previous one. getinfo.c. Shows how to read information about the OpenGL version and how to get internal state variables. This also shows how to access command line arguments. This shows just a sample; there are more. showinput.c. Shows how to get input. This also shows the coordinate system used to report mouse events. Units are pixels.  (0,0) ...... (xmax,0) .... .... .... (0,ymax).....(xmax,ymax) Beyond double buffering: How to avoid tearing caused by swapping the foreground and background buffers in the middle of refreshing the image and the two buffers have different images? One solution is to wait until the vertical retrace to swap the buffers. However, if each buffer takes about 1/60 second to recompute, sometimes more and other times less, then the refresh rate will fluctuate between 1/60 and 2/60 second. Another solution is to use 3 buffers. You display from the 1st, have the 2nd ready to swap with the 1st in the next vertical retrace, and meanwhile compute into the 3rd. This uses 50% more memory. How to fight tearing OpenGL Extension WGL_I3D_swap_frame_lock Smooth Gaming with Triple Buffering AngelCG08.ppt more on callbacks Reading: Angel, chapter 3. Announcements: Homework 4 available, due Sep 23. 11 Wed Sep 17 Topics: chance to talk to Jixu Reading: Announcements: 12 Fri Sep 19 Topics: time.c. Times how quickly a frame with a square can be drawn. square2.c. Demonstrates glutMotionFunc callback. Change glutMotionFunc to glutPassiveMotionFunc to see what happens. manywindows.c. Shows that many top level windows (a new one with each left mouse click) can be dynamically created. paintxor.c modified by paint.c to write triangles into the color buffer in XOR mode. Everything else is still written in COPY mode. XOR mode is useful for cursors and rubberbanding because XORing the same object twice restores the original buffer. AngelCG09.ppt Better interactive programs AngelCG10.ppt Geometry Reading: Announcements: By popular requests, homeworks will henceforth be due on Fridays. 13 Tues Sep 23 Topics: I will present transformations 3 different ways to help you understand this important topic. AngelCG11.ppt Representation AngelCG12.ppt Transformations My note on homogeneous coordinates and projections demoed by Albrecht Durer (The following display better in Firefox than Internet Explorer.) Homogeneous matrix examples, p' = M p for Translate by (1,2,3): {$M = \left(\begin{array}{cccc} 1 & 0 & 0 & 1\\ 0 & 1 & 0 & 2\\ 0 & 0 & 1 & 3\\ 0 & 0 & 0 & 1\end{array} \right)$} . This also works: {$M = \left(\begin{array}{cccc} 2 & 0 & 0 & 2 \\ 0 & 2 & 0 & 4 \\ 0 & 0 & 2 & 6 \\ 0 & 0 & 0 & 2 \end{array} \right)\$} Rotate around Z axis by an angle whose cosine is 0.6: {$$M = \left(\begin{array}{cccc} .6 & -.8 & 0 & 0 \\ .8 & .6 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \end{array} \right)$$} Reading: Announcements: Tomorrow, go to Tiemann's talk. The final exam has been set for Fri Dec 12 11:30-2:30. 14 Wed Sep 24 Topics: Michael Tiemann, Red Hat, Exonovation--Leveraging Innovation from the Edge, DCC324 Reading: Announcements: 15 Fri Sep 26 Topics: My note on 3D rotation all rigid transformations in 3D that don't move the origin have a line of fixed points, i.e., an axis, that they rotate around. deriving the vector formula for a rotation given the axis and angle computing the matrix from a rotation axis and angle testing whether a matrix is a rotation if it is, then finding the axis and angle Bill Jacobs' OpenGL video tutorial - excellent Reading: Announcements: The display list question from homework 4 is postponed until the next homework. Next Wed, go to the Network-Centric Data Acquisition talk 16 Tues Sep 30 Topics: My note on homogeneous coordinates and projections demoedby Albrecht Durer in more detail. My note on 3D rotation in more detail Reading: Announcements: Homework 3 solution online. Dreamworks is visiting RPI around Nov 4-5, to give a talk and interview students. If interested, contact the CDC. 17 Wed Oct 1 Topics: special talk, Dr. Gavin Pearson, Ministry of Defense in the UK, The Coming Transformation of Network-Centric DataAcquisition: Concept, Technologies, Benefits andChallenges, Lally 102 Reading: Announcements: 18 Fri Oct 3 Class cancelled on 9/9 by Provost. 19 Tues Oct 7 Topics: Review for midterm exam Announcements: What do you think of my replacing my lectures with pointers to distinguished external speakers, such as on open SW? Do you want to use calculators in tomorrow's exam? I'm working to set up a behind-the-scenes tour of EMPAC. The video and audio capabilities are incredible. 20 Wed Oct 8 Topics: Midterm examAnnouncements: Calculators, and any books, papers, and notes are allowed. Computers (above the level of calculators), communication tools, and sharing material with other students are not allowed. DreamWorks Animation will be coming to campus on Friday, February 29th. They are very interested in interviewing seniors in EMAC, EART and CSCI for a variety of full-time positions (Effects Animators, Effects Developers, Crowd Simulation Animators, Character FX Animators, Technical Directors). The RedHawk JobLink Job ID is 691510 for the full-time position, and #691536 for summer internships (use job ID in Keyword field). Resume submission ends on February 19th. ... DreamWorks's URL is: http://www.dreamworksanimation.com. DreamWorks will be making a presentation that is open to all students on Friday, 02/29 at 4:00 PM in Sage 3303. (More info is available.) Homework Solution4.pdf online. 21 Fri Oct 10 Topics: displaylist.c - sample display list program. AngelCG13.ppt OpenGL transformations # Note that the last transformation catenated onto  the current matrix is the first transformation applied to the object.  (Unless I hear objections) I'll defer quaternions until later (if there's time).  # More info is in chapter 4. AngelCG14.ppt Model Building This topic becomes ever more important as your models get bigger. The goal is to store large models in a more organized way, and then render them with fewer function calls. We start to see the separation of geometry from topology. A goal is to represent one piece of info, such as a vertex location, only once. Another goal is to store things that change more often (geometry), separately from things that don't (topology). AngelCG15.ppt Classical viewing This is largely obsolete. However you should recognize the terms. Vanishing points is useful for drawing perspective objects by hand. AngelCG16.ppt Computer viewing There are utility routines to help specify the camera and projection. The big idea is view normalization or projection normalization. We want to view the object with our desired perspective projection. To do this, we transform the object into another object that looks like an amusement park fun house (all the angles and lengths are distorted). However, the default parallel projection of this normalized object gives exactly the same result as our desired perspective projection of the original object. Therefore, we can always clip against a 2x2x2 cube, and project thus: (x,y,z)->(x,y,0) etc. More info is in Angel, page 270 and the next slide set. Reading: Chapter 5. Announcements: Homework 5 online. 23 Wed Oct 15 regular lecture.Topics: AngelCG17.ppt Projection matrices AngelCG18.ppt Shading I The big idea is the Phong shading model. AngelCG19.ppt Shading II We start to get into OpenGL specifics. Reading: Announcements: 24 Fri Oct 17 Topics: AngelCG20.ppt Shading in OpenGL Reading: Announcements: 25 Tues Oct 21 Topics: cubeview.c. Shows smooth shading the faces of a cube, and rotating it. See Angel 5.10. sphere.c. Shows 3 modes of shading a sphere with different levels of accuracy. shadow.c. Shows how to create a shadow onto a flat surface by projecting the object onto that surface. See Angel 5.10. tutors_src.zip. Nate Robbins's light tutorial. Reading:# Angel 5.10, 6. Announcements: Tomorrow is a regular lecture. 26 Wed Oct 22 Topics: Today is a regular lecture. Computer graphics in the real world Forma Urbis Romae - reconstruction of a street map of 211AD Rome from 1186 pieces like this one: Another OpenGL tutorial The Practical Physicist's OpenGL tutorial Edward S. Boyden Steve Baker's notes on some graphics topics: AngelCG21.ppt Implementation I - Rasterization, Clipping We now change from learning the API to studying how things are implemented under the API. Advantage of using Cohen-Sutherland line clipping. You still have to include the code for the detailed clipping since sometimes the CS algorithm reports that it doesn't know. However often it can classify the line segment (or the box with everything inside) as either completely in or else completely out. In that case, the rest of the pipeline is faster. However you have to write more lines of code. You don't have to know how this works, only what its purpose is. AngelCG22.ppt Implementation II - Clipping, Visibility Reading: Announcements: 27 Fri Oct 24 Topics: Properties of the various visibility methods: Painters: Sorting the faces is hard and maybe impossible. Then you must split some faces. However sometimes some objects are always in front of some other objects. Then you can render the background before the foreground. Z-buffer: Subpixel objects randomly appear and disappear (aliasing). Artifacts occur when objects are closer than their Z-extent across one pixel. This happens on the edge where two faces meet. BSP tree: In 3D, many faces must be split to build the tree. Bresenham presents the fast line and circle drawing algorithms better than the text. For more info on testing whether a point is in a polygon, see my note. Also see the comp.graphics.algorithms FAQ, question 2.03. The flood fill will fail if the interior is not connected. That happens when two close edges cause adjacent pixels to be set. It will also fail if there is a gap in the perimeter - the color will leak out. The scan line fill must handle special cases like a vertex being on a scan line. My solution is to pretend that any vertex on a scan line is really slightly above. This is a simple case of a serious technique called ''Simulation of Simplicity'' invented by Herbert Edelsbrunner. One problem with interpolating color inside a polygon is that you may be creating successive frames of a video. Then, the color must be consistent from frame to frame even as the object is moving. E.g. if a quadrilateral rotates, it may be triangulated differently depending on its orientation. The two different triangulations may get shaded differently. Anti-aliasing is a big and important topic. Reading: Announcements: Term project proposal due, containing: title, team members (name, email, RIN), 100 word summary. Email to TA Jixu Chen, chenjFOUR ATrpiDOTedu 28 Tues Oct 28 Topics: Bresenham circle algorithm. AngelCG23.ppt Implementation III, ctd Reading: chapter 7. Announcements: 29 Wed Oct 29 Topics: regular lecture. AngelCG24.ppt Buffers OpenGL and images: Following the less is more design philosophy, OpenGL has no facilities for reading and writing image data to disk. It does let you bitblt data between its buffers and your arrays. Otherwise, use your choice of tools. Netpbm is a large set of standalone command line programs for processing and converting image files. These programs follow the Unix pipe metaphor, and can be chained together. Imagemagick is another large set of standalone command-line programs for mogrifying images. You can run any standalone program from inside your C program with the system call. The only way to get info back and forth between that program and your program is via a file. It is dangerous to run system with an argument partly supplied by the user unless you thoroughly check for metachars. That, in a slightly different context, is the flaw exploited by the SQL injection attack on RFID tags. xv is a nice interactive shareware program, which I used in class today. I actually bought 2 licenses years ago. PPM (portable pixmap) is a file format that is so simple you can easily write programs to read or write it. Its files are big, but you can use one of the other above systems to convert. I showed this in class, and Angel's slides also do. Reading: chapter 8. Announcements: Fri Oct 31 No class; prof running Fall Workshop in Computational Geometry at RPI Tues Nov 4 Announcements: No class today, prof and students presenting 3 papers at 16th ACM SIGSPATIAL International Conference on Advances in Geographic Information Systems (ACM GIS 2008) On Nov 12, Dreamworks will give 2 talks, one at the same time as our lab. 30 Wed Nov 5 Topics: chance to talk to Jixu Reading: Announcements: Fri Nov 7 Topics:No class, prof and students presenting 3 papers at 16th ACM SIGSPATIAL International Conference on Advances in Geographic Information Systems (ACM GIS 2008) Reading: Announcements: progress report due; email to TA Jixu Chen, chenjFOUR ATrpiDOTedu. 31 Tues Nov 11 Topics: AngelCG25.ppt Texture mapping The hard problems with texture mapping are: Determining what texel in the texture map corresponds to each pixel in the frame buffer. The involves inverting some complicated mappings. That the pixel in the frame buffer is rarely the same size as the corresponding texel, but may be much larger or smaller. That varies with the distance of the object from the camera. Solutions include various smoothing techniques, and using a hierarchy of texture maps of different resolutions. AngelCG26.ppt OpenGL Texture mapping Reading: Announcements: Erin Glasheen specifically welcomes ECSE-4750 students to the morning Dreamworks talk (as well as the afternoon one). BTW, not many students signed up for job interviews or internships. ?!! Next Wed at 4pm, Harry Lewis, former Dean of Harvard College will talk about his new book, Blown to Bits, about privacy in the digital age. CC324. On Dec 4 at 3pm, Mark M. Little '82, Ph.D., Senior Vice President and Director of GE Global Research will talk in the Biotech Auditorium. Little shows that it is possible to survive RPI (and prosper). Reasons to attend talks like this is include to see how he talks and what he thinks is important. 32 Wed Nov 12 Topics: No lab because: 10:30am Dreamworks talk Sage 4101 4pm Dreamworks talk Sage 3303. Reading: Announcements: 33 Fri Nov 14 Topics: tutors_src.zip. Nate Robbins's tutorials (ctd). fog texture http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=06 another nice and very detailed texture programming tutorial, from Neon Helium productions OpenGL_Tutorial_Framework:Texture_Mapping AngelCG27.ppt Compositing and blending AngelCG28.ppt Programmable pipelines Reading: Announcements: 34 Tues Nov 18 Topics: (We'll do these in more detail in the spring.) AngelCG28.ppt Programmable pipelines AngelCG29.ppt GLSL I AngelCG30.ppt GLSL II Reading: Announcements: On Fri, go to the Lenovo talk. Sign up with Jixu for a 5-minute presentation of your project on Dec 2 or 3. Lockheed Martin has summer internships available. See Pat Rickert. 35 Wed Nov 19 Topics: Harry Lewis DCC324 Reading: Announcements: 36 Fri Nov 21 Topics: On Friday 11/21 Marc Cohen, a Lenovo executive, will be on campus and will give a presentation at 2pm in Ricketts 203. The talk is titled ''Designing Exceptionally Engineered Notebooks''. It will cover Lenovo's approach for defining and designing ThinkPad notebooks. The acclaimed X300 and the newly announced W700 mobile workstation will be used as examples. Mark will also give a view of where technology is headed and what to expect in notebooks over the next several years. The talk will give an interesting window into how a successful company conceives and introduces products. There will also be time for questions and answers on subjects ranging from technology and notebook design to the role of an engineer and value of a business degree in a technology company. Lenovo's Mark Cohen is a Distinguished Engineer and Vice President in the Notebook Business Unit. He is responsible for managing Lenovo's ThinkPad portfolio of products. His responsibilities include product definition and managing the development process. Mark has a strong engineering background and has just completed an MBA program to round out his educational background. Reading: Announcements: progress report due; email to TA Jixu Chen, chenjFOUR ATrpiDOTedu. 37 Tues Nov 25 Topics: Vertex and fragment shaders from chapter 17 of the OpenGL SuperBible. AngelCG39.ppt Curves and surfaces in OpenGL Reading: Announcements: Here is an interesting new book: OpenGL® ES 2.0 Programming Guide by Aaftab Munshi, Dan Ginsburg, Dave Shreiner. Should I move the course this way in the future? If you got value from this course, please fill out your course surveys (and say nice things if appropriate). This makes the department head like me and continue to let me teach it. I like this topic, spent a lot of time of it, and hope you liked the result. If you haven't given a preference to Jixu for which day next week you'd like to present your 5 minute fast forward talk on your project, he will assign a day. Tues Dec 2 Topics: Five minute term project presentations. Schedule Reading: Announcements: Wed Dec 3 Topics: Five minute term project presentations. Reading: Announcements: Fri Dec 5 Topics: review for final exam Reading: Announcements: Tues Dec 9 Topics: 2pm: office hours by Chen in Lally 104 Wed Dec 10 Topics: 4pm: office hours by Chen in Science 2C14 (not 2C22) Fri Dec 12 Topics: Final exam. 11:30-2:30, Sage 3510.