Hi Lebostein
(@Stefan Möbius, du hast doch immer so schöne kleine DX-Routinen herumliegen )
Du könntest den ColorBox-Befehl aus meiner
SpriteEx-Userlib verwenden:
Code: Alles auswählen
InitSprite()
InitKeyboard()
OpenScreen(800,600,16,"Fast colorboxes")
StartDrawing(ScreenOutput())
PixelFormat=DrawingBufferPixelFormat()
StopDrawing()
Repeat
ClearScreen(0,0,0)
For c=0 To 300
ColorBox(100,100,50,50,RGBColor(PixelFormat,255,0,0))
Next
Count+1
If ElapsedMilliseconds()-Start=>1000:Start=ElapsedMilliseconds():FPS=Count:Count=0:EndIf
StartDrawing(ScreenOutput())
DrawText(Str(FPS))
StopDrawing()
FlipBuffers(0)
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_All)
oder diese Prozedur, wenn du keine Userlibs verwenden willst:(Funktioniert nicht im 8-Bit Farbmodus)
Code: Alles auswählen
Structure DDBLTFX
dwSize.l
dwDDFX.l
dwROP.l
dwDDROP.l
dwRotationAngle.l
dwZBufferOpCode.l
dwZBufferLow.l
dwZBufferHigh.l
dwZBufferBaseDest.l
dwZDestConstBitDepth.l
dwZDestConst.l
dwZSrcConstBitDepth.l
dwZSrcConst.l
dwAlphaEdgeBlendBitDepth.l
dwAlphaEdgeBlend.l
dwReserved.l
dwAlphaDestConstBitDepth.l
dwAlphaDestConst.l
dwAlphaSrcConstBitDepth.l
dwAlphaSrcConst.l
dwFillColor.l
dwColorSpaceLowValue.l
dwColorSpaceHighValue.l
dwColorSpaceLowValue2.l
dwColorSpaceHighValue2.l
EndStructure
#DDBLT_COLORFILL=1024
#DDBLT_WAIT=16777216
Procedure _GetScreenWidth()
!extrn _PB_DirectX_ScreenWidth
!MOV Eax,[_PB_DirectX_ScreenWidth]
ProcedureReturn
EndProcedure
Procedure _GetScreenHeight()
!extrn _PB_DirectX_ScreenHeight
!MOV Eax,[_PB_DirectX_ScreenHeight]
ProcedureReturn
EndProcedure
Procedure _GetPixelFormat()
!extrn _PB_DirectX_PixelFormat
!MOV Eax,[_PB_DirectX_PixelFormat]
ProcedureReturn
EndProcedure
Procedure _GetBackBufferSurface()
!extrn _PB_Sprite_CurrentBitmap
!MOV Eax,[_PB_Sprite_CurrentBitmap]
ProcedureReturn
EndProcedure
Procedure _RGBColor(R,G,B)
Select _GetPixelFormat()
Case #PB_PixelFormat_15Bits
ProcedureReturn B>>3+(G>>3)<<5+(R>>3)<<10
Case #PB_PixelFormat_16Bits
ProcedureReturn B>>3+(G>>2)<<5+(R>>3)<<11
Case #PB_PixelFormat_24Bits_RGB
ProcedureReturn R+G<<8+B<<16
Case #PB_PixelFormat_24Bits_BGR
ProcedureReturn b+G<<8+R<<16
Case #PB_PixelFormat_32Bits_RGB
ProcedureReturn R+G<<8+B<<16
Case #PB_PixelFormat_32Bits_BGR
ProcedureReturn B+G<<8+R<<16
EndSelect
EndProcedure
Procedure DrawColorBox(x,y,width,height,RGB)
*Back.IDirectDrawSurface7=_GetBackBufferSurface()
a.rect\left=x
a\right=x+width
a\top=y
a\bottom=y+height
b.rect\left=0
b\right=_GetScreenWidth()
b\top=0
b\bottom=_GetScreenHeight()
If IntersectRect_(dest.rect,a.rect,b.rect)=0:ProcedureReturn 0:EndIf
BltInfo.DDBLTFX\dwSize=SizeOf(DDBLTFX)
BltInfo\dwFillColor=_RGBColor(Red(RGB),Green(RGB),Blue(RGB))
ProcedureReturn *Back\Blt(dest,0,0,#DDBLT_COLORFILL|#DDBLT_WAIT,BltInfo)
EndProcedure
InitSprite()
InitKeyboard()
OpenScreen(800,600,16,"Fast colorboxes")
Repeat
ClearScreen(0,0,0)
For c=0 To 300
DrawColorBox(100,100,50,50,#red)
Next
Count+1
If ElapsedMilliseconds()-Start=>1000:Start=ElapsedMilliseconds():FPS=Count:Count=0:EndIf
StartDrawing(ScreenOutput())
DrawText(Str(FPS))
StopDrawing()
FlipBuffers(0)
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_All)
Gruß
Stefan