It is currently Thu Dec 12, 2019 4:34 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: open 3d window
PostPosted: Sun Oct 13, 2019 12:51 pm 
Offline
User
User

Joined: Sat Apr 13, 2019 12:17 pm
Posts: 45
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


Top
 Profile  
Reply with quote  
 Post subject: Re: open 3d window
PostPosted: Sun Oct 13, 2019 1:54 pm 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 2057
Location: Germany
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...

_________________
My Projects ThreadToGUI / OOP-BaseClass / OOP-BaseClassDispatch / EventDesigner V3
PB v3.30 / v5.70 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
 Post subject: Re: open 3d window
PostPosted: Sun Oct 13, 2019 3:08 pm 
Offline
User
User

Joined: Sat Apr 13, 2019 12:17 pm
Posts: 45
thanks just found the examples didn't know they were in there.


Top
 Profile  
Reply with quote  
 Post subject: Re: open 3d window
PostPosted: Sun Oct 13, 2019 5:23 pm 
Offline
Addict
Addict

Joined: Thu Aug 30, 2007 11:54 pm
Posts: 1160
Location: right here
- 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


Top
 Profile  
Reply with quote  
 Post subject: Re: open 3d window
PostPosted: Sun Oct 13, 2019 7:39 pm 
Offline
User
User

Joined: Sat Apr 13, 2019 12:17 pm
Posts: 45
Thanks Addict I wasn't getting on very well with the examples . will work with what you put up this evening . Thanks again.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 17 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye