PDA

View Full Version : Texture mapping again



03-21-2003, 01:22 PM
i'm mapping my 3d objects with BITMAP
but whatever what i do with gltexCoord2f
the first pixel of my 256x256 24bit bitmap
is the only color that i se on my objects




AUX_RGBImageRec *TextureImage = NULL;
FILE *file = NULL;

file = fopen(path, "r");
if (file)
{
fclose(file);
TextureImage =auxDIBImageLoad(path);
this->texture=(unsigned int * )malloc(TextureImage->sizeX*TextureImage->sizeY*3);
this->width=TextureImage->sizeX;
this->height=TextureImage->sizeY;
this->texture=(unsigned int *)malloc(TextureImage->sizeX*TextureImage->sizeY*3);
memcpy(this->texture,TextureImage->data,TextureImage->sizeX*TextureImage->sizeY*3 );
this->path=path;
this->name=path;
}

glGenTextures(1, &this->glNumTex);
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
glBindTexture(GL_TEXTURE_2D, this->glNumTex);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, this->width, this->height, GL_RGB, GL_UNSIGNED_BYTE, this->texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, this->width, this->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, this->texture );
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, this->width, this->height,0, GL_RGB, GL_UNSIGNED_BYTE, this->texture);
CTexture::TexturesList.push_back(this);
free(this->texture);
free(TextureImage);
return path;



do you see something wrong with this?

03-21-2003, 02:24 PM
sorry its plain stupid to push you only a part of the code sor here is the complete vc++ 6 project [URL]http://jp.homeunix.net/phobos.zip[URL] be aware that a lot of code is only for debugging
and testing so it is really not clean