1 / 16

Outline

Outline. Announcements HWII on web, due Friday Sign-up for CTC account http://www.tc.cornell.edu/Services/allocations/explore.asp Dynamic Libraries. HW I Issues. Some problems: cc -lm csin.c -ocsin -l<name> tells compiler to find a library called “libname.a,” and get any routines it needs

verdi
Télécharger la présentation

Outline

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Outline Announcements HWII on web, due Friday Sign-up for CTC account http://www.tc.cornell.edu/Services/allocations/explore.asp Dynamic Libraries

  2. HW I Issues Some problems: cc -lm csin.c -ocsin -l<name> tells compiler to find a library called “libname.a,” and get any routines it needs -lm says to look for libm.a (or .so) -lblas says to look for libblas.a (or .so)

  3. HW I Issues Calling BLAS Look on BLAS sheet for routines that do y<-Ax nothing matches, but find several routines that solve y<-Ax+y CALL SGEMV('n',m,n,1.0,C,MMAX,v,1, 0.0, PC, 1) As a matrix, C is m-by-n, but as an array, it is MMAX-by-NMAX BLAS needs both: MMAX (LDA) lets BLAS know where columns start Also,  &  should be real (1.0 and 0.0, 1 and 0 won’t work on some systems) m MMAX

  4. BLAS Increments BLAS lets (makes) you specify an increment. Allows you to use 2D arrays as vectors: INC=MMAX(6) INC=MMAX+1

  5. Why Add Graphics? Writing graphics routines can be difficult (not as hard as you think, though) There are many packages for scientific visualization (MATLAB, AVS, OpenDX) So, why bother coding yourself? Get a quick view of results Make program accessible to non-specialists It’s cool!

  6. OpenGL OpenGL is the graphics library Started as proprietary library on Silicon Graphics workstations Now available everywhere (standard with most systems) Tightly coupled with graphics cards Underlying system for most games and scientific visualization systems

  7. OpenGL Built-in primitives to draw points, lines, polygons Can easily transform objects in 3D scale, rotate, translate, change viewpoint Can control opacity of objects, not just color Can add textures to objects For more info: www.opengl.org or CS417

  8. OpenGL and GLUT OpenGL is a rich description of graphics operations But, OpenGL needs to interact with system needs windows to draw in needs windows to recognize graphics commands GLUT--Graphics Library Utility Toolkit System independent library for creating windows and managing simple user interaction (mouse, keyboard, menus) Can call from C (C++), FORTRAN, and now Java

  9. GLUT Can build simple GUI’s with GLUT for more sophisticated GUI’s consider Java or system-dependent tools However, GLUT GUI’s demonstrate basic GUI ideas: Developer writes Callbacks--routines that are executed upon user events: Mouse click in window, keyboard input The program tells GUI system which routines go with which events Control is turned over to GUI system GUI system calls Callback for corresponding event

  10. Event-Driven Programming Most scientific programs are simple Read data Compute something Output answer Quit GUIs are fundamentally different Start Process mouse or keyboard Do something Repeat 1-3

  11. Event-Driven Programming GUIs have two key features Never quit until user demands it Process events Suggests a simple structure While(true){ Get next event Determine event type Action determined by type }

  12. Event-Driven Programming All GUIs regardless of OS and language do the same thing Some systems require (allow) you more flexibility Write event loop yourself Parse events yourself GLUT is not designed for writing “full-fledged” GUIs GLUT has its own event loop Hidden from you GLUT allows you to “register” subroutines to handle a limited number of events.

  13. GLUT Programs follow a simple structure Create window(s) Register subroutines to handle events Turn control over to GLUT GLUT Program Structure

  14. GLUT and RAD1D I added GLUT routines to RAD1D to plot C at several times main: Creates a window Registers “DrawC” as “DisplayFunc” DrawC is called when screen must be re-drawn No inputs to display functions! Registers “ResizeIt” as “ReshapeFunc” ResizeIt(width,height) is called when window is resized Calls RunRad Original RAD1D main Periodically calls AddC which stores current C in array GLC array Gives control to GLUT

  15. plots a line for every time observation of C stored in GLC first line is red, last line is blue, color varies in between DrawC

  16. Drawing with OpenGL GLUT creates windows and handles events, Graphics in DrawC are produced by OpenGL OpenGL is very powerful, but drawing is fairly simple Set color: glColor3f Tell OpenGL you’re starting to draw: glBegin(GL_LINE_STRIP); Place several vertices: glVertex2d (creates one vertex) Tell OpenGL to stop drawing glEnd();

More Related