1
Binghamton University
EngiNet™
State University of New York
Thomas J. Watson
School of Engineeringand Applied Science
EngiNet™
WARNING
All rights reserved. No Part of this video lectureseries may be reproduced in any form or by any
electronic or mechanical means, including the useof information storage and retrieval systems,
without written approval from the copyright owner.
©2007 The Research Foundation of theState University of New York
CS 460/560
Computer Graphics
Professor Richard Eckert
Lecture # 1
January 22, 2007
CS-460/560Computer Graphics
Richard R. Eckert
M,W 8:30-9:55 A.M.EBJ-15
Lecture 1 - 1/22/2007
2
Contacting Me
? Office: EB-N6
? Office Hours: Tue. 10:00-11:30, Thur. 9:00-10:30 A.M. ? Office Phone: 607-777-4365
? Department phone: 607-777-4802? email: [email protected]
? My web page: www.cs.binghamton.edu/~reckert/
– See link to: CS-460/560 (Computer Graphics)? Listserv: [email protected]
– Activated during the first week of classes
Course Materials? Text book
– D. Hearn and M.P. Baker, "Computer Graphics with OpenGL“, 3rd Edition, Prentice Hall
? Online notes– CS-460/560 link on my home page
• Lots of information available there– CS-360 link on my home page
• Information on using Visual Studio, VC++, C#, Example Programs
? Classroom lecture videos: EngiNet, CS-560? Old EngiNet Classroom Lecture Tapes/CDs
– Available from instructor in emergencies
? PowerPoint slides in PDF format– Will be online at course web site
Using EngiNet Angel System? http://www.enginet.binghamton.edu/angel
– User Name: CS560
– Password: CS560– Under “My Courses” find CS-560
• Will take you to the Syllabus page
– Clicking on “Lessons” tab takes you to links to online materials and streaming video of lectures
• Streaming video is only for EngiNet students• In emergency situations CDs of the lectures will be
available to other students a couple of days after the class– See professor
Software? Microsoft Visual Studio 2005 Professional
Edition– In all Pods & Watson School Microlab– Available to Watson School students (free)
• Through Microsoft Academic Alliance– Go to:
• Micro.binghamton.edu/downloads.htmor• msdn04.e-academy.com/binghamton_watson
– Search for product• To download you will need a password• You should have it or it will be emailed to you
Course Prerequisites? Data Structures (CS-240)? Basic Knowledge of Linear Algebra
– Matrix/Vector Manipulation
? C or C++ or C# Programming– Visual C++ Ideal
• But we will do a quick review• Extensive notes/examples at CS-360 web pages
? Some Knowledge of Computer Organization– e.g., CS-220
Course Evaluation
? CS-460:– 2 Term Exams (20% each)
– Programming Assignments (40%)– Final Exam (20%)
? CS-560:– 2 Term Exams (19% each)– Programming Assignments (38%)
– Research Paper or Project (6%)– Final Exam (18%)
3
Course Schedule (by weeks)
? Introduction/Applications/History, Introduction to Windows Programming
? Computer Graphics Hardware and Software? Graphics Output Primitives: Scan converting
lines, polygons, circles, curves, text; Introduction to OpenGL
? Display Attributes and Area Fill Algorithms? 2-Dimensional Geometric Transformations? 2-D Windows, Viewports, and Clipping
*** Term Examination # 1 ***
Course Schedule (by weeks)
? Interactive 2-D Graphics: Input Devices, GUI Techniques
? Segmentation, Hierarchical Modeling; PHIGS, OpenGL
? Curved lines and surfaces, parametric equations, Bezier and B-spline curves
? Animation, Sprites, Game Development, DirectX ? 3-D Graphics: Modeling & Transformations? 3-D Graphics: Viewing and Projections
Course Schedule (by weeks)
? Hidden Surface Removal
*** Term Examination # 2 ***? Illumination, Reflection, Shading,
Texturing, Ray Tracing, Radiosity? Fractals, Iterated Function Systems, L-
Systems, Particle Systems, Escape-time algorithms, Chaos
Introduction to Computer Graphics
Computer Graphics?Using a computer to generate visual
images?Definition of Computer Graphics:
– Creation, storage, manipulation, and display of models of scenes using the computer
? Interactive Computer Graphics:– User dynamically controls displayed image
attributes by means of interactive input devices
Motivation
?Human visual channel highly developed
? Efficient for communicating complex ideas
4
Related Field: Image Processing
? Image enhancement/understanding? Reconstruction of objects from images? Computer Graphics--Synthesis of images? Image Processing--Analysis of images? Image Processing subfields:
– image enhancement– Image understanding– computer vision– pattern recognition (A.I. important)
Computer Graphics & Image Processing
Three Phases of Computer Graphics
? Modeling– Representing objects/scenes
mathematically?Rendering
– Producing an image from a model? Animation
– Making an image move
Features of Computer Graphics Models
?Output primitives:– building blocks
?Data structures:– how primitives relate to each other
Levels of Complexity of CG
? 2-D line Drawings: Primitives? 2-D colored images: Area fill? 3-D line drawings: 3-D to 2-D projection? 3-D colored images: Hidden surface removal,
color, shading? 3-D photorealistic images: materials
properties, lighting, reflection, transparency, shadows (physics), complex object models
? Animation at all levels: Movement
2-D Line Drawing
5
2-D Colored Image 3-D Line Drawing
3-D Line Drawing (some hidden surfaces removed)
3-D Colored Image (flat shaded)
3-D Colored Image (smooth shaded) 3-D Photorealistic Image (ray traced image with texture mapping)
6
3-D Photorealistic Image (fractal mountains, L-system plants)
An Animation of a 3D Scene? Frames generated by ray tracing
Some Applications of CG? Data Presentation (statistics, business,
scientific, demographics...)? CAD, CAM, CIM? Painting/Drawing systems? TV Commercials? Entertainment
– Video Games– Motion Picture Industry
? Cartography? Computer Art
Graphics Applications
?Computer Aided Design (CAD)
Graphics Applications
? Entertainment: Cinema
Pixar: Monster’s Inc.
?Desktop Publishing? Architectural Design? Simulation of Reality
– Flight simulators– Ground vehicle simulators– Arcade games– Virtual reality devices
Graphics Applications
7
Simulation Graphics Applications
? Scientific Simulation/Visualization– Use graphics to make sense of vast amounts of
scientific data– Use when too dangerous/expensive or impossible to
do real experiments
? Hypermedia– Integrate broadcasting, computing, publishing
? Education and Training? Process Control? CASE
Graphics Applications
? Scientific Visualization
Graphics Applications? Image Processing/Enhancement? Medicine
– Computed Tomography (CT, CAT Scan)– X-ray, ultrasound, NMR, PET:– All can give 3-D images of human anatomy– Computer-aided Surgery
? GUIs? World Wide Web Development? New Stuff--can't even be imagined
Graphics Applications?Medical Visualization
MIT: Image-Guided Surgery Project
The Visible H
uman P
roject
Computer Graphics--
? A huge, fast-moving, exciting field that integrates the best of art and science
?Needs new Renaissance men & women– Bright and analytic enough to understand
the science & math– Sensitive and creative enough to do the art
? Both left and right sides of the brain required!
8
Brief History of Computer Graphics
? Early 50s--MIT Whirlwind Computer– First computer-driven CRT & keyboard input
? Middle 50s--SAGE Air Defense System– Selection of targets with light pen– First interactive graphics
? Early 60s--Ivan Sutherland’s PhD thesis– “Sketchpad: a Man/Machine Graphical Comm. System”– Proposed first model for interactive graphics– Identified basic data structures– Discovered important algorithms
History of CG (continued)? Middle 60s--GM's Digigraphic Design System
– Beginning of CAD– Costly hardware– Hard-to-write programs– Non-portable software
? Late 60s--Tektronix Direct View Storage Tube– First “inexpensive” graphics display device
? ARPA/SRI– Doug Engelbart
? Xerox PARC– Alto computer
History of CG (continued)
? Early 70s -- First microprocessors– first microcomputers– inexpensive– primitive graphics capability
? Late 70s -- First graphics software standard – (CORE -- ACM SIGGRAPH, 1977)– first attempt at portable graphics software
History of CG (continued)? 1980s
– Micros with extensive graphics capabilities
? Introduction of first Work Stations (graphics engines)– Graphics standards with increased capabilities
GKS (1984), GKS-3D (1988), PHIGS (1988)– Microcomputer GUIs (Macintosh, Windows, X
Windows)
History of CG (continued)
? 1990s - 2000s– Graphics engines – many algorithms implemented in hardware– Fast, powerful, cheap– Multimedia systems– Windows-95/98/NT/2000/XP– X Windows with PEX– GL, OpenGL industry standard graphics libraries– Microsoft Direct-X– Web-based graphics
Microsoft Visual Studio .NET:An Integrated Windows Program Development
Environment
9
Using Microsoft Visual Studio .NET
? Self-contained environment for Windows program development:– creating– compiling– linking– testing/debugging
? IDE that accompanies Visual C++, Visual Basic, Visual C#, and other Microsoft Windows programming languages
? See Chapter 2 of the Deitel text? Also Appendix C of the Gregory text
.NET Architecture
Compilation in the .NET Framework
CommonLanguageRuntime
Visual Studio Capabilities? Generate starter applications without
writing code? View a programming project in many
different ways? Edit source, header, and include files? Build the application’s user interface
visually? Compile and link? Debug an application while it runs? Obtain online help? Lots of others
Some Visual Studio Components
? The Editors:C, C++, C#, VB source program text
editors• cut/paste, color cues, indentation• generate source text files
Resource Editors• icons, bitmaps, cursors, menus, dialog boxes, etc.• graphical, WYSIWYG, Integrated• generates resource script (.rc) files• integrated with text editor• Done visually
? C/C++ Compiler– translates source programs to machine
language– detects and reports errors– generates object (.obj) files for linker
? Resource Compiler– Reads .rc file– Generates binary resource (.res) file for
linker
VC++ Unmanaged Code Compiler
10
The Linker
?Reads compiler .obj/.res files? Accesses C/C++/Windows libraries?Generates executable (.exe or .dll)
The Debugger
? Powerful source code debugger? Integrated with all parts of Visual Studio? Features
– breakpoints– tracing through/over functions– variable watch windows– much more
The Wizards? AppWizard
– Windows code generator for MFC apps– automatically creates working program
templates & skeleton code
? ClassWizard– facilitates easy extension of AppWizard-
generated classes– creation of new classes– used to tailor AppWizard-generated MFC &
.NET skeletons– Replaced by Properties Window in .NET
Help? Hover over key words in edit window and a
one-line help message appears? More detailed help can be obtained by:
– ‘Start Page’ – ‘Developer Center’• To access the MSDN Online Library
? Easier to use the ‘Help’ Menu Item– ‘Dynamic Help’ – context sensitive
• Click on text in edit window and corresponding topic appears in help window
• Click on topic in help window to get help
– ‘Contents’: Select a topic– ‘Search’: Enter a topic– ‘Index’: Enter a topic
MSDN Library (on Web)
?Go to: http://msdn.microsoft.com– Search MSDN for desired topic– Good URL for MFC:http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/vcmfc98/html/_mfc_class_library_reference_introduction.asp
11
Using Visual Studio .NET? To prepare many kinds of applications
– Win32 Console Applications (DOS programs)– Win32 API Apps in C or VC++– MFC Apps in VC++– DLLs– .NET Windows Forms Apps in Managed C#,
VB, C++, and other languages– ASP.NET Web Apps and Services– ADO.NET Data Base Apps– Others
Visual Studio Layout? Menu Bar? Several Tool Bars? View Windows (to the side)
– Solution Explorer– Class View– Resource View– Properties Window
? Working Area (main window)– Text Editor to enter/modify source code– Resource Editors– Tab between different work areas
? Output Window & Status Bar (bottom).– System Messages (errors)
? Windows can be moved around, docked and undocked
Toolbars
? Contain Icons--instant routes to main menu functions
? Many of them? May not be visible? If not, right click on any visible toolbar? Brings up following popup window? Can activate a toolbar by clicking on its
check box
Keyboard Shortcuts
? All Menu/Toolbar selections are available from the keyboard using key combinations
?Can be faster?More information in Online Help
– ‘Index’ | ‘Keyboard Shortcuts’ | ‘Predefined’
12
Solutions and Projects? Solution
– A single application– Can contain one or more projects
• In Managed applications, projects can be in different languages
– Overall solution information stored in a .SLN file– Open this when you want to work on a solution
? Project– Collection of files:
• Source, headers, resources, settings, configuration information, many more
Important Visual Studio Generated Files
? .sln Solution? .vcproj Project? .c, .cpp, .cs C/C++/C# Windows App src code? .h C/C++ header? .rc Resource script? .res Compiled resource? .ico Icon? .bmp Bitmap image? .exe Executable program? .dll Dynamic Link Library? .aspx ASP.NET Web Form src code? .asmx ASP.NET Web Service src code
? Many are very big and can (should) be removed!? .obj Compiler machine code translation? .ilk Incremental link file? .pch Precompiled header (huge!!!)? .pdb Precompiled debugging info? .idb Incremental debug info? .ncb Supports viewing classes? .aps Supports viewing resources? others
Temporary Visual Studio Generated Files
Program Configurations
?Debug– appends debugging information– produces more and larger files
?Release– no debugging information– optimized for size, performance, &
efficiency
Setting the Configuration
?Click ‘Build’ on Main Menu?Choose ‘Configuration Manager’?Choose desired configuration (‘Debug’
or ‘Release’) in Configuration Manager’s ‘Active Solution Configuration Box’
?Default is ‘Debug’
Creating a Win32 API Windows Application with Visual Studio
? Startup– click ‘Start’ on Task Bar – ‘All Programs’– ‘Microsoft Visual Studio .NET 2005’ | ‘Microsoft
Visual Studio .NET 2005’
? Creating a new Win32 API solution– ‘File’ | ‘New’ | ‘Project’ from Menu Bar– In ‘New Project’ box, select ‘Visual C++’ ‘Win32’ from
‘Project Types:’ & click on ‘Win32 Project’ in ‘Templates’
– Set the ‘Location’ to a convenient directory & name the project (e.g. win32app1) & click ‘OK’
• All solution files will be in a new directory with that name
13
?Click ‘Application Settings’ in resulting ‘Win32 Application Wizard’ Box– Select ‘Windows Application’ from ‘Application
Type’ radio buttons– Select ‘Empty Project’ from ‘Additional Options’
check boxes– Click ‘Finish’
? Inserting source files into project:– Open a new C++ file & type or copy/paste the code into
the program:• ‘File’ | ‘New’ | ‘File’ from menu• Choose ‘Visual C++’ from ‘Categories’, C++ file (.cpp) from
‘Installed Templates’, & click ‘Open’• Type or paste source code into the resulting Edit window• Save the file in the project’s subdirectory as a C++ source file,
giving it an appropriate name (e.g., win32app1)– Add the source file to the project:
• Choose ‘Project’ | ‘Add Existing Item’ from menu• Click on the file you saved (e.g. win32app1.cpp)• Confirm that it was added to the project by expanding ‘Source
Files’ in the Solution Explorer Window– If Solution Explorer is not visible, select ‘View – Solution Explorer’
from the menu
?Alternative Way of Adding a Source File to a Project:– You can also copy an existing source code
file into the project’s subdirectory– Then as before:
• Choose ‘Project’ | ‘Add Existing Item’ from the menu
• Select the .cpp file & click ‘Open’– Should appear in Solution Explorer window– Open it by double clicking on it
?Building the Solution:– ‘Build’ | ‘Build Solution’ from menu– Project will be compiled/linked– Messages/errors will appear in Output Window
?Running the Program:– ‘Debug’ | ‘Start’ from menu
• Shortcut key: F5
– Or ‘Debug’ | ‘Start Without Debugging’ from menu• Shortcut key: Ctrl-F5
Compiling from Command Line? Command Line Compilers:
– C++: CL.EXE– C# : CSC.EXE– Visual Basic: VBC.EXE
? All are run from a DOS session, but directory paths must be set correctly
? Easiest to start a Visual Studio .NET Command Prompt (paths already set)– From Task Bar:
• Start | All Programs | Microsoft Visual Studio 2005 | Visual Studio Tools | Visual Studio 2005 Command Prompt
Command Line Compiling, continued
? To compile our first Visual C++, Win32 API application from the command line:– cl kernel32.lib user32.lib gdi32.lib win32a1.cpp– Note that any required libraries (DLLs) must be
specified
? There are many compiler options:– See Online Help:– ‘Index’ | ‘cl.exe compiler’ | ‘building programs’– For C#: ‘Index’ | ‘csc.exe’
? We won’t be using them much in this course, but they’re there if you need them
14
?Cleanup:– Copy solution, project, source, header,
resource files to disk– Copy .exe file from project's Debug directory– Best: Delete all temporary files & copy entire
solution (project directory) to floppy or CD– Delete project directory from hard drive
? Exiting Developer Studio:– ‘File’ | ‘Exit’ from menu