Wrapper pour Eliza3D
Publié : lun. 24/avr./2006 21:27
Eliza3D est un moteur basé sur DirectX 9 !
www.eliza3D.com
Je travaille sur un wrapper de cet engine, mais je crois bien que ces connaissance sont trés faibles.
J'essaie de traduire l'exemple le plus simples des tutoriaux.
Download wrapper 0.001 : >>Ici<<
Mais je ne comprends pas pourquoi il bloque sur EL_d3dDev9\CreateVertexBuffer
www.eliza3D.com
Je travaille sur un wrapper de cet engine, mais je crois bien que ces connaissance sont trés faibles.
J'essaie de traduire l'exemple le plus simples des tutoriaux.
Download wrapper 0.001 : >>Ici<<
Code : Tout sélectionner
;-Macros
; Macro Function(nom.s,)
; *Function = GetFunction(0,nom.s)
; If *Function
; Function = CallFunctionFast(*Function,nom.s,)
; EndIf
; ProcedureReturn Function
; EndMacro
;-Globales
;{
Global Eliza_dll
Global EL_d3d9.IDirect3D9
Global EL_d3dDev9.IDirect3DDevice9
Global EL_WIDTH
Global EL_HEIGHT
Global EL_hwnd
;}
;-Constantes
;{
; Font creation flags
#D3DFONT_BOLD = $0001
#D3DFONT_ITALIC = $0002
#D3DFONT_ZENABLE = $0004
#D3DFOG_NONE = 0
#D3DFOG_EXP = 1
#D3DFOG_EXP2 = 2
#D3DFOG_LINEAR = 3
#D3DFOG_FORCE_DWORD = $7fffffff
; flag pour les collisions entre deux entity
#NX_IGNORE_PAIR =0
#NX_NOTIFY_ON_START_TOUCH =1
#NX_NOTIFY_ON_END_TOUCH =2
#NX_NOTIFY_ON_TOUCH =3
; flag pour les affectations des groupes
#GROUP_NON_COLLIDABLE = 0
#GROUP_COLLIDABLE_NON_PUSHABLE = 1
#GROUP_COLLIDABLE_PUSHABLE = 2
;}
;-Structures
;{
Structure D3DXVECTOR2
x.f
y.f
EndStructure
Structure D3DXVECTOR3
x.f
y.f
z.f
EndStructure
Structure D3DXMATRIX
_11.f
_12.f
_13.f
_14.f
_21.f
_22.f
_23.f
_24.f
_31.f
_32.f
_33.f
_34.f
_41.f
_42.f
_43.f
_44.f
EndStructure
Structure D3DXCOLOR
r.f
g.f
b.f
a.f
EndStructure
Structure PARTICULE
Yaw.f
YawVariation.f
Pitch.f
PitchVariation.f
Size.f
SizeVariation.f
Speed.f
SpeedVariation.f
Lifetime.f
LifetimeVariation.f
gravity.f
interval.l
StartColorR.l
StartColorG.l
StartColorB.l
StartColorA.l
EndColorR.l
EndColorG.l
EndColorB.l
EndColorA.l
EndStructure
Structure CCamera
EndStructure
Structure CLight
EndStructure
Structure CSprite2D
EndStructure
Structure CParticleEmitter
EndStructure
Structure CSky
EndStructure
Structure Child
EndStructure
Structure CSpline
EndStructure
Structure CPMirror
EndStructure
Structure NxActor
EndStructure
Structure CTexture9
EndStructure
;}
Declare Eliza_Init()
Declare Eliza_End()
Declare Eliza_InitD3D( hWnd , W, H, Depth, FullScreen.b, vS.b, UseHard.b, physic.b)
Declare EL_InitD3D9(W.w, H.w, Depth.w, FullScreen.b, vS.b, UseHard.b, physic.b)
Declare EL_GetD3D9()
Declare EL_GetDevice9()
Declare NewIDirect3DDevice9()
Procedure Eliza_Init()
Eliza_dll=OpenLibrary(#PB_Any,"Eliza3D.dll")
EndProcedure
Procedure Eliza_End()
CloseLibrary(0)
EndProcedure
Procedure Eliza_InitD3D( hWnd , W, H, Depth, FullScreen.b, vS.b, UseHard.b, physic.b)
*Function = GetFunction(0,"Eliza_InitD3D")
If *Function
Function = CallFunctionFast(*Function,"Eliza_InitD3D",hWnd , W, H, Depth, FullScreen.b, vS.b, UseHard.b, physic.b)
EndIf
ProcedureReturn Function
EndProcedure
Procedure EL_InitD3D9(W.w, H.w, Depth.w, FullScreen.b, vS.b, UseHard.b, physic.b)
Protected a
OpenScreen(W,H,Depth.w,"Eliza3D")
EL_hwnd = GetActiveWindow_()
a=Eliza_InitD3D(EL_hWnd , W, H, Depth, FullScreen, vS, UseHard, physic)
EL_d3d9 = EL_GetD3D9()
EL_d3dDev9.IDirect3DDevice9=NewIDirect3DDevice9()
EL_d3dDev9 = EL_GetDevice9()
EL_WIDTH=W
EL_HEIGHT=H
EndProcedure
Procedure EL_GetD3D9()
ProcedureReturn CallFunction(Eliza_dll,"EL_GetD3D9")
EndProcedure
Procedure EL_GetDevice9()
ProcedureReturn CallFunction(Eliza_dll,"EL_GetDevice9")
EndProcedure
Procedure EL_CreateFont(rang, filename.s, taille, flag)
*Function = GetFunction(0,"EL_CreateFont")
If *Function
Function = CallFunctionFast(*Function,"EL_CreateFont",rang, filename.s, taille, flag)
EndIf
ProcedureReturn Function
EndProcedure
Procedure EL_RegisterFunctionGUI(fonction)
*Function = GetFunction(0,"EL_RegisterFunctionGUI")
If *Function
Function = CallFunctionFast(*Function,"EL_RegisterFunctionGUI",fonction)
EndIf
ProcedureReturn Function
EndProcedure
Procedure EL_RegisterFunctionRender(fonction)
*Function = GetFunction(0,"EL_RegisterFunctionRender")
If *Function
Function = CallFunctionFast(*Function,"EL_RegisterFunctionRender",fonction)
EndIf
ProcedureReturn Function
EndProcedure
Procedure EL_LightDisable()
*Function = GetFunction(0,"EL_LightDisable")
If *Function
Function = CallFunctionFast(*Function,"EL_LightDisable")
EndIf
ProcedureReturn Function
EndProcedure
Procedure EL_GetCurentCamera()
*Function = GetFunction(0,"EL_GetCurentCamera")
If *Function
Function = CallFunctionFast(*Function,"EL_GetCurentCamera")
EndIf
ProcedureReturn Function
EndProcedure
Procedure EL_CameraYaw(cam, angle)
*Function = GetFunction(0,"EL_CameraYaw")
If *Function
Function = CallFunctionFast(*Function,"EL_CameraYaw",cam, angle)
EndIf
ProcedureReturn Function
EndProcedure
Procedure EL_CameraMove(cam, units, x, y, z)
*Function = GetFunction(0,"EL_CameraMove")
If *Function
Function = CallFunctionFast(*Function,"EL_CameraMove",cam, units, x, y, z)
EndIf
ProcedureReturn Function
EndProcedure
Procedure Eliza_Render()
*Function = GetFunction(0,"Eliza_Render")
If *Function
Function = CallFunctionFast(*Function,"Eliza_Render")
EndIf
ProcedureReturn Function
EndProcedure
Procedure Eliza_CleanUp()
*Function = GetFunction(0,"Eliza_CleanUp")
If *Function
Function = CallFunctionFast(*Function,"Eliza_CleanUp")
EndIf
ProcedureReturn Function
EndProcedure
Procedure EL_DrawText(rang, x, y, str.s)
*Function = GetFunction(0,"EL_DrawText")
If *Function
Function = CallFunctionFast(*Function,"EL_DrawText",rang, x, y, str.s)
EndIf
ProcedureReturn Function
EndProcedure
Procedure NewIDirect3DDevice9()
; allocation de la mémoire
*new.IDirect3DDevice9 = AllocateMemory(SizeOf(IDirect3DDevice9))
ProcedureReturn *new
EndProcedure
;Global cam.CCamera
Global buf.IDirect3DVertexBuffer9
Global *tt
Global Dim vv.l(12)
vv(0)=-100.0
vv(1)=0.0
vv(2)=500.0
vv(3)=6666.0
vv(4)=0.0
vv(5)=100.0
vv(6)=500.0
vv(7)=9999.0
vv(8)=100.0
vv(9)=0.0
vv(10)=500.0
vv(11)=2222.0
InitKeyboard()
InitSprite()
Eliza_Init()
EL_InitD3D9 (800, 600, 32, 0, 1, 1, 0)
EL_CreateFont(0, "Arial", 8, 1)
EL_RegisterFunctionGUI( GUIRender )
EL_RegisterFunctionRender( MyRender )
EL_LightDisable()
; def triangle
Vertex = D3DFVF_XYZ | D3DFVF_DIFFUSE
EL_d3dDev9\CreateVertexBuffer( 3*16 ,0, Vertex, D3DPOOL_DEFAULT, buf, Null )
buf\Lock( 0, 48, *tt, 0 )
CopyMemory(*tt, *vv, 48)
buf\Unlock()
cam = EL_GetCurentCamera()
Repeat
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Left)
EL_CameraYaw(cam, 0.05)
EndIf
If KeyboardPushed(#PB_Key_Right)
EL_CameraYaw(cam, -0.05)
EndIf
If KeyboardPushed(#PB_Key_Up)
EL_CameraMove(cam, 1.0, 0,0,10.5)
EndIf
If KeyboardPushed(#PB_Key_Down)
EL_CameraMove(cam, 1.0, 0,0,-10.5)
EndIf
Eliza_Render()
Until KeyboardPushed(#PB_Key_Escape)
Eliza_CleanUp()
Eliza_End()
Procedure MyRender(v)
EL_d3dDev9\SetFVF( Vertex )
EL_d3dDev9\SetStreamSource( 0, buf, 0, 16 )
EL_d3dDev9\DrawPrimitive(D3DPT_TRIANGLELIST,0, 1)
EndProcedure
Procedure GUIRender(v)
EL_DrawText( 0, 10, 10, "Triangle (dir Key for camera)" )
EndProcedure