void loadSkyboxTextures(void) { char *impathfile[6] = { "textures/front.tga", "textures/back.tga", "textures/right.tga", "textures/left.tga", "textures/top.tga", "textures/bottom.tga" }; int i; // Carrega as imagens de textura da skybox for (i = 0; i<6; i++) { im2[i] = tgaLoad(impathfile[i]); //printf("IMAGE INFO: %s\nstatus: %d\ntype: %d\npixelDepth: %d\nsize%d x %d\n", impathfile[i], im2[i]->status, im2[i]->type, im2[i]->pixelDepth, im2[i]->width, im2[i]->height); fflush(stdout); } for (i = 0; i<6; i++) { // Selecciona uma textura glBindTexture(GL_TEXTURE_2D, skyboxtextures[i]); // Impede a existência de "bordas" entre as texturas glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); // MIPMAP glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // build our texture mipmaps gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, im2[i]->width, im2[i]->height, GL_RGB, GL_UNSIGNED_BYTE, im2[i]->imageData); // MIPMAP glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, im2[i]->width, im2[i]->height, 0, GL_RGB, GL_UNSIGNED_BYTE, im2[i]->imageData); } // Destroi as imagens for (i = 0; i<6; i++) tgaDestroy(im2[i]); }
TileMapAtlas::~TileMapAtlas() { if (_TGAInfo) { tgaDestroy(_TGAInfo); } }
void loadTextures(tgaInfo *info, GLuint *texture) { GLsizei w, h; int mode; if (info->status != TGA_OK) { fprintf(stderr, "error loading texture image: %d\n", info->status); return; } mode = info->pixelDepth / 8; // will be 3 for rgb, 4 for rgba glGenTextures(1, texture); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glBindTexture(GL_TEXTURE_2D, texture[0]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); // Upload the texture bitmap. w = info->width; h = info->height; reportGLError("before uploading texture"); GLint format = (mode == 4) ? GL_RGBA : GL_RGB; glTexImage2D(GL_TEXTURE_2D, 0, format, w, h, 0, format, GL_UNSIGNED_BYTE, info->imageData); reportGLError("after uploading texture"); tgaDestroy(info); }
TileMapAtlas::~TileMapAtlas() { if (_TGAInfo) { tgaDestroy(_TGAInfo); } CC_SAFE_RELEASE(_posToAtlasIndex); }
CCTileMapAtlas::~CCTileMapAtlas() { if (m_pTGAInfo) { tgaDestroy(m_pTGAInfo); } CC_SAFE_RELEASE(m_pPosToAtlasIndex); }
void TileMapAtlas::releaseMap() { if (_TGAInfo) { tgaDestroy(_TGAInfo); } _TGAInfo = nullptr; }
void TileMapAtlas::releaseMap() { if (_TGAInfo) { tgaDestroy(_TGAInfo); } _TGAInfo = NULL; CC_SAFE_RELEASE_NULL(_posToAtlasIndex); }
void CCTileMapAtlas::releaseMap() { if (m_pTGAInfo) { tgaDestroy(m_pTGAInfo); } m_pTGAInfo = NULL; CC_SAFE_RELEASE_NULL(m_pPosToAtlasIndex); }
CCTileMapAtlas::~CCTileMapAtlas() { if (m_pTGAInfo) { tgaDestroy(m_pTGAInfo); } if (m_pPosToAtlasIndex) { m_pPosToAtlasIndex->clear(); delete m_pPosToAtlasIndex; m_pPosToAtlasIndex = NULL; } }
Button::~Button() { deque<Button *>::iterator rit; for(rit=buttons.begin() ; rit < buttons.end(); rit++){ if((*rit)==this){ buttons.erase(rit); break; } } tgaDestroy(pic); }
bool tgaReadImage(const std::string &file, U8 *&bitmap, glm::ivec2 &dims, BitmapTexture::Format &format) { tgaInfo *info = tgaLoad(file.c_str()); if (info == NULL) { return false; } if (info->status != TGA_OK) { tgaDestroy(info); IO::printf("Error reading TGA: %d", info->status); return false; } dims.x = info->width; dims.y = info->height; format = (info->pixelDepth == 24 ? BitmapTexture::FormatRGB8 : BitmapTexture::FormatRGBA8); bitmap = new U8[info->width * info->height * (info->pixelDepth / 8)]; memcpy(bitmap, info->imageData, info->width * info->height * (info->pixelDepth / 8)); tgaDestroy(info); return true; }
void CCTileMapAtlas::releaseMap() { if (m_pTGAInfo) { tgaDestroy(m_pTGAInfo); } m_pTGAInfo = NULL; if (m_pPosToAtlasIndex) { m_pPosToAtlasIndex->clear(); delete m_pPosToAtlasIndex; m_pPosToAtlasIndex = NULL; } }
void load_tga_image(std::string nome, GLuint texture, bool transparency) { std::string impathfile = "textures/" + nome + ".tga"; std::vector<char> writable(impathfile.begin(), impathfile.end()); writable.push_back('\0'); // Carrega a imagem de textura im = tgaLoad(&writable[0]); //printf("IMAGE INFO: %s\nstatus: %d\ntype: %d\npixelDepth: %d\nsize%d x %d\n", impathfile, im->status, im->type, im->pixelDepth, im->width, im->height); // Seleciona a textura atual glBindTexture(GL_TEXTURE_2D, texture); // set up quadric object and turn on FILL draw style for it mysolid = gluNewQuadric(); gluQuadricDrawStyle(mysolid, GLU_FILL); // turn on texture coordinate generator for the quadric gluQuadricTexture(mysolid, GL_TRUE); // select modulate to mix texture with color for shading glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); // MIPMAP glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // build our texture mipmaps if (!transparency){ gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, im->width, im->height, GL_RGB, GL_UNSIGNED_BYTE, im->imageData); // MIPMAP glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, im->width, im->height, 0, GL_RGB, GL_UNSIGNED_BYTE, im->imageData); } else{ //Textura com transparência (anéis de saturno) gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, im->width, im->height, GL_RGB, GL_UNSIGNED_BYTE, im->imageData); // MIPMAP glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, im->width, im->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, im->imageData); } // Destroi a imagem tgaDestroy(im); }
hud::~hud(void){ tgaDestroy(this->font); glDeleteLists(this->base,256); message("[HUD]\t\tFont deleted"); }
Image::~Image() { tgaDestroy(pic); }
int terrainLoadFromImage(char *filename, int normals) { tgaInfo *info; int mode; float pointHeight; /* if a terrain already exists, destroy it. */ if (terrainHeights != NULL) terrainDestroy(); /* load the image, using the tgalib */ info = tgaLoad(filename); /* check to see if the image was properly loaded remember: only greyscale, RGB or RGBA noncompressed images */ if (info->status != TGA_OK) return(TERRAIN_ERROR_LOADING_IMAGE); /* if the image is RGB, convert it to greyscale mode will store the image's number of components */ mode = info->pixelDepth / 8; if (mode == 3) { tgaRGBtoGreyscale(info); mode = 1; } /* set the width and height of the terrain */ terrainGridWidth = info->width; terrainGridLength = info->height; /* alocate memory for the terrain, and check for errors */ terrainHeights = (float *)malloc(terrainGridWidth * terrainGridLength * sizeof(float)); if (terrainHeights == NULL) return(TERRAIN_ERROR_MEMORY_PROBLEM); /* allocate memory for the normals, and check for errors */ if (normals) { terrainNormals = (float *)malloc(terrainGridWidth * terrainGridLength * sizeof(float) * 3); if (terrainNormals == NULL) return(TERRAIN_ERROR_MEMORY_PROBLEM); } else terrainNormals = NULL; /* if mode = RGBA then allocate memory for colors, and check for errors */ if (mode == 4) { terrainColors = (float *)malloc(terrainGridWidth * terrainGridLength * sizeof(float)*3); if (terrainColors == NULL) return(TERRAIN_ERROR_MEMORY_PROBLEM); } else terrainColors = NULL; /* fill arrays */ for (int i = 0 ; i < terrainGridLength; i++) for (int j = 0;j < terrainGridWidth; j++) { /* compute the height as a value between 0.0 and 1.0 */ pointHeight = info->imageData[mode*(i*terrainGridWidth + j)+(mode-1)] / 255.0; terrainHeights[i*terrainGridWidth + j] = pointHeight; /* if mode = RGBA then fill the colors array as well */ if (mode==4) { terrainColors[3*(i*terrainGridWidth + j)] = (info->imageData[mode*(i*terrainGridWidth + j)])/255.0; terrainColors[3*(i*terrainGridWidth + j)+1] = (info->imageData[mode*(i*terrainGridWidth + j)+1])/255.0; terrainColors[3*(i*terrainGridWidth + j)+2] = (info->imageData[mode*(i*terrainGridWidth + j)+2])/255.0; } } /* if we want normals then compute them */ if (normals) terrainComputeNormals(); /* free the image's memory */ tgaDestroy(info); return(TERRAIN_OK); }
Mouse::~Mouse() { tgaDestroy(image); }