1Introduction A display list is a group of OpenGL commands that have been stored for later execution. Most OpenGL commands can be either stored in a display.

Slides:



Advertisements
Similar presentations
Computer Graphics - Graphics Programming -
Advertisements

OpenGL CMSC340 3D Character Design & Animation. What is OpenGL? A low-level graphics library specification designed for use with the C and C++ provides…
OpenGL: Simple Use Open a window and attach OpenGL to it Set projection parameters (e.g., field of view) Setup lighting, if any Main rendering loop –Set.
©Zachary Wartell, UNCC9/28/ :30 AM 1 Overview of OpenGL Revision: 1.2 Copyright Professor Zachary Wartell, University of North Carolina All Rights.
Line and Curve Drawing Algorithms. Line Drawing x0x0 y0y0 x end y end.
Chapter 2: Graphics Programming
O a polygon is a plane figure specified by a set of three or more coordinate positions, called vertices, that are connected in sequence by straight-Line.
CMPE 466 COMPUTER GRAPHICS
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Building Models modified by Ray Wisman Ed Angel Professor of Computer Science,
1 Building Models. 2 Objectives Introduce simple data structures for building polygonal models ­Vertex lists ­Edge lists OpenGL vertex arrays.
Computer Graphics(Fall 2003) COMS 4160, Lecture 7: OpenGL 3 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
Notes Over 6.4 Graph Sine, Cosine Functions Notes Over 6.4 Graph Sine, Cosine, and Tangent Functions Equation of a Sine Function Amplitude Period Complete.
In the name of God Computer Graphics Bastanfard.
 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.
