grabbing the device pointer
Posted: Wed Aug 10, 2011 10:02 pm
hi
can you run this code and tell me if the screen is red please. You must use DirectX9.
I wrote a ugly hack function to retrieve the pointer of the d3d device created by purebasic when the software call OpenWindowScreen().
can you run this code and tell me if the screen is red please. You must use DirectX9.
Code: Select all
InitSprite()
InitSprite3D()
InitKeyboard()
UsePNGImageDecoder()
Macro D3DRGBA (r, g, b, a)
(a&$ff)<<24 | (r&$ff)<<16 | (g&$ff)<<8 | (b&$ff)
EndMacro
OpenWindow(0, 0, 0, 860, 660, "Test", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 5, 5, 840, 640, 0, 0, 0,#PB_Screen_NoSynchronization)
; grab the d3d device pointer
Procedure GrabDevicePointer()
Variable.l
Start3D()
Stop3D()
! MOV EAX, [ESP-24]
! MOV dword [p.v_Variable], EAX
ProcedureReturn Variable
EndProcedure
*D3DDevice.IDirect3DDevice9 = GrabDevicePointer()
Repeat
ExamineKeyboard()
Repeat
Event = WindowEvent()
Select Event
Case #PB_Event_CloseWindow
End
EndSelect
Until Event = 0
*D3DDevice\Clear(0, 0, 1, D3DRGBA(255,0,0,255), 0.0, 0)
*D3DDevice\BeginScene()
*D3DDevice\EndScene()
*D3DDevice\Present(NULL, NULL, NULL, NULL)
Until KeyboardPushed(#PB_Key_Escape)
Code: Select all
Procedure GrabDevicePointer()
Variable.l
Start3D()
Stop3D()
! MOV EAX, [ESP-24]
! MOV dword [p.v_Variable], EAX
ProcedureReturn Variable
EndProcedure