#include <texture.h>
Inheritance diagram for ImageTexture:


Public Member Functions | |
| virtual void | bind () |
| unsigned int | getName () const |
| virtual const TextureTile | getTile (int lod, int u, int v) |
| ImageTexture (Image &img, AddressMode, MipMapMode) | |
| virtual void | setBorderColor (Color) |
| ~ImageTexture () | |
Private Attributes | |
| unsigned int | glName |
|
||||||||||||||||
|
Definition at line 401 of file texture.cpp. References CalcMipLevelCount(), GetGLTexAddressMode(), Texture::getHeight(), getInternalFormat(), Texture::getWidth(), GL_GENERATE_MIPMAP_SGIS, GL_TEXTURE_MAX_LEVEL, glName, LoadMiplessTexture(), and LoadMipmapSet(). 00403 : 00404 Texture(img.getWidth(), img.getHeight()), 00405 glName(0) 00406 { 00407 glGenTextures(1, (GLuint*)&glName); 00408 glBindTexture(GL_TEXTURE_2D, glName); 00409 00410 bool mipmap = mipMapMode == DefaultMipMaps; 00411 bool precomputedMipMaps = false; 00412 00413 // Require a complete set of mipmaps 00414 int mipLevelCount = img.getMipLevelCount(); 00415 if (mipmap && 00416 mipLevelCount == CalcMipLevelCount(img.getWidth(), img.getHeight())) 00417 precomputedMipMaps = true; 00418 00419 // We can't automatically generate mipmaps for compressed textures. 00420 // If a precomputed mipmap set isn't provided, turn of mipmapping entirely. 00421 if (!precomputedMipMaps && img.isCompressed()) 00422 mipmap = false; 00423 00424 GLenum texAddress = GetGLTexAddressMode(addressMode); 00425 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, texAddress); 00426 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, texAddress); 00427 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 00428 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, 00429 mipmap ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR); 00430 00431 if (mipMapMode == AutoMipMaps) 00432 glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE); 00433 00434 int internalFormat = getInternalFormat(img.getFormat()); 00435 00436 if (mipmap) 00437 { 00438 #if 0 00439 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 00440 maxMipMapLevel); 00441 #endif 00442 if (precomputedMipMaps) 00443 { 00444 LoadMipmapSet(img, GL_TEXTURE_2D); 00445 } 00446 else 00447 { 00448 gluBuild2DMipmaps(GL_TEXTURE_2D, 00449 internalFormat, 00450 getWidth(), getHeight(), 00451 (GLenum) img.getFormat(), 00452 GL_UNSIGNED_BYTE, 00453 img.getPixels()); 00454 } 00455 } 00456 else 00457 { 00458 LoadMiplessTexture(img, GL_TEXTURE_2D); 00459 } 00460 00461 alpha = img.hasAlpha(); 00462 }
|
|
|
Definition at line 465 of file texture.cpp. References glName. 00466 {
00467 if (glName != 0)
00468 glDeleteTextures(1, (const GLuint*) &glName);
00469 }
|
|
|
Implements Texture. Definition at line 472 of file texture.cpp. References glName. Referenced by setBorderColor(). 00473 {
00474 glBindTexture(GL_TEXTURE_2D, glName);
00475 }
|
|
|
Definition at line 487 of file texture.cpp. References glName. Referenced by VirtualTexture::getTile(). 00488 {
00489 return glName;
00490 }
|
|
||||||||||||||||
|
Implements Texture. Definition at line 478 of file texture.cpp. References glName. 00479 {
00480 if (lod != 0 || u != 0 || v != 0)
00481 return TextureTile(0);
00482 else
00483 return TextureTile(glName);
00484 }
|
|
|
Reimplemented from Texture. Definition at line 493 of file texture.cpp. References bind(), and SetBorderColor(). 00494 {
00495 bind();
00496 SetBorderColor(borderColor, GL_TEXTURE_2D);
00497 }
|
|
|
Definition at line 112 of file texture.h. Referenced by bind(), getName(), getTile(), ImageTexture(), and ~ImageTexture(). |
1.4.1