Meshes Dr. Scott Schaefer. 3D Surfaces Vertex Table.
OpenGL (Graphics Library) Software Interface to graphics software Allows to create interactive programs that produce color images of moving 3D objects.
Draw a Simple Object. Example 1/4 #include “ glut.h ” void display(); void reshape(GLsizei w, GLsizei h); void main(int argc, char** argv){ glutInit(&argc,
Computer Graphics Ben-Gurion University of the Negev Fall 2012.
Introduction to OpenGL. What is OpenGL OpenGL is a low-level software interface to graphics hardware No commands for performing windowing tasks or obtaining.
Warm Up 1.) Draw a triangle. The length of the hypotenuse is 1. Find the length of the two legs. Leave your answers exact.
UNIT CIRCLE. Review: Unit Circle – a circle drawn around the origin, with radius 1.
3.5 The Trig Functions. sine cosine cosecant secant tangent cotangent sine and cosine are only 2 of the trig functions! Here are all 6!, x ≠ 0, y ≠ 0.
COS 397 Computer Graphics Assoc. Prof. Svetla Boytcheva AUBG 2013 COS 397 Computer Graphics Practical Session №1 Introduction to OpenGL, GLFW and CG.
Jehee Lee Seoul National University
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.
OpenGl Graphics Programming. Introduction OpenGL is a low-level graphics library specification. It makes available to the programmer a small set of geomteric.
Section 4.7 Inverse Trigonometric Functions. A brief review….. 1.If a function is one-to-one, the function has an inverse. 2.If the graph of a function.
Section 7.5 Inverse Circular Functions
Week One Raster & Vector Formats. 2 Computer Graphics Vector Graphics Pictures are produced via a series of ‘draw commands’ These commands will draw short.
Using Inventor with OpenGL Chapter objectives Create Inventor callback nodes that include calls to the OpenGL Library Explain how Inventor.
9-2 Review 1. Draw a line perpendicular to a plane. 2. Draw two parallel planes.
MAE152 Computer Graphics for Scientists and Engineers Fall 03 Display Lists.
1 3D API OPENGL ES v1.0 Owned by Silicon Graphics (SGL) Control was then transferred to Khronos Group Introduction.
Trigonometric Functions: The Unit Circle & Right Triangle Trigonometry
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Draw a Simple Object. Pixel pipeline Vertex pipeline Course Map Transformation & Lighting Primitive assembly Viewport culling & clipping Texture blending.
Affine Geometry Jehee Lee Seoul National University.
CA 302 Computer Graphics and Visual Programming Lecture 2: Introduction to OpenGL Aydın Öztürk
Chun-Yuan Lin Introduction to OpenGL 2015/12/19 1 CG.
Scene Graph & Game Engines. 2 Limitations of Immediate Mode Graphics  When we define a geometric object in an application, upon execution of the code.
1 Computer Graphics Week1 -Introduction. Computer graphics History Computer graphics generally means creation, storage and manipulation of models and.
360°450°630°720°090°180°270° 540° Where θ is given for Where are the solutions and how many solutions?
8421 Binary Hexadecimal Seven segment display 8421 Binary Hexadecimal Seven segment display 0000.
Graphics: Conceptual Model
The Canvas Class Lecture 8 Fri, Sep 12, The Canvas Class We will create a simple Canvas class that will encapsulate the commands that create and.
1 Computer Graphics Week11 : Hidden Surface Removal.
OpenGL: Introduction #include main() { OpenWindow() ; glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0,
SPACE SHUTTLE LAUNCHING GUIDE Mis. V.R.PRATIMA Mr. ASWIN KUMAR PUNITH.K PAUL SUDEEP.G Submitted by.
Notes Over 14.1 Graph Sine, Cosine, and Tangent Functions.
Graphics Graphics Korea University kucg.korea.ac.kr Graphics Programming 고려대학교 컴퓨터 그래픽스 연구실.
Introduction to 3D Solids and Solids of Revolution Some 3D shapes can be formed by revolving a 2D shape around a line (called the axis of revolution).
14.1 The Unit Circle Part 2. When measuring in radians, we are finding a distance ____ the circle. This is called. What is the distance around a circle?
5.7 Inverse Trig Functions. Does the sine function have an inverse?
Plane Figures. What are the types of figures? A closed figure begins and ends at the same end point. An open figure has ends that do not meet.
Lesson: Regular Polygons, Trigonometry, & Area
Computer Graphics Lecture 39 Building Polygonal Models of Surfaces Taqdees A. Siddiqi
Draw a Simple Object.
Notes Over 6.4 Graph Sine, Cosine Functions.
12.1 Tangents.
STORE MANAGER RESPONSIBILITIES.
Arc Length Area of a Sector Unit Circle Trig values of unit circle
Geometry Portfolio Term 2
CS297 Graphics with Java and OpenGL
Section 6.5 Law of Cosines Objectives:
How to Draw a Regular Polygon
Objective: Use power-reducing and half angle identities.
Figure 3. Converting an expression into a binary expression tree.
What is the radian equivalent?
Presentation transcript:

1Introduction A display list is a group of OpenGL commands that have been stored for later execution. Most OpenGL commands can be either stored in a display list or issued in immediate mode.

2 For example, suppose you want to draw a circle with 100 line segments drawCircle() { GLint i; GLfloat cosine, sine; glBegin(GL_POLYGON); for(i=0;i<100;i++){ cosine=cos(i*2*PI/100.0); sine=sin(i*2*PI/100.0); glVertex2f(cosine,sine); } glEnd(); }

3 This method is terribly inefficient because the trigonometry has to be performed each time the circle is rendered. Save the coordinates in a table: drawCircle() { GLint i; GLfloat cosine, sine; static GLfloat circoords[100][2]; static GLint inited=0; if(inited==0){ inited=1; for(i=0;i<100;i++){ circcoords[i][0]=cos(i*2*PI/100.0); circcoords[i][1]=sin(i*2*PI/100.0); } } glBegin(GL_POLYGON); for(i=0;i<100;i++) glVertex2fv(&circcoords[i][0]); glEnd(); }

4 Draw the circle once and have OpenGL remember how to draw it for later use. #define MY_CIRCLE_LIST 1 buildCircle() { GLint i; GLfloat cosine, sine; glNewList(MY_CIRCLE_LIST, GL_COMPILE); glBegin(GL_POLYGON); for(i=0;i<100;i++){ cosine=cos(i*2*PI/100.0); sine=sin(i*2*PI/100.0); glVertex2f(cosine,sine); } glEnd(); glEndList(); } MY_CIRCLE_LIST is an integer index that uniquely iden- tifies this display list. You can execute the display list later with this glCallList() command: glCallList(MY_CIRCLE_LIST);

5 A display list contains only OpenGL calls. The coordinates and other variables are evaluated and copied into the display list when the list is compiled. You can delete a display list and create a new one, but you cant edit an existing display list. Display lists reside with the server and network traffic is minimized. Matrix computations, lighting models, textures, etc. Display List disadvantages: large storage; immutability of the contents of a display list.

6 If glLoadMatrix(M); glCallList(1); are called all the time, it is better to store the matrix in the display list: glNewList(1, GL_COMPILE); glLoadMatrix(M); draw_some_geometry(); glEndList(); glCallList(1); Use a Display List: list.c glNewList (listName, GL_COMPILE); glColor3f(1.0, 0.0, 0.0); glBegin (GL_TRIANGLES); glVertex2f(0.0,0.0);glVertex2f(1.0,0.0); glVertex2f (0.0, 1.0); glEnd (); glTranslatef (1.5, 0.0, 0.0); glEndList (); glShadeModel (GL_FLAT);

7 void display(void) { GLuint i; glClear (GL_COLOR_BUFFER_BIT); glColor3f(0.0, 1.0, 0.0); for (i = 0; i < 10; i++) glCallList (listName); drawLine (); /* color red; affected by the 10 translate */ glFlush (); } Constants are stored and wont change GLfloat color_vector[3]={0.0,0.0,0.0}; glNewList(1,GL_COMPILE); glColor3fv(color_vector); glEndList(); color_vector[0]=1.0; // color will be black if you use the display list

8 glNewList(listIndex,GL_COMPILE); glPushMatrix(); glPushAttrib(GL_CURRENT_BIT); glColor3f(1.0, 0.0, 0.0); 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); glPopAttrib(); glPopMatrix(); glEndList(); The code below would draw a green, untranslated line. void display(void) { GLint i; glClear (GL_COLOR_BUFFER_BIT); glColor3f(0.0, 1.0, 0.0); for (i = 0; i < 10; i++) glCallList (listIndex); drawLine (); glFlush (); } Use glPushAttrib() to save a group of state variables and glPopAttrib() to restore

9 Hierarchical Display Lists You can create a hierarchical display list, a display list that executes another display list. Useful for an object thats made of components which are used more than once. glNewList(listIndex,GL_COMPILE); glCallList(handlebars); glCallList(frame); glTranslatef(1.0,0.0,0.0); glCallList(wheel); glTranslatef(3.0,0.0,0.0); glCallList(wheel); glEndList();

1010 Editable Display Lists Example editable display list: To render the polygon, call display list number 4. To edit a vertex, you need only recreate the single display list corresponding to that vertex. glNewList(1,GL_COMPILE); glVertex3f(v1); glEndList(); glNewList(2,GL_COMPILE); glVertex3f(v2); glEndList(); glNewList(3,GL_COMPILE); glVertex3f(v3); glEndList(); glNewList(4,GL_COMPILE); glBegin(GL_POLYGON); glCallList(1); glCallList(2); glCallList(3); glEnd(); glEndList();

Managing Display List Indices listIndex=glGenLists(1); if(listIndex!=0) { glNewList(listIndex,GL_COMPILE);... glEndList(); } 11 List Indices can be automatically generated:

Fonts and Display Lists Fonts are array of characters. Different font types are saved in the same bitmap arrays with different offset that is added to the indices glGenLists(GLsizei range); Allocates range number of continuous list indices (for different characters.) It returns the index that marks the beginning of the list indices glListBase(Gluint base); the offset added to the display list indices in glCallLists below; it has no effect on glCallList. It is used as an offset to different font types glCallLists(GLsizei n, GLenum type, const GLvoid *lists); to call all display lists that draw individual characters. n is the # of characters to be drawn, type is GL_BYTE for the font, and lists is an array of character codes; Font 12