PureBasic Forum
http://forums.purebasic.com/english/

open 3d window
http://forums.purebasic.com/english/viewtopic.php?f=13&t=73798
Page 1 of 1

Author:  pfaber11 [ Sun Oct 13, 2019 12:51 pm ]
Post subject:  open 3d window

Hi having trouble opening a 3d window here is the code could somebody tell me where I'm going wrong . Thanks for reading .
Code:
; new 3d program
InitEngine3D()
InitKeyboard()
InitSprite()

OpenWindowedScreen(WindowID(0),0,0,1366,768)
OpenWindow3D(0,0,0,1366,768,"3D experiment")

begin:
ClearScreen(#Red)

WindowEvent3D()
FlipBuffers()

ExamineKeyboard()
If KeyboardPushed(#PB_Key_Return)
  End
  EndIf
Goto begin

Author:  mk-soft [ Sun Oct 13, 2019 1:54 pm ]
Post subject:  Re: open 3d window

No beginning with Goto and Gosub. It's old and not save...

P.S.
Look more in the help and open the examples in the Example folder of Purebasic...

Author:  pfaber11 [ Sun Oct 13, 2019 3:08 pm ]
Post subject:  Re: open 3d window

thanks just found the examples didn't know they were in there.

Author:  #NULL [ Sun Oct 13, 2019 5:23 pm ]
Post subject:  Re: open 3d window

- 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:
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

Author:  pfaber11 [ Sun Oct 13, 2019 7:39 pm ]
Post subject:  Re: open 3d window

Thanks Addict I wasn't getting on very well with the examples . will work with what you put up this evening . Thanks again.

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/