[Problem] Loading image with OpenGL orthogonal view pixel-to-pixel

Posts: 2
Joined: 2009.08
Post: #1
I'm trying to load an image onto my opengl scene.
i've created a shape, and used texture to load the image on to that shape.

Here is my setupView function (which is called by initWithCodeSmile
- (void)setupView {
    const GLfloat zNear = 0.01, zFar = 10000.0;
    GLfloat size;
    // This give us the size of the iPhone display
    CGRect rect = self.bounds;
    glOrthof(-size, size, -size / (rect.size.width / rect.size.height), size / (rect.size.width / rect.size.height), zNear, zFar);
    glViewport(0, 0, rect.size.width, rect.size.height);
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

The problem is, when i load my texture, i have to guess the size of the shape (for my 256x256, so it will be a power-of-2 size) image, i use the size: 1.58.

Anyone knows how could i do this pixel-to-pixel, meaning: 2.56 (256 pixels) would be the size i would have to enter?

Quote this message in a reply
Posts: 1,234
Joined: 2002.10
Post: #2
glOrthof(0, rect.size.width, 0, rect.size.height, zNear, zFar);
Quote this message in a reply
Posts: 2
Joined: 2009.08
Post: #3
Thanks it works.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Best toolset/engine for iOS pixel art game? eXpiation 3 9,286 Oct 16, 2012 06:22 AM
Last Post: Skorche
  opengl es strange 16bit texture scale problem spuckfunkel 6 14,255 Aug 14, 2011 10:44 PM
Last Post: headkaze
  Need help with pixel oriented framebuffer edepot 24 31,871 Mar 3, 2011 07:15 AM
Last Post: mariocaprino
  Attempting to add landscape IB buttons to an openGL View Madrayken 1 4,932 Oct 17, 2010 07:03 AM
Last Post: iamflimflam1
  iPhone GLES 2 Orthogonal frame jeckil 2 4,269 Apr 16, 2010 08:33 AM
Last Post: dazza