- You tried to open a screen on a window that does not exist yet. You first need a normal pb window, then open a screen on the window, then open a 3d window on the screen.
- You must process the events of the normal window
- You must also process separately the events of the 3d window.
- To actually see something on the screen you need to:
- - provide a theme for the 3d gui via Add3DArchive()
- - create and position a camera
- - call RenderWorld()
- To make the mouse cursor work you need:
- - InitMouse()
- - ExamineMouse()
- - pass mouse information to the 3d gui via InputEvent3D()
[- I would also remove the goto and use a normal loop, just for fun]
Code: Select all
InitEngine3D()
InitKeyboard()
InitSprite()
InitMouse()
OpenWindow(0, 100, 100, 800, 600, "window")
OpenWindowedScreen(WindowID(0), 0, 0, 800, 600)
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/GUI", #PB_3DArchive_FileSystem)
CompilerElseIf #PB_Compiler_OS = #PB_OS_Linux
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/GUI", #PB_3DArchive_FileSystem)
CompilerEndIf
OpenWindow3D(0, 10, 10, 150, 50,"3D experiment")
;ShowGUI(128, 1)
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 0, 100, 100, #PB_Absolute)
begin:
ClearScreen(#Red)
ExamineMouse()
ExamineKeyboard()
While WindowEvent()
If Event() = #PB_Event_CloseWindow
End
EndIf
Wend
InputEvent3D(MouseX(), MouseY(), MouseButton(#PB_MouseButton_Left))
Repeat
Event = WindowEvent3D()
If Event = #PB_Event3D_CloseWindow
CloseWindow3D(EventWindow3D())
EndIf
Until Event = 0
If KeyboardPushed(#PB_Key_Return) Or KeyboardPushed(#PB_Key_Escape)
End
EndIf
RenderWorld()
FlipBuffers()
Goto begin