Create a texture

Started by
3 comments, last by Loicus 16 years, 10 months ago
Hi I have a stupid problem... but I can't find a solution so I hope that someone can help me... In fact, I want to create my own texture en RGB 24 bits Texture = new unsigned char [img_width*img_height*3]; for(j=0;j<img_height;j++) { for(i=0;i<img_width;i++) { index = j*img_width*3+i*3; Texture[index+0] = r Texture[index+1] = g Texture[index+2] = b } } glBindTexture (GL_TEXTURE_2D, *id); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexImage2D (GL_TEXTURE_2D, 0, 3, img_width, img_height, 0, GL_RGB, GL_UNSIGNED_BYTE, Texture); The problem is : when I use this texture I do not have the Texture I have define... The picture is different... I am sure it's a stupid error.. but I do not see it thanks a lot for help Loicus,
Advertisement
glBindTexture (GL_TEXTURE_2D, *id);

The *id looks suspicous.

Apart from that, what you posted looks ok.

Regards
elFarto
I have the *id because id is a pointer on unsigned int

If you have loaded the texture from a 24-bit bitmap and you are using your own function make sure you have the right byte order. (24 bitmaps have BGR order)
If that doesent fix the problem load a simple Red texture(255,0,0) then load a blue one and a green one and chek weather you have problems with a certain channel.
ok I solved the problem...

in fact the problem came from how I calcule the r,g,b values

thanks for help
and sorry for disturbing...

Loicus,

This topic is closed to new replies.

Advertisement