Skip to main content
gamedev.net
🔒 Locked

Tiling border problem

Started by JDBrown 0 replies 500+ views
Original Post
JDBrown
JDBrown
I''m playing around with a tiling engine. I''ve got a 64x64 bitmap containing 4 32x32 images (tiles.bmp link below). When I tile I get a 1 pixel border around the tile of the adjacent image in the tiles.bmp. I thought perhaps it was my math or just the late hour, but I''m obviously overlooking something. Here''s the source for drawing the tiles (in Delphi). var w, h, SrcX, SrcY: Single; Row, Col: integer; begin w := FTileWidth / FWidth; h := FTileHeight / FHeight; Row := Round((TileNum / FColumnCount) + 0.01); Col := TileNum - ((Row - 1) * FColumnCount); SrcX := (Col - 1) * w; SrcY := (Row - 1) * h; glBindTexture(GL_TEXTURE_2D, FTexture); glBegin(GL_QUADS); glTexCoord2f(SrcX, SrcY); glVertex3f(DestX, DestY, 0.0); glTexCoord2f(SrcX + w, SrcY); glVertex3f(DestX+1, DestY, 0.0); glTexCoord2f(SrcX + w, SrcY + h); glVertex3f(DestX+1, DestY+1, 0.0); glTexCoord2f(SrcX, SrcY + h); glVertex3f(DestX, DestY+1, 0.0); glEnd; end; See the problem - http://www.thinkneu.com/tiling.jpg See the texture - http://www.thinkneu.com/tiles.bmp Jon
JDBrown
JDBrown
I figured out my problem... it was a matter of subtracting 0.01 from the texture coord to prevent the pixel blending.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.