Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

BananaDuffle

macrumors member
Original poster
Mar 29, 2009
30
0
I used the demo's from the apple development website to build my texture class and It's the only thing I can really think of thats causing my problem.

All my textures have dimensions that are a power of 2. But anything over 128x128 renders as plain white.

Here's the code for my Texture2D class (sans dealloc stuff):

Code:
- (id) initWithFileName:(NSString*)fileName
{
	if(self = [super init])
	{
		_spriteSheet = [UIImage imageNamed:fileName].CGImage;
		_width = CGImageGetWidth(_spriteSheet);
		_height = CGImageGetHeight(_spriteSheet);
		
		_spriteData = (GLubyte *) malloc(_width * _height * 4);
		_spriteContext = CGBitmapContextCreate(_spriteData, _width, _height, 8, _width * 4, CGImageGetColorSpace(_spriteSheet), kCGImageAlphaPremultipliedLast);
		CGContextDrawImage(_spriteContext, CGRectMake(0.0, 0.0, (CGFloat)_width, (CGFloat)_height), _spriteSheet);
		CGImageRelease(_spriteSheet);		
		
		glGenTextures(1, &_name);
		glBindTexture(GL_TEXTURE_2D, _name);	
		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _width, _height, 0, GL_RGBA, GL_UNSIGNED_BYTE,_spriteData);			
	}
	
	return self;
}

Here is the code from my setupView that deals with textures:
Code:
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);

And here is my drawing code for my 2D texture (though the same happens when drawing textures to a 3D surface, the method for which is nearly identical)
Code:
-(void) drawTexturedQuad2D:(GLfloat*) quad texture:(Texture2D*)texture textCoords:(GLfloat*)textCoords
{	
	glVertexPointer(2, GL_FLOAT, 0, quad);
	glTexCoordPointer(2, GL_FLOAT, 0, textCoords);
	if(texture) {
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
		glBindTexture( GL_TEXTURE_2D, texture.name);			
	}
	glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
}

Any ideas guys?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.