Texture coordinates

I am creating a terrain and I have a texture that I would like to map over the entire surface. When specifying each vertex within this terrain I would like to attach it to a certaing part of the texture using glTexCoord2f(), but it doesn’t want to work…the values I pass to glTexCoord2f can be as small as 1/2048,1/2048 …is this a problem…??

If this is a problem can you please tell a way that it can be done .thanks.

Steve

Exactly what problem do you have? You only want the texture to be at certain polys, not at all? Then try to use GL_CLAMP instead of GL_REPEAT in the texture settings.

1/2048 gives you a result of 0.00048828125… or there abouts.

so using floats glTexCoord2f()you are loosing quite some precision.

try
glTexCoord2d()

If you have a landscape with a grid of 2049x2049 vertices (!), values like 1/2048, 2/2048, etc seem “normal” to me (! again).

Tell us more.

It could be because of integer roundoff. Try using 1.0f/2048.0f.

j

I have tried 1.0/(double)2048 etc but the same problem persists…

Thanks,
Steve

IIRC certain cards read ‘voodoo’ had problems with large numbers ‘100+’ as texture coords perhaps you’re seeing the opposite.

though i believe the problem lies elsewhere

are u using
for (x=0;x<2048;x++)
glTexCoord2f( ( 1.0/2048.0 ), ( 1.0/2048.0 ))

instead of
for (x=0;x<2048;x++)
glTexCoord2f( x*( 1.0/2048.0 ), y*( 1.0/2048.0 ))

Thanks zed (and everyone else!) what you suggested fixed it (:-))

Steve

Originally posted by dans:
1/2048 gives you a result of 0.00048828125… or there abouts.

so using floats glTexCoord2f()you are loosing quite some precision.

Wrong.
You see - usual floating point formats are binary based, not decimal.
1/2048 = 2^-11, it is exact number in binary representation - “float” has more then enough precision for it.

Serge, that is something I was wondering when dans posted his message yesterday: perhaps you will be able to tell me:

Taken from MSDN:

float 4 none 3.4E +/- 38 (7 digits)
double 8 none 1.7E +/- 308 (15 digits)
long double 10 none 1.2E +/- 4932 (19 digits)

What does the (x digits) means ??? Does it mean that a float has 7 digits precision ?

Thanks for any explanation…

Regards.

Eric

P.S.: phew, OpenGL is far, far away from this question…

yep the x digits gives you the precision of the type (acutally i think float has only 6 digits precision but i am not sure)

e.g with float 12.456 is different from 12.456 but
12.4561 ist the same as 12.4567

hmmm hope that helps
Chris

Originally posted by Eric:
float 4 none 3.4E +/- 38 (7 digits)
double 8 none 1.7E +/- 308 (15 digits)
long double 10 none 1.2E +/- 4932 (19 digits)

What does the (x digits) means ??? Does it mean that a float has 7 digits precision ?

It means that float has enough precision to hold 7 significant decimal digits for sure.

float(9.1) = 9.100000381… // first 7 decimal digits are correct

// binary form: float = (+/-) 1.xxx * 2^n
// exponent : -127<n<128
// mantissa : 24bit, 1(integer)+23(fraction)
// another point of view : float = (+/-)24bit_integer * 2^(n-23)

Thanks, both of you !

Regards.

Eric