Sign in to follow this  
Loicus

Create a texture

Recommended Posts

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,

Share this post


Link to post
Share on other sites
glBindTexture (GL_TEXTURE_2D, *id);

The *id looks suspicous.

Apart from that, what you posted looks ok.

Regards
elFarto

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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,

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this