Texture Mapping Nehe Demo 6 - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

Texture Mapping Nehe Demo 6

Description:

We want 1 texture identifier and we are going to store it in the array texture ... Places the program in a loop. Waits for user input to end the loop by pressing ESC. ... – PowerPoint PPT presentation

Number of Views:57
Avg rating:3.0/5.0
Slides: 19
Provided by: Gren6
Category:
Tags: demo | going | mapping | nehe | places | texture

less

Transcript and Presenter's Notes

Title: Texture Mapping Nehe Demo 6


1
Texture MappingNehe Demo 6
  • COSC 471
  • Matt Devilbiss

2
Abstract
  • I will explain the coding that pertains to OpenGL
    and the various function calls used to achieve
    texture mapping.

3
Outline
  • Setting up the functions to texture map
  • The contents of those functions
  • Declaring a texture object
  • Binding the texture
  • Specifying the texture
  • Drawing the object and applying the texture

4
Auxiliary Library
  • The header file glaux.h stands for Graphics
    Library Auxiliary
  • This demo uses the glaux library
  • It emphasizes creating a program by using a small
    amount of code.

5
Load the texture
  • AUX_RGBImageRec LoadBMP(char Filename)
  • Loads the texture bitmap.
  • Uses the Glaux library for this purpose

6
Loading the texture
  • int LoadGLTextures()
  • This functions loads the texture and performs the
    binding, and filtering functions.

7
Create texture object
  • glGenTextures(n, texture0)
  • This function returns n unused texture
    identifiers for use.
  • glGenTextures(1, texture0)
  • We want 1 texture identifier and we are going to
    store it in the array texture

8
Bind the texture
  • glBindTexture(GL_TEXTURE_2D, texture0)
  • This line tells OpenGL we are dealing with a 2D
    texture.
  • The last parameter tells it which texture object
    we want to bind

9
Specify the texture
  • glTexImage2D(GL_TEXTURE_2D, 0, 3,
    TextureImage0-gtsizeX, TextureImage0-gtsizeY,
    0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage0-gtdata
    )
  • The first line specifies dimensionality
  • The second determines level of detail for mipmaps
  • The third tells OpenGL how to store the texture
    in video memory.(RGB)

10
Filtering Properties
  • glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE
    R,GL_LINEAR)
  • The first parameter refers to the texture target
  • The second parameter refers to magnification or
    minification filter.
  • The third refers to the method used to determine
    texels at various distance ranges.

11
Various setup
  • glEnable(GL_TEXTURE_2D)
  • Enables 2D texturing
  • glShadeModel(GL_SMOOTH)
  • Enables smooth shading
  • glClearColor(0.0f, 0.0f, 0.0f, 0.5f)
  • Sets background to black
  • glClearDepth(1.0f)
  • Setup depth buffer

12
Cont.
  • glEnable(GL_DEPTH_TEST)
  • Enable depth testing
  • glDepthFunc(GL_LEQUAL)
  • Specifies how to depth test
  • glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
  • Used to control quality on different machines
  • Gets passed GL_FASTEST, GL_NICEST, GL_DONT_CARE.

13
Rotating the cube
  • glTranslatef(0.0f,0.0f,-5.0f)
  • glRotatef(xrot,1.0f,0.0f,0.0f)
  • glRotatef(yrot,0.0f,1.0f,0.0f)
  • glRotatef(zrot,0.0f,0.0f,1.0f)

14
Speed of Rotation
  • xrot0.01f
  • yrot0.01f
  • zrot0.01f
  • These control the speed of rotation
  • The larger the value the faster the spin.

15
Texture Coordinates
  • glTexCoord2f(0.0f, 0.0f) glVertex3f(-1.0f,
    -1.0f, 1.0f)

(1.0,1.0)
(0.0, 1.0)
(0.0, 0.0)
(1.0, .0.0)
16
Correctly positioning the Texture
  • Use the texture coordinates to orient the texture
    as you see fit.
  • Simply reverse the coordinates to reverse and
    flip the texture.

17
The Main Function
  • Draws the scene
  • Places the program in a loop
  • Waits for user input to end the loop by pressing
    ESC.

18
Demonstration
  • Now to demonstrate the textured model.
Write a Comment
User Comments (0)
About PowerShow.com