Tilemap Problem

BlitzMax Forums/MiniB3D Module/Tilemap Problem

Krischan(Posted 2011) [#1]
I'm not new to Blitz3D but I'm totally new to Bmax and miniB3D and I have a problem I couldn't solve myself. I wrote a small B3D program to display a tilemap using a single surface mesh and moving the tiles by moving the UV coordinates only, which is 7 times faster than DrawImageRect (in B3D).

Download Example B3D + BMAX

Screenshot Blitz3D


To learn Blitzmax, I ported it to minib3D and it works but there are strange 1 Pixel wide seams I can't find the origin (I already know the "patch" with GL_NEAREST but the pixel seam is still there):

Screenshot BMAX 3D Mode


Using the same display routine but drawing the tile with DrawSubImageRect, everything looks fine:

Screenshot BMAX 2D Mode


Any suggestions? I'm stuck.

Last edited 2011


ima747(Posted 2011) [#2]
I believe it has to do with the scaling methods used in OpenGL. Try disabling mipmapping and see if that helps....


Krischan(Posted 2011) [#3]
Hmm I changed

Local tiletex:TTexture=LoadTexture("incbin::tiles.png",1+8)

to

Local tiletex:TTexture=LoadTexture("incbin::tiles.png",1)

but nothing happened (incbin makes no difference here). Some more background: I load the texture, scale the texture to its dimensions (here: 128x128, contains 4x4 32x32px tiles), calculate the tile row/column to get the corresponding UV coordinates and move the UVs accordingly, which works in B3D with the same code but without seams:

u=(h Mod TileColumns)*TileSize
v=(h/TileRows)*TileSize

VertexTexCoords surf,V0[x,y],u,v
VertexTexCoords surf,V1[x,y],u+TileSize,v
VertexTexCoords surf,V2[x,y],u+TileSize,v+TileSize
VertexTexCoords surf,V3[x,y],u,v+TileSize


Krischan(Posted 2011) [#4]
I found the solution, finally. In the Function "CreateTilemap", the mesh gets positioned with an offset of 0.5 - without the offset the seams vanish :-D

PositionEntity Mesh,-(ScreenX/2.0)+(TileSize/2.0),(Screeny/2.0)-(TileSize/2.0),0