Wrong x,y coordinates with Texture2D class
Hi everyone ! 
I'm currently creating a game with OpenGL|ES and the Texture2D class which is from Apple.
But the x,y coordinates seems to be wrong with a little code like :
Here when I touch the screen, the player is not at x,y coordinates of my touch !
I have to "CGPointMake(0, 16)" to have it at right coordinates...
This is with CGPointMake(0,0) :
http://h4xr.org/cdqi
And with my "handcrafted" CGPointMake(0,16) it is approximately in the center of my touch.
Can you help me ?
Thanks.

I'm currently creating a game with OpenGL|ES and the Texture2D class which is from Apple.
But the x,y coordinates seems to be wrong with a little code like :
Code:
pos.x = _touch.x
pos.y = _touch.y
_textures[kTexture_Player] = [[Texture2D alloc] initWithImage: [UIImage imageNamed:@"Player.png"]];
glLoadIdentity();
glPushMatrix();
glTranslatef(player.x, 460 - player.y, 0);
[_textures[kTexture_Player] drawAtPoint:CGPointMake(0, 0)];
glPopMatrix();Here when I touch the screen, the player is not at x,y coordinates of my touch !
I have to "CGPointMake(0, 16)" to have it at right coordinates...
This is with CGPointMake(0,0) :
http://h4xr.org/cdqi
And with my "handcrafted" CGPointMake(0,16) it is approximately in the center of my touch.
Can you help me ?
Thanks.
I think you want 480-y. Your view is probably 480 pixels high when the status bar is hidden.
And I'm not sure how exactly drawAtPoint works, but it may not be centered, so if this is the case you will have to offset it by half the texture size.
And I'm not sure how exactly drawAtPoint works, but it may not be centered, so if this is the case you will have to offset it by half the texture size.
Chopper, iSight Screensavers, DuckDuckDuck: http://majicjungle.com
Oh god !
Yes it is simply that ^^
For drawAtPoint, it centres the texture
Thank you a lot man ! =)
Yes it is simply that ^^
For drawAtPoint, it centres the texture

Thank you a lot man ! =)
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Texture2d crash lander | ajrs84 | 0 | 2,249 |
Apr 1, 2012 08:54 AM Last Post: ajrs84 |
|
| OpenAL, i am doing it wrong or is it broken on iPad simulator? | AdrianM | 3 | 3,373 |
Apr 23, 2010 11:18 AM Last Post: Rasterman |
|
| Problem using Texture2D sub-section | bendell | 0 | 2,086 |
Mar 20, 2010 02:06 AM Last Post: bendell |
|
| Create a texture2d with contents of other textures | godexsoft | 6 | 3,773 |
Nov 12, 2009 10:24 PM Last Post: godexsoft |
|
| OpenGL ES and Texture2D | Talyn | 37 | 27,585 |
Jul 30, 2009 09:34 AM Last Post: Splat21 |
|

