Download presentation
Presentation is loading. Please wait.
Published bySharon Parker Modified over 9 years ago
1
Scientific Visualization with OpenGL 22 February 2006
2
Agenda Wrap-up Project 1 OpenGL Homework –Read Chapters 1 and 2 in Cunningham –Study for next week’s Quiz 3 User Testing Chapter 0 – Getting Started in Cunningham
3
Computer Graphics Definition producing pictures or images using a computer 40 years ago –drawing lines on a cathode ray tube Today –produce images indistinguishable from photos –produce “realistic” and animated dinosaurs –produce 3D worlds
4
Computer Graphics Applications Display of Information Design Simulation User Interfaces
5
Display of Information Maps –GIS –Spatial Resource Planning (SRP) Medicine –MRI –Ultrasound Scientific Visualization –“seeing the unseen” –Visual Human Project –biology –electrophysiology –mathematics
6
GIS Buncombe Co. GIS
7
Spatial Resource Planning Spatially-referenced data within engineering, operations and distribution network management Analogous to what Enterprise Resource Planning (ERP) solutions do for data held in accounting, human resources, procurement and project management systems,
8
Magnetic Resonance Imaging Uses magnetism and radio waves to produce images
9
Ultrasound Images are produced by very high frequency sound waves of between 3.5 to 5.0 megahertz.
10
Scientific Visualization Electrophysiology Computed Potential Distribution on the Cardiac Surface during reentry: Spiral Tip Meandering, an arrhythmia model
11
Design “The evaluation of alternative solutions and the specification of a solution” CAD VLSI design Generate a possible design, test, use solution as a basis for other solution
12
Simulation Flight Simulators Games Educational (edutainment) software Virtual Reality
13
User Interfaces Interaction with computers –windows –icons –menus –a pointing device
14
Frame Buffer Depth -- number of bits used for each pixel –full color systems true color systems RGB color systems 24 or more bits per pixel Resolution -- number of pixels in the frame buffer
15
Output Devices Dominant type of display is the CRT (cathode ray tube). CRT emits light for a short time -- a few milliseconds. For a human to see a steady image the path must be retraced or refreshed at least 50x/sec. How are pixels displayed?
16
How Are Pixels Displayed? Noninterlaced –Displayed row by row Interlaced –Displayed every other row –50-75X/second (50-75Hertz) –60Hz display refreshes the entire screen 30x/sec –Commercial TV
17
Color CRTs 3 phosphors Arranged in (sometimes triangular) triads Shadow mask CRT Screen with small holes ensures only one phosphor is excited
18
Other [Amazing] Raster Output Devices Liquid Crystal Displays (LCD) Printers
19
Ways to Read an Input Device Sampling –What is its input right now ? Event-based –Wait until the user does something
20
Objects and Viewers 3d world Object is a constant Viewer forms the image –human viewing system - back of eye –camera - film plane –different viewers see the same object differently
21
The Human Vision System Resolution –the measure of what size objects we can see –how close we can place two points and they remain distinct Intensity –physical measure of light energy Brightness –measure of how intense we perceive the light to be.
22
Programming with OpenGL Part 1: Background Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts: University of New Mexico
23
Objectives Development of the OpenGL API OpenGL Architecture –OpenGL as a state machine Functions –Types –Formats Simple program
24
Early History of APIs IFIPS (1973) formed two committees to come up with a standard graphics API –Graphical Kernel System (GKS) 2D but contained good workstation model –Core Both 2D and 3D –GKS adopted as IS0 and later ANSI standard (1980s) GKS not easily extended to 3D (GKS-3D) Far behind hardware development
25
PHIGS and X Programmers Hierarchical Graphics System (PHIGS) –Arose from CAD community –Database model with retained graphics (structures) X Window System –DEC/MIT effort –Client-server architecture with graphics PEX combined the two –Not easy to use (all the defects of each)
26
SGI and GL Silicon Graphics (SGI) revolutionized the graphics workstation by implementing the pipeline in hardware (1982) To use the system, application programmers used a library called GL With GL, it was relatively simple to program three dimensional interactive applications
27
OpenGL The success of GL lead to OpenGL (1992), a platform-independent API that was –Easy to use –Close enough to the hardware to get excellent performance –Focus on rendering –Omitted windowing and input to avoid window system dependencies
28
OpenGL Evolution Controlled by an Architectural Review Board (ARB) –Members include SGI, Microsoft, Nvidia, HP, 3DLabs,IBM,……. –Relatively stable –Evolution reflects new hardware capabilities –3D texture mapping and texture objects –Vertex programs –Allows for platform specific features through extensions
29
OpenGL Libraries OpenGL core library –OpenGL32 on Windows –GL on OS X/UNIX/Linux systems OpenGL Utility Library (GLU) –Provides functionality in OpenGL core but avoids having to rewrite code Links with window system –OpenGl does not “do” windowing –Windowing is OS specific
30
GLUT OpenGL Utility Library (GLUT) –Provides functionality common to all window systems Open a window Get input from mouse and keyboard Menus Event-driven –Code is portable but GLUT lacks the functionality of a good toolkit for a specific platform Slide bars
31
Software Organization GLUT GLU GL GLX, AGL or WGL X, Win32, Mac O/S software and/or hardware application program OpenGL Motif widget or similar
32
OpenGL Architecture Immediate Mode Display List Polynomial Evaluator Per Vertex Operations & Primitive Assembly Rasterization Per Fragment Operations Texture Memory CPU Pixel Operations Frame Buffer Geometric pipeline
33
OpenGL Functions Primitives –Points –Line Segments –Polygons Attributes Transformations –Viewing –Modeling Control Input (GLUT)
34
OpenGL State OpenGL is a state machine OpenGL functions are of two types –Primitive generating Can cause output if primitive is visible How vertices are processes and appearance of primitive are controlled by the state –State changing Transformation functions Attribute functions
35
Lack of Object Orientation OpenGL is not object oriented so that there are multiple functions for a given logical function, e.g. glVertex3f, glVertex2i, glVertex3dv,….. Underlying storage mode is the same Easy to create overloaded functions in C++ but issue is efficiency
36
OpenGL function format glVertex3f(x,y,z) belongs to GL library function name x,y,z are floats glVertex3fv(p) p is a pointer to an array
37
OpenGL #defines Most constants are defined in the include files gl.h, glu.h and glut.h –Note #include should automatically include the others –Examples –glBegin(GL_PLOYGON) –glClear(GL_COLOR_BUFFER_BIT) include files also define OpenGL data types: Glfloat, Gldouble,….
38
A Simple Program Generate a square on a solid background
39
simple.c #include void mydisplay(){ glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POLYGON); glVertex2f(-0.5, -0.5); glVertex2f(-0.5, 0.5); glVertex2f(0.5, 0.5); glVertex2f(0.5, -0.5); glEnd(); glFlush(); } int main(int argc, char** argv){ glutCreateWindow("simple"); glutDisplayFunc(mydisplay); glutMainLoop(); }
40
Event Loop Note that the program defines a display callback function named mydisplay –Every glut program must have a display callback –The display callback is executed whenever OpenGL decides the display must be refreshed, for example when the window is opened –The main function ends with the program entering an event loop
41
Graphics System as a Black Box User Program Graphics System Input/Output Devices Function Calls Data Output Input
42
Pipeline Architectures Example Benefits –translates well to computer graphics –four steps to producing an image transforms (rotations, scale, translations) clipper projector (from 3d to 2d) rasterizer (scan conversion process)
43
Camera Analogy (from the red book)
44
Stages of Vertex Transformation in OpenGL
45
The Geometry Pipeline: Stages and Mappings
46
3D Coordinate Systems LEFT HANDEDRIGHT HANDED X Z Y Z Y X
47
3D Geometry: Model Coordinate Systems modeling - The process of creating and defining this geometry is called –This is usually done by defining each object in terms of a coordinate system that makes sense for that particular object. –Ants vs Star Wars
48
3D Geometry: Graphics Pipeline MIT graphics
49
3D Geometry Clipping
50
3D Geometry Projections
51
3D Geometry Projections – Parallel vs Orthographic
52
Appearance Color - RBG or RGBA
53
Appearance Texture mapping
54
Appearance Depth buffering
55
A Basic OpenGL Program Download Heat Distribution Program Heat Distribution Program Open Xcode (Icon has blue rectangle with hammer) File / New Project Select Command Line Utility / C++ Tool Name the project heatflow Add heatflow.c to the project source files. Add System/Library/Frameworks/Glut.framework and System/Library/Frameworks/OpenGL.framework to the project.
56
An OpenGL Program Select Build and Run Fix the errors –For a Mac substitute for “glut.h” –With c main() should return an int. Change the return value of main(). Build and Run
57
Unique to C Definitions precede code statements in functions. main() returns an int. argv, argc
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.