[Problem] Loading image with OpenGL orthogonal view pixel-to-pixel
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 initWithCode
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.
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 initWithCode

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.
glOrthof(0, rect.size.width, 0, rect.size.height, zNear, zFar);
Thanks it works.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Best toolset/engine for iOS pixel art game? | eXpiation | 3 | 2,765 |
Oct 16, 2012 06:22 AM Last Post: Skorche |
|
| Need help with pixel oriented framebuffer | edepot | 24 | 16,411 |
Mar 3, 2011 07:15 AM Last Post: mariocaprino |
|
| Attempting to add landscape IB buttons to an openGL View | Madrayken | 1 | 3,000 |
Oct 17, 2010 07:03 AM Last Post: iamflimflam1 |
|
| iPhone GLES 2 Orthogonal frame | jeckil | 2 | 2,312 |
Apr 16, 2010 08:33 AM Last Post: dazza |
|
| SOIL image library problem or texture lib problem | hippocoder | 12 | 7,339 |
Mar 22, 2010 08:51 PM Last Post: Frank C. |
|

