1CS148 OverviewDisplay DevicesCS148: Intro to CGInstructor: Dan MorrisTA: Sean WalkerJune 21, 2005Outline for today{ What is computer graphics?{ Intro to CS148{ Some terminology{ Display devices{ Graphics/GUI programmingOutline for today{ What is computer graphics?{ Intro to CS148{ Some terminology{ Display devices{ Graphics/GUI programming2Computer graphics is…{ Computer-generated artwork{ Interactive 2D graphics{ Interactive 3D graphics{ Photorealistic 3D graphics{ Photorealistic 3D video{ Digital photographyOne definition to rule them all…{ Computer graphics is the science of coloring pixels on a display to trick the viewer into seeing an object or a scene.3What type of computer graphics will we address this quarter?{ CS148 is (mostly) about interactive 3D graphicsz A little bit on 2D graphicsz A little bit on non-interactive 3D graphicsz No image processing or digital photography{ CS448a: Computational photography{ CS448b: Visualization{ CS348a: Geometric modeling{ CS348b: Rendering{ CS223b: Computer visionOutline for today{ What is computer graphics?{ Intro to CS148{ Some terminology{ Display devices{ Graphics/GUI programming{ Introduces important mathematical concepts in graphics{ Primarily focused on giving you a working knowledge of OpenGLz What you learn will generalize to other 3D environments, e.g. DirectX, Matlab, Amira, Maya{ Not as theoretically in-depth as CS248; if you plan to continue in graphics at Stanford, you should look at CS248CS148: Intro to GraphicsAdministrative Blah Blah 1: Grading{ 50% Programming Projects{ 20% Midterm{ 30% Final{ You need passing work on both exams and all projects to pass{ This part of the lecture is boring so I’m including thoroughly gratuitous pictures of cute puppies to keep you awake:Administrative Blah Blah 2: Late Policy{ You have three “late days” for the quarter{ 25% lost per day after that{ 3 hours late is 1 late day{ For group projects, all members lose late days for late submissions{ Make your life easier and submit on timeAdministrative Blah Blah 3: Textbook{ OpenGL Programming Guide v1.4, Fourth Edition (“The Red Book”) is the official text{ Second edition is online and linked from the website (85% similar){ Handouts posted the night before class – print them out if you want them in class4Administrative Blah Blah 4: Math{ There is math in graphics{ This is not a math course{ Look over the “essential math”handout{ Get in touch with us if youhave questionsAdministrative Blah Blah 5: Programming{ OpenGL and GLUT (GL Utility Toolkit){ All grading will be done on the myth, firebird, and raptor Linux machines in Sweet Hall{ You can develop at home if you like, and we’ll provide Windows project files, but be sure to test on the Linux machines{ Subtle subtext: there is substantial programming in CS148Wait! That’s not a puppy!Administrative Blah Blah 6:Getting in Touchhttp://[email protected]’s office hours:Tuesday, 1pm-3pm, Gates 116Or email [email protected]’s office hours:TBASummary: How to Succeed in CS148{ Come to class{ Start the projects early{ The staff will not debug your programs!{ Be creative: we want to give you extra creditz Suggest optional project components or whole projects from your own work{ Submit questions for examsOutline for today{ What is computer graphics?{ Intro to CS148{ Some terminology{ Display devices{ Graphics/GUI programmingTerminology:PRIMITIVES are made of PIXELS{ Pixels are the dots that make your display, you have on the order of a million of them{ Primitives are 2D shapes… generally lines, triangles, and quads (4-sided polygons)5Terminology:OBJECTS are made of PRIMITIVES{ Even 3D objects are made of 2D primitives{ Objects can be tens to billions of primitives{ More primitives Æ smoother objectsFun With Primitives: Make an Octagon From…TrianglesQuadsOne quad + triangles (why?)Terminology:SCENES are made of OBJECTS{ Tens to thousands of objects per scene{ Millions of primitives in many scenes{ Speed is huge in graphicsOutline for today{ What is computer graphics?{ Intro to CS148{ Some terminology{ Display devices{ Graphics/GUI programmingAn ideal graphics programming interfaceDear Monitor,Please draw a green spaceship in which a purple alien is shooting at a blue robot.Sincerely,DanWhat can your monitor do?{ You can’t tell your monitor “draw some spaceships”{ You can’t even tell your monitor “draw some triangles”{ Your monitor only knows how to turn dots on and off.6Raster-Scan Displays: CRT’s{ Incoming volts turn on electron gun{ Magnetic field bends beam toward screen{ Electrons hit tiny phosphor elements to turn them on{ You see pixels{ Beam sweeps over and over at about 60Hzz Why so fast?Raster-Scan Displays: LCD’s{ Grid of wires puts volts on crystals{ Crystals twist to block light or let it pass{ Big white light shines behind the whole grid{ A red, green, or blue filter sits in front of each crystal{ Still scans from side to side and top to bottomRaster-Scan Displays: Summary{ All a raster-scan display can do is scan through every pixel sequentially.{ It needs instructions about what to do for every pixel.Doing it by handfor(int i=0; i<height; i++) {for(int j=0; j<width; j++) {put out the volts for the current pixel;wait until it’s time for the next pixel;}}This would not be very much fun…Disappointment?Dear Monitor,Communicating with you seems terribly tedious. I’m dropping graphics and taking compilers instead.Sincerely,DanPS Don’t call me either.Solution: the framebuffer{ Graphics card takes care of talking to the monitor{ You just need to fill up an array telling the graphics card which colors should go where7Framebuffer data11 (brightest)112/3 (brighter)101/3 (dim)010 (none of this color)00Relative intensityBit values1bpp black-and-white display6bpp color displayWhat color is 000101 in a 6bpp BGR framebuffer?Real-world framebuffers{ Typically 24bpp or 16bpp{ Typically 1280x1024{ How much memory does this take up?Has this made our lives easier?{ Filling the framebuffer with pixels manually isn’t practical{ Even simple images have thousands of pixels{ Try drawing this baby pixel-by-pixel…Primitives save the dayvoid circle(int cx, int cy, double radius, boolfilled);void rectangle(int cornerx, int cornery, double width, double height, double angle, boolfilled);{ Now drawing the baby doesn’t seem so bad…How does all this fit into CS148?{ Thursday’s class and Project 1: Turning
View Full Document