MAE152 Computer Graphics for Scientists and Engineers Fall 03 Display Lists.

Slides:



Advertisements
Similar presentations
Programming with OpenGL - Getting started - Hanyang University Han Jae-Hyek.
Advertisements

Chapter 11. Faster Geometry Throughput Presented by Garrett Yeh.
Better Interactive Programs
©Zachary Wartell, UNCC9/28/ :30 AM 1 Overview of OpenGL Revision: 1.2 Copyright Professor Zachary Wartell, University of North Carolina All Rights.
Chapter 2: Graphics Programming
Graphics Pipeline.
OPENGL Return of the Survival Guide. Buffers (0,0) OpenGL holds the buffers in a coordinate system such that the origin is the lower left corner.
Meshes Dr. Scott Schaefer. 3D Surfaces Vertex Table.
Computer Graphics Ben-Gurion University of the Negev Fall 2012.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Computer Science,
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Better Interactive Programs Ed Angel Professor of Computer Science, Electrical and Computer.
OpenGL Display Lists A way to improve performance.
Hierarchical ModelingHofstra University1 Modeling Define volumetric objects in terms of surfaces patches that surround the volume Each surface patch is.
Hierarchical ModelingHofstra University1 Hierarchical Modeling: Tree of Transformations, Display Lists and Functions, Matrix and Attribute Stacks,
Programming with OpenGL Part 1: Background Mohan Sridharan Based on slides created by Edward Angel CS4395: Computer Graphics 1.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Models and Architectures Ed Angel Professor of Computer Science, Electrical and Computer.
Computer Graphics (Fall 2004) COMS 4160, Lecture 11: OpenGL 2
COS 397 Computer Graphics Assoc. Prof. Svetla Boytcheva AUBG 2013 COS 397 Computer Graphics Practical Session №1 Introduction to OpenGL, GLFW and CG.
CSC461 Lecture 11: Interactive Programs Contents and Objectives Picking Writing modes – XOR/Copy Rubberbanding Display list.
TWO DIMENSIONAL GEOMETRIC TRANSFORMATIONS CA 302 Computer Graphics and Visual Programming Aydın Öztürk
Image Synthesis Rabie A. Ramadan, PhD 2. 2 Java OpenGL Using JOGL: Using JOGL: Wiki: You can download JOGL from.
Hank Childs, University of Oregon
CSC 461: Lecture 41 CSC461: Lecture 4 Introduction to OpenGL Objectives: Development of the OpenGL API OpenGL Architecture -- OpenGL as a state machine.
Speeding Up Rendering After Deciding What to Draw.
Korea University Korea University Computer Graphics Laboratory Computer Graphics Laboratory Jung Lee, Chapter 13.
Lecture 12 Blending, Anti-aliasing, Fog, Display Lists.
Input and Interaction Lecture No. 4.
Programming with OpenGL Part 1: Background
CSE 470: Computer Graphics. 10/15/ Defining a Vertex A 2D vertex: glVertex2f(GLfloat x, GLfloat y); 2D vertexfloating pointopenGL parameter type.
CSC 461: Lecture 3 1 CSC461 Lecture 3: Models and Architectures  Objectives –Learn the basic design of a graphics system –Introduce pipeline architecture.
Interactive Computer Graphics CS 418 – Spring 2015 Mesh Rendering, Transformation, Camera Viewing and Projection in OpenGL TA: Zhicheng Yan Sushma S Kini.
Computing & Information Sciences Kansas State University Lecture 20 of 42CIS 636/736: (Introduction to) Computer Graphics Lecture 21 of 42 William H. Hsu.
1 Better Interactive Programs. 2 Objectives Learn to build more sophisticated interactive programs using ­Picking Select objects from the display Three.
Modeling with OpenGL Practice with OpenGL transformations.
Review of OpenGL Basics
Introduction to OpenGL  OpenGL is a graphics API  Software library  Layer between programmer and graphics hardware (and software)  OpenGL can fit in.
Computer Graphics Bing-Yu Chen National Taiwan University.
1 3D API OPENGL ES v1.0 Owned by Silicon Graphics (SGL) Control was then transferred to Khronos Group Introduction.
3D Programming and Viewing Week 3 David Breen Department of Computer Science Drexel University Based on material from Ed Angel, University of New Mexico.
OpenGL Architecture Display List Polynomial Evaluator Per Vertex Operations & Primitive Assembly Rasterization Per Fragment Operations Frame Buffer Texture.
Program 2 due 02/01  Be sure to document your program  program level doc  your name  what the program does  each function  describe the arguments.
David Luebke1/5/2016 CS 551 / 645: Introductory Computer Graphics David Luebke
1 Angel: Interactive Computer Graphics5E © Addison- Wesley 2009 Image Formation Fundamental imaging notions Fundamental imaging notions Physical basis.
What are shaders? In the field of computer graphics, a shader is a computer program that runs on the graphics processing unit(GPU) and is used to do shading.
1 Programming with OpenGL Part 2: Complete Programs.
OpenGL API 2D Graphic Primitives Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
© David Kirk/NVIDIA and Wen-mei W. Hwu, ECE408, University of Illinois, Urbana-Champaign 1 GPU.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 17 Animations, Loops.
CSC Graphics Programming Budditha Hettige Department of Statistics and Computer Science.
Introduction to OpenGL (INF 250) Veronika Solteszova et al., UiB Dept. of Informatics,
Computer Graphics I, Fall Programming with OpenGL Part 2: Complete Programs.
COMP 175 | COMPUTER GRAPHICS Remco Chang1/XX13 – GLSL Lecture 13: OpenGL Shading Language (GLSL) COMP 175: Computer Graphics April 12, 2016.
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
Hank Childs, University of Oregon Oct. 28th, 2016 CIS 441/541: Introduction to Computer Graphics Lecture 16: textures.
Modeling Transformations
Computer Graphics and Visualization (06 CS 65)
Hank Childs, University of Oregon
Draw a Simple Object.
Computer Graphics Lecture 32
Better Interactive Programs
Programming with OpenGL Part 2: Complete Programs
Advanced Graphics Algorithms Ying Zhu Georgia State University
Programming with OpenGL Part 2: Complete Programs
Project 1: Into Space! CG Concepts Needed
Display Lists & Text Glenn G. Chappell
Better Interactive Programs
Computer Graphics Practical Lesson 7
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 1: Background
Programming with OpenGL Part 2: Complete Programs
Presentation transcript:

