Hardware 2D acceleration

Find quick help here to get you started with Hollywood
Post Reply
ArtBlink
Posts: 484
Joined: Mon Nov 01, 2010 10:37 am
Location: Albert - France
Contact:

Hardware 2D acceleration

Post by ArtBlink »

Hello,

Is Hollywood 2D engine use hardware acceleration? because when i use more than 300 brush, hollywood is too slower (24FPS on Sam 460 with SM502).

My 2d tile scrolling on MicroAone is more more slower (in the same size of screen) than my 2D tile scrolling AmosPro on my old basic Amiga 1200 ?!! :shock:

I use double buffer technique in the two langage, 32x32 pixels size of tile.
pecaN
Posts: 124
Joined: Thu Jun 10, 2010 4:15 pm

Re: Hardware 2D acceleration

Post by pecaN »

As far as i know, only transition effects are hardware accelerated on MorphOs 2.x and AOS 4.x... but maybe on Windows it may be different... pecaN
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Hardware 2D acceleration

Post by airsoftsoftwair »

Double buffering and crossfades are hardware accelerated on MorphOS 2 and OS4. The rest is not hardware accelerated. Implementing generic hardware acceleration e.g. for brushes is not possible. This would require new APIs because I can't just relocate the brushes to video memory. Though that would give a good speedup when drawing them it would on the other hand slow down image manipulation routines considerably because reading from video memory is much slower than reading from fast memory.
ArtBlink
Posts: 484
Joined: Mon Nov 01, 2010 10:37 am
Location: Albert - France
Contact:

Re: Hardware 2D acceleration

Post by ArtBlink »

Well, with doublebuffer, all of my engine are slow, it's strange... Yet amiga ng have got a good speed, and much higher than Amiga classic machine.

It's a shame especially that hollywood is very powerful and simple langage
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Hardware 2D acceleration

Post by airsoftsoftwair »

Double buffer currently always refreshes the whole display. So if you only need to update a very small area then double buffer will obviously be slower.
ArtBlink
Posts: 484
Joined: Mon Nov 01, 2010 10:37 am
Location: Albert - France
Contact:

Re: Hardware 2D acceleration

Post by ArtBlink »

I refresh all display for my scroll (and all other of my prg, i try to make 2D game at this moment)... But, i use .Png picture to brush and tiles, is it a good picture format? what is the speedest image format on Hollywood? IFF, Png, Jpg?

If i load Png picture, is it decompress at all display or is it decompress when is it load and save in memory?

Try this code, it is too slow on microAone when i load PNG picture for tiles and brush and i don't understand why?

Code: Select all

