Page 1 of 1

DisplaySprite3D and clipping

Posted: Mon Oct 02, 2006 12:53 am
by andreyu
How to make clip for CreateSprite3D? I wish to place many fragments on one texture (animation for one object on one texture, for example) because texture switching is slow.

Posted: Mon Oct 02, 2006 6:26 pm
by djes
Thanx to Dr. Dri ;)

Code: Select all

Structure D3DVIEWPORT7
  dwX.l
  dwY.l
  dwWidth.l
  dwHeight.l
  dvMinZ.f
  dvMaxZ.f
EndStructure

ProcedureDLL.l ScreenWidth()
  !extrn _PB_Screen_Width
  !MOV   eax, [_PB_Screen_Width]
  ProcedureReturn
EndProcedure

ProcedureDLL.l ScreenHeight()
  !extrn _PB_Screen_Height
  !MOV   eax, [_PB_Screen_Height]
  ProcedureReturn
EndProcedure

ProcedureDLL.l ScreenDepth()
  !extrn _PB_Screen_Depth
  !MOV   eax, [_PB_Screen_Depth]
  ProcedureReturn
EndProcedure

ProcedureDLL.l ClipScreen3D()
  Protected Clip.l, *ViewPort.D3DVIEWPORT7
  Protected Sprite3DDevice.IDirect3DDevice7
 
  !extrn _PB_Direct3D_Device
  !MOV eax, dword [_PB_Direct3D_Device]
  !MOV dword [p.v_Sprite3DDevice], eax
 
  !extrn _PB_3DViewPort
  !MOV dword [p.p_ViewPort], _PB_3DViewPort
 
  *ViewPort\dwX = 0
  *ViewPort\dwY = 0
  *ViewPort\dwWidth  = ScreenWidth()
  *ViewPort\dwHeight = ScreenHeight()
  *ViewPort\dvMinZ = 0.0
  *ViewPort\dvMaxZ = 1.0
 
  If Sprite3DDevice\SetViewport(*ViewPort) = #S_OK
    Clip = #True
  EndIf
 
  ProcedureReturn Clip
EndProcedure

ProcedureDLL.l ClipScreen3D2(x.l, y.l, Width.l, Height.l)
  Protected Clip.l, *ViewPort.D3DVIEWPORT7
  Protected Sprite3DDevice.IDirect3DDevice7
 
  !MOV eax, dword [_PB_Direct3D_Device]
  !MOV dword [p.v_Sprite3DDevice], eax
 
  !MOV dword [p.p_ViewPort], _PB_3DViewPort
 
  *ViewPort\dwX = x
  *ViewPort\dwY = y
  *ViewPort\dwWidth  = Width
  *ViewPort\dwHeight = Height
  *ViewPort\dvMinZ = 0.0
  *ViewPort\dvMaxZ = 1.0
 
  If Sprite3DDevice\SetViewport(*ViewPort) = #S_OK
    Clip = #True
  EndIf
 
  ProcedureReturn Clip
EndProcedure

ProcedureDLL.l ClipScreen3D3(x.l, y.l, Width.l, Height.l, MinZ.f, MaxZ.f)
  Protected Clip.l, *ViewPort.D3DVIEWPORT7
  Protected Sprite3DDevice.IDirect3DDevice7
 
  !MOV eax, dword [_PB_Direct3D_Device]
  !MOV dword [p.v_Sprite3DDevice], eax
 
  !MOV dword [p.p_ViewPort], _PB_3DViewPort
 
  *ViewPort\dwX = x
  *ViewPort\dwY = y
  *ViewPort\dwWidth  = Width
  *ViewPort\dwHeight = Height
  *ViewPort\dvMinZ = MinZ
  *ViewPort\dvMaxZ = MaxZ
 
  If Sprite3DDevice\SetViewport(*ViewPort) = #S_OK
    Clip = #True
  EndIf
 
  ProcedureReturn Clip
EndProcedure

InitSprite()
InitSprite3D()

OpenWindow(0, 0, 0, 640, 480, "ClipScreen3D")
OpenWindowedScreen(WindowID(0), 0, 0, 640, 480, 0, 0, 0)

CreateSprite(0, 128, 128, #PB_Sprite_Texture)
If StartDrawing( SpriteOutput(0) )
  Box(0, 0, 128, 128, #Green)
  Circle(64, 64, 64, #Red)
  StopDrawing()
EndIf

CreateSprite3D(0, 0)

If Start3D()
 
  ;ClipScreen3D2(0, 0, 100, 100)
 
  DisplaySprite3D(0, 50, 50)
 
  Stop3D()
EndIf

FlipBuffers()

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow

Posted: Tue Oct 03, 2006 9:24 am
by andreyu
djes wrote:Thanx to Dr. Dri ;)
This is not good for me because this code utilize DirectX. I need cross-platform solution.

Posted: Tue Oct 03, 2006 2:03 pm
by Num3
Bad news...

Sprite3d is windows only.. Because it's DX based...

Posted: Tue Oct 03, 2006 2:18 pm
by White Eagle
Sprite3d is windows only.. Because it's DX based...
Correct me if I am wrong, but isn't that only true if you are using DX. With 4.0, if you are using the OpenGL subsystem, doesn't Sprite3D use OpenGL and won't it be cross-platform as soon as the Linux & Mac versions of 4.0 appear?

Posted: Tue Oct 03, 2006 7:54 pm
by andreyu
White Eagle wrote:
Sprite3d is windows only.. Because it's DX based...
Correct me if I am wrong, but isn't that only true if you are using DX. With 4.0, if you are using the OpenGL subsystem, doesn't Sprite3D use OpenGL and won't it be cross-platform as soon as the Linux & Mac versions of 4.0 appear?
As i know linux version should support Sprite3D in future. But linux does not support DirectX.

Posted: Mon Oct 09, 2006 8:14 am
by andreyu
Fred, may be you can help me? Or, may be, you plan to add this functionality?

Posted: Wed Nov 29, 2006 5:00 pm
by dell_jockey
Num3 wrote:Bad news...

Sprite3d is windows only...

not anymore, enter 4.x on Tux... ;)