Is there a way to repeat/scroll a part of a texture in a loaded surface?
Ex: I got a tile-system 64x64 that got all tiles in one large surface image 2048x2048.
I set up the tiles tristrip using this function in visual basic:
Private Sub Tile_GetRect(bytTileNumber As Integer, ByRef lngTileX As Single, ByRef lngTileY As Single, TileImgWidth As Integer, TileImgHeight As Integer, TileInXYRow As Single, TileWidth As Single, TileHeight As Single, Optional ColorValue1 As Long = &HFFFFFFFF, Optional ColorValue2 As Long = &HFFFFFFFF, Optional ColorValue3 As Long = &HFFFFFFFF, Optional ColorValue4 As Long = &HFFFFFFFF) Dim XRow As Single, YRow As Single, CalcCof As Single, X2Row As Single, Y2Row As Single ' Calc Y Row cof (X row is the same) ' TILE_HEIGHT = 64 ' theHeightOfImage = 2048 ' TileInYRow = TILE_HEIGHT / theHeightOfImage ' The tiles must have x=y grids if it has 4 tiles on the y axis it must have 4 tiles on the x axis CalcCof = TileInXYRow * bytTileNumber '1 XRow = Int(CalcCof) '1 YRow = (CalcCof - XRow) + gArtifactLines '0 XRow = (XRow * TileInXYRow) + gArtifactLines '0.5 X2Row = (XRow + TileInXYRow) - gArtifactLines '1 Y2Row = (YRow + TileInXYRow) - gArtifactLines '0.5 ' Set up Rect TriStrip(0) = CreateTLVertex(lngTileX, lngTileY, 0, 1, ColorValue1, 0, XRow, YRow) TriStrip(1) = CreateTLVertex(lngTileX + TileWidth, lngTileY, 0, 1, ColorValue2, 0, X2Row, YRow) TriStrip(2) = CreateTLVertex(lngTileX, lngTileY + TileHeight, 0, 1, ColorValue3, 0, XRow, Y2Row) TriStrip(3) = CreateTLVertex(lngTileX + TileWidth, lngTileY + TileHeight, 0, 1, ColorValue4, 0, X2Row, Y2Row) End Sub
This function just calculates the position of the tilenumber. Ex I want tile number 5 and I get the tiles UV pos in the surface. This works well.
But I now want to be able to scroll it inside the created vertex area. Ex:
My tile is drawn like this:
Say I want to scroll it like this:
Now parts of the texture is black. But I want it to wrap like this (added some black lines just to make it clear):
Is this possible to do with one draw? Or do I need to draw 4 tiles and cut and fit them to the right place? I know I can create a repeat area like this:
And just calc a UV pos 64x64 tile in this surface and when I scroll and reach one end I just add or substract 64 from the currect UV pos to make it repeat. But If I do this I will end up with a 4096x4096 surface.
Why do I want to do this. I want to make a parallax image so when the player moves the tiles scrolls inside a drawn and moving vertex area.