Hi slagusev. The
OpenWindow3D() function is more complex than PureBasic's standard
OpenWindow(). In order to use it, the 3D engine has to be initialised, along with the sprite, keyboard and mouse environments, and it will only work within a screen. Furthermore, the 3D GUI elements have to be loaded using the
Add3DArchive() function, with the path properly set. Here's an example adapted from PureBasic's help file:
(win3D.dll)Code: Select all
ProcedureDLL win3D(width, height, title.s)
Enumeration
#MainWindow
#Window3D
#Button3D
EndEnumeration
If InitEngine3D() And InitSprite() And InitKeyboard() And InitMouse()
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/GUI", #PB_3DArchive_FileSystem)
wFlags = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
OpenWindow(#MainWindow, 0, 0, width, height, "OpenWindow3D() Example", wFlags)
OpenWindowedScreen(WindowID(#MainWindow), 0, 0, width, height, 0, 0, 0)
CreateCamera(0, 0, 0, 100, 100)
OpenWindow3D(#Window3D, 10, 10, 300, 100, "The 3D Window...")
ButtonGadget3D(#Button3D, 150, 40, 120, 25, "Quit")
ShowGUI(200, 1)
alive3D = 1
Repeat
If ExamineKeyboard() And ExamineMouse()
Input$ = KeyboardInkey()
If alive3D
InputEvent3D(MouseX(), MouseY(), MouseButton(#PB_MouseButton_Left), Input$, 0)
EndIf
EndIf
Repeat
Event = WindowEvent3D()
Select Event
Case #PB_Event3D_CloseWindow
ShowGUI(128, 0)
CloseWindow3D(#Window3D)
SetWindowTitle(#MainWindow, "3D window closed - press ESC to end...")
alive3D = 0
Case #PB_Event3D_Gadget
appQuit = 1
EndSelect
Until Event = 0
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or appQuit = 1
EndIf
EndProcedure
(the test code)Code: Select all
If OpenLibrary(0, "win3D.dll")
CallFunction(0, "win3D", 640, 480, @"OpenWindow3D() Example")
CloseLibrary(0)
EndIf
Hope it helps!
