iDevGames Forums
Problem with picture placement - Printable Version

+- iDevGames Forums (
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: iPhone, iPad & iPod Game Development (/forum-11.html)
+--- Thread: Problem with picture placement (/thread-1665.html)

Problem with picture placement - kendric - Mar 8, 2009 06:56 PM

Im trying to put a 2d picture on my opengl es iphone app. Here is the setup:
glViewport(0, 0, backingWidth,backingHeight);
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);
glTexCoordPointer(2, GL_SHORT, 0, spriteTexcoords);
//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?

Problem with picture placement - kendric - Mar 8, 2009 09:04 PM

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.