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

Nibbie
Posts: 2
Joined: 2009.08
Post: #1
Hi!
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
Code:
- (void)setupView {
  
    const GLfloat zNear = 0.01, zFar = 10000.0;
    GLfloat size;
  
    glEnable(GL_DEPTH_TEST);
    glMatrixMode(GL_PROJECTION);
    size=1.0;
  
    // 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?

thanks.
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #2
glOrthof(0, rect.size.width, 0, rect.size.height, zNear, zFar);
Quote this message in a reply
Nibbie
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 5,605 Oct 16, 2012 06:22 AM
Last Post: Skorche
  Need help with pixel oriented framebuffer edepot 24 20,058 Mar 3, 2011 07:15 AM
Last Post: mariocaprino
  Attempting to add landscape IB buttons to an openGL View Madrayken 1 3,797 Oct 17, 2010 07:03 AM
Last Post: iamflimflam1
  iPhone GLES 2 Orthogonal frame jeckil 2 2,864 Apr 16, 2010 08:33 AM
Last Post: dazza
  SOIL image library problem or texture lib problem hippocoder 12 8,960 Mar 22, 2010 08:51 PM
Last Post: Frank C.