Advertisement Jump to content
Sign in to follow this  

Lesson 6 + OS X problem

This topic is 4912 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
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]);

[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, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!