MAE152 Computer Graphics for Scientists and Engineers Fall 03 Display Lists

Objective Understand how display lists can be used along with commands in immediate mode to organize your data and improve performance. Maximize performance by knowing how and when to use display lists.

What is Display List Display list is a group of OpenGL commands that have been stored for later execution. When a display list is invoked, the commands in it are executed in the order in which they were issued. Immediate mode –commands are executed immediately You can freely mix immediate mode programming and display lists.

Immediate Mode versus Display Lists Display Listed Immediate Mode Display List Polynomial Evaluator Per Vertex Operations & Primitive Assembly Rasterization Per Fragment Operations Texture Memory CPU Pixel Operations Frame Buffer

Immediate Mode vs Display Listed Rendering Immediate Mode Graphics –Primitives are sent to pipeline and displayed right away –No memory of graphical entities Display Listed Graphics –Primitives placed in display lists –Display lists kept on graphics server –Can be redisplayed with different state –Can be shared among OpenGL graphics contexts

Why Use Display Lists? It can reduce OpenGL command transmission –When running OpenGL programs remotely to another machine on the network. Display lists are stored in server computer. You can reduce the cost of repeatedly transmitting commands over the network. Performance Gain in Local Running –Some graphics hardware may store display lists in dedicated memory or may store the data in an optimized form that is more compatible with the graphics hardware or software.

