Hello everyone!
I have found a really weird result when I display a 2D texture (with GL_QUAD) on the screen at a different size to what it normally is:

E.G when I display a 64x32 image(texture) on the screen at 128x64 and it contains an alpha channel the pixelated borders seem to obtain a grey-ish border?

This is the initializing functions I use openGL wise:

    glEnable(GL_TEXTURE_2D);
    glClearColor(0.70f, 0.70f, 0.70f, 0.0f);
    glClearDepth(1.0f);
    GLint iViewport[4];
    glGetIntegerv( GL_VIEWPORT, iViewport );
    glMatrixMode( GL_PROJECTION );
    glPushMatrix();
    glLoadIdentity();
    glOrtho(iViewport[0], iViewport[0]+iViewport[2],iViewport[1]+iViewport[3], iViewport[1], -1, 1 );
    glMatrixMode( GL_MODELVIEW );
    glPushMatrix();
    glLoadIdentity();
    glPushAttrib( GL_DEPTH_BUFFER_BIT | GL_LIGHTING_BIT );
    glDisable( GL_DEPTH_TEST );
    glDisable( GL_LIGHTING );
    glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_BLEND);
    glColor4f(1.0f,1.0f,1.0f,1.0f);

And this is my displaying function:

glBindTexture(GL_TEXTURE_2D,Tile_Texture);
glBegin(GL_QUADS);
    glEnable(GL_TEXTURE_2D);

    glTexCoord2f( 0.0, 0.0); glVertex2f(0,0);
    glTexCoord2f( 1.0, 0.0); glVertex2f(128,0);
    glTexCoord2f( 1.0, 1.0); glVertex2f(128,64);
    glTexCoord2f( 0.0, 1.0); glVertex2f(0,64);

    glDisable(GL_TEXTURE_2D);
glEnd();

And if you need a diagram, this is a photo of it happening:
(see attachment).

I hope I have provided enough information and I can provide more if necessary.
Thanks in advance!
Will,

The reason why the boarder is gray is because your clear color is gray. As for why it is not scaling up is unknown to me without seeing your glTexParameteri() functions.

When I made my tile game I used:

glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

Unless you know exactly what each of them do I would suggest playing around with them a whole bunch and seeing what they do. For me when I did not use GL_CLAMP_TO_EDGE I noticed texture ripping between each tile.

Thanks for the quick reply!
I wish it was the clear colour but it is not the same shade. It happens with all my textures around the border, but the weird thing is that it isn't the actual textures border but where the transparent part meets the non-transparent (see attachment) as those tiles are exactly touching and not showing the clear color background.

One idea I had was that it could be that the blending algorithm for when the texture is stretched is somehow blending the border with the transparent pixel which somehow produces that outline? The reason I made this post is because I can't find anyone with the same problem.

Thanks in advance again,
Will.

What program are you drawing all your textures in?

I had that problem when I was using photoshop to make my textures because it feathers out and keeps some of your key color (transparent).

I switched to MS paint and wrote a program that converts 24 bit BMPs to 32 bit TGAs.

The editor doesn't seem to be the problem though as at normal resolution it is perfect with no fading into the alpha transparent part? Is it something to do with how OpenGL stretches the texture? And is there a way to change it if it is?

Thanks for your help!
Will,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.