Presentation is loading. Please wait.

Presentation is loading. Please wait.

TEXTURES & OTHER GOODIES Computer Graphics. glTexCoord2f(...); + =

Similar presentations


Presentation on theme: "TEXTURES & OTHER GOODIES Computer Graphics. glTexCoord2f(...); + ="— Presentation transcript:

1 TEXTURES & OTHER GOODIES Computer Graphics

2 glTexCoord2f(...); + =

3 + (0,0)(1,0) (1,1)(0,1) =

4 glTexCoord2f(...); + (0,0)(1/2,0) (1/2,1/2)(0,1/2) =

5 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 pre-filtered 2D texture maps of decreasing resolutions gluBuild2DMipmaps(GL_TEXTURE_2D, 4, 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 interaction with a background color using the alpha channel of image // GL_REPLACE to completely disregard lighting and replace it with actual colors from the texture image glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); All this done for you!

6 glBindTexture(GL_TEXTURE_2D, tex1); // tex1 is the identifier for the image you are trying to map on a quad glBegin(GL_POLYGON); glTexCoord2f(0.0, 0.0); glVertex3f(-5, -5, 4); glNormal3f(0, 0, 1); glTexCoord2f(1.0, 0.0); glVertex3f(5, -5, 4); glNormal3f(0, 0, 1); glTexCoord2f(1.0, 1.0); glVertex3f(5, 5, 4); glNormal3f(0, 0, 1); glTexCoord2f(0.0, 1.0); glVertex3f(-5, 5, 4); glNormal3f(0, 0, 1); glEnd();

7 (0, 0) (1, 0) (1, 1) (0, 1) + (-5, -5, 4)(5, -5, 4) (5, 5, 4)(-5, 5, 4) World coordinates Texture coordinates =

8

9 TEXTURING EXAMPLES Simple image loader Texturing example

10 Advance Texturing Techniques Making things look wicked awesome!!!

11 LIGHTMAPS +=

12

13 BUMPMAPS

14 Normal Maps +=

15 Displacement Maps

16 TERRAINS: SKYBOX

17

18

19 ASSIGNMENT Download ‘PlanetTextures’ zip file Contains textures for various planets Download ‘texturesOnQuadObjects’ zip file Shows how to do texturing on various quadratic objects Now, add textures to your planets to make it look more realistic Download ‘skyboxTextures’ zip file Now, put your solar system in a skybox Insulate translations and scaling on the skybox. Only allow rotations. Why?

20 ADDITIONAL GOODIES NormalVector.zip Calculates normal vector, given three vertices OpenGLFontRender.zip Write text using OpenGL fonts SimpleImageLoader.zip Simple illustration for loading textures TexturingExample.zip Various things you can do with texture mapping


Download ppt "TEXTURES & OTHER GOODIES Computer Graphics. glTexCoord2f(...); + ="

Similar presentations


Ads by Google