This is probably something simple, but I cant seem to spot whats wrong with it.
http://img386.imageshack.us/my.php?image=picture4gk6.png
I load the image just like the GLSprite example,
My power of 2 function is working fine, but it looks like some size is being messed up somewhere. I'm thinking it has something to do with the arrays im using for glTexturePointer and glTexCoordPointer, since i still dont fully get what those 2 are for. I tried to go through the Texture2D code to figure out what values to use, and i came up with this:
Drawing with:
Also the texture randomly flashes on and off the screen :-/
Anyone tell me what noob mistake I'm making?
http://img386.imageshack.us/my.php?image=picture4gk6.png
I load the image just like the GLSprite example,
Code:
tempImage = [UIImage imageNamed:@"BackgroundGrid.png"].CGImage;
width = next_power_of_2(CGImageGetWidth(tempImage));
height = next_power_of_2(CGImageGetHeight(tempImage));
// Allocate memory for bitmap context
tempData = (GLubyte *) malloc(width * height * 4);
tempContext = CGBitmapContextCreate(tempData, width, height, 8, width*4, CGImageGetColorSpace(tempImage), kCGImageAlphaPremultipliedLast);
// Draw sprite on the context
CGContextDrawImage(tempContext, CGRectMake(0, 0, (CGFloat)width, (CGFloat)height), tempImage);
// etc...
Code:
// Sets up an array of values to use as the sprite vertices.
const GLfloat spriteVertices[] = {
0, 0, 1,
320, 0, 1,
0, 480, 1,
320, 480, 1,
};
// Sets up an array of values for the texture coordinates.
const GLshort spriteTexcoords[] = {
0, 1,
1, 1,
0, 0,
1, 0,
};
Code:
glBindTexture(GL_TEXTURE_2D, sprites[eTexBackground].tex);
glVertexPointer(3, GL_FLOAT, 0, spriteVertices);
glTexCoordPointer(2, GL_FLOAT, 0, spriteTexcoords);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
Anyone tell me what noob mistake I'm making?