Problem with picture placement

Member
Posts: 306
Joined: 2009.03
Post: #1
Im trying to put a 2d picture on my opengl es iphone app. Here is the setup:
glViewport(0, 0, backingWidth,backingHeight);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrthof(0, 320, 0, 480, -1.0f, 1.0f);

I have a 512x512 picture(forget about the fact that it won't fit for now)
To put it on the screen I do

glTranslatef(x, y, 0);
float halfWidth=width/2.0f;
float halfHeight=height/2.0f;
// Sets up pointers and enables states needed for using vertex arrays and textures
const GLfloat spriteVertices[] = {
x-halfWidth, y-halfHeight,
x+halfWidth, y-halfHeight,
x-halfWidth, y+halfHeight,
x+halfWidth, y+halfHeight,
};
glVertexPointer(2, GL_FLOAT, 0, spriteVertices);
glEnableClientState(GL_VERTEX_ARRAY);
glTexCoordPointer(2, GL_SHORT, 0, spriteTexcoords);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
//Draw the texture
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

The thinking is that x and y will be the center of the image. I pass 256,256 to this function. What i get is the picture about 100 pixels indented from the bottom left corner(not in the bottom left as I expect). If i pass the function 128,128(exactly 1/4th) its in the bottom left corner correctly. I am confused as to what is going on here. Any ideas?
EDIT: OOPS i was adding x in and translating... Problem 1 solved, still open to suggestions on the problem 2(below)

Second follow up question, without using the undocumented function, is there a good way to take a 480x320 picture and programatically resize it to 512x512 so that I can use it on the iphone?
Quote this message in a reply
Member
Posts: 306
Joined: 2009.03
Post: #2
A followup followup question if anyone knows the answer. My full screen opengl es app seems to be blocking touch events on the space where the status bar thingy would be. I have done application.statusBarHidden=TRUE so its not showing, but it looks like its still stealing touch events. I even am doing [event allTouches] so one would think that would still catch the bars. The view does appear to be full screen as I can see the image from my app all the way up to 0,0. Just no touch events between 0,0 and 320,20.
Thanks in advance.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  IAP needs a picture to start the submission? Applewood 5 6,780 Mar 19, 2011 05:12 AM
Last Post: Applewood
  512x512 picture for applications, where do they show it? Lostlogic 1 3,282 Oct 10, 2008 04:15 PM
Last Post: Taxxodium
  boton = picture png (transparent) imaumac 2 3,541 Oct 9, 2008 05:32 AM
Last Post: imaumac