Hello there.
I’m having a problem: mysterious abnormalities appear along the edges of where two of my tile graphics meet (the edges of the colored portions of two neighboring tiles). To give you an idea of what I mean, here first is my tile.
I’ve colored the transparent background black for visual purposes. Also, the tile isn’t at the exact position it would be in the 64x64 texture within my engine, but close so you get the idea. (middle, bottom - the bottom side of an isometric cube)
Now here’s what I get when I try to tile them (the problem)
Just a snippet of a larger screen (640 x 480) from the game. The tile image should tile perfectly using the coordinates that I give it in-game. Each tile is placed 30 left/right of tiles next to it, and 15 above / below tiles above or below it. What this means is: 1. there is no horizontal overlap, 2. the tile below is fitted exactly in-between the two above it and overlaps them by one pixel vertically (forming an overlap line that is two-across, one-down style.
Anyways, sorry for that lengthy description but I want to provide the information in case anyone would like it.
So as you can see, there are darkened pixels along lines of adjacent tiles.
What I don’t know is whether this is caused by some kind of non-pixel-perfect problem with my OpenGL view, texture options, positioning, etc…
or with some kind of texture overlay problem… like multiplying instead of replacing or something to that effect.
To provide you with some information (this is the stuff that kind of boggles my mind when I try to think about it too much…) here is my OpenGL setup code.
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glViewport(0, 0, 640, 480);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(1000.0f, 1640, 1480, 1000.0f, -1.0f, 1.0f);
glMatrixMode(GL_MODELVIEW); // I officially don't even know what's going on here... annyways.
glLoadIdentity();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_TEXTURE2D)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
and here is the function that draws textures, including the tiles…
void VideoManager::DrawGraph(float PX, float PY, Graphicality* Graph)
{
// PX & PY are offsets based on the camera's position
float X = Graph->X; // coords of the object to be drawn
float Y = Graph->Y;
int Width = Graph->Width; // 64 ("width" of texture)
int Height = Graph->Height; // 0 (represents height in iso-land)
int Depth = Graph->Depth; // 64 ("height" of texture)
Graph->CurrentTex->Bind();
glColor4f(1.0,1.0,1.0,1.0);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex3f(X-Width/2+PX, Y+Depth/4+PY, 1.0f); // Bottom left
glTexCoord2f(1.0f, 0.0f); glVertex3f(X+Width/2+PX, Y+Depth/4+PY, 1.0f); // Bottom Right
glTexCoord2f(1.0f, 1.0f); glVertex3f(X+Width/2+PX, Y-3*Depth/4+PY, 1.0f); // Top Right
glTexCoord2f(0.0f, 1.0f); glVertex3f(X-Width/2+PX, y-3*Depth/4+PY, 1.0f); // Top Left
glEnd();
}
Just to note, I have tried casting various floats to ints (like all of them…) and I have also made sure via debugging that the coordinates of the tiles (X and Y in the draw function) are what they should be, as described up above.
Anyways forgive my retyping so much code… I don’t want to simplify too much since I’m not sure where the problem is.
So if anyone has any idea what I’m doing wrong (or any pointers for anything else you see that I should work on) then please post