Lesson 6 + OS X problem

Started by
2 comments, last by valiantsoul 18 years, 8 months ago
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)
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.
How do I invert the red channel?

Also with GL_RGB instead of GL_RGBA it looks like this:
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]

This topic is closed to new replies.

Advertisement