OpenGL problem

Hi,

I’ve got a problem with OpenGL. I found an example of drawing a skybox for
windows
and converted it to SDL, but when I ran it created a white border around the
texture.
I tested another texture, in which I had drawed a green line at the bottom
of the image,
and found some green at the top of the texture! I use the same code, the
only differens is
that I use 24bit bmp’s and the example uses 8bit bmp’s.
I use LoadBMP from the NEHE SDL OPENGL example…

I think it’s an OpenGL problem but since I use the same OpenGL code…
OpenGL or SDL problem?

/Pontus

Sounds like an OpenGL thing. Note that textures are wrapped by default, and
with linear filtering, wrapping will influence the edges of a polygon even if
the texture fits “exactly”.

You’ve got two choices basically: Either disable wrapping
(glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP), same for WRAP_T).
Or, you could use texture coordinates so that they’re actually in the middle
of the border texels, i.e.:

int tw, th; // texture size

s1 = 0.5 / tw;
s2 = (tw - 0.5) / tw;
t1= 0.5 / th;
t2 = (th - 0.5) / th;

cu,
PrefectAm Samstag, 2. M?rz 2002 15:27 schrieb Pontus Folkesson:

Hi,

I’ve got a problem with OpenGL. I found an example of drawing a skybox for
windows
and converted it to SDL, but when I ran it created a white border around
the texture.
I tested another texture, in which I had drawed a green line at the bottom
of the image,
and found some green at the top of the texture! I use the same code, the
only differens is
that I use 24bit bmp’s and the example uses 8bit bmp’s.
I use LoadBMP from the NEHE SDL OPENGL example…

I think it’s an OpenGL problem but since I use the same OpenGL code…
OpenGL or SDL problem?

Hi,

I’ve got a problem with OpenGL. I found an example of drawing a skybox
for

windows
and converted it to SDL, but when I ran it created a white border around
the texture.
I tested another texture, in which I had drawed a green line at the
bottom

of the image,
and found some green at the top of the texture! I use the same code, the
only differens is
that I use 24bit bmp’s and the example uses 8bit bmp’s.
I use LoadBMP from the NEHE SDL OPENGL example…

I think it’s an OpenGL problem but since I use the same OpenGL code…
OpenGL or SDL problem?

Sounds like an OpenGL thing. Note that textures are wrapped by default,
and
with linear filtering, wrapping will influence the edges of a polygon even
if
the texture fits “exactly”.

You’ve got two choices basically: Either disable wrapping
(glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP), same for
WRAP_T).

Actually you should use GL_CLAMP_TO_EDGE (OpenGL 1.2 or higher,
GL_EXT_texture_edge_clamp or GL_SGIS_texture_edge_clamp). On when that is
not
supported should you fall back to GL_CLAMP. That is because GL_CLAMP is
supposed
to use border pixels in the filtering process and GL_CLAMP_TO_EDGE does not.
However, on earlier nVidia cards, GL_CLAMP worked as GL_CLAMP_TO_EDGE works.
(I’ve been told it’s a hardware bug.)

Or, you could use texture coordinates so that they’re actually in the
middle
of the border texels, i.e.:

int tw, th; // texture size

s1 = 0.5 / tw;
s2 = (tw - 0.5) / tw;
t1= 0.5 / th;
t2 = (th - 0.5) / th;

Yes I suppose this would do the same trick.

Dirk Gerrits

Interesting, I didn’t know that. Do you know what GL_CLAMP is supposed to do
when the texture has no border (or is that undefined)?

cu,
NicolaiAm Samstag, 2. M?rz 2002 19:00 schrieb Dirk Gerrits:

You’ve got two choices basically: Either disable wrapping
(glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP), same for

WRAP_T).

Actually you should use GL_CLAMP_TO_EDGE (OpenGL 1.2 or higher,
GL_EXT_texture_edge_clamp or GL_SGIS_texture_edge_clamp). On when that is
not
supported should you fall back to GL_CLAMP. That is because GL_CLAMP is
supposed
to use border pixels in the filtering process and GL_CLAMP_TO_EDGE does
not. However, on earlier nVidia cards, GL_CLAMP worked as GL_CLAMP_TO_EDGE
works. (I’ve been told it’s a hardware bug.)

Clamp just repeats the last pixel line of a texture. Serious Sam has in
its hall of models (tech test) two walls with a very simple texture on it,
one tinted red, the other tinted blue. One’s drawn with repeat - if you
specify texcoords outside of the 0-1 range, you’ll get more than one copy
of the texture. A clamped texture doesn’t do that.

If you don’t have the red book, go download the older edition PDF from
GameDev. If you do have it, open to chapter 9 and start reading. =)On Sun, Mar 03, 2002 at 12:40:52PM +0100, Nicolai Haehnle wrote:

Interesting, I didn’t know that. Do you know what GL_CLAMP is supposed to do
when the texture has no border (or is that undefined)?


Joseph Carter This end upside-down

<Anarchy> Argh… who’s handing out the paper bags 8)

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020303/d305902c/attachment.pgp