Skip to main content
GameDev.net gamedev.net
🔒 Locked

Problems with textures

Started by keinname Feb 20, 2003 at 9:49 AM 2 replies 300+ views
Original Post
keinname
keinname
Hi everyone, I am having problems with using textures on Visual C++. I suspect that somehow my texture is not being loaded properly. Could anyone help me, please? Here is the code. I use the function CargarBMP to load the BMP and the function InicializaTexturas should get the texture, but when I bind the texture to an object on the Display function nothing is shown Thanks in advance for your help //TEXTURES GLuint texturas[1]; //id''s of the textures AUX_RGBImageRec *imagen[1]; //struct that saves the bitmap //included in GLAUX.H //this function loads a BMP //it can be found on Lesson 6 of Nehe Productions AUX_RGBImageRec *CargarBMP(char *NombreFichero) { FILE *Imagen=NULL; if (!NombreFichero) // we check if we have the file name { return NULL; //if not we return NULL } Imagen=fopen(NombreFichero,"r"); if (Imagen) // we check if file exists { fclose(Imagen); // if affirmative we close the handle return auxDIBImageLoad(NombreFichero); // and return the BMP } return NULL; //if not we return NULL } //this function prepares the textures void InicializaTexturas() { memset(imagen,0,sizeof(void *)*1); //initialize of the table memory if(imagen[0]= CargarBMP("asfalto.bmp")) { //if we can load the BMP we begin to create the texture glPixelStorei(GL_UNPACK_ALIGNMENT,1); glGenTextures(1,&texturas[0]); //assign an id for texture glBindTexture(GL_TEXTURE_2D, texturas[0]); //bind the texture to work on it //texture will be mixed with material glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE, GL_MODULATE); //texture will be repeated glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); //this line below DOES NOT work on my code(?) // glTexImage2D(GL_TEXTURE_2D, 2, GL_RGB,imagen[0]->sizeX, imagen[0]->sizeY, // 0, GL_RGB, GL_UNSIGNED_BYTE, imagen[0]->data); //we assign the texture. It works only sometimes gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, imagen[0]->sizeX, imagen[0]->sizeY, GL_BGR_EXT, GL_UNSIGNED_BYTE, imagen[0]->data); } } Further info: - Texture is 64x64 - TexCoord are assigned correctly
keinname
keinname
Yes, I enabled GL_TEXTURE_2D and removing the [1] did also not solve the problem...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.