Re: PB_DX9Sprite - Textur-Kachelung - Sprite3D-Färbung
Verfasst: 01.08.2010 01:34
bei mir funktioniert es
Das deutsche PureBasic-Forum
https://www.purebasic.fr/german/
Code: Alles auswählen
InitSprite()
InitSprite3D()
; DirectX9
Structure Sprite3D_DX9_Vertex
x.f:y.f:z.f
rhw.f:Color.l
tu.f:tv.f
EndStructure
Structure Sprite3D_DX9
TexRes.i
Vertice.Sprite3D_DX9_Vertex[4]
TmpVertice.Sprite3D_DX9_Vertex[4]
Width.l
Height.l
RealWidth.l
RealHeight.l
Angle.f
Transformed.l
EndStructure
Procedure DisplayBoxedSprite3D(Sprite3D, x, y, Width, Height, Top, Right, Bottom, Left)
Protected *Sprite3D.Sprite3D_DX9 = IsSprite3D(Sprite3D)
Protected Dim u.f(3), Dim v.f(3) ; Vertex
Protected Dim x.i(3), Dim y.i(3) ; Position
Protected ix.i, iy.i
With *Sprite3D
u(0) = 0 : u(1) = Left/\RealWidth : u(2) = 1-Right/\RealWidth : u(3) = 1
v(0) = 0 : v(1) = Top/\RealHeight : v(2) = 1-Bottom/\RealHeight : v(3) = 1
x(0) = x : x(1) = x+Left : x(2) = x+Width-Right : x(3) = x+Width
y(0) = y : y(1) = y+Top : y(2) = y+Height-Bottom : y(3) = y+Height
; 9 Felder clippen und zoomen und anzeigen
For iy = 0 To 2
For ix = 0 To 2
\Vertice[0]\tu = u(ix) : \Vertice[0]\tv = v(iy)
\Vertice[1]\tu = u(ix+1) : \Vertice[1]\tv = v(iy)
\Vertice[2]\tu = u(ix) : \Vertice[2]\tv = v(iy+1)
\Vertice[3]\tu = u(ix+1) : \Vertice[3]\tv = v(iy+1)
\Width = x(ix+1)-x(ix) : \Height = y(iy+1)-y(iy)
\Transformed = #False
DisplaySprite3D(Sprite3D, x(ix), y(iy))
Next
Next
; Reset, damit das Bild wieder "Default"-Eigenschaften hat
\Vertice[0]\tu = 0 : \Vertice[0]\tv = 0
\Vertice[1]\tu = 1 : \Vertice[1]\tv = 0
\Vertice[2]\tu = 0 : \Vertice[2]\tv = 1
\Vertice[3]\tu = 1 : \Vertice[3]\tv = 1
\Width = \RealWidth : \Height = \RealHeight
\Transformed = #False
EndWith
EndProcedure
OpenWindow(0, 0, 0, 800, 600, "Screen", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, WindowWidth(0), WindowHeight(0), 0, 0, 0)
UsePNGImageDecoder()
CatchSprite(0, ?Window_png, #PB_Sprite_Texture|#PB_Sprite_AlphaBlending)
CreateSprite3D(0, 0)
Repeat
ClearScreen($FFFFFF)
Start3D()
Time.f = ElapsedMilliseconds()/1000
DisplaySprite3D(0, 0, 0)
DisplayBoxedSprite3D(0, 100, 100, 400+Sin(Time)*100, 300+Cos(Time)*100, 32, 16, 16, 16)
Stop3D()
FlipBuffers()
Until WindowEvent() = #PB_Event_CloseWindow
DataSection
Window_png:
Data.q $0A1A0A0D474E5089,$524448490D000000,$4000000040000000,$7169AA0000000608,$47527301000000DE
Data.q $0000E91CCEAE0042,$FF0044474B620600,$93A7BDA0FF00FF00,$7359487009000000,$130B0000130B0000
Data.q $000000189C9A0001,$08DA07454D497407,$5F29C112161B151C,$5441444959020000,$30C26E7D9BEDDA78
Data.q $F7636C413F5FC50C,$E0970A3D28E0971A,$D368A7D92760DC06,$DD2851337B51FD96,$DA0AD592D8B250D8
Data.q $22017814DD8BF78A,$E94A651931C2648F,$C800AFE51D94F463,$ED0899210C941400,$BBB286F164A0719A
Data.q $F02AE4A732294004,$1C88D94B7E8F0011,$1549644CDAF1DC8D,$AC6F16016E7C10C0,$73E124A003BFAAC1
Data.q $D1C8056BE004820B,$D5B9095630F39F97,$0DA214212E10A5F3,$8FC5B7D189D0047C,$0CFDF44280251CDE
Data.q $B2A610C7AAAAACC0,$E213EBD4A81EAAAA,$8085CA31320073DB,$76EDF8B5E56AD580,$1CDE00F600F7000B
Data.q $ADC866739348616D,$B6DB400059173EB9,$A1D3916852C11421,$0809E90031B2C19C,$2DB696E00084C630
Data.q $00B58E9F10E341B5,$B0154059915238DF,$92D49B83C52F11A0,$3F73EF29EB00039C,$2D29E9AA4F900A90
Data.q $F80A90228E841F53,$1DFC054810059C71,$BA00D44015EFBE80,$EF400A00500AD3AE,$006E24924802F101
Data.q $0532CB200DC79E79,$05B400A015A02DA0,$E2EDDBB0056202B4,$D9B016BDAF5EB006,$00A1E4453F3A2E6C
Data.q $01400A0050028014,$02801400A0050028,$07BF90C6200A0050,$DBEFD2FF68FAEBB0,$A9D03FB1C6B60A57
Data.q $0DC01CD7BFFC15C5,$30EE00176F15B706,$900B68AC18971098,$015E00EFF133CC7B,$BDAF42F00278033C
Data.q $02AA7F76F24F3063,$7C49D35915B69FA4,$B4F7224D4014F19C,$5C05AC7EAEB0352F,$062DA7ED8C5D0DE2
Data.q $565F06E9668F9E1F,$0028C20BBB3E9AD9,$F0B94CE72DB5A9E9,$08D992C18BD9C6F0,$5EDC2CE2DC130610
Data.q $BB77CF7E7476C219,$3A059D9C41810DBC,$4C1690E1301B17B8,$2707400029BA10D8,$00B1A664B6870B8E
Data.q $01B17249D0002A60,$E6CBA5345CBFFE8F,$686A4E17AFF31C26,$0555541F1D446868,$0000000B4E3C66FF
Data.q $6042AE444E454900,$0000000000000082
EndDataSection
Code: Alles auswählen
InitSprite()
InitSprite3D()
Procedure.s GetPixelFormat(Value)
Protected Result$
If Value & #PB_PixelFormat_ReversedY
Value & ~#PB_PixelFormat_ReversedY
Result$ = "ReversedY , "
EndIf
Select Value
Case #PB_PixelFormat_8Bits : Result$ + "8 Bit , 1 Byte , Palette"
Case #PB_PixelFormat_15Bits : Result$ + "15 Bit , 2 Byte"
Case #PB_PixelFormat_16Bits : Result$ + "16 Bit , 2 Byte"
Case #PB_PixelFormat_24Bits_RGB : Result$ + "24 Bit , 3 Byte , RRGGBB"
Case #PB_PixelFormat_24Bits_BGR : Result$ + "24 Bit , 3 Byte , BBGGRR"
Case #PB_PixelFormat_32Bits_RGB : Result$ + "32 Bit , 4 Byte , (AA)RRGGBB"
Case #PB_PixelFormat_32Bits_BGR : Result$ + "32 Bit , 4 Byte , (AA)BBGGRR"
EndSelect
ProcedureReturn Result$
EndProcedure
OpenWindow(0, 0, 0, 800, 600, "Screen", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, WindowWidth(0), WindowHeight(0), 0, 0, 0)
CreateImage(1, 32, 32, 24)
StartDrawing(ImageOutput(1))
Debug "24-Bit-Image : "+GetPixelFormat(DrawingBufferPixelFormat())
StopDrawing()
CreateImage(2, 32, 32, 32)
StartDrawing(ImageOutput(2))
Debug "32-Bit-Image : "+GetPixelFormat(DrawingBufferPixelFormat())
StopDrawing()
CreateSprite(1, 32, 32)
StartDrawing(SpriteOutput(1))
Debug "Sprite : "+GetPixelFormat(DrawingBufferPixelFormat())
StopDrawing()
CreateSprite(2, 32, 32, #PB_Sprite_Texture)
StartDrawing(SpriteOutput(2))
Debug "Sprite-Texture : "+GetPixelFormat(DrawingBufferPixelFormat())
StopDrawing()
CreateSprite(3, 32, 32, #PB_Sprite_Texture|#PB_Sprite_AlphaBlending)
StartDrawing(SpriteOutput(3))
Debug "Alpha-Sprite-Texture : "+GetPixelFormat(DrawingBufferPixelFormat())
StopDrawing()
StartDrawing(WindowOutput(0))
Debug "Window : "+GetPixelFormat(DrawingBufferPixelFormat())
StopDrawing()
StartDrawing(ScreenOutput())
Debug "Screen : "+GetPixelFormat(DrawingBufferPixelFormat())
StopDrawing()
Repeat
ClearScreen(0)
FlipBuffers()
Until WindowEvent() = #PB_Event_CloseWindow
Code: Alles auswählen
24-Bit-Image : ReversedY , 24 Bit , 3 Byte , BBGGRR
32-Bit-Image : ReversedY , 32 Bit , 4 Byte , (AA)BBGGRR
Sprite : 32 Bit , 4 Byte , (AA)BBGGRR
Sprite-Texture : 32 Bit , 4 Byte , (AA)BBGGRR
Alpha-Sprite-Texture : 32 Bit , 4 Byte , (AA)BBGGRR
Window :
Screen : 32 Bit , 4 Byte , (AA)BBGGRR
Code: Alles auswählen
24-Bit-Image : ReversedY , 24 Bit , 3 Byte , BBGGRR
32-Bit-Image : ReversedY , 32 Bit , 4 Byte , (AA)BBGGRR
Sprite : 32 Bit , 4 Byte , (AA)BBGGRR
Sprite-Texture : 32 Bit , 4 Byte , (AA)BBGGRR
Alpha-Sprite-Texture : 32 Bit , 4 Byte , (AA)BBGGRR
Window :
Screen : 32 Bit , 4 Byte , (AA)BBGGRR