IrrLicht without wrapper DLL
Posted: Wed May 11, 2005 4:19 pm
By the first look at the Irrlicht engine I was convinced it was possible
to use the original DLL from PureBasic even without writing a wrapper
DLL beforehand (Hey Dracflamloc!:)).
I tried using interfaces but failed.
Yet there had to be a way...
Here's something I came up with by accident:
Maybe someone will find this useful, I have no real clue about
what I'm doing here - it just works...
I'd be glad if someone could tell me what has to be done in order
to make it work with PB's interfaces. Thanks in advance.
to use the original DLL from PureBasic even without writing a wrapper
DLL beforehand (Hey Dracflamloc!:)).
I tried using interfaces but failed.
Yet there had to be a way...
Here's something I came up with by accident:
Code: Select all
;
;
; "Es werde Licht!" - "Let there be light!" - Irrlicht in PB ?
;
;
;
Procedure.l L(string.s)
*out = AllocateMemory(lstrlen_(string)*4)
MultiByteToWideChar_(#CP_ACP, 0, string, -1, *out, lstrlen_(string))
ProcedureReturn *out
EndProcedure
;
Procedure.l Irr_Device_setWindowCaption(device.l, caption.l)
!MOV esi, dword [esp]
!MOV edx, [esi]
!MOV eax, dword [edx+44]
!MOV ecx, esi
!PUSH dword [esp+4]
!CALL eax
EndProcedure
;
Procedure.l Irr_Device_isWindowActive(device.l)
!MOV esi, dword [esp]
!MOV edx, [esi]
!MOV eax, dword [edx+48]
!MOV ecx, esi
!CALL eax
ProcedureReturn
EndProcedure
;
Procedure.l Irr_Device_run(device.l)
!MOV esi, dword [esp]
!MOV edx, dword [esi]
!MOV eax, dword [edx+4]
!MOV ecx, esi
!CALL eax
ProcedureReturn
EndProcedure
;
Procedure.l Irr_Device_getVideoDriver(device.l)
!MOV esi, dword [esp]
!MOV edx, dword [esi]
!MOV eax, dword [edx+8]
!MOV ecx, esi
!CALL eax
ProcedureReturn
EndProcedure
;
Procedure.l Irr_Device_getGUIEnvironment(device.l)
!MOV esi, dword [esp]
!MOV edx, dword [esi]
!MOV eax, dword [edx+16]
!MOV ecx, esi
!CALL eax
ProcedureReturn
EndProcedure
;
Procedure.l Irr_Driver_beginScene(driver.l, backBuffer.l, zBuffer.l, color.l)
!MOV esi, dword [esp]
!MOV edx, dword [esi]
!MOV eax, dword [edx+4]
!MOV ecx, esi
!PUSH dword [esp+12]
!PUSH dword [esp+8]
!PUSH dword [esp+4]
!CALL eax
ProcedureReturn
EndProcedure
;
Procedure.l Irr_Driver_endScene(driver.l)
!MOV esi, dword [esp]
!MOV edx, dword [esi]
!MOV eax, dword [edx+8]
!MOV ecx, esi
!CALL eax
ProcedureReturn
EndProcedure
;
;
;
IrrDLL.l = OpenLibrary(#PB_Any, "Irrlicht.dll")
d.POINT
d\x = 640
d\y = 480
*device = CallFunction(IrrDLL, "createDevice", 2, d, 16, #False, #False, #False, 0)
*driver = Irr_Device_getVideoDriver(*device)
*guienv = Irr_Device_getGUIEnvironment(*device)
Irr_Device_setWindowCaption(*device, L("Wello Horld!"))
;
While Irr_Device_run(*device)
If Irr_Device_isWindowActive(*device)
Irr_Driver_beginScene(*driver, 0, 0, $00000070)
;
; render something here
;
Irr_Driver_endScene(*driver)
EndIf
Sleep_(10)
Wend
CloseLibrary(IrrDLL)
End
what I'm doing here - it just works...
I'd be glad if someone could tell me what has to be done in order
to make it work with PB's interfaces. Thanks in advance.
