Jump to content
  • Advertisement
Sign in to follow this  
jake_Ghost

problem with tgas and mipmap

This topic is 4913 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

when i create my lin and near parts of a texture it works fine, but when i try and make a mipmap of it, the thing went white on me. heres the code.
glGenTextures(1,&TGATexture[TexCountTGA-1].imageDataMip);

		// Bind Mipmap Texture
		glBindTexture(GL_TEXTURE_2D, TGATexture[TexCountTGA-1].imageDataMip);
		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);
		gluBuild2DMipmaps(GL_TEXTURE_2D, TGATexture[TexCountTGA-1].bpp / 8, TGATexture[TexCountTGA-1].width, TGATexture[TexCountTGA-1].height, TGATexture[TexCountTGA-1].type, GL_UNSIGNED_BYTE, TGATexture[TexCountTGA-1].imageData);

any help would be great thx

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by jake_Ghost
when i create my lin and near parts of a texture it works fine, but when i try and make a mipmap of it, the thing went white on me. heres the code.

*** Source Snippet Removed ***

any help would be great thx


So if you use glTexImage2D() instead of gluBuild2DMipmaps() your texture loads fine?

Share this post


Link to post
Share on other sites
Why don't you go there: http://www.freewebs.com/vortex666/index.html

and download the modified texture loader i've done. It will load bmp, tga and jpeg and can add an alpha channel based on the colour of you're choice with any of these file format?

Share this post


Link to post
Share on other sites
Quote:
Original post by MARS_999
Quote:
Original post by jake_Ghost
when i create my lin and near parts of a texture it works fine, but when i try and make a mipmap of it, the thing went white on me. heres the code.

*** Source Snippet Removed ***

any help would be great thx


So if you use glTexImage2D() instead of gluBuild2DMipmaps() your texture loads fine?


yup

Share this post


Link to post
Share on other sites
heres the code for that part...


BOOL cTGA :: LoadGLTextures (std::string Filename, int TYPE)
{
FILE * fTGA; // File pointer to texture file
fTGA = fopen(Filename.c_str(), "rb"); // Open file for reading

if(fTGA == NULL) // If it didn't open....
{
MessageBox(NULL, "Could not open texture file", "ERROR", MB_OK); // Display an error message
return false; // Exit function
}

if(fread(&tgaheader, sizeof(TGAHeader), 1, fTGA) == 0) // Attempt to read 12 byte header from file
{
MessageBox(NULL, "Could not read file header", "ERROR", MB_OK); // If it fails, display an error message
if(fTGA != NULL) // Check to seeiffile is still open
{
fclose(fTGA); // If it is, close it
}
return false; // Exit function
}

TGATex tmpTGA;

TGATexture.push_back(tmpTGA);
TexCountTGA += 1;

if(memcmp(uTGAcompare, &tgaheader, sizeof(tgaheader)) == 0) // See if header matches the predefined header of
{ // an Uncompressed TGA image
LoadUncompressedTGA(&TGATexture[TexCountTGA-1], Filename.c_str(), fTGA); // If so, jump to Uncompressed TGA loading code
}
else if(memcmp(cTGAcompare, &tgaheader, sizeof(tgaheader)) == 0) // See if header matches the predefined header of
{ // an RLE compressed TGA image
LoadCompressedTGA(&TGATexture[TexCountTGA-1], Filename.c_str(), fTGA); // If so, jump to Compressed TGA loading code
}
else // If header matches neither type
{
MessageBox(NULL, "TGA file be type 2 or type 10 ", "Invalid Image", MB_OK); // Display an error
fclose(fTGA);
return false; // Exit function
}

// Generate Textures
//if (TYPE == 1)
//{
glGenTextures(1,&TGATexture[TexCountTGA-1].imageDataNear);

// Bind Nearest Texture
glBindTexture(GL_TEXTURE_2D, TGATexture[TexCountTGA-1].imageDataNear);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, TGATexture[TexCountTGA-1].bpp / 8, TGATexture[TexCountTGA-1].width, TGATexture[TexCountTGA-1].height, 0, TGATexture[TexCountTGA-1].type, GL_UNSIGNED_BYTE, TGATexture[TexCountTGA-1].imageData);
//}
//else if(TYPE==2)
//{
glGenTextures(1,&TGATexture[TexCountTGA-1].imageDataLin);

// Bind Linear Texture
glBindTexture(GL_TEXTURE_2D, TGATexture[TexCountTGA-1].imageDataLin);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, TGATexture[TexCountTGA-1].bpp / 8, TGATexture[TexCountTGA-1].width, TGATexture[TexCountTGA-1].height, 0, TGATexture[TexCountTGA-1].type, GL_UNSIGNED_BYTE, TGATexture[TexCountTGA-1].imageData);
//}
//else if(TYPE == 3)
//{
glGenTextures(1,&TGATexture[TexCountTGA-1].imageDataMip);

// Bind Mipmap Texture
glBindTexture(GL_TEXTURE_2D, TGATexture[TexCountTGA-1].imageDataMip);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);
gluBuild2DMipmaps(GL_TEXTURE_2D, TGATexture[TexCountTGA-1].bpp / 8, TGATexture[TexCountTGA-1].width, TGATexture[TexCountTGA-1].height, TGATexture[TexCountTGA-1].type, GL_UNSIGNED_BYTE, TGATexture[TexCountTGA-1].imageData);
//}

TGATexture[TexCountTGA-1].FileName = Filename;
return true; // All went well, continue on
}

Share this post


Link to post
Share on other sites
Dude if that code is right you have commented out your code and its running all three texture setup code fragments...

Share this post


Link to post
Share on other sites
some comments

TGATexture[TexCountTGA-1].bpp / 8
-- use an internal format
TGATexture[TexCountTGA-1].FileName = Filename;
-- im surprised this works
also go
Texdgshjsagdj &tex = TGATexture[TexCountTGA-1];
so u can write tex.imageDataMip (easier to understand)

in answer to your question though i have no idea :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!