Jump to content
  • Advertisement
Sign in to follow this  
Loicus

Create a texture

This topic is 4155 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!