Jump to content
  • Advertisement
Sign in to follow this  

Texture Mapping problem

This topic is 4213 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

I have been using tao 2.0 opengl and I was doing the NeHe tutorials and I got to tutorial 6 but my cube just shows up white and I and trying to figure out where it not applying the texture the texture. was trying to do it on my own and convert it my self but then I ran into this problem and went back through the examples source and change my code here and there Thanks http://rafb.net/p/YE2wJF83.html

Share this post

Link to post
Share on other sites
Nevermind I got it

texName = new string[1];
texName[0] = "NeHe006.bmp";
texture = new int[1];

if (File.Exists(DataDirectory + GetTextureName()[0]))
FilePath = "";
// Status indicator
bool status = false;
Bitmap[] textureImage = new Bitmap[GetTextureName().Length];
// Create Storage Space for the texture
for (int i = 0; i < GetTextureName().Length; i++)
textureImage = new Bitmap(FilePath + DataDirectory + GetTextureName());
// Load the Bitmap
// CHeck for errors, if bitmap not found, quit
if (textureImage[0] != null)
status = true;
// Create the texture
Gl.glGenTextures(GetTexture().Length, GetTexture());

for (int i = 0; i < textureImage.Length; i++)
// Flip the bitmap along the Y axis
// rectangle for locking the bitmap in memory
Rectangle rectangle = new Rectangle(0, 0, textureImage.Width, textureImage.Height);
// Get the bitmap's pixel data from the locked bitmap
BitmapData bitmapData =
textureImage.LockBits(rectangle, ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
// Typical texture generation using data from the bitmap
Gl.glBindTexture(Gl.GL_TEXTURE_2D, GetTexture());
Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGB8, textureImage.Width, textureImage.Height, 0, Gl.GL_BGR, Gl.GL_UNSIGNED_BYTE, bitmapData.Scan0);

if (textureImage != null)
// if texture exists
// unlock the pixel data from memory
// Dispose the bitmap
return status;

thanks anyway

Share this post

Link to post
Share on other sites
Hi. I have the same problem: my object is white, but is should be covered with a texture. How did you solve this ?

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!