[SDL] OpenGL problem...

Nicolai Haehnle prefect_ at gmx.net
Sat Mar 2 07:03:00 PST 2002


Am 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?

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,
Prefect




More information about the SDL mailing list