Restored from previous forum. Originally posted by sigi.
Hi,
how can i make a 3D Screen in Windowed Mode with a Menu, without the
Screenmoderequester that is in the Examples Sources.
Here a piece of code:
If InitEngine3D()
InitSprite()
InitKeyboard()
InitMouse()
mainwin=OpenWindow(0,0,0,640,480,#PB_Window_SystemMenu|#PB_Window_WindowCentered,"test")
CreateMenu(0, WindowID())
MenuTitle("Project")
MenuItem(1, "Quit")
MenuTitle("About")
MenuItem(2, "About...")
If OpenWindowedScreen(mainwin,0,0,640,480,0,0,0)=0
MessageRequester("Error","Failed to open DirectX Window",#MB_ICONERROR)
End
EndIf
Repeat
event=WaitWindowEvent()
Select event
Case #PB_Event_Menu
Select EventMenuID()
Case 1
Quit = 1
Case 2
MessageRequester("Info", "Windowed 3D in PureBasic !", 0)
EndSelect
Case #PB_Event_CloseWindow
Quit = 1
EndSelect
If Quit = 1 : End : EndIf ; Quit the app immediately
;RenderWorld() <- if i uncomment this it crashes
;FlipBuffers() <- if i uncomment this it crashes
Until event = 0
Else
MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
End
please help a really newbie,
thank you
3D Window without Screenmoderequester
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Kale.
here you go matey
:
all media for this example comes with v3.50 of PureBasic
--Kale
Getting used to PureBasic and falling in Love!
here you go matey
Code: Select all
#ROOT_WINDOW = 1
#MENU_ITEM_QUIT = 1
#MENU_ITEM_ABOUT = 2
#MESH_ROBOT = 1
Global quit.b
If InitEngine3D()
If OpenWindow(#ROOT_WINDOW, 0, 0, 640, 480, #PB_Window_SystemMenu | #PB_Window_WindowCentered, "3D Windowed Screen")
CreateMenu(0, WindowID())
MenuTitle("Project")
MenuItem(1, "Quit")
MenuTitle("About")
MenuItem(2, "About...")
If InitKeyboard()
If InitMouse()
If InitSprite()
If OpenWindowedScreen(WindowID(#ROOT_WINDOW), 0, MenuHeight(), 640, 480-MenuHeight(), 0, 0, 0)
LoadMesh(#MESH_ROBOT, "Robot.mesh", 0, 0, 0)
MeshAnimation(#MESH_ROBOT, "Walk")
LoadTexture(#MESH_ROBOT, "r2skin.jpg")
MeshTexture(#MESH_ROBOT, TextureID(#MESH_ROBOT))
CreateCamera(0, 0, 0, 100, 100)
CameraLocate(0, 0, 40, 100)
SetFrameRate(60)
Repeat
EventID.l = WindowEvent()
Select EventID
Case #PB_EventMenu
Select EventMenuID()
Case #MENU_ITEM_QUIT
quit = 1
Case #MENU_ITEM_ABOUT
MessageRequester("About...", "3D Engine in a window", #PB_MessageRequester_Ok)
EndSelect
Case #PB_EventCloseWindow
quit = 1
EndSelect
RotateMesh(#MESH_ROBOT, 1, 0, 0)
RenderWorld()
FlipBuffers()
Until quit = 1
Else
MessageRequester("Error", "Windowed screen can't be opened", #PB_MessageRequester_Ok)
EndIf
Else
MessageRequester("Error", "Couldn't intialise sprites", #PB_MessageRequester_Ok)
EndIf
Else
MessageRequester("Error", "Couldn't intialise mouse", #PB_MessageRequester_Ok)
EndIf
Else
MessageRequester("Error", "Couldn't intialise keyboard", #PB_MessageRequester_Ok)
EndIf
Else
MessageRequester("Error", "Window can't be opened", #PB_MessageRequester_Ok)
EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized", #PB_MessageRequester_Ok)
EndIf
End
--Kale
Getting used to PureBasic and falling in Love!
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm