Since DirectDraw has been deprecated, I am learning how to use Direct3D to make a 2D tile-based game, using the book ".NET Game Programming with DirectX 9.0" (VB .NET Edition).
The problem I have is a row of pixels from the textures seems to wrap around on the right and bottom edges. This only happens when I use a hardware device, not a reference device.
The textures are 32x32 and the squares that they are rendered in are 32x32.
This happened both with my source and the source included on a CD that came with the book. I tried using different overloads to load the textures. I tried changing the coordinates of the texture to be applied from (0 to 1) to (0 to .999), which helped somewhat, but I am worried that both the problem and that solution may vary depending on hardware. I googled, it scoured the DirectX documentation, and looked through the object browser for and relevant classes and properties, and found nothing that helped.
Here is the code I am using:
Can anyone explain to me why this is occuring or how to prevent it? I've spent hours trying to figure this out. My head hurts.
The problem I have is a row of pixels from the textures seems to wrap around on the right and bottom edges. This only happens when I use a hardware device, not a reference device.
The textures are 32x32 and the squares that they are rendered in are 32x32.
This happened both with my source and the source included on a CD that came with the book. I tried using different overloads to load the textures. I tried changing the coordinates of the texture to be applied from (0 to 1) to (0 to .999), which helped somewhat, but I am worried that both the problem and that solution may vary depending on hardware. I googled, it scoured the DirectX documentation, and looked through the object browser for and relevant classes and properties, and found nothing that helped.
Here is the code I am using:
Visual Basic:
'To load textures
Images(i) = TextureLoader.FromFile(Device, _
IO.Path.Combine(ImagePath, ImageList(i)))
'To create polygons
Const Size As Integer = 32
'Vertex = (X, Y, Z, tU, tV)
Vertices(0) = New CustomVertex(X * Size, Y * Size, 1, 0, 1)
Vertices(1) = New CustomVertex(X * Size + Size, Y * Size, 1, 1, 1)
Vertices(2) = New CustomVertex(X * Size, Y * Size + Size, 1, 0, 0)
Vertices(3) = New CustomVertex(X * Size + Size, Y * Size + Size, 1, 1, 0)
'To render polygons
Direct3DDevice.SetTexture(0, SpriteImage)
Direct3DDevice.SetStreamSource(0, VertBuffer, 0)
Direct3DDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2)
Can anyone explain to me why this is occuring or how to prevent it? I've spent hours trying to figure this out. My head hurts.