Hi, this is my first post here, but I have a time reading the forum.
I have a very rare and funny problem, I tried to find other similar bug but no luck.
Description:
Randomly a sprite area change when I move the sprite.
I create only one time a sprite from a Texture with a "intrect", the texture and the sprite are power of 2 (texture 512*256 and sprite 64*64).
In the main loop, I'm only move the sprite with the position method, in some frame the drawing looks perfect, but in others, a part of the texture that is not originally in the sprite appears on the screen.
What I did notice is that the bug does not appear if the speed is a rational number, example VelX = VelY = 0.5, etc.
code:
Imports SFML.Window
Imports SFML.System
Imports SFML.Graphics
Public Class FrmFrameWork
Dim WithEvents SFMLwindow As RenderWindow
Private Sub FrmFrameWork_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim auxStyles As Styles = Styles.Default
Dim MainLoop As Boolean = True
Dim auxTimer As Integer = 0
SFMLwindow = New RenderWindow(New VideoMode(1366, 768), "Prueba error SFML ", auxStyles) 'styles.fullscreen
SFMLwindow.SetVisible(True)
SFMLwindow.SetVerticalSyncEnabled(False)
SFMLwindow.SetFramerateLimit(60)
Dim texTest As New Texture("proyectiles2.png")
Dim rctTest As IntRect
rctTest.Width = 64
rctTest.Height = 64
rctTest.Left = 0
rctTest.Top = 64
Dim sprTest As New Sprite(texTest, rctTest)
Dim PosX, PosY As Single
Dim VelX, VelY As Single
VelX = 4 * Math.Sin(15 * Math.PI / 180)
VelY = 4 * Math.Cos(15 * Math.PI / 180)
While MainLoop
SFMLwindow.DispatchEvents()
If Keyboard.IsKeyPressed(Keyboard.Key.Escape) Then MainLoop = False 'ESC siempre cierra el juego
SFMLwindow.Clear(Color.Black) 'Limpiamos la pantalla
auxTimer += 1
If auxTimer Mod 30 = 0 Then
PosX += VelX
PosY += VelY
sprTest.Position = New Vector2f(PosX, PosY)
End If
'auxSprite = New Sprite(oMeta.oRtScreen.Texture)
'auxSprite.Position = oMeta.posScreen
SFMLwindow.Draw(sprTest)
SFMLwindow.Display()
End While
SFMLwindow.Close()
Me.Close()
End Sub
End Class
Detail:
I have the same problems with 2 PC.
PC 1
SFML.NET 2.2(32bit) + NET 4.52
VB NET community 2017
OS: Windows 10
CPU: Intel i7 3610qm
GPU: Nvidia GTX 660m
PC2
SFML.NET 2.4(64bit) + NET 4.52
VB NET Community 2019
OS: Windows 10
CPU: Intel i7 4790
GPU: 4095MB NVIDIA GeForce GTX 980 (MSI)
I always have my drivers and OS updated
PD: Sorry for my English is not my native language.