large texture scaling

Started by knoggly, June 02, 2005, 13:02:13

Previous topic - Next topic

knoggly

Hi,

i am currently working on a gui system and basically it works but i have one "cosmetic" problem:

I draw my borders with small images (typically 5x5 pixels). This image is contained within a larger image which contains all my tiles and which is loaded as texture. I map this subimage on a quad and scale the quad to the size the border finally should have (e.g. if my border should be 100 pixels wide i scale the quad by factor 20 (if the subimage is 5 pixels wide)).

Now the problem occurs that my texture-image fades to black (the background-color in my texture-image) at the left and the right border.

I think because the texture-coords are floating point there are some rounding errors on the sides and opengl interpolates the color.

I tried stuff like GL_CLAMP and GL_REPEAT but that obviously doesn't work(my tex-coords are never larger than 1).

I would like not to change the texture coordinates of the quad because all other tiles use the same quad and so i would have to use on quad for every tile (maybe thats the only option).

Has anybody done something similar yet, or has someone any idea how to tell opengl not to use this interpolation??

greetings knoggly

knoggly

here is a screenie of my problem (notice the red border fading)

Fool Running

To disable the interpolation use GL11.GL_NEAREST when you create your texture instead of GL11.GL_LINEAR.  
Although I think the fading looks pretty cool.  :wink:
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

knoggly

hi, i already use GL_NEAREST and thought that this would solve my problem, but it seems not so (the screenshot is renderd using GL_NEAREST)

knoggly

Fool Running

Could you post a shot of the texture and maybe some code (if possible).  I can't think of what would cause this if you are using GL_NEAREST (maybe someone else does).
EDIT: by "texture" I mean the large texture (although I'm not sure if it will make a difference)  :roll:
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

knoggly

ok, heres the "big" image:


and this is the sub-image


the position of the subimage is (30,0) and the size is (5,5)

the code is rather straight forward:
on startup i set texture mag-filter to GL_NEAREST
then i call some glTranslate and glScale methods
and then draw the quad.

one thing is, if i set the position of the subimage in the source-image not to the exact borders of the sub-image but one pixel more to the right and reduce the width by two, so that the left and right neighbour pixels of the sub-image are also red [position(31,0) size(3,5)] , then the streching is right, but that is no solution, because i would have to set up this offset for every tile individually.

knoggly

Fool Running

I'm sorry, I forgot to look into this  :oops:  I'll look into it this weekend if it is still a problem  :?
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D