PDA

View Full Version : GL_LINEAR & two textures



CKulT
12-29-2004, 10:06 AM
Hi. There is a usual code for a drawing of two textures:


for(i = 0;i < 2;i++)
{
* * glBindTexture(GL_TEXTURE_2D, tex(i));
* * glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
* * glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
* * glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
* * glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
* * glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, SQ_DIV, SQ_DIV, 0, GL_RGBA, GL_UNSIGNED_BYTE, part(i));

* * glNewList(list(i), GL_COMPILE_AND_EXECUTE);
* * glBindTexture(tex(i));
* * glBegin(GL_QUADS);
* * * glTexCoord2f(0.0f, 0.0f); glVertex2f(x1(i), y1(i));
* * * glTexCoord2f(1.0f, 0.0f); glVertex2f(x2(i), y1(i));
* * * glTexCoord2f(1.0f, 1.0f); glVertex2f(x2(i), y2(i));
* * * glTexCoord2f(0.0f, 1.0f); glVertex2f(x1(i), y2(i));
* * glEnd();
glEndList()As one would expect, the place of joining of textures is drawn obviously crookedly:

http://www.gamedev.ru/images/show.php?id=3129

How it is possible to get rid of it (with GL_LINEAR)?
Thanks.

ZbuffeR
12-29-2004, 11:55 AM
Try this :
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

But I think the proper way would be to use 'texture borders'.

CKulT
12-30-2004, 05:30 AM
>>glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
>>glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
=> the same effect :(

>>But I think the proper way would be to use 'texture borders'.

For example ?
Thanks. :)

ZbuffeR
12-31-2004, 02:31 AM
Read the doc for glTexImage2D.
There is a parameter called 'border', often set to 0 : set it to 1, and send a larger texture, including a one pixel border copied from the adjacent texture.

Have a look at the Gl spec too.

An quick and dirty tutorial speaking about this problem :
http://home.planet.nl/~monstrous/skybox.html

(But it avoids the only correct way to deal with it, that is using texture borders)

Omaha
01-01-2005, 09:01 PM
Texture borders would be the easiest way to solve this one, without compositing both textures into one.

Basically you add one pixel all the way around the texture and specify the neighboring colors. So for example, your top texture's bottom row (the border row) will be filled with the top row of the bottom texture (the actual texture, not the border row) and vice versa.

Then just pass 1 instead of 0 to the border parameter of glTexImage2D, and add 2 to the height and width.