@SCREEN {Mode="Ask",Width=640, Height=480, depth=16}
SetFillStyle(#FILLCOLOR)
CreateBrush (1,32,32,$000000)
SelectBrush(1)
Polygon (0,0,{32,16,0,32,0,0},3,$FF0000)
EndSelect
CreateBrush (2,32,32,$000000)
SelectBrush(2)
Box (0,0,32,32,$00AA00)
EndSelect
CreateBrush (3,32,32,$000000)
SelectBrush(3)
Box (0,0,32,32,$555555)
EndSelect
CreateBrush (4,32,32,$000000)
SelectBrush(4)
Box (0,0,32,16,$00AA00)
Box (0,16,32,32,$555555)
EndSelect
CopyBrush (4,5)
RotateBrush(5,-90)
CopyBrush (4,6)
RotateBrush(6,90)
CopyBrush (4,7)
RotateBrush(7,180)
SetBrushTransparency(1,$000000)
Dim Circuit[30][30]
Circuit[0]={2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2}
Circuit[1]={2,2,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,2,2}
Circuit[2]={2,6,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,5,2}
Circuit[3]={2,6,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,5,2}
Circuit[4]={2,6,3,3,2,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,2,3,3,5,2}
Circuit[5]={2,6,3,3,5,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,6,3,3,5,2}
Circuit[6]={2,6,3,3,5,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,6,3,3,5,2}
Circuit[7]={2,6,3,3,5,2,2,2,2,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,5,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,6,3,3,5,2}
Circuit[23]={2,6,3,3,5,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,6,3,3,5,2}
Circuit[24]={2,6,3,3,5,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,6,3,3,5,2}
Circuit[25]={2,6,3,3,2,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,2,3,3,5,2}
Circuit[26]={2,6,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,5,2}
Circuit[27]={2,6,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,5,2}
Circuit[28]={2,2,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,2,2}
Circuit[29]={2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2}
X=0
Y=0
Angle=0 
vitesse=0 
XVoiture=320
YVoiture=240
Voiture = 1
SetFontStyle(#EDGE, #BLACK, 1)

Function supercar()
   StartTimer(1)
   Flip
   
   Local Avance = IsKeyDown("UP") 
   Local Recule = IsKeyDown("Down") 
   Local Droite = IsKeyDown("RIGHT") 
   Local Gauche = IsKeyDown("LEFT")
   Local ToucheA = IsKeyDown("a")
   Local ToucheB = IsKeyDown("z")
   
   If Avance = True 
      
      
      Vitesse=vitesse+0.5
      If vitesse>6 Then vitesse=6
      Else
      If vitesse>0 Then vitesse=vitesse-0.3
      EndIf
   
   

   If Recule = True
      Vitesse=vitesse-1
      If vitesse<-3 Then vitesse=-3
   Else
      If vitesse<0 Then vitesse=vitesse+0.2

   EndIf
   
   If vitesse>0 And vitesse<0.1 Then vitesse=0
   Radians=Angle*0.01745
   If XVoiture=320 Then X=X+Cos(Radians)*vitesse
   If YVoiture=240 Then Y=Y-Sin(Radians)*vitesse
   ;Blocage du scroll
   If x>320 Then X=320 
      If X=320
      XVoiture=Xvoiture+Cos(Radians)*vitesse
      If XVoiture>600 Then XVoiture=600
      If XVoiture<320 Then XVoiture=320
      EndIf
   If X<0 Then X=0
      If X=0
      XVoiture=Xvoiture+Cos(Radians)*vitesse
      If XVoiture<40 Then XVoiture=40
      If XVoiture>320 Then XVoiture=320
      EndIf

   If Y<0 Then Y=0
   If Y=0
      YVoiture=Yvoiture-Sin(Radians)*vitesse
      If YVoiture<40 Then YVoiture=40
      If YVoiture>240 Then YVoiture=240
      EndIf

   If Y>(29*32)/2 Then Y=(29*32)/2
   If Y=(29*32)/2

      YVoiture=Yvoiture-Sin(Radians)*vitesse
      If YVoiture>440 Then YVoiture=440
      If YVoiture<240 Then YVoiture=240
      EndIf

   ; Si la voiture ne roule pas, elle ne tourne pas
   If vitesse<>0
      If Droite = True Then Angle=Angle-2
      If Gauche = True Then Angle=Angle+2
   EndIf
    
   Local ViewXOffset=ViewXOffset+X
   Local ViewYOffset=ViewYOffset+Y
   If ViewXOffset<0 
      ViewXOffset=0
   Else
      If ViewXOffset>29 Then ViewXoffset=29
   EndIf
      If ViewYOffset<0 
         ViewYOffset=0
      Else
      If ViewYOffset>29 Then ViewYoffset=29
   EndIf

   scrolling()
   TextOut(0,0,"speed : ")
   TextOut(80,0,Round(Abs(vitesse*10)))
   TextOut(110,0,"Km/h")
   DisplayBrush(voiture,XVoiture,YVoiture,{AnchorX = 0.5, AnchorY = 0.5,rotate=Angle})
   Local Temps=GetTimer(1)
   TextOut (350,1,"Number of picture by second",#BLUE)
   TextOut (586,1,Round((1/Temps)*1000))
EndFunction

Function scrolling()
   
   Local TileX=Int(X/32)
   Local TileY=Int(Y/32)
   If TileX<0 Then TileX=0
   If tileX>9 Then TileX=9
   If TileY<0 Then TileY=0
   If tileY>14 Then TileY=14
   For Local RowCtr=TileY To 15+TileY
      For Local ColCtr=tileX To 20+tileX 
         Local TileNum=Circuit[RowCtr][ColCtr]
         Local TilePointX=(ColCtr*32)-X
         Local TilePointY=(RowCtr*32)-Y

         DisplayBrush(TileNum,TilePointX,TilePointY)

      Next
   Next
EndFunction

SetInterval (1,supercar,20)
BeginDoubleBuffer

Repeat
   WaitEvent
Forever
Bugala
Posts: 1178
Joined: Sun Feb 14, 2010 7:11 pm

Re: Hardware 2D acceleration

Post by Bugala »

To my understanding (and this is in no way a sure thing) PNG is basically very similar to Amigas IFF formats.

So it shoudnt be compressed and should be pretty fast choice, unlike for example JPEG, which is one of the slowest and very unaccurate format.

Naturally this however comes with cost of space. JPEGs, while unaccurate and slow to load and use, can be very small in file size, while PNGs are pretty similar to Amigas IFF sizes (which is one of the reasons i think they are close to being similar).
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Hardware 2D acceleration

Post by airsoftsoftwair »

PNG (like IFF ILBM) provides lossless compression which means that the original image will be preserved 100%. JPEGs compression is lossy, even when using the highest possible quality you will lose some of the image data.
Post Reply