Hi everyone.
A quick question - in PB, how do you go about creating a normal windowed program with widgets, which includes a 3D "window"? I want to create a program with normal buttons etc, which then affect a displayed 3d mesh. I know it' s possible, but I can't seem to figure it out from the help...
Mixing 3D with traditional windows program
Mixing 3D with traditional windows program
PC 1:AMD Athlon XP 2000,Geforce 2 MX400 64Mb, Windows 2000 
PC 2:Intel P3 1ghz, Nvidia Vanta 16Gb, Windows 2000
Registered Purebasic User
PureBasic Game Creation Site
http://www.hypervox.co.uk/PureBasic/

PC 2:Intel P3 1ghz, Nvidia Vanta 16Gb, Windows 2000

Registered Purebasic User

PureBasic Game Creation Site
http://www.hypervox.co.uk/PureBasic/
-
- Enthusiast
- Posts: 537
- Joined: Wed Oct 29, 2003 10:35 am
DOH! Sorry for being so thick 

PC 1:AMD Athlon XP 2000,Geforce 2 MX400 64Mb, Windows 2000 
PC 2:Intel P3 1ghz, Nvidia Vanta 16Gb, Windows 2000
Registered Purebasic User
PureBasic Game Creation Site
http://www.hypervox.co.uk/PureBasic/

PC 2:Intel P3 1ghz, Nvidia Vanta 16Gb, Windows 2000

Registered Purebasic User

PureBasic Game Creation Site
http://www.hypervox.co.uk/PureBasic/
Hi again
I've got the following code working as a basic skeleton for what i'm trying to achieve. My problem is that the whole window becomes blacked out whilst displaying the cube when it runs, thereby obscuring the gadgets. it's obviously a painting issue, but I can't see where - any one see what I'm doing wrong?
TIA
Hypervox
; PureBasic Visual Designer v3.95 build 1485 (PB4Code)
IncludeFile "Common.pb"
;IncludeFile "Screen3DRequester.pb"
If InitEngine3D() = 0 Or InitKeyboard() = 0 Or InitSprite() = 0
MessageRequester("Error", "Can't open DirectX 7 or later", 0)
End
EndIf
#CameraSpeed = 5
Define.f KeyX, KeyY, MouseX, MouseY
Open_Window_0()
If OpenWindowedScreen(WindowID(0),200,45,460,470,0,0,0)
Add3DArchive("..\Examples\Sources\Data\" , #PB_3DArchive_FileSystem)
Add3DArchive("..\Examples\Sources\Data\Skybox.zip", #PB_3DArchive_Zip)
;InitMouse()
;If Screen3DRequester()
; The data has to be organize in this order: Vertex, Color, Normal, UVCoordinate (per vertex)
;
; Create a cube, manually.. See the DataSetion, for more precisions
;
CreateMesh(0, 100)
SetMeshData(0, #PB_Mesh_Vertex | #PB_Mesh_Normal | #PB_Mesh_Color, ?CubeData2,
SetMeshData(0, #PB_Mesh_Face, ?CubeDataIndex, 12)
CreateMaterial(0, LoadTexture(0, "clouds.jpg"))
CreateEntity(0, MeshID(0), MaterialID(0))
CreateCamera(0, 0, 0, 100, 100)
CameraLocate(0,0,0,1000)
;EndIf
Else
MessageRequester("Error", "Can't open windowed screen!", 0)
End
EndIf
direction = 1
playerX = 1
playerY = 1
Repeat
Event.l = WaitWindowEvent()
If Event = #PB_Event_Gadget
; do the normal application stuff here...
Gadget = EventGadget()
Select Gadget
Case 1, 2, 3
SetGadgetText(4,"Button "+Str(Gadget)+" pressed.")
EndSelect
Else
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Left)
KeyX = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Right)
KeyX = #CameraSpeed
Else
KeyX = 0
EndIf
If KeyboardPushed(#PB_Key_Up)
KeyY = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Down)
KeyY = #CameraSpeed
Else
KeyY = 0
EndIf
EndIf
;If ExamineMouse()
;If 0
; MouseX = -(MouseDeltaX()/10)*#CameraSpeed/2
; MouseY = -(MouseDeltaY()/10)*#CameraSpeed/2
;EndIf
RotateEntity(0, 1, 1, 1)
RotateCamera(0, MouseX, MouseY, RollZ)
MoveCamera (0, KeyX, 0, KeyY)
RenderWorld()
;Screen3DStats()
FlipBuffers()
EndIf
Until Event = #PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape)
End
#SQRT13 = 0.57735026
DataSection
CubeData2:
Data.f -100.0,100.0,-100.0 ; 0 position
Data.f -#SQRT13,#SQRT13,-#SQRT13 ; 0 normal
Data.f 255 ; 0 colour
Data.f 100.0,100.0,-100.0 ; 1 position
Data.f #SQRT13,#SQRT13,-#SQRT13 ; 1 normal
Data.f 255 ; 1 colour
Data.f 100.0,-100.0,-100.0 ; 2 position
Data.f #SQRT13,-#SQRT13,-#SQRT13 ; 2 normal
Data.f 255 ; 2 colour
Data.f -100.0,-100.0,-100.0 ; 3 position
Data.f -#SQRT13,-#SQRT13,-#SQRT13 ; 3 normal
Data.f 255 ; 3 colour
Data.f -100.0,100.0,100.0 ; 4 position
Data.f -#SQRT13,#SQRT13,#SQRT13 ; 4 normal
Data.f 255 ; 4 colour
Data.f 100.0,100.0,100.0 ; 5 position
Data.f #SQRT13,#SQRT13,#SQRT13 ; 5 normal
Data.f 255 ; 5 colour
Data.f 100.0,-100.0,100.0 ; 6 position
Data.f #SQRT13,-#SQRT13,#SQRT13 ; 6 normal
Data.f 255 ; 6 colour
Data.f -100.0,-100.0,100.0 ; 7 position
Data.f -#SQRT13,-#SQRT13,#SQRT13 ; 7 normal
Data.f 255 ; 7 colour
CubeDataIndex:
Data.w 0,2,3
Data.w 0,1,2
Data.w 1,6,2
Data.w 1,5,6
Data.w 4,6,5
Data.w 4,7,6
Data.w 0,7,4
Data.w 0,3,7
Data.w 0,5,1
Data.w 0,4,5
Data.w 2,7,3
Data.w 2,6,7
EndDataSection

I've got the following code working as a basic skeleton for what i'm trying to achieve. My problem is that the whole window becomes blacked out whilst displaying the cube when it runs, thereby obscuring the gadgets. it's obviously a painting issue, but I can't see where - any one see what I'm doing wrong?
TIA
Hypervox
; PureBasic Visual Designer v3.95 build 1485 (PB4Code)
IncludeFile "Common.pb"
;IncludeFile "Screen3DRequester.pb"
If InitEngine3D() = 0 Or InitKeyboard() = 0 Or InitSprite() = 0
MessageRequester("Error", "Can't open DirectX 7 or later", 0)
End
EndIf
#CameraSpeed = 5
Define.f KeyX, KeyY, MouseX, MouseY
Open_Window_0()
If OpenWindowedScreen(WindowID(0),200,45,460,470,0,0,0)
Add3DArchive("..\Examples\Sources\Data\" , #PB_3DArchive_FileSystem)
Add3DArchive("..\Examples\Sources\Data\Skybox.zip", #PB_3DArchive_Zip)
;InitMouse()
;If Screen3DRequester()
; The data has to be organize in this order: Vertex, Color, Normal, UVCoordinate (per vertex)
;
; Create a cube, manually.. See the DataSetion, for more precisions
;
CreateMesh(0, 100)
SetMeshData(0, #PB_Mesh_Vertex | #PB_Mesh_Normal | #PB_Mesh_Color, ?CubeData2,

SetMeshData(0, #PB_Mesh_Face, ?CubeDataIndex, 12)
CreateMaterial(0, LoadTexture(0, "clouds.jpg"))
CreateEntity(0, MeshID(0), MaterialID(0))
CreateCamera(0, 0, 0, 100, 100)
CameraLocate(0,0,0,1000)
;EndIf
Else
MessageRequester("Error", "Can't open windowed screen!", 0)
End
EndIf
direction = 1
playerX = 1
playerY = 1
Repeat
Event.l = WaitWindowEvent()
If Event = #PB_Event_Gadget
; do the normal application stuff here...
Gadget = EventGadget()
Select Gadget
Case 1, 2, 3
SetGadgetText(4,"Button "+Str(Gadget)+" pressed.")
EndSelect
Else
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Left)
KeyX = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Right)
KeyX = #CameraSpeed
Else
KeyX = 0
EndIf
If KeyboardPushed(#PB_Key_Up)
KeyY = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Down)
KeyY = #CameraSpeed
Else
KeyY = 0
EndIf
EndIf
;If ExamineMouse()
;If 0
; MouseX = -(MouseDeltaX()/10)*#CameraSpeed/2
; MouseY = -(MouseDeltaY()/10)*#CameraSpeed/2
;EndIf
RotateEntity(0, 1, 1, 1)
RotateCamera(0, MouseX, MouseY, RollZ)
MoveCamera (0, KeyX, 0, KeyY)
RenderWorld()
;Screen3DStats()
FlipBuffers()
EndIf
Until Event = #PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape)
End
#SQRT13 = 0.57735026
DataSection
CubeData2:
Data.f -100.0,100.0,-100.0 ; 0 position
Data.f -#SQRT13,#SQRT13,-#SQRT13 ; 0 normal
Data.f 255 ; 0 colour
Data.f 100.0,100.0,-100.0 ; 1 position
Data.f #SQRT13,#SQRT13,-#SQRT13 ; 1 normal
Data.f 255 ; 1 colour
Data.f 100.0,-100.0,-100.0 ; 2 position
Data.f #SQRT13,-#SQRT13,-#SQRT13 ; 2 normal
Data.f 255 ; 2 colour
Data.f -100.0,-100.0,-100.0 ; 3 position
Data.f -#SQRT13,-#SQRT13,-#SQRT13 ; 3 normal
Data.f 255 ; 3 colour
Data.f -100.0,100.0,100.0 ; 4 position
Data.f -#SQRT13,#SQRT13,#SQRT13 ; 4 normal
Data.f 255 ; 4 colour
Data.f 100.0,100.0,100.0 ; 5 position
Data.f #SQRT13,#SQRT13,#SQRT13 ; 5 normal
Data.f 255 ; 5 colour
Data.f 100.0,-100.0,100.0 ; 6 position
Data.f #SQRT13,-#SQRT13,#SQRT13 ; 6 normal
Data.f 255 ; 6 colour
Data.f -100.0,-100.0,100.0 ; 7 position
Data.f -#SQRT13,-#SQRT13,#SQRT13 ; 7 normal
Data.f 255 ; 7 colour
CubeDataIndex:
Data.w 0,2,3
Data.w 0,1,2
Data.w 1,6,2
Data.w 1,5,6
Data.w 4,6,5
Data.w 4,7,6
Data.w 0,7,4
Data.w 0,3,7
Data.w 0,5,1
Data.w 0,4,5
Data.w 2,7,3
Data.w 2,6,7
EndDataSection
PC 1:AMD Athlon XP 2000,Geforce 2 MX400 64Mb, Windows 2000 
PC 2:Intel P3 1ghz, Nvidia Vanta 16Gb, Windows 2000
Registered Purebasic User
PureBasic Game Creation Site
http://www.hypervox.co.uk/PureBasic/

PC 2:Intel P3 1ghz, Nvidia Vanta 16Gb, Windows 2000

Registered Purebasic User

PureBasic Game Creation Site
http://www.hypervox.co.uk/PureBasic/
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany

Code: Select all
;
; ------------------------------------------------------------
;
; PureBasic - Windowed Screen example file
;
; (c) 2006 - Fantaisie Software
;
; ------------------------------------------------------------
;
If InitSprite() = 0 Or InitKeyboard() = 0
MessageRequester("Error", "Can't open DirectX 7 or later", 0)
End
EndIf
If OpenWindow(0,0,0,410,310,"A screen in a window... using gadget and sprites!",#PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_ScreenCentered)
If CreateGadgetList(WindowID(0))
ButtonGadget(1,340, 10,60,20,"Button 1")
ButtonGadget(2,340, 40,60,20,"Button 2")
ButtonGadget(3,340, 70,60,20,"Button 3")
TextGadget (4,340,110,60,30,"")
EndIf
If OpenWindowedScreen(WindowID(0),5,5,320,300,0,0,0)
CreateSprite(0,20,20)
; Draw some red line on our sprite
If StartDrawing(SpriteOutput(0))
FrontColor(RGB(255,0,0))
For k = 0 To SpriteHeight(0) Step 2
Line(0, k, SpriteWidth(0), 0)
Next
StopDrawing()
EndIf
CopySprite(0,1)
CopySprite(0,2)
Else
MessageRequester("Error", "Can't open windowed screen!", 0)
End
EndIf
EndIf
direction = 1
playerX = 1
playerY = 1
Repeat
Event.l = WindowEvent()
If Event = #PB_Event_Gadget
; do the normal application stuff here...
Gadget = EventGadget()
Select Gadget
Case 1, 2, 3
SetGadgetText(4,"Button "+Str(Gadget)+" pressed.")
EndSelect
Else
; do the sprite & screen stuff here...
FlipBuffers() ; Inverse the buffers (the back become the front (visible)... and we can do the rendering on the back
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Up) And playerY > 0 : playerY -3 : EndIf
If KeyboardPushed(#PB_Key_Down) And playerY < 280 : playerY +3 : EndIf
If KeyboardPushed(#PB_Key_Left) And playerX > 0 : playerX -3 : EndIf
If KeyboardPushed(#PB_Key_Right) And playerX < 300 : playerX +3 : EndIf
; Clear the screen and draw our sprites
ClearScreen(RGB(0,0,0))
ClipSprite(0, 0, 0, x, x/8)
DisplaySprite(0, x, 100)
DisplaySprite(1, x, x)
DisplaySprite(0, 300-x, x)
DisplaySprite(2, playerX, playerY)
x + direction
If x > 300 : direction = -1 : EndIf ; moving back to the left with negative value
If x < 0 : direction = 1 : EndIf ; moving to the right with positive value
Delay(1)
EndIf
Until Event = #PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape)
End
Code: Select all
PureBasic Visual Designer v3.95 build 1485 (PB4Code)
;- Window Constants
;
Enumeration
#Window_0
EndEnumeration
;- MenuBar Constants
;
Enumeration
#MenuBar_0
EndEnumeration
Enumeration
#mnu_Open
#mnu_SaveAs
#mnu_Exit
#mnu_Scale
EndEnumeration
;- Gadget Constants
;
Enumeration
#Frame_CMD
#Frame_3D
EndEnumeration
;- StatusBar Constants
;
Enumeration
#StatusBar_1
EndEnumeration
Procedure Open_Window_0()
If OpenWindow(#Window_0, 216, 0, 680, 581, "Scaler Test", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered )
If CreateMenu(#MenuBar_0, WindowID(#Window_0))
MenuTitle("File")
MenuItem(#mnu_Open, "Open")
MenuItem(#mnu_SaveAs, "Save As")
MenuItem(#mnu_Exit, "Exit")
MenuTitle("Edit")
MenuItem(#mnu_Scale, "Scale")
EndIf
If CreateStatusBar(#StatusBar_1, WindowID(#Window_0))
EndIf
If CreateGadgetList(WindowID(#Window_0))
Frame3DGadget(#Frame_CMD, 10, 30, 170, 500, "Commands")
Frame3DGadget(#Frame_3D, 190, 30, 480, 500, "")
EndIf
EndIf
EndProcedure

PC 1:AMD Athlon XP 2000,Geforce 2 MX400 64Mb, Windows 2000 
PC 2:Intel P3 1ghz, Nvidia Vanta 16Gb, Windows 2000
Registered Purebasic User
PureBasic Game Creation Site
http://www.hypervox.co.uk/PureBasic/

PC 2:Intel P3 1ghz, Nvidia Vanta 16Gb, Windows 2000

Registered Purebasic User

PureBasic Game Creation Site
http://www.hypervox.co.uk/PureBasic/
- Fluid Byte
- Addict
- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
Thanks!
PC 1:AMD Athlon XP 2000,Geforce 2 MX400 64Mb, Windows 2000 
PC 2:Intel P3 1ghz, Nvidia Vanta 16Gb, Windows 2000
Registered Purebasic User
PureBasic Game Creation Site
http://www.hypervox.co.uk/PureBasic/

PC 2:Intel P3 1ghz, Nvidia Vanta 16Gb, Windows 2000

Registered Purebasic User

PureBasic Game Creation Site
http://www.hypervox.co.uk/PureBasic/
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
> Hope that's better Kaeru
a bit... just wondering, why you only posted an example now.
additionally, your code in the ast but one posting (where you didn't add the code-tags)
seems to have typos, too.
when I add the include-file, I still get typo-syntax errors.
when posting code for showing problems and asking questions,
better post code that is in ONE block and will run and shows the problem
and does not need additional data like pictures or other stuff,
unless that is stuff included in the PB\Examples\Data folder.
so I'm sorry, I cannot reproduce your problem yet...
perhaps better have a look at the code Fluid linked.
there is a short example by netmeastro wich is really good.

additionally, your code in the ast but one posting (where you didn't add the code-tags)
seems to have typos, too.
when I add the include-file, I still get typo-syntax errors.
when posting code for showing problems and asking questions,
better post code that is in ONE block and will run and shows the problem
and does not need additional data like pictures or other stuff,
unless that is stuff included in the PB\Examples\Data folder.
so I'm sorry, I cannot reproduce your problem yet...
perhaps better have a look at the code Fluid linked.
there is a short example by netmeastro wich is really good.
oh... and have a nice day.