Original Post
Hi, i'm tryng to create an engine, and now i want to add the texture compression loader in my engine. So, that's the code: COMPRESSER: /* bla bla bla TGA loading */ ... ... if ( status = true ) { nTexture = textureId++; glGenTextures (1, &nTexture); glBindTexture (GL_TEXTURE_2D, nTexture); glTexImage2D (GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB, texti->width, texti->height, 0, texti->type, GL_UNSIGNED_BYTE, texti->data); glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED_ARB, &compressed); if ( compressed == GL_TRUE ) { GLubyte *comp_data; //Qui mettiamo i dati compressi della texture GLuint width, height; //Larghezza e altezza della texture GLint internal_format; //Formato di compressione della texture GLint imageSize; //Grandezza della texture glGetTexLevelParameteriv(GL_TEXTURE_2D,0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB, &imageSize); cout << "Grandezza immagine dopo compressione: " << imageSize << " Bytes" << endl; comp_data = (GLubyte*)malloc(imageSize*sizeof(GLubyte)); //Otteniamo il formato interno dell'immagine glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &internal_format); cout << "Formato interno: " << internal_format << endl; glGetCompressedTexImage( GL_TEXTURE_2D, 0, comp_data ); width = texti->width; height = texti->height; cout << "Inizio scrittura del nuovo file..." << endl; FILE *f1; //Nuova texture f1 = fopen ( "new.mtx", "wb" ); /* STRUTTURA FILE TEXTURE // WIDTH // HEIGHT // INTERNAL FORMAT // SIZE // DATA */ fprintf( f1, "%d %d %X %d",width, height, internal_format, imageSize ); fwrite ( comp_data, 1, imageSize, f1); fclose (f1); ----------------------------------------------------------------------- And that's the loader: bool CTexture::loadMtx(FILE *fTGA, texture *texti) { cout << "Carico un MTX" << endl; fscanf(fTGA, "%d %d %X %d",&texti->width, &texti->height, &texti->internal_format, &texti->size ); cout << texti->width << " " << texti->height << " " << texti->internal_format << " " << texti->size << endl; texti->data = (GLubyte*)malloc(texti->size); fread ( texti->data, 1, texti->size, fTGA); return true; } /* bla bla, mtx loading */ GLint compressed; GLint imageSize; if ( status = true ) { nTexture = textureId++; glGenTextures (1, &nTexture); glBindTexture (GL_TEXTURE_2D, nTexture); glCompressedTexImage2D(GL_TEXTURE_2D, 0, texti->internal_format, texti->width, texti->height, 0, texti->size, texti->data); //glTexImage2D (GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, texti->width, texti->height, 0, texti->type, GL_UNSIGNED_BYTE, texti->data); //Setta i filtri e crea il mipmap glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR); // gluBuild2DMipmaps( GL_TEXTURE_2D, 3, texti->width, texti->height, texti->type, GL_UNSIGNED_BYTE, texti->data); } ----------------------------------------------------------------------- Well, i get a white square... why? What's wrong? For the extensions, i'm using glee compiled within the project.. If someone wants, i can give him the entire source code, it's too big for postint it here. Thanks and sorry for my bad english