iDevGames Forums
[SOLVED]OpenGL edges of textures - Printable Version

+- iDevGames Forums (
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: [SOLVED]OpenGL edges of textures (/thread-8061.html)

[SOLVED]OpenGL edges of textures - mk12 - Sep 2, 2010 07:45 PM

I've finally got pixel-perfect rasterization of my textures on integer tex coords for my 2d game (pong). At first I used GL_NEAREST, but that looked bad because you could tell it was jumping from one pixel to the next. So I used GL_LINEAR, and it looked great, the pixels smoothly transition, fading in to the next location (which you can see when the ball speed is very slow). However, the edges of the ball don't do this. They just disappear on one side and appear on the other. I guess this is because they are on the edges of the texture so there isn't enough neighbours to interpolate the colour, but what else can I do? I tried adding a 1 pixel alpha border around the textures and that worked, but it's a big hassle and it messes things up when the viewport is resized.

I'm pretty sure this isn't what AA is for, but I tried it anyway and it did work like I wanted it to sort of, but it didn't seem to be interpolating every frame, more like 3-4 times per second, even with 16 super/multi samples.


RE: OpenGL edges of textures - arekkusu - Sep 2, 2010 08:03 PM

Vertex coordinates are quantized during rasterization to integral pixels (or MSAA samples.)
Texture coordinates are interpolated during rasterization; you see sub-pixel filtering within each pixel that was produced by rasterization.

You need an alpha border.

RE: OpenGL edges of textures - mk12 - Sep 2, 2010 08:07 PM

Ok I was thinking that when I resized the window and use glViewport, it would be the alpha border would be double. But I was confusing my input with OpenGL's output. The thing I was worrying about was the ball rebounding off the alpha border, before it appears to actually hit, but I just need to make sure my game logic rects don't include the alpha border.

Thanks for the quick reply.