[Résolu] (GUI) : OpenWindow3D() ne fonctionne pas

Généralités sur la programmation 3D
Avatar de l’utilisateur
falsam
Messages : 7323
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

[Résolu] (GUI) : OpenWindow3D() ne fonctionne pas

Message par falsam »

Je voulais tester la création d'une interface graphique. J'ai un premier souci, l'instruction OpenWindow3D() ne fonctionne pas (Donc pas d'affichage de la souris) et je ne vois pas ou est mon erreur.

Code : Tout sélectionner

Define.f CamX, CamY, MouseX, MouseY, RatioX, RatioY, SpeedRotate, CameraSpeed = 0.4

InitEngine3D()
InitKeyboard()
InitSprite()
InitMouse()

window = OpenWindow(#PB_Any,0,0,1024,768, "M", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(window),0,0,1024,768,0, 0, 0)

; Mesh
Cube_Mesh = CreateCube(#PB_Any, 1) 
Ground_Mesh = CreatePlane(#PB_Any, 20, 20, 3, 6, 6, 6)

; Materiel
Texture1 = CreateTexture(#PB_Any,512,512)
StartDrawing(TextureOutput(Texture1))
Box(0,0,512,512,RGB(0, 0, 0))
Box(1,1,510,510,RGB(255, 216, 0))
StopDrawing()
Material1 = CreateMaterial(#PB_Any,TextureID(texture1))

; Création du sol 
Ground_Entity = CreateEntity(#PB_Any, MeshID(Ground_Mesh), MaterialID(Material1), 0, 0, 0)
EntityPhysicBody(Ground_Entity, #PB_Entity_StaticBody, 2, 0, 1)

;
;Lumiere et ombre
AmbientColor(RGB(127, 127, 127))
CreateLight(#PB_Any,RGB(151, 251, 151), -1.8, 10, 5)
WorldShadows(#PB_Shadow_Additive)

;
; Une camera 
Camera = CreateCamera(#PB_Any,0,0,100,100)
CamX=2.0
CamY=5.0
KeyZ=15
MoveCamera(Camera, CamX, CamY, KeyZ, #PB_Absolute)  

Window3D = OpenWindow3D(#PB_Any, 100, 100, 300, 100, "")

Debug Window3D ; <== OpenWindow3D ne s'initialise pas 

;Affiche le GUI semi transparent et la souris
ShowGUI(128, 1) ; 

Repeat
  Repeat
    Event3D = WindowEvent3D()
  Until Event3D = 0
    
  If ExamineMouse()
    MouseX = -MouseDeltaX() * CameraSpeed * 0.05
    MouseY = -MouseDeltaY() * CameraSpeed * 0.05
    InputEvent3D(MouseX(), MouseY(), MouseButton(#PB_MouseButton_Left))
  EndIf
  
  If ExamineKeyboard()    
    If KeyboardPushed(#PB_Key_Escape)
      Break
    EndIf  
        
    If KeyboardPushed(#PB_Key_Left)
      CamX - CameraSpeed   
    ElseIf KeyboardPushed(#PB_Key_Right)
      CamX + CameraSpeed   
    EndIf
        
    If KeyboardPushed(#PB_Key_Up)
      CamY  -CameraSpeed   
    ElseIf KeyboardPushed(#PB_Key_Down)
      CamY + CameraSpeed   
    EndIf
  
  EndIf
  
  MoveCamera(Camera, CamX, CamY, KeyZ, #PB_Absolute)  
  
  CameraLookAt(camera,0,0,0)
  
  ; Affiche le rendu de la scène
  ClearScreen(RGB(0, 0, 0))
  RenderWorld()
  FlipBuffers()
ForEver
Merci d'avance pour vos explications.
Dernière modification par falsam le mer. 10/juil./2013 7:44, modifié 2 fois.
Configuration : Windows 11 Famille 64-bit - PB 6.20 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
Avatar de l’utilisateur
SPH
Messages : 4944
Inscription : mer. 09/nov./2005 9:53

Re: Interface graphique (GUI) : OpenWindow3D() ne fonctionne

Message par SPH »

Ca le fait aussi chez moi.

ICI :

Code : Tout sélectionner

Define.f CamX, CamY, MouseX, MouseY, RatioX, RatioY, SpeedRotate, CameraSpeed = 0.4

If InitEngine3D()=0
  Debug "InitEngine3D() non activé"
EndIf
If InitKeyboard()=0
  Debug "InitKeyboard() non activé"
EndIf
If InitSprite()=0
  Debug "InitSprite() non activé"
EndIf
If InitMouse()=0
  Debug "InitMouse() non activé"
EndIf

window = OpenWindow(#PB_Any,0,0,1024,768, "M", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(window),0,0,1024,768,0, 0, 0)

; Mesh
Cube_Mesh = CreateCube(#PB_Any, 1) 
Ground_Mesh = CreatePlane(#PB_Any, 20, 20, 3, 6, 6, 6)

; Materiel
Texture1 = CreateTexture(#PB_Any,512,512)
StartDrawing(TextureOutput(Texture1))
Box(0,0,512,512,RGB(0, 0, 0))
Box(1,1,510,510,RGB(255, 216, 0))
StopDrawing()
Material1 = CreateMaterial(#PB_Any,TextureID(texture1))

; Création du sol 
Ground_Entity = CreateEntity(#PB_Any, MeshID(Ground_Mesh), MaterialID(Material1), 0, 0, 0)
EntityPhysicBody(Ground_Entity, #PB_Entity_StaticBody, 2, 0, 1)

;
;Lumiere et ombre
AmbientColor(RGB(127, 127, 127))
CreateLight(#PB_Any,RGB(151, 251, 151), -1.8, 10, 5)
WorldShadows(#PB_Shadow_Additive)

;
; Une camera 
Camera = CreateCamera(#PB_Any,0,0,100,100)
CamX=2.0
CamY=5.0
KeyZ=15
MoveCamera(Camera, CamX, CamY, KeyZ, #PB_Absolute)  

Window3D = OpenWindow3D(#PB_Any, 100, 100, 300, 100, "")

Debug Window3D ; <== OpenWindow3D ne s'initialise pas 

;Affiche le GUI semi transparent et la souris
ShowGUI(128, 1) ; 

Repeat
  Repeat
    Event3D = WindowEvent3D()
  Until Event3D = 0
    
  If ExamineMouse()
    MouseX = -MouseDeltaX() * CameraSpeed * 0.05
    MouseY = -MouseDeltaY() * CameraSpeed * 0.05
    InputEvent3D(MouseX(), MouseY(), MouseButton(#PB_MouseButton_Left))
  EndIf
  
  If ExamineKeyboard()    
    If KeyboardPushed(#PB_Key_Escape)
      Break
    EndIf  
        
    If KeyboardPushed(#PB_Key_Left)
      CamX - CameraSpeed   
    ElseIf KeyboardPushed(#PB_Key_Right)
      CamX + CameraSpeed   
    EndIf
        
    If KeyboardPushed(#PB_Key_Up)
      CamY  -CameraSpeed   
    ElseIf KeyboardPushed(#PB_Key_Down)
      CamY + CameraSpeed   
    EndIf
  
  EndIf
  
  MoveCamera(Camera, CamX, CamY, KeyZ, #PB_Absolute)  
  
  CameraLookAt(camera,0,0,0)
  
  ; Affiche le rendu de la scène
  ClearScreen(RGB(0, 0, 0))
  RenderWorld()
  FlipBuffers()
ForEver

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Intel Core i7 4770 64 bits - GTX 650 Ti
Version de PB : 6.12LTS- 64 bits
Avatar de l’utilisateur
falsam
Messages : 7323
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: Interface graphique (GUI) : OpenWindow3D() ne fonctionne

Message par falsam »

SPH a écrit :Ca le fait aussi chez moi.
Normal que tu es la même erreur. Mais ça ne me dit pas pourquoi.
Configuration : Windows 11 Famille 64-bit - PB 6.20 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
comtois
Messages : 5186
Inscription : mer. 21/janv./2004 17:48
Contact :

Re: Interface graphique (GUI) : OpenWindow3D() ne fonctionne

Message par comtois »

Il faut ajouter cette ligne

Code : Tout sélectionner

Add3DArchive("Data/GUI", #PB_3DArchive_FileSystem)
http://purebasic.developpez.com/
Je ne réponds à aucune question technique en PV, utilisez le forum, il est fait pour ça, et la réponse peut profiter à tous.
Avatar de l’utilisateur
falsam
Messages : 7323
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: Interface graphique (GUI) : OpenWindow3D() ne fonctionne

Message par falsam »

Bonjour Comtois et merci pour cette réponse :)
Configuration : Windows 11 Famille 64-bit - PB 6.20 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
Répondre