Distortion when moving across the screen sprite (Raspberry 4B))
Re: Distortion when moving across the screen sprite (Raspberry 4B))
I found it on the Internet. The guy almost effortlessly wrote a 2D driver for the Raspberry 4B GPU. Maybe someone will be interested? Maybe taking this material as a basis, someone can optimize FreeBasic for Raspberry?
Benjamin Doherty
https://blog.benjdoherty.com/2019/05/21 ... pberry-Pi/
Benjamin Doherty
https://blog.benjdoherty.com/2019/05/21 ... pberry-Pi/
Re: Distortion when moving across the screen sprite (Raspberry 4B))
@PavelUT: Why don't you simply use Raylib?
https://github.com/glasyalabolas/fb-raylib
It also supports the RPI...
https://github.com/glasyalabolas/fb-raylib
It also supports the RPI...
Re: Distortion when moving across the screen sprite (Raspberry 4B))
Or SDL, for which FB ships with include files.
Seriously, @PavelUT, you're going to have to look outside the FB graphics library which implements what was pretty advanced graphics 35 years ago. Today there are much better options that take advantage of graphics hardware.
Seriously, @PavelUT, you're going to have to look outside the FB graphics library which implements what was pretty advanced graphics 35 years ago. Today there are much better options that take advantage of graphics hardware.
Re: Distortion when moving across the screen sprite (Raspberry 4B))
I'll try Cairo later, but generally Cairo is a bit slow and you need more dll's than can fit in a folder.
However member srvaldez has combined all these dll's into one which makes Cairo very easy to handle.
Not sure about Linux though (.so), or are you (PavelUT) using wine (in a computing sense), or Linux proper?
However member srvaldez has combined all these dll's into one which makes Cairo very easy to handle.
Not sure about Linux though (.so), or are you (PavelUT) using wine (in a computing sense), or Linux proper?
Re: Distortion when moving across the screen sprite (Raspberry 4B))
At the moment I am using a Raspberry 4B microcomputer (about the size of a business card, but has a 4-core 64-bit processor, 4 Gigabytes of RAM, and a 3D graphics card). Operating system "Raspberry pi os" based on Debian.(Linux)dodicat wrote:I'll try Cairo later, but generally Cairo is a bit slow and you need more dll's than can fit in a folder.
However member srvaldez has combined all these dll's into one which makes Cairo very easy to handle.
Not sure about Linux though (.so), or are you (PavelUT) using wine (in a computing sense), or Linux proper?
Re: Distortion when moving across the screen sprite (Raspberry 4B))
So you are not using Wine on Linux to run Windows stuff.
(I have never used Raspberry machines)
I only ask because I can test the Cairo library on windows for this moving box.
(I have never used Raspberry machines)
I only ask because I can test the Cairo library on windows for this moving box.
Re: Distortion when moving across the screen sprite (Raspberry 4B))
This is very bad. It's not that "my majesty" wants a simple modern 2D graphics driver for FreeBasic for Linux. The problem is that without this driver it is impossible to use FreeBasic to write modern toys for Linux.caseih wrote:Or SDL, for which FB ships with include files.
Seriously, @PavelUT, you're going to have to look outside the FB graphics library which implements what was pretty advanced graphics 35 years ago. Today there are much better options that take advantage of graphics hardware.
The principle of using 2D graphics in FreeBasice is simple and straightforward. I would like to get the same simple feature when using third-party graphic libraries, "without dancing with a tambourine"
Re: Distortion when moving across the screen sprite (Raspberry 4B))
It's not about drawing a rectangle. In place of this rectangle, there should be a sprite moving across the monitor screen in Linux OS without distortion.dodicat wrote:So you are not using Wine on Linux to run Windows stuff.
(I have never used Raspberry machines)
I only ask because I can test the Cairo library on windows for this moving box.
Re: Distortion when moving across the screen sprite (Raspberry 4B))
You could try this.
Code: Select all
ScreenRes 800, 600, 32,2
width 800\8,600\16
dim as any ptr im=imagecreate(128,128,rgb(200,0,0))
Screenset 1,0
Function Regulate(Byval MyFps As Long,Byref fps As Long) As Long
Static As Double timervalue,lastsleeptime,t3,frames
frames+=1
If (Timer-t3)>=1 Then t3=Timer:fps=frames:frames=0
Var sleeptime=lastsleeptime+((1/myfps)-Timer+timervalue)*1000
If sleeptime<1 Then sleeptime=1
lastsleeptime=sleeptime
timervalue=Timer
Return sleeptime
End Function
Sub YinYang(x As long, y As long, r As long,im as any ptr=0)' r code
Circle im,(x, y), 2 * r, rgb(0,0,0),,,, F
Line im,(x, y - 2 * r) - (x, y + 2 * r), rgb(200,0,0), B
Paint im,(x - r, y),rgb(255,255,255), rgb(200,0,0)
Circle im,(x, y - r), r - 1, rgb(255,255,255),,,, F
Circle im,(x, y + r), r - 1, rgb(0,0,0),,,, F
Circle im,(x, y - r), r / 3, rgb(0,0,0),,,, F
Circle im,(x, y + r), r / 3, rgb(255,255,255),,,, F
End Sub
Sub rotateimage(Byref dest As Any Ptr=0,im As Any Ptr,angle As Single,shiftx As Long=0,shifty As Long=0,sc As Single=1,miss As Ulong=Rgb(255,0,255),fixedpivot As boolean=false)
Static As Integer pitch,pitchs,xres,yres,runflag
Static As Any Ptr row,rows
Static As Integer ddx,ddy,resultx,resulty
Imageinfo im,ddx,ddy,,pitch,row
If dest=0 Then
Screeninfo xres,yres,,,pitchS
rowS=Screenptr
Else
If sc<>1 Then
Dim As Integer x,y
Imageinfo dest,x,y
Imagedestroy dest:dest=0: dest=Imagecreate(x*sc,y*sc)
End If
Imageinfo dest, xres,yres,,pitchS,rows
End If
Dim As Long centreX=ddx\2,centreY=ddy\2
Dim As Single sx=Sin(angle)
Dim As Single cx=Cos(angle)
Dim As Long mx=Iif(ddx>=ddy,ddx,ddy),shftx,shfty
Var fx=sc*.7071067811865476,sc2=1/sc
If fixedpivot=false Then
shiftx+=centreX*sc-centrex
shiftY+=centrey*sc-centrey
End If
For y As Long=centrey-fx*mx+1 To centrey+ fx*mx
Dim As Single sxcy=Sx*(y-centrey),cxcy=Cx*(y-centrey)
shfty=y+shifty
For x As Long=centrex-mx*fx To centrex+mx*fx
If x+shiftx >=0 Then 'on the screen
If x+shiftx <xres Then
If shfty >=0 Then
If shfty<yres Then
resultx=sc2*(Cx*(x-centrex)-Sxcy) +centrex:resulty=sc2*(Sx*(x-centrex)+Cxcy) +centrey
If resultx >=0 Then 'on the image
If resultx<ddx Then
If resulty>=0 Then
If resulty<ddy Then
Dim As Ulong u=*Cast(Ulong Ptr,row+pitch*((resultY))+((resultX)) Shl 2 ) 'point(image)
If u<>miss Then *Cast(Ulong Ptr,rowS+pitchS*(y+shifty)+(x+shiftx) Shl 2)= u 'pset (screen)
End If:End If:End If:End If
End If:End If:End If:End If
Next x
Next y
End Sub
YinYang(64,64,20,im)
dim as long fps
dim as single a
Dim As Integer x = 0
Color RGB(255, 128, 0), RGB(0, 0, 200)
Cls
Do
a-=.05
Cls
rotateimage(,im,a,x,80,1,rgb(200,0,0))
line(0,185)-(800,185)
locate 2
print "framerate = ";fps
x += 1: If (x > 639) Then x = 0
Flip
sleep regulate(60*3,fps)
Loop While Inkey = ""
sleep
end
Re: Distortion when moving across the screen sprite (Raspberry 4B))
As a daily linux user and occasional game programmer I am aware of the screen tearing issue, but it never bothered me too much. Maybe the issue is more prominent on a slower Raspberry.
The issue was also brought up last year: Freebasic is not smooth in graphics, although the OS was never specified.
Cairo graphics is not really meant for games and sprites, but it is of course possible. Example: https://erleuchtet.org/2008/03/project- ... storm.html
SDL(2) is probably the best solution, but the examples that come with freebasic are old (so expect trouble): https://github.com/freebasic/fbc/tree/m ... aphics/SDL
Another option might be SFML: https://freebasic.net/forum/viewtopic.php?f=14&t=26678
The issue was also brought up last year: Freebasic is not smooth in graphics, although the OS was never specified.
Cairo graphics is not really meant for games and sprites, but it is of course possible. Example: https://erleuchtet.org/2008/03/project- ... storm.html
SDL(2) is probably the best solution, but the examples that come with freebasic are old (so expect trouble): https://github.com/freebasic/fbc/tree/m ... aphics/SDL
Another option might be SFML: https://freebasic.net/forum/viewtopic.php?f=14&t=26678
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: Distortion when moving across the screen sprite (Raspberry 4B))
I self tested latest stable FreeBASIC on my old Raspberry PI b and PI 3 and my friend reported no problems on his PI 4.
May be your PI 4 has a problem do you use overclocking ? or do you modify something in the video config ?
Joshy
May be your PI 4 has a problem do you use overclocking ? or do you modify something in the video config ?
Joshy
Re: Distortion when moving across the screen sprite (Raspberry 4B))
D.J.Peters wrote:I self tested latest stable FreeBASIC on my old Raspberry PI b and PI 3 and my friend reported no problems on his PI 4.
May be your PI 4 has a problem do you use overclocking ? or do you modify something in the video config ?
Joshy
1) Have you tested my circle and rectangle program? What is the latest stable version of FreeBasic that you tested on?
2) No, I do not use overclocking.
3) Distortion is almost invisible at +1 speed. But at a speed of +3 they are very noticeable. That's what's surprising.
Re: Distortion when moving across the screen sprite (Raspberry 4B))
D.J.Peters wrote:I self tested latest stable FreeBASIC on my old Raspberry PI b and PI 3 and my friend reported no problems on his PI 4.
May be your PI 4 has a problem do you use overclocking ? or do you modify something in the video config ?
Joshy
Here on the forum I was told that the distortions are due to the X11 driver 35 years ago. But computers have changed a lot over the past 20 years. Is it possible to test and optimize Frebasic graphics drivers?
Re: Distortion when moving across the screen sprite (Raspberry 4B))
I ran this code. The ball rotates without distortion, only when moving it turns out to be a little "shaggy"dodicat wrote:You could try this.Code: Select all
ScreenRes 800, 600, 32,2 width 800\8,600\16 dim as any ptr im=imagecreate(128,128,rgb(200,0,0)) Screenset 1,0 Function Regulate(Byval MyFps As Long,Byref fps As Long) As Long Static As Double timervalue,lastsleeptime,t3,frames frames+=1 If (Timer-t3)>=1 Then t3=Timer:fps=frames:frames=0 Var sleeptime=lastsleeptime+((1/myfps)-Timer+timervalue)*1000 If sleeptime<1 Then sleeptime=1 lastsleeptime=sleeptime timervalue=Timer Return sleeptime End Function Sub YinYang(x As long, y As long, r As long,im as any ptr=0)' r code Circle im,(x, y), 2 * r, rgb(0,0,0),,,, F Line im,(x, y - 2 * r) - (x, y + 2 * r), rgb(200,0,0), B Paint im,(x - r, y),rgb(255,255,255), rgb(200,0,0) Circle im,(x, y - r), r - 1, rgb(255,255,255),,,, F Circle im,(x, y + r), r - 1, rgb(0,0,0),,,, F Circle im,(x, y - r), r / 3, rgb(0,0,0),,,, F Circle im,(x, y + r), r / 3, rgb(255,255,255),,,, F End Sub Sub rotateimage(Byref dest As Any Ptr=0,im As Any Ptr,angle As Single,shiftx As Long=0,shifty As Long=0,sc As Single=1,miss As Ulong=Rgb(255,0,255),fixedpivot As boolean=false) Static As Integer pitch,pitchs,xres,yres,runflag Static As Any Ptr row,rows Static As Integer ddx,ddy,resultx,resulty Imageinfo im,ddx,ddy,,pitch,row If dest=0 Then Screeninfo xres,yres,,,pitchS rowS=Screenptr Else If sc<>1 Then Dim As Integer x,y Imageinfo dest,x,y Imagedestroy dest:dest=0: dest=Imagecreate(x*sc,y*sc) End If Imageinfo dest, xres,yres,,pitchS,rows End If Dim As Long centreX=ddx\2,centreY=ddy\2 Dim As Single sx=Sin(angle) Dim As Single cx=Cos(angle) Dim As Long mx=Iif(ddx>=ddy,ddx,ddy),shftx,shfty Var fx=sc*.7071067811865476,sc2=1/sc If fixedpivot=false Then shiftx+=centreX*sc-centrex shiftY+=centrey*sc-centrey End If For y As Long=centrey-fx*mx+1 To centrey+ fx*mx Dim As Single sxcy=Sx*(y-centrey),cxcy=Cx*(y-centrey) shfty=y+shifty For x As Long=centrex-mx*fx To centrex+mx*fx If x+shiftx >=0 Then 'on the screen If x+shiftx <xres Then If shfty >=0 Then If shfty<yres Then resultx=sc2*(Cx*(x-centrex)-Sxcy) +centrex:resulty=sc2*(Sx*(x-centrex)+Cxcy) +centrey If resultx >=0 Then 'on the image If resultx<ddx Then If resulty>=0 Then If resulty<ddy Then Dim As Ulong u=*Cast(Ulong Ptr,row+pitch*((resultY))+((resultX)) Shl 2 ) 'point(image) If u<>miss Then *Cast(Ulong Ptr,rowS+pitchS*(y+shifty)+(x+shiftx) Shl 2)= u 'pset (screen) End If:End If:End If:End If End If:End If:End If:End If Next x Next y End Sub YinYang(64,64,20,im) dim as long fps dim as single a Dim As Integer x = 0 Color RGB(255, 128, 0), RGB(0, 0, 200) Cls Do a-=.05 Cls rotateimage(,im,a,x,80,1,rgb(200,0,0)) line(0,185)-(800,185) locate 2 print "framerate = ";fps x += 1: If (x > 639) Then x = 0 Flip sleep regulate(60*3,fps) Loop While Inkey = "" sleep end
Re: Distortion when moving across the screen sprite (Raspberry 4B))
Thanks for the tips. Only running these third party libraries is not very easy. Can you advise any literature? For now, 2D graphics, sounds and keyboard and mouse controls are enough for me.badidea wrote:As a daily linux user and occasional game programmer I am aware of the screen tearing issue, but it never bothered me too much. Maybe the issue is more prominent on a slower Raspberry.
The issue was also brought up last year: Freebasic is not smooth in graphics, although the OS was never specified.
Cairo graphics is not really meant for games and sprites, but it is of course possible. Example: https://erleuchtet.org/2008/03/project- ... storm.html
SDL(2) is probably the best solution, but the examples that come with freebasic are old (so expect trouble): https://github.com/freebasic/fbc/tree/m ... aphics/SDL
Another option might be SFML: https://freebasic.net/forum/viewtopic.php?f=14&t=26678