Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Display List<br />Texture Mapping<br />CS3241 Lab 8<br />
Objective<br />Display List<br />Understanding the benefit & limitation<br />Setup Display List<br />Texturing<br />Unders...
Display List vs Immediate Mode<br />Faster <br />As geometries are cached<br />See the difference (sample program loading ...
Display List<br />Generating empty display list (init)<br />baseId = glGenLists(range);<br />Setup the list (init)<br />gl...
Task 1<br />Task 1.1<br />Use display list to draw a teapot<br />Task 1.2<br />Use display list to draw 4 wheels attaching...
Texture<br />Enabling /Disabling Texture Mapping<br />glEnable/glDisable(GL_TEXTURE_1D);<br />glEnable/glDisable(GL_TEXTUR...
Texture Object<br />Better texture management<br />Generate texture name (init)<br />GLuinttexObj;           // global<br ...
Texture Parameters<br />Repeating / Clamping<br />Direction – s/t<br />Repeating<br />Clamping<br />
Texture Parameters<br />Filtering<br />
Texture Coordinate<br />To supply texture coordinate to a vertex<br />Add glTexCoord2f(s, t); before specifying the vertex...
Task 2<br />Task 2.1<br />Load a texture from program generated source / file<br />Apply to Teapot<br />Task 2.2<br />Supp...
Example<br />Modeling a car<br />Separating different part of the mesh<br />For animating<br />the front wheel can move ac...
Upcoming SlideShare
Loading in …5
×

Cs3241 Lab 8

808 views

Published on

Published in: Technology, Business
  • Be the first to comment

  • Be the first to like this

Cs3241 Lab 8

  1. 1. Display List<br />Texture Mapping<br />CS3241 Lab 8<br />
  2. 2. Objective<br />Display List<br />Understanding the benefit & limitation<br />Setup Display List<br />Texturing<br />Understanding basic texture mapping<br />Specify a texture image <br />Generated by program, e.g. checkerboard<br />Loaded from file<br />Using texture object<br />Supply texture co-ordinate<br />
  3. 3. Display List vs Immediate Mode<br />Faster <br />As geometries are cached<br />See the difference (sample program loading dino)<br />Once setup, cannot be changed<br />
  4. 4. Display List<br />Generating empty display list (init)<br />baseId = glGenLists(range);<br />Setup the list (init)<br />glNewList(id, GL_COMPILE); <br /> // your draw code <br />glEndList(); <br />Using the list (display)<br />glCallList(id);<br />
  5. 5. Task 1<br />Task 1.1<br />Use display list to draw a teapot<br />Task 1.2<br />Use display list to draw 4 wheels attaching the teapot<br />So we have the body and wheels. What’s next?<br />Animation<br />Loading Mesh<br />Texturing<br />Material…..<br />
  6. 6. Texture<br />Enabling /Disabling Texture Mapping<br />glEnable/glDisable(GL_TEXTURE_1D);<br />glEnable/glDisable(GL_TEXTURE_2D);<br />
  7. 7. Texture Object<br />Better texture management<br />Generate texture name (init)<br />GLuinttexObj; // global<br />glGenTextures(1, &texObj);// init()<br />Bind texture Object to texture data (init)<br />glBindTexture(GL_TEXTURE_2D, texObj);<br />glTexParameter*(); // setup parameter<br /> glTexImage2D(…..); // alloc space & copy texture map<br />Using texture Object (display)<br />glBindTexture(GL_TEXTURE_2D, texObj);<br />glutSolidTeapot(1);<br />TextureName (Gluint)<br />Parameter<br />Texture Data<br />Texture Object<br />
  8. 8. Texture Parameters<br />Repeating / Clamping<br />Direction – s/t<br />Repeating<br />Clamping<br />
  9. 9. Texture Parameters<br />Filtering<br />
  10. 10. Texture Coordinate<br />To supply texture coordinate to a vertex<br />Add glTexCoord2f(s, t); before specifying the vertex<br />E.g.<br />glBegin(GL_QUADS); <br />glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -1.0, 0.0);<br />…..<br />glEnd();<br />5,5<br />5,0<br />0,0<br />0,5<br />
  11. 11. Task 2<br />Task 2.1<br />Load a texture from program generated source / file<br />Apply to Teapot<br />Task 2.2<br />Supply texture co-ordinate to a plane <br />Apply the texture in 2.1 to the plane<br />
  12. 12. Example<br />Modeling a car<br />Separating different part of the mesh<br />For animating<br />the front wheel can move according to key in:P<br />All the wheels will rotate according to its speed<br />For having different texture/material<br />Try to extend it by putting better mesh :P<br />

×