Rendering issues in a tile based game (DX9)

Started by
1 comment, last by AntonioR 12 years, 5 months ago
Hi,

I have a problem.

For my "tile based game" I was loading a new texture from a file for each tile type. Everything was fine, but it is not very good when you need to load >100 textures.

ssb_aaah2.gif

Now I wanted to save all those textures in only one file (a tile map), and every tile in the game would actually be a part of that texture that is rendered. I made that big texture (textures/tiles are separated by one alpha pixel), wrote the code so I can render parts of the texture... and it doesn't work properly.

Gaps appear between the tiles (or colored lines (like in the image bellow), if I fill the ares between the tiles in the big texture with color).
These gaps/lines appear when I scroll. They come and go.

NOTE: This issue doesn't happen when every tile texture is loaded from a different texture (like you can see in the gif above).

11688188.png

I am using DX9, and rendering using ID3DXSprite.

I don't understand what is causing this problem ?
Advertisement
can you post your code for loading textures... my guess without looking at your code, is that your not using pointsampling. Though that should only be a problem if your stretching the texture beyond it's actual size in pixels. Another thing you can look into, is offsetting your uv coords by a half pixel. As DX takes pixel samples from the center of the pixel... which can cause nearby pixels to bleed into other pixels.
[ dev journal ]
[ current projects' videos ]
[ Zolo Project ]
I'm not mean, I just like to get to the point.
Hello. I don't even know what point sampling is ?

Here is the texture class definition:


class Texture
{
public:
LPDIRECT3DTEXTURE9 texture;

Texture();
~Texture();

bool Load(std::string filename, D3DCOLOR transcolor = D3DCOLOR_XRGB(255,0,255));

LPDIRECT3DTEXTURE9 GetTexture() { return texture; }
int getWidth();
int getHeight();

void Release();

private:
D3DXIMAGE_INFO info;
};


And here is its function to load textures from a file, if that is what you mean;


bool Texture::Load(std::string filename, D3DCOLOR transcolor)
{
//standard Windows return value
HRESULT result;

//get width and height from bitmap file
result = D3DXGetImageInfoFromFile(filename.c_str(), &info);

if (result != D3D_OK)
{
texture = NULL;
return false;
}

//create the new texture by loading a bitmap image file
result = D3DXCreateTextureFromFileEx(
g_engine->getDevice(), //Direct3D device object
filename.c_str(), //bitmap filename
info.Width, //bitmap image width
info.Height, //bitmap image height
1, //mip-map levels (1 for no chain)
D3DPOOL_DEFAULT, //the type of surface (standard)
D3DFMT_UNKNOWN, //surface format (default)
D3DPOOL_DEFAULT, //memory class for the texture
D3DX_DEFAULT, //image filter
D3DX_DEFAULT, //mip filter
transcolor, //color key for transparency
&info, //bitmap file info (from loaded file)
NULL, //color palette
&texture ); //destination texture

//make sure the bitmap textre was loaded correctly
if (result != D3D_OK)
{
texture = NULL;
return false;
}

return true;

}

This topic is closed to new replies.

Advertisement