Jump to content
  • Advertisement
Sign in to follow this  

Rendering issues in a tile based game (DX9)

This topic is 2592 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


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.


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).


I am using DX9, and rendering using ID3DXSprite.

I don't understand what is causing this problem ?

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
Hello. I don't even know what point sampling is ?

Here is the texture class definition:

class Texture


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

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

void Release();


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;


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!