A Simple Example void init(void) { GLuint theTorus = glGenLists(1); glNewList(theTorus, GL_COMPILE); torus(8, 25) glEndList(); } void display(void) { glCallList(theTorus); glFlush(); }

A Simple Example (cont) void torus(int numc, int numt) { for(i=0; i<numc; i++) { glBegin(GL_QUAD_STRIP); for(j=0; j<=numt; j++) { for(k=1; k>=0; k--) { x = (1+.1*cos(s(twopi/umc))*cos(t*twopi/numt); y = (1+.1*cos(s(twopi/umc))*sin(t*twopi/numt); z =.1 * sin(s*twopi/numc); } glEnd(); }

Demo Display List for Triangles

Display-List Design Philosophy Display list can not be changed. –this is to MAXIMIZE the performance gain. Display list stores only the final values. –does NOT store the intermediate results –Ex) glRotate*() directly stores the matrix –Ex) when the material properties are changed for each item –Ex) when dealing with textures

Naming a Display List Each display list is identified by an integer index. To allocate one or more unused index, use glGenLists() command. –listIndex = glGenLists(n); allocates n consecutive previously unallocated display-list indices, and returns the first index.

Creating a Display List Use glNewList() and glEndList() glNewList(listIndex, GL_COMPILE);... glEndList(); Options for glNewList() –GL_COMPILE_AND_EXECUTE –GL_COMPILE

What’s Stored in a Display List Almost all OpenGL commands can be stored in a display list. Only the values for expressions are stored in the list. GLfloat v[3] = {0, 0, 0}; glNewList(1, GL_COMPILE); glColor3fv(v); glEndList(); v[0] = 1.0; // no effect

Executing a Display List Use glCallList() command to execute commands in a display list. void display(void { glCallList(theTorus); glFlush(); }

Display Lists and Hierarchy Consider model of a car –Create display list for chassis –Create display list for wheel glNewList( CAR, GL_COMPILE ); glCallList( CHASSIS ); glTranslatef( … ); glCallList( WHEEL ); glTranslatef( … ); glCallList( WHEEL ); … glEndList();

Hierarchical Display List Hierarchical display list is a display list that includes other display lists in it. Limit on the nesting = 64 glNewList(listIndex, GL_COMPILE); glCallList(frame); glTranslatef(1.0, 1.0, 0.0); glCallList(wheel); glEndList();

Managing Display List Indices Use glIsList() command to determine whether a specific index is in use. GLboolean glIsList(GLuint list) Use glDeleteLists() command to delete a contiguous range of display lists. glDeleteLists(list, n) deletes n display lists, starting at the index specified by list.

Executing Multiple Display Lists Use glListBase() command to set base index of glCallLists() glListBase(base) Use glCallLists() command to execute multiple display lists. glCallLists(n, type, lists) executes n display lists. See the next example.

An Example void display() { glListBase(10); GL_INT lists[] = { 1, 1, 3, 5 }; glCallLists(4, GL_INT, lists); } // Executed display lists are of // index 11, 12, 15, 20

Managing State Variables You can not use glGet*() in a display list. –glGetFloatv(GL_CURRENT_COLOR, &v[0]) Instead, use glPushAttrib() command to save a group of state variables. Use glPopAttrib() to restore the values when you’re ready for them. How to include state changes in display lists?

Managing State Variables glNewList(listIndex, GL_COMPILE);// Example code. glPushMatrix();// Save current matrix glPushAttrib();// Save current attribute glColor3f(1.0, 0.0, 0.0);// Attribute change glBegin(GL_POLYGON); glVertex2f(0.0, 0.0); glVertex2f(1.0, 0.0); glVertex2f(0.0, 1.0); glEnd(); glTranslatef(1.5, 0.0, 0.0);// Matrix change glPopAttrib();// Restore attribute glPopMatrix();// Restore matrix glEndList();

End of Display List