Page 1 of 1

UseBuffer() with sprites3D

Posted: Fri Jun 15, 2007 5:09 pm
by bombseb
Hello,

is it possible to make the usebuffer function work with sprite3D features please ?

I would like to display a sprite3D in a Sprite2D...



Thanx

Posted: Fri Jun 15, 2007 5:25 pm
by Chrono Syndrome
Seconded.

Re: UseBuffer() with sprites3D

Posted: Fri Jun 22, 2007 6:39 pm
by Kaeru Gaman
bombseb wrote:I would like to display a sprite3D in a Sprite2D...
doesn't that work? I think it would....

anyhow:
the team is working on implementing DX9 into PB for the near future.
since Sprite and Sprite3D-functions are a complete DX issue,
perhaps better wait for the changes to come.

Posted: Fri Jun 22, 2007 7:55 pm
by S.M.
if you use my dx9 subsystem you can just use usebuffer() to draw a 3d-sprite on a sprite :wink:

//edit:
for dx7 you can use this old code from me:

Code: Select all

;Collision between 3D-Sprites.
;*****************************
;Adapted for PB 4.0

Structure DDPIXELFORMAT 
  dwSize.l 
  dwFlags.l 
  dwFourCC.l 
  dwRGBBitCount.l 
  dwRBitMask.l 
  dwGBitMask.l 
  dwBBitMask.l 
  dwRGBAlphaBitMask.l 
EndStructure 

Structure DDCOLORKEY 
  dwColorSpaceLowValue.l 
  dwColorSpaceHighValue.l 
EndStructure 

Structure DDSCAPS2 
  dwCaps.l 
  dwCaps2.l 
  dwCaps3.l 
  dwCaps4.l 
EndStructure 

Structure DDSURFACEDESC2 
  dwSize.l 
  dwFlags.l 
  dwHeight.l 
  dwWidth.l 
  lPitch.l 
  dwBackBufferCount.l 
  dwRefreshRate.l 
  dwAlphaBitDepth.l 
  dwReserved.l 
  lpSurface.l 
  ddckCKDestOverlay.DDCOLORKEY 
  ddckCKDestBlt.DDCOLORKEY 
  ddckCKSrcOverlay.DDCOLORKEY 
  ddckCKSrcBlt.DDCOLORKEY 
  ddpfPixelFormat.DDPIXELFORMAT 
  ddsCaps.DDSCAPS2 
  dwTextureStage.l 
EndStructure 

Structure PB_Sprite 
  Sprite.l 
  Width.w 
  Height.w 
  Depth.w 
  Mode.w 
  FileName.l 
  RealWidth.w 
  RealHeight.w 
  ClipX.w 
  ClipY.w 
EndStructure 

#DDSD_WIDTH=4 
#DDSD_HEIGHT=2 
#DDSD_CAPS=1 
#DDSCAPS_3DDEVICE=8192 
#DDSCAPS_OFFSCREENPLAIN=64 

Global *D3DDevice.IDirect3DDevice7 
Global *BackBuffer.IDirectDrawSurface7 

Procedure CreateRenderSprite(Sprite,Width,Height) 
  Result=CreateSprite(Sprite,Width,Height) 
  If Result=0:ProcedureReturn 0:EndIf 
  *PBSprite.PB_Sprite=IsSprite(Sprite) 
  *DDS.IDirectDrawSurface7=*PBSprite\Sprite 
  *DDS\GetDDInterface(@*DD.IDirectDraw7) 
  *DDS\Release() 
  DDSD.DDSURFACEDESC2 
  DDSD\dwSize=SizeOf(DDSURFACEDESC2) 
  DDSD\dwFlags=#DDSD_WIDTH|#DDSD_HEIGHT|#DDSD_CAPS 
  DDSD\dwWidth=Width 
  DDSD\dwHeight=Height 
  DDSD\ddsCaps\dwCaps=#DDSCAPS_3DDEVICE|#DDSCAPS_OFFSCREENPLAIN 
  Result=*DD\CreateSurface(DDSD,*PBSprite,0) 
  *DD\Release()  
  If Result:ProcedureReturn 0:EndIf 
  ProcedureReturn *PBSprite\Sprite 
EndProcedure 

Procedure SelectRenderSprite(Sprite) 
  !extrn _PB_Direct3D_Device 
  !MOV Eax,[_PB_Direct3D_Device] 
  !MOV [p_D3DDevice],Eax 
  !extrn _PB_DirectX_BackBuffer 
  !MOV Eax,[_PB_DirectX_BackBuffer] 
  !MOV [p_BackBuffer],Eax 
  *D3DDevice\EndScene() 
  Select Sprite 
    Case -1 
      *D3DDevice\SetRenderTarget(*BackBuffer,2) 
    Default 
      *D3DDevice\SetRenderTarget(PeekL(IsSprite(Sprite)),2) 
  EndSelect 
  *D3DDevice\BeginScene() 
EndProcedure 






;Example: 

InitSprite() 
InitSprite3D() 


InitKeyboard() 
InitMouse() 

OpenWindow(1,0,0,640,480,"Collision detection with 3D-Sprites")
OpenWindowedScreen(WindowID(1),0,0,1024,768,1,0,0) 


CreateRenderSprite(0,181,181) 
CreateRenderSprite(1,181,181) 


TransparentSpriteColor(0,#Magenta) 
TransparentSpriteColor(1,#Magenta) 

FontID=LoadFont(1,"Arial",20)

CreateSprite(5,128,128,#PB_Sprite_Texture)
StartDrawing(SpriteOutput(5))
Ellipse(64,64,64,32,#Blue) 
DrawingMode(1) 
DrawingFont(FontID)
DrawText(10,48,"3D-Sprite",#Yellow) 
StopDrawing()

CreateSprite3D(5,5) 


Repeat 
  ExamineKeyboard() 
  ExamineMouse() 
  
  ClearScreen(#Black) 
  
  UseBuffer(0) 
  ClearScreen(#Magenta);Clear Sprite 0 
  UseBuffer(1) 
  ClearScreen(#Magenta);Clear Sprite 1 
  UseBuffer(-1) 
  
  
  Start3D() 
  
  SelectRenderSprite(0);Draw the 3D-Sprite on Sprite 0 
  Angle1+2 
  RotateSprite3D(5,Angle1,0) 
  DisplaySprite3D(5,27,27) 
  
  
  SelectRenderSprite(1);Draw the 3D-Sprite on Sprite 1 
  Angle2-2 
  RotateSprite3D(5,Angle2,0) 
  DisplaySprite3D(5,27,27) 
  
  SelectRenderSprite(-1);Draw on Backbuffer 
  Stop3D() 
  
  
  DisplayTransparentSprite(0,MouseX(),MouseY()) 
  DisplayTransparentSprite(1,200,100) 
  
  If SpritePixelCollision(0,MouseX(),MouseY(),1,200,100) 
    StartDrawing(ScreenOutput()) 
    DrawingMode(1) 
    DrawingFont(FontID)
    DrawText(0,0,"Collision !",#Yellow) 
    StopDrawing() 
  EndIf 
  
  FlipBuffers() 
  Event=WindowEvent()
Until KeyboardPushed(#PB_Key_Escape) Or Event=#PB_Event_CloseWindow

 

Posted: Wed Jun 27, 2007 9:26 am
by IceSoft
S.M. wrote:if you use my dx9 subsystem you can just use usebuffer() to draw a 3d-sprite on a sprite :wink:
Thats really a great feature!!!!
Thanks a lot.
Hope we will get more improved DX9 features.

Posted: Wed Jun 27, 2007 1:04 pm
by Kaeru Gaman
afaik Fred is working on a complete implementation of DX9,
so in not too far future we don't need the additional subsystem anymore...

Posted: Wed Jun 27, 2007 1:17 pm
by IceSoft
Kaeru Gaman wrote:afaik Fred is working on a complete implementation of DX9,
so in not too far future we don't need the additional subsystem anymore...
Theres a lot of more improvement which have to be done...
...e.g.: the 2D drawing lib.

This all can be done with the DX9 subsystem too.

Belive me:
As long as the DX9 Subsystem is better (has more features) as the 'native' port of DX9 which came from @Fred as long will DX9 be used.

Posted: Wed Jun 27, 2007 2:14 pm
by Kaeru Gaman
I don't get your point...

when Fred changes all PB libs from DX7 to DX9, of course the DirectDraw version 9 will be used...

...sure I presume that Fred would implement ALL features of DX9 then...

doing different will make no sense.
He has done a lot of good work for the Win-Application programming abilities,
now it's time to push the Gaming abilities of PB again.

Posted: Wed Jun 27, 2007 3:10 pm
by IceSoft
Kaeru Gaman wrote:...now it's time to push the Gaming abilities of PB again.
Yes that is what I mean ;-)