Cs3241 Lab 8

754 views
675 views

Published on

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
754
On SlideShare
0
From Embeds
0
Number of Embeds
266
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

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 />

×