Holes in textures

Member
Posts: 75
Joined: 2009.01
Post: #1
I have this in my draw method:
Code:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

If I comment out the two, my textures do not show but with them uncommented, eveything shows correctly on the simulator but on the iPhone there are a bunch of white spots all over the place.

I assumed it could be that I'm passing complicated numbers for the texture coordinates.
I have a 1024x1024 sprite sheet and use the number: 0.015625 * (texture number row and column desired).

How I create my texture coordinates are like so:
Code:
typedef float TexCoords[2];
TexCoords mapTexCoords[1000];

- (void)setTexCoords:(TexCoords)t :(double)x :(double)y {

t[0] = x;
t[1] = y;
}

Can anyone tell me why these "holes" are appearing?

EDIT:
Hole's do not appear when I use a 32x32 or any size sprite but DO appear when I use a 16x16/32x32 sprite from a larger sprite sheet say 128x128 to 1024x1024.

Any ideas?
Quote this message in a reply
Moderator
Posts: 373
Joined: 2006.08
Post: #2
I believe since your x's and y's are doubles, and your TexCoords are floats, you're going to lose precision. Currently you're using seven digits of precision, and floats only support six, so that could be your problem.

The above answer is pretty much a shot in the dark, by the way, but it might we worth trying Rasp

Worlds at War (Current Project) - http://www.awkward-games.com/forum/
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #3
wyrmmage Wrote:Currently you're using seven digits of precision, and floats only support six, so that could be your problem.

This is inaccurate. Read about how floats work here: http://en.wikipedia.org/wiki/IEEE_754-1985
Quote this message in a reply
Moderator
Posts: 373
Joined: 2006.08
Post: #4
ah, right, my bad.

Well, you still should avoid assigning a double to a float.

Worlds at War (Current Project) - http://www.awkward-games.com/forum/
Quote this message in a reply
Post Reply