TYPE by juanagao

VIEWS: 0 PAGES: 8

									                                                  Hallym University GVE LAB.




Texture Mapping
     Chapter 12

                          컴퓨터공학부 GVE Lab




    Graphics and Virtual Environment Laboratory
                                                                               1
                                                                  Hallym University GVE LAB.




1. How To ...
• Basic Concept
• Drape images onto Polygons (Texture Mapping)
   – glTexImage1D(……..)
   – glTexParameter(……..)
• Use .BMP files as textures
   –   glTexImage2D(.…….)
   –   glTexEnv(……..)
   –   glTexCoord(……..)
   –   gluBuild2DMipmaps(……..)
• Use automatic texture coordinate generation
   – glTexGen(……..)

                    Graphics and Virtual Environment Laboratory
                                                                                               2
                                                                   Hallym University GVE LAB.




2. Basic Concept
• 1D Texture
   – image with width no height / image with height no width

• 2D Texture
   – image that is more than 1 pixel wide and high
   – It is generally loaded from a Windows .BMP file


• 3D Texture(volume texture)
   – Some H/W supports 3D texture with OpenGL



                     Graphics and Virtual Environment Laboratory
                                                                                                3
                                                                       Hallym University GVE LAB.




3. 1D Texture
• Defining 1D Textures
    – void glTexImage1D(GLenum target, GLint level, Glint components, GLsizei
      width, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
        • ex) Page 389
    – void glTexParameteri(GLenum target, GLenum pname, Glint param)
        • ex) Page 389
                                                                 GL_TEXTURE_MIN_FILTER
                                                                 GL_TEXTURE_MAG_FILTER
• Texture Image Filters                                          GL_TEXTURE_WRAP_S
  Filter                 Description                             GL_TEXTURE_WRAP_T
  GL_NEAREST             Nearest-neighbor filtering
  GL_LINEAR              Linear interpolation



                         Graphics and Virtual Environment Laboratory
                                                                                                    4
                                                                       Hallym University GVE LAB.




4. 2D Texture(1)
• Defining 2D Textures
   – void glTexImage2D(GLenum target, GLint level, Glint components, GLsizei
      width, Glsizei height, GLint border, GLenum format, GLenum type, const GLvoid
      *pixels)
       • ex) Page 388
   – void glTexParameteri(GLenum target, GLenum pname, Glint param)
       • ex) Page 387
                                                                                 GL_REPEAT
                                                                                 GL_CLAMP
• Drawing Textured Polygon
   – void glTexEnvi(GLenum target, GLenum pname, GLint param) Page 388
   – void glTexCoord1f(GLfloat s) Page 389



                         Graphics and Virtual Environment Laboratory
                                                                                                    5
                                                                 Hallym University GVE LAB.




4. 2D Texture(2)
• Texture Modes for GL_TEXTURE_ENV_MODE
 Mode          Description
 GL_MODULATE   Texture pixels “filter” existing pixel colors on the screen
 GL_DECAL      Texture pixels replace existing pixels on the screen
 GL_BLEND      Texture pixels “filter” existing pixels colors and are
               combined with a constant color



• GL_CLAMP

• GL_REPEAT


                   Graphics and Virtual Environment Laboratory
                                                                                              6
                                                                     Hallym University GVE LAB.




5. Mipmapped Textures
• Multiple Levels of Detail
• Level : 0=highest-resolution, 1=half the size of the 0 image
• Defining Mipmapped Textures(1)
   – page 391
• Defining Mipmapped Textures(2)
   – int gluBuild2DMipmaps(GLenum target, GLint components, GLint width,
                  GLint height, GLenum format, GLenum type, const void * data )

• Minification Filters
   –   GL_NEAREST_MIPMAP_NEAREST
   –   GL_NEAREST_MIPMAP_LINEAR
   –   GL_LINEAR_MIPMAP_NEAREST
   –   GL_LINEAR_MIPMAP_LINEAR
                       Graphics and Virtual Environment Laboratory
                                                                                                  7
                                                                    Hallym University GVE LAB.




6. Automatically Generating
   Texture Coordinates
• Defining Coordinates
   – void glTexCoord{1234}{sifd}(TYPE coords)
   – void glTexCoord{1234}{sifd}v(TYPE coords)

• Automatically Defining Coordinates
   – void glTexGen{ifd}(Glenum coord, Glenum pname, TYPE param)
   – void glTexGen{ifd}v(Glenum coord, Glenum pname, TYPE param)
   – Page 397

• glEnable(GL_TEXTURE_GEN_S)
• glEnable(GL_TEXTURE_GEN_T)
                      Graphics and Virtual Environment Laboratory
                                                                                                 8

								
To top