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