Jump to content
  • Advertisement
Sign in to follow this  
valiantsoul

Lesson 6 + OS X problem

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

It seems the texture is loading incorrectly (OS X doesn't have AUX so we use NSBitmapImageRep as seen in the Cocoa version of the source for lesson 6). I've tried using GL_RGB, GL_RGBA, GL_BGR, and GL_BGRA with no luck on getting my texture to look correct. It just looks like this: Any thoughts from someone who has taken a look at the OS X code? (Note on the pic, the left picture is how the texture should look and the right side is how it is appearing)

Share this post


Link to post
Share on other sites
Advertisement
that image should be GL_RGB and nothing else.
It looks like the red channel has been inverted so go into the code just before it's loaded in the texture memory and invert the red channel.
I don't know why it is like this but my guess is that it has something to do with mac's, and how it orders bytes around.

Share this post


Link to post
Share on other sites
I think it may have actually been loading the bitmap upsidedown, after a lot of googling I found this code: (with NeHe.bmp in place of the original)
	NSBitmapImageRep *bitmap;
NSImage *image;

glGenTextures(1, &texture[0]);

glBindTexture(GL_TEXTURE_2D, texture[0]);

image = [NSImage imageNamed:@"NeHe.bmp"];
if (image == nil)
return FALSE;

bitmap = [[NSBitmapImageRep alloc] initWithData:[image TIFFRepresentation]];
if (bitmap == nil)
return FALSE;

glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, [bitmap size].width, [bitmap size].height, 0, GL_RGB, GL_UNSIGNED_BYTE, [bitmap bitmapData]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

[bitmap release];
[image release];
return TRUE;


and it works fine! ...I keep solving my problems...

[Edited by - valiantsoul on August 9, 2005 9:53:37 PM]

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!