Texture & Terrain

wordpress.vrac.iastate.edu
  • No tags were found...

Texture & Terrain

Texture & Terrain


Textures


TexturesglTexCoord2f (…);


(0,1)(1,1)+ =(0,0)(1,0)Textures


(0,.5)(.5,.5)+ =(0,0)(.5,0)Textures


(0,.5)(.5,.5)+ =(0,0)(.5,0)Textures


Textures: Creating


glGenTextures(1, &texname); // Generate texture names glPixelStorei(GL_UNPACK_ALIGNMENT, 1); // set pixel storage modes glBindTexture(GL_TEXTURE_2D, texname); // bind a texture to a texturing target // build a 2D mipmap -­‐ builds a series of prefiltered 2D texture maps of decreasing resoluPons gluBuild2DMipmaps(GL_TEXTURE_2D, 4, width, height, GL_RGBA, GL_UNSIGNED_BYTE, image-­‐>getPixels()); // set texture parameters glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); //use GL_MODULATE for standard texturing //GL_DECAL for unlightedness //GL_BLEND for interacPon with a background color using alpha channel of image //GL_REPLACE to completely disregard lighPng and replace it with the actual colors from the texture image glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);


Textures: Using


glBindTexture(GL_TEXTURE_2D, tex1); // Bind the texture iniPalized in the init() funcPon, here we are iniPalizing tex1 // glTexCoord2f() is used for texture coordinates. They go from 0 to 1. // glVertex3f() is the place at which the polygon is iniPalized. Also, the texture coordinate (0,0) is bound to this vertex // glNormal3f() call is used to create a normal vector. Used for lighPng purposes glBegin(GL_POLYGON); glTexCoord2f(0.0, 0.0); glVertex3f(-­‐15.0, -­‐15.0, -­‐15.0);glTexCoord2f(1.0, 0.0); glVertex3f(15.0, -­‐15.0, -­‐15.0); glTexCoord2f(1.0, 1.0); glVertex3f(15.0, 15.0, -­‐15.0); glNormal3f(0, 0, 1); glNormal3f(0, 0, 1); glNormal3f(0, 0, 1); glEnd(); glTexCoord2f(0.0, 1.0); glVertex3f(-­‐15.0, 15.0, -­‐15.0); glNormal3f(0, 0, 1);


Textures: Advanced


+ =Textures: Lightmaps


Textures: Lightmaps


Textures: Lightmaps


+ =Textures: Bumpmaps


+ =Textures: Bumpmaps


Textures: Projective Texture


Terrains


Terrains: Billboarding


Terrains: Billboarding


Terrains: Billboarding


Terrains: Skybox


Terrains: Skybox


Terrains: Skybox


Terrains: Skybox


Terrains: Skybox


Yes!!!


Assignment


Questions???

More magazines by this user
Similar magazines