mirror of
https://github.com/glest/glest-source.git
synced 2025-08-21 23:45:14 +02:00
- a bunch of in progress work related to texture compression and more timely texture memory management cleanup. For now to test texture compression use the following ini setting: EnableTextureCompression=true
This commit is contained in:
@@ -23,6 +23,44 @@ namespace Shared{ namespace Graphics{ namespace Gl{
|
||||
|
||||
using namespace Platform;
|
||||
|
||||
GLint toCompressionFormatGl(GLint format) {
|
||||
if(Texture::useTextureCompression == false) {
|
||||
return format;
|
||||
}
|
||||
|
||||
//GL_COMPRESSED_ALPHA <- white things but tile ok!
|
||||
//GL_COMPRESSED_LUMINANCE <- black tiles
|
||||
//GL_COMPRESSED_LUMINANCE_ALPHA <- black tiles
|
||||
//GL_COMPRESSED_INTENSITY <- black tiles
|
||||
//GL_COMPRESSED_RGB <- black tiles
|
||||
//GL_COMPRESSED_RGBA <- black tiles
|
||||
|
||||
// With the following extension (GL_EXT_texture_compression_s3tc)
|
||||
//GL_COMPRESSED_RGB_S3TC_DXT1_EXT
|
||||
//GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
|
||||
//GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
|
||||
//GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
|
||||
|
||||
switch(format) {
|
||||
case GL_LUMINANCE:
|
||||
case GL_LUMINANCE8:
|
||||
return GL_COMPRESSED_LUMINANCE;
|
||||
case GL_RGB:
|
||||
case GL_RGB8:
|
||||
//return GL_COMPRESSED_RGB;
|
||||
return GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
|
||||
case GL_RGBA:
|
||||
case GL_RGBA8:
|
||||
//return GL_COMPRESSED_RGBA;
|
||||
return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
|
||||
case GL_ALPHA:
|
||||
case GL_ALPHA8:
|
||||
return GL_COMPRESSED_ALPHA;
|
||||
default:
|
||||
return format;
|
||||
}
|
||||
}
|
||||
|
||||
GLint toWrapModeGl(Texture::WrapMode wrapMode){
|
||||
switch(wrapMode){
|
||||
case Texture::wmClamp:
|
||||
@@ -96,44 +134,6 @@ GLint toInternalFormatGl(Texture::Format format, int components){
|
||||
}
|
||||
}
|
||||
|
||||
GLint toCompressionFormatGl(GLint format) {
|
||||
return format;
|
||||
|
||||
//GL_COMPRESSED_ALPHA <- white things but tile ok!
|
||||
//GL_COMPRESSED_LUMINANCE <- black tiles
|
||||
//GL_COMPRESSED_LUMINANCE_ALPHA <- black tiles
|
||||
//GL_COMPRESSED_INTENSITY <- black tiles
|
||||
//GL_COMPRESSED_RGB <- black tiles
|
||||
//GL_COMPRESSED_RGBA <- black tiles
|
||||
|
||||
// With the following extension (GL_EXT_texture_compression_s3tc)
|
||||
//GL_COMPRESSED_RGB_S3TC_DXT1_EXT
|
||||
//GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
|
||||
//GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
|
||||
//GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
|
||||
|
||||
/*
|
||||
switch(format) {
|
||||
case GL_LUMINANCE:
|
||||
case GL_LUMINANCE8:
|
||||
return GL_COMPRESSED_LUMINANCE;
|
||||
case GL_RGB:
|
||||
case GL_RGB8:
|
||||
//return GL_COMPRESSED_RGB;
|
||||
return GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
|
||||
case GL_RGBA:
|
||||
case GL_RGBA8:
|
||||
//return GL_COMPRESSED_RGBA;
|
||||
return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
|
||||
case GL_ALPHA:
|
||||
case GL_ALPHA8:
|
||||
return GL_COMPRESSED_ALPHA;
|
||||
default:
|
||||
return format;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// =====================================================
|
||||
// class Texture1DGl
|
||||
// =====================================================
|
||||
@@ -147,6 +147,7 @@ void Texture1DGl::init(Filter filter, int maxAnisotropy){
|
||||
GLint wrap= toWrapModeGl(wrapMode);
|
||||
GLint glFormat= toFormatGl(format, pixmap.getComponents());
|
||||
GLint glInternalFormat= toInternalFormatGl(format, pixmap.getComponents());
|
||||
GLint glCompressionFormat = toCompressionFormatGl(glInternalFormat);
|
||||
|
||||
//pixel init var
|
||||
const uint8* pixels= pixmapInit? pixmap.getPixels(): NULL;
|
||||
@@ -171,7 +172,7 @@ void Texture1DGl::init(Filter filter, int maxAnisotropy){
|
||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
int error= gluBuild1DMipmaps(
|
||||
GL_TEXTURE_1D, glInternalFormat, pixmap.getW(),
|
||||
GL_TEXTURE_1D, glCompressionFormat, pixmap.getW(),
|
||||
glFormat, GL_UNSIGNED_BYTE, pixels);
|
||||
|
||||
if(error!=0){
|
||||
@@ -187,7 +188,7 @@ void Texture1DGl::init(Filter filter, int maxAnisotropy){
|
||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
glTexImage1D(
|
||||
GL_TEXTURE_1D, 0, glInternalFormat, pixmap.getW(),
|
||||
GL_TEXTURE_1D, 0, glCompressionFormat, pixmap.getW(),
|
||||
0, glFormat, GL_UNSIGNED_BYTE, pixels);
|
||||
|
||||
GLint error= glGetError();
|
||||
@@ -199,6 +200,7 @@ void Texture1DGl::init(Filter filter, int maxAnisotropy){
|
||||
}
|
||||
}
|
||||
inited= true;
|
||||
OutputTextureDebugInfo(format, pixmap.getComponents(),getPath());
|
||||
}
|
||||
|
||||
assertGl();
|
||||
@@ -280,17 +282,17 @@ void Texture2DGl::init(Filter filter, int maxAnisotropy){
|
||||
sprintf(szBuf,"Error creating texture 2D, returned: %d [%s] w = %d, h = %d, glInternalFormat = %d, glFormat = %d",error,pixmap.getPath().c_str(),pixmap.getW(),pixmap.getH(),glInternalFormat,glFormat);
|
||||
throw runtime_error(szBuf);
|
||||
}
|
||||
|
||||
OutputTextureDebugInfo(&pixmap,format, pixmap.getComponents(),getPath());
|
||||
}
|
||||
inited= true;
|
||||
OutputTextureDebugInfo(format, pixmap.getComponents(),getPath());
|
||||
}
|
||||
|
||||
assertGl();
|
||||
}
|
||||
|
||||
void Texture2DGl::end(){
|
||||
if(inited){
|
||||
if(inited) {
|
||||
//printf("==> Deleting GL Texture [%s] handle = %d\n",getPath().c_str(),handle);
|
||||
assertGl();
|
||||
glDeleteTextures(1, &handle);
|
||||
assertGl();
|
||||
@@ -310,6 +312,7 @@ void Texture3DGl::init(Filter filter, int maxAnisotropy){
|
||||
GLint wrap= toWrapModeGl(wrapMode);
|
||||
GLint glFormat= toFormatGl(format, pixmap.getComponents());
|
||||
GLint glInternalFormat= toInternalFormatGl(format, pixmap.getComponents());
|
||||
GLint glCompressionFormat = toCompressionFormatGl(glInternalFormat);
|
||||
|
||||
//pixel init var
|
||||
const uint8* pixels= pixmapInit? pixmap.getPixels(): NULL;
|
||||
@@ -328,7 +331,7 @@ void Texture3DGl::init(Filter filter, int maxAnisotropy){
|
||||
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
glTexImage3D(
|
||||
GL_TEXTURE_3D, 0, glInternalFormat,
|
||||
GL_TEXTURE_3D, 0, glCompressionFormat,
|
||||
pixmap.getW(), pixmap.getH(), pixmap.getD(),
|
||||
0, glFormat, GL_UNSIGNED_BYTE, pixels);
|
||||
|
||||
@@ -340,6 +343,8 @@ void Texture3DGl::init(Filter filter, int maxAnisotropy){
|
||||
throw runtime_error(szBuf);
|
||||
}
|
||||
inited= true;
|
||||
|
||||
OutputTextureDebugInfo(format, pixmap.getComponents(),getPath());
|
||||
}
|
||||
|
||||
assertGl();
|
||||
@@ -422,7 +427,7 @@ void TextureCubeGl::init(Filter filter, int maxAnisotropy){
|
||||
throw runtime_error(szBuf);
|
||||
}
|
||||
|
||||
OutputTextureDebugInfo(currentPixmap,format, currentPixmap->getComponents(),getPath());
|
||||
OutputTextureDebugInfo(format, currentPixmap->getComponents(),getPath());
|
||||
}
|
||||
inited= true;
|
||||
|
||||
@@ -439,29 +444,28 @@ void TextureCubeGl::end(){
|
||||
}
|
||||
}
|
||||
|
||||
void TextureGl::OutputTextureDebugInfo(const Pixmap2D *pixmap,Texture::Format format, int components,const string path) {
|
||||
void TextureGl::OutputTextureDebugInfo(Texture::Format format, int components,const string path) {
|
||||
if(Texture::useTextureCompression == true) {
|
||||
GLint glFormat= toFormatGl(format, components);
|
||||
|
||||
/*
|
||||
GLint glFormat= toFormatGl(format, components);
|
||||
printf("**** Texture filename: [%s] format = %d components = %d, glFormat = %d\n",path.c_str(),format,components,glFormat);
|
||||
|
||||
printf("**** Texture filename: [%s] format = %d components = %d, glFormat = %d, path [%s]\n",pixmap->getPath().c_str(),format,components,glFormat,path.c_str());
|
||||
GLint compressed=0;
|
||||
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED, &compressed);
|
||||
int error = glGetError();
|
||||
|
||||
GLint compressed=0;
|
||||
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED, &compressed);
|
||||
int error = glGetError();
|
||||
printf("**** Texture compressed status: %d, error [%d]\n",compressed,error);
|
||||
|
||||
printf("**** Texture compressed status: %d, error [%d]\n",compressed,error);
|
||||
compressed=0;
|
||||
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &compressed);
|
||||
error = glGetError();
|
||||
printf("**** Texture image size in video RAM: %d, error [%d]\n",compressed,error);
|
||||
|
||||
compressed=0;
|
||||
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &compressed);
|
||||
error = glGetError();
|
||||
printf("**** Texture image size in video RAM: %d, error [%d]\n",compressed,error);
|
||||
|
||||
compressed=0;
|
||||
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &compressed);
|
||||
error = glGetError();
|
||||
printf("**** Texture image compression format used: %d, error [%d]\n",compressed,error);
|
||||
*/
|
||||
compressed=0;
|
||||
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &compressed);
|
||||
error = glGetError();
|
||||
printf("**** Texture image compression format used: %d, error [%d]\n",compressed,error);
|
||||
}
|
||||
}
|
||||
|
||||
}}}//end namespace
|
||||
|
@@ -34,7 +34,8 @@ using namespace Util;
|
||||
|
||||
// ==================== constructor & destructor ====================
|
||||
|
||||
Mesh::Mesh(){
|
||||
Mesh::Mesh() {
|
||||
textureManager = NULL;
|
||||
frameCount= 0;
|
||||
vertexCount= 0;
|
||||
indexCount= 0;
|
||||
@@ -48,24 +49,25 @@ Mesh::Mesh(){
|
||||
|
||||
for(int i=0; i<meshTextureCount; ++i){
|
||||
textures[i]= NULL;
|
||||
texturesOwned[i]=false;
|
||||
}
|
||||
|
||||
twoSided= false;
|
||||
customColor= false;
|
||||
}
|
||||
|
||||
Mesh::~Mesh(){
|
||||
Mesh::~Mesh() {
|
||||
end();
|
||||
}
|
||||
|
||||
void Mesh::init(){
|
||||
void Mesh::init() {
|
||||
vertices= new Vec3f[frameCount*vertexCount];
|
||||
normals= new Vec3f[frameCount*vertexCount];
|
||||
texCoords= new Vec2f[vertexCount];
|
||||
indices= new uint32[indexCount];
|
||||
}
|
||||
|
||||
void Mesh::end(){
|
||||
void Mesh::end() {
|
||||
delete [] vertices;
|
||||
delete [] normals;
|
||||
delete [] texCoords;
|
||||
@@ -73,6 +75,16 @@ void Mesh::end(){
|
||||
delete [] indices;
|
||||
|
||||
delete interpolationData;
|
||||
|
||||
if(textureManager != NULL) {
|
||||
for(int i = 0; i < meshTextureCount; ++i) {
|
||||
if(texturesOwned[i] == true && textures[i] != NULL) {
|
||||
//printf("Deleting Texture [%s] i = %d\n",textures[i]->getPath().c_str(),i);
|
||||
textureManager->endTexture(textures[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
textureManager = NULL;
|
||||
}
|
||||
|
||||
// ========================== shadows & interpolation =========================
|
||||
@@ -91,7 +103,8 @@ void Mesh::updateInterpolationVertices(float t, bool cycle) const{
|
||||
|
||||
// ==================== load ====================
|
||||
|
||||
void Mesh::loadV2(const string &dir, FILE *f, TextureManager *textureManager){
|
||||
void Mesh::loadV2(const string &dir, FILE *f, TextureManager *textureManager,bool deletePixMapAfterLoad) {
|
||||
this->textureManager = textureManager;
|
||||
//read header
|
||||
MeshHeaderV2 meshHeader;
|
||||
size_t readBytes = fread(&meshHeader, sizeof(MeshHeaderV2), 1, f);
|
||||
@@ -125,6 +138,12 @@ void Mesh::loadV2(const string &dir, FILE *f, TextureManager *textureManager){
|
||||
if(textures[mtDiffuse]==NULL){
|
||||
textures[mtDiffuse]= textureManager->newTexture2D();
|
||||
textures[mtDiffuse]->load(texPath);
|
||||
texturesOwned[mtDiffuse]=true;
|
||||
// M.V. Test
|
||||
textures[mtDiffuse]->init(textureManager->getTextureFilter(),textureManager->getMaxAnisotropy());
|
||||
if(deletePixMapAfterLoad == true) {
|
||||
textures[mtDiffuse]->deletePixels();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +159,9 @@ void Mesh::loadV2(const string &dir, FILE *f, TextureManager *textureManager){
|
||||
readBytes = fread(indices, sizeof(uint32)*indexCount, 1, f);
|
||||
}
|
||||
|
||||
void Mesh::loadV3(const string &dir, FILE *f, TextureManager *textureManager){
|
||||
void Mesh::loadV3(const string &dir, FILE *f, TextureManager *textureManager,bool deletePixMapAfterLoad) {
|
||||
this->textureManager = textureManager;
|
||||
|
||||
//read header
|
||||
MeshHeaderV3 meshHeader;
|
||||
size_t readBytes = fread(&meshHeader, sizeof(MeshHeaderV3), 1, f);
|
||||
@@ -170,6 +191,12 @@ void Mesh::loadV3(const string &dir, FILE *f, TextureManager *textureManager){
|
||||
if(textures[mtDiffuse]==NULL){
|
||||
textures[mtDiffuse]= textureManager->newTexture2D();
|
||||
textures[mtDiffuse]->load(texPath);
|
||||
texturesOwned[mtDiffuse]=true;
|
||||
// M.V. Test
|
||||
textures[mtDiffuse]->init(textureManager->getTextureFilter(),textureManager->getMaxAnisotropy());
|
||||
if(deletePixMapAfterLoad == true) {
|
||||
textures[mtDiffuse]->deletePixels();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,7 +214,9 @@ void Mesh::loadV3(const string &dir, FILE *f, TextureManager *textureManager){
|
||||
readBytes = fread(indices, sizeof(uint32)*indexCount, 1, f);
|
||||
}
|
||||
|
||||
void Mesh::load(const string &dir, FILE *f, TextureManager *textureManager){
|
||||
void Mesh::load(const string &dir, FILE *f, TextureManager *textureManager,bool deletePixMapAfterLoad) {
|
||||
this->textureManager = textureManager;
|
||||
|
||||
//read header
|
||||
MeshHeader meshHeader;
|
||||
size_t readBytes = fread(&meshHeader, sizeof(MeshHeader), 1, f);
|
||||
@@ -222,10 +251,15 @@ void Mesh::load(const string &dir, FILE *f, TextureManager *textureManager){
|
||||
textures[i]= static_cast<Texture2D*>(textureManager->getTexture(mapFullPath));
|
||||
if(textures[i]==NULL){
|
||||
textures[i]= textureManager->newTexture2D();
|
||||
if(meshTextureChannelCount[i]!=-1){
|
||||
if(meshTextureChannelCount[i] != -1){
|
||||
textures[i]->getPixmap()->init(meshTextureChannelCount[i]);
|
||||
}
|
||||
textures[i]->load(mapFullPath);
|
||||
texturesOwned[i]=true;
|
||||
textures[i]->init(textureManager->getTextureFilter(),textureManager->getMaxAnisotropy());
|
||||
if(deletePixMapAfterLoad == true) {
|
||||
textures[i]->deletePixels();
|
||||
}
|
||||
}
|
||||
}
|
||||
flag*= 2;
|
||||
@@ -313,6 +347,14 @@ void Mesh::computeTangents(){
|
||||
}
|
||||
}
|
||||
|
||||
void Mesh::deletePixels() {
|
||||
for(int i = 0; i < meshTextureCount; ++i) {
|
||||
if(textures[i] != NULL) {
|
||||
textures[i]->deletePixels();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===============================================
|
||||
// class Model
|
||||
// ===============================================
|
||||
@@ -359,7 +401,7 @@ uint32 Model::getTriangleCount() const{
|
||||
return triangleCount;
|
||||
}
|
||||
|
||||
uint32 Model::getVertexCount() const{
|
||||
uint32 Model::getVertexCount() const {
|
||||
uint32 vertexCount= 0;
|
||||
for(uint32 i=0; i<meshCount; ++i){
|
||||
vertexCount+= meshes[i].getVertexCount();
|
||||
@@ -369,17 +411,17 @@ uint32 Model::getVertexCount() const{
|
||||
|
||||
// ==================== io ====================
|
||||
|
||||
void Model::load(const string &path){
|
||||
void Model::load(const string &path, bool deletePixMapAfterLoad) {
|
||||
string extension= path.substr(path.find_last_of('.')+1);
|
||||
if(extension=="g3d" || extension=="G3D"){
|
||||
loadG3d(path);
|
||||
loadG3d(path,deletePixMapAfterLoad);
|
||||
}
|
||||
else{
|
||||
throw runtime_error("Unknown model format: " + extension);
|
||||
}
|
||||
}
|
||||
|
||||
void Model::save(const string &path){
|
||||
void Model::save(const string &path) {
|
||||
string extension= path.substr(path.find_last_of('.')+1);
|
||||
if(extension=="g3d" ||extension=="G3D" || extension=="s3d" || extension=="S3D"){
|
||||
saveS3d(path);
|
||||
@@ -428,7 +470,7 @@ void Model::save(const string &path){
|
||||
}*/
|
||||
|
||||
//load a model from a g3d file
|
||||
void Model::loadG3d(const string &path){
|
||||
void Model::loadG3d(const string &path, bool deletePixMapAfterLoad) {
|
||||
|
||||
try{
|
||||
FILE *f=fopen(path.c_str(),"rb");
|
||||
@@ -462,7 +504,7 @@ void Model::loadG3d(const string &path){
|
||||
//load meshes
|
||||
meshes= new Mesh[meshCount];
|
||||
for(uint32 i=0; i<meshCount; ++i){
|
||||
meshes[i].load(dir, f, textureManager);
|
||||
meshes[i].load(dir, f, textureManager,deletePixMapAfterLoad);
|
||||
meshes[i].buildInterpolationData();
|
||||
}
|
||||
}
|
||||
@@ -472,7 +514,7 @@ void Model::loadG3d(const string &path){
|
||||
readBytes = fread(&meshCount, sizeof(meshCount), 1, f);
|
||||
meshes= new Mesh[meshCount];
|
||||
for(uint32 i=0; i<meshCount; ++i){
|
||||
meshes[i].loadV3(dir, f, textureManager);
|
||||
meshes[i].loadV3(dir, f, textureManager,deletePixMapAfterLoad);
|
||||
meshes[i].buildInterpolationData();
|
||||
}
|
||||
}
|
||||
@@ -482,7 +524,7 @@ void Model::loadG3d(const string &path){
|
||||
readBytes = fread(&meshCount, sizeof(meshCount), 1, f);
|
||||
meshes= new Mesh[meshCount];
|
||||
for(uint32 i=0; i<meshCount; ++i){
|
||||
meshes[i].loadV2(dir, f, textureManager);
|
||||
meshes[i].loadV2(dir, f, textureManager,deletePixMapAfterLoad);
|
||||
meshes[i].buildInterpolationData();
|
||||
}
|
||||
}
|
||||
@@ -523,4 +565,10 @@ void Model::saveS3d(const string &path){
|
||||
fclose(f);*/
|
||||
}
|
||||
|
||||
void Model::deletePixels() {
|
||||
for(uint32 i = 0; i < meshCount; ++i) {
|
||||
meshes[i].deletePixels();
|
||||
}
|
||||
}
|
||||
|
||||
}}//end namespace
|
||||
|
@@ -352,8 +352,13 @@ void Pixmap1D::init(int w, int components){
|
||||
pixels= new uint8[w*components];
|
||||
}
|
||||
|
||||
Pixmap1D::~Pixmap1D(){
|
||||
void Pixmap1D::deletePixels() {
|
||||
delete [] pixels;
|
||||
pixels = NULL;
|
||||
}
|
||||
|
||||
Pixmap1D::~Pixmap1D(){
|
||||
deletePixels();
|
||||
}
|
||||
|
||||
void Pixmap1D::load(const string &path){
|
||||
@@ -463,8 +468,13 @@ void Pixmap2D::init(int w, int h, int components) {
|
||||
pixels= new uint8[h*w*components];
|
||||
}
|
||||
|
||||
Pixmap2D::~Pixmap2D(){
|
||||
void Pixmap2D::deletePixels() {
|
||||
delete [] pixels;
|
||||
pixels = NULL;
|
||||
}
|
||||
|
||||
Pixmap2D::~Pixmap2D(){
|
||||
deletePixels();
|
||||
}
|
||||
|
||||
Pixmap2D* Pixmap2D::loadPath(const string& path) {
|
||||
@@ -778,8 +788,13 @@ void Pixmap3D::init(int components){
|
||||
pixels= NULL;
|
||||
}
|
||||
|
||||
Pixmap3D::~Pixmap3D(){
|
||||
void Pixmap3D::deletePixels() {
|
||||
delete [] pixels;
|
||||
pixels = NULL;
|
||||
}
|
||||
|
||||
Pixmap3D::~Pixmap3D(){
|
||||
deletePixels();
|
||||
}
|
||||
|
||||
void Pixmap3D::loadSlice(const string &path, int slice){
|
||||
@@ -862,5 +877,11 @@ void PixmapCube::loadFace(const string &path, int face){
|
||||
faces[face].load(path);
|
||||
}
|
||||
|
||||
void PixmapCube::deletePixels() {
|
||||
for(int i=0; i<6; ++i){
|
||||
faces[i].deletePixels();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}}//end namespace
|
||||
|
@@ -24,6 +24,7 @@ namespace Shared{ namespace Graphics{
|
||||
|
||||
const int Texture::defaultSize= 256;
|
||||
const int Texture::defaultComponents = 4;
|
||||
bool Texture::useTextureCompression = false;
|
||||
|
||||
Texture::Texture(){
|
||||
mipmap= true;
|
||||
@@ -49,6 +50,15 @@ void Texture1D::load(const string &path){
|
||||
this->path= path;
|
||||
}
|
||||
|
||||
string Texture1D::getPath() const {
|
||||
return (pixmap.getPath() != "" ? pixmap.getPath() : path);
|
||||
}
|
||||
|
||||
void Texture1D::deletePixels() {
|
||||
//printf("+++> Texture pixmap deletion for [%s]\n",getPath().c_str());
|
||||
pixmap.deletePixels();
|
||||
}
|
||||
|
||||
// =====================================================
|
||||
// class Texture2D
|
||||
// =====================================================
|
||||
@@ -64,6 +74,15 @@ void Texture2D::load(const string &path){
|
||||
this->path= path;
|
||||
}
|
||||
|
||||
string Texture2D::getPath() const {
|
||||
return (pixmap.getPath() != "" ? pixmap.getPath() : path);
|
||||
}
|
||||
|
||||
void Texture2D::deletePixels() {
|
||||
//printf("+++> Texture pixmap deletion for [%s]\n",getPath().c_str());
|
||||
pixmap.deletePixels();
|
||||
}
|
||||
|
||||
// =====================================================
|
||||
// class Texture3D
|
||||
// =====================================================
|
||||
@@ -79,6 +98,15 @@ void Texture3D::loadSlice(const string &path, int slice){
|
||||
this->path= path;
|
||||
}
|
||||
|
||||
string Texture3D::getPath() const {
|
||||
return (pixmap.getPath() != "" ? pixmap.getPath() : path);
|
||||
}
|
||||
|
||||
void Texture3D::deletePixels() {
|
||||
//printf("+++> Texture pixmap deletion for [%s]\n",getPath().c_str());
|
||||
pixmap.deletePixels();
|
||||
}
|
||||
|
||||
// =====================================================
|
||||
// class TextureCube
|
||||
// =====================================================
|
||||
@@ -94,4 +122,25 @@ void TextureCube::loadFace(const string &path, int face){
|
||||
this->path= path;
|
||||
}
|
||||
|
||||
string TextureCube::getPath() const {
|
||||
string result = "";
|
||||
for(int i = 0; i < 6; ++i) {
|
||||
if(pixmap.getPath(i) != "") {
|
||||
if(result != "") {
|
||||
result += ",";
|
||||
}
|
||||
result += pixmap.getPath(i);
|
||||
}
|
||||
}
|
||||
if(result == "") {
|
||||
result = path;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void TextureCube::deletePixels() {
|
||||
//printf("+++> Texture pixmap deletion for [%s]\n",getPath().c_str());
|
||||
pixmap.deletePixels();
|
||||
}
|
||||
|
||||
}}//end namespace
|
||||
|
Reference in New Issue
Block a user