Advertisement

gentextures probs

Started by August 22, 2002 11:49 AM
2 comments, last by modification 22 years, 6 months ago
hello all, got a nice simple (maybe) gentextures prob for ya... in my game i have a vector array of materials, each material has its own shineyness, colour and (more importantly) texture... to load said texture into the material vector i use the following code...
  
int TextureStack::LoadTexture(char* name)
{
    int Status=FALSE;
    GLuint temp;

    tgaInfo *image;
    image = tgaLoad(name);

    if (image != NULL)
    {
        glGenTextures(1, &temp);
		glBindTexture(GL_TEXTURE_2D, temp);
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image->width, image->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image->imageData);
		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);

        printf("\t- Loaded!");

        Texture* tempTexture = new Texture(name, temp);
        textures.push_back(tempTexture);
        Status = TRUE;
	}
    else
        printf("\t- Not Loaded!", name);


	return Status;
}
  
h''okay.. so thats the code... as you can see temp is assigned the GLuint from the gentextures command and then temp is stored in the Texture object... basically the GLuint that is stored in the Texture never changes. in fact its always 858993460 for some reason. i''m probably doing something intrinsicly wrong. can anyone offer any assistance? Mod
ideas:

1) are you sure the targa loading code is correct?
2) I'm mot sure; does tga have an alpha channel (notice the GL_RGBA parameter!)
3) where are you checking the value of temp? try checking it before you add tempTexture to the vector (that is, check the value of temp, not the value of textures]i[-&gttextureHandle)

the code seems ok from where I'm standing...

Crispy

edit: html... - don't remember the codes for ] and [, so I inverted them


[edited by - crispy on August 22, 2002 1:57:41 PM]
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
Advertisement
ello agian,

yeah the targa is loading correctly (i assume, i used a tga loader i''ve used for a while now)..

i''ve checked the value of temp before and after the gentextures cmd and the value doesnt change at all. very strange :\


Mod
aaaaaaaaaaaaaaahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh

ok... i''m a fool.. i admit it!


i just bin talkin my prob over with a mate of mine and he brought it to my attention that i mite not have a DC before i call glGenTextures... and lo, he was right!

Cheers OJ!!

well dont i feel a fool now


thanks one and all!



Mod

This topic is closed to new replies.

Advertisement