2 bugs ?

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
Mesa
Messages : 1126
Inscription : mer. 14/sept./2011 16:59

2 bugs ?

Message par Mesa »

J'ai plusieurs bugs :
Le code exemple fournit avec PB sur les images me donne un fond noir alors qu'il devrait afficher des lignes de couleurs

Code : Tout sélectionner

;
; ------------------------------------------------------------
;
;   PureBasic - Image example file
;
;    (c) 2001 - Fantaisie Software
;
; ------------------------------------------------------------
;


If OpenWindow(0, 100, 100, 500, 300, "PureBasic - Image")

  If CreateImage(0, 255, 255)

    StartDrawing(ImageOutput(0))
    ;==============LIGNES DE COULEUR ICI==========
    For k=0 To 255
      FrontColor(RGB(k,0, k))  ; a rainbow, from black to pink
      Line(0, k, 255, 0)
    Next

    DrawingMode(#PB_2DDrawing_Transparent)
    FrontColor(RGB(255,255,255)) ; print the text to white !
    DrawText(40, 50, "An image created easely...")

    StopDrawing() ; This is absolutely needed when the drawing operations are finished !!! Never forget it !
    
  EndIf
  
  CopyImage(0, 1)
  ResizeImage(1, 100, 100)
  
  GrabImage(0, 2, 100, 60, 150, 40)

        
  Repeat
    EventID = WaitWindowEvent()
    
    If EventID = #PB_Event_Repaint
      StartDrawing(WindowOutput(0))
        DrawImage(ImageID(0), 20, 10)
        DrawImage(ImageID(1), 320, 80)
        DrawImage(ImageID(2), 320, 200)
      StopDrawing()    
    EndIf
    
  Until EventID = #PB_Event_CloseWindow  ; If the user has pressed on the close button
  
EndIf

End   ; All the opened windows are closed automatically by PureBasic
;============================
Et le code toujours fournit avec PB sur les palette ne compile pas du tout

Code : Tout sélectionner

;
; ------------------------------------------------------------
;
;   PureBasic - Palette example file
;
;    (c) 2004 - Fantaisie Software
;
; ------------------------------------------------------------
;
CompilerIf Subsystem("directx7") = 0
  CompilerError "This example only works with the DirectX7 subsystems"
CompilerEndIf

If InitSprite() = 0 Or InitKeyboard() = 0 Or InitPalette() = 0
  MessageRequester("Error", "Can't open DirectX 7 or later", 0)
  End
EndIf

If OpenScreen(640, 480, 8, "PureBasic - Palette Example")
  LoadSprite(0, #PB_Compiler_Home + "Examples\Sources\Data\AlphaChannel.bmp", 0)
  
  ; Build 256 precalculated palette to do a nice cycling effect !
  ;
  For Palette = 0 To 255
    CreatePalette(Palette)
      For Index = 1 To 255  ; Let the first color always Black
        Color = Index+Palette
        If Color > 255
          Color - 256
        EndIf
        
        SetPaletteColor(Palette, Index, Color << 8)
      Next
  Next
  
  Palette = 0
  Repeat
    FlipBuffers()                                 ; Flip for DoubleBuffering
    ClearScreen(RGB(0, 0, 0))
    
    DisplayPalette(Palette)
    DisplaySprite(0, 100, 100)
    
    Palette+1
    If Palette > 255 : Palette = 0 : EndIf
      
    ExamineKeyboard()
  Until KeyboardPushed(#PB_Key_Escape)
EndIf

End  
Quelle que soit la version de PB.

Et chez vous ?

Mesa.
Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

Re: 2 bugs ?

Message par Backup »

line contient un parametre de couleur !
pas besoin de Frontcolor :

et puis pour la ligne encore , si tu incremente le parametre Y , il faut aussi incrementer le parametre "hauteur" si tu veux des ligne paralleles

Code : Tout sélectionner

;
; ------------------------------------------------------------
;
;   PureBasic - Image example file
;
;    (c) 2001 - Fantaisie Software
;
; ------------------------------------------------------------
;


If OpenWindow(0, 100, 100, 500, 300, "PureBasic - Image")

  If CreateImage(0, 255, 255)

    StartDrawing(ImageOutput(0))
    ;==============LIGNES DE COULEUR ICI==========
    For k=0 To 255
		;	FrontColor(RGB(k,0, k))  ; a rainbow, from black to pink
      Line(0, k, 255, k,rgb(k,0,k))   ; DOBRO : ici oublie du 'k' dans le parametre line ... et puis ajout de RGB() pas besoin de Front color pour line()
    Next

    DrawingMode(#PB_2DDrawing_Transparent)
    FrontColor(RGB(255,255,255)) ; print the text to white !
    DrawText(40, 50, "An image created easely...")

    StopDrawing() ; This is absolutely needed when the drawing operations are finished !!! Never forget it !
   
  EndIf
 
  CopyImage(0, 1)
  ResizeImage(1, 100, 100)
 
GrabImage(0, 2, 100, 60, 150, 40)

       
  Repeat
    EventID = WaitWindowEvent()
   
    If EventID = #PB_Event_Repaint
      StartDrawing(WindowOutput(0))
        DrawImage(ImageID(0), 20, 10)
        DrawImage(ImageID(1), 320, 80)
        DrawImage(ImageID(2), 320, 200)
      StopDrawing()   
    EndIf
   
  Until EventID = #PB_Event_CloseWindow  ; If the user has pressed on the close button
 
EndIf

End   ; All the opened windows are closed automatically by PureBasic 
ps : je regarde le 2em code ..
commentaire dans le code ! :roll:

Code : Tout sélectionner


; ------------------------------------------------------------
;
;   PureBasic - Palette example file
;
;    (c) 2004 - Fantaisie Software
;
; ------------------------------------------------------------
;
CompilerIf Subsystem("directx7") = 0
  CompilerError "This example only works with the DirectX7 subsystems"
CompilerEndIf

If InitSprite() = 0 Or InitKeyboard() = 0 Or InitPalette() = 0
  MessageRequester("Error", "Can't open DirectX 7 or later", 0)
  End
EndIf




If OpenScreen(640, 480, 32, "PureBasic - Palette Example")
  LoadSprite(0,  "E:\Dobro\PureBasic\dobro\ExemplePerso\Graphisme\ecran.bmp") ; met directement le chemin vers ton image ! <<<<<<<<<< Dobro
 
  ; Build 256 precalculated palette to do a nice cycling effect !
  ;
  For Palette = 0 To 255
    CreatePalette(Palette)
      For Index = 1 To 255  ; Let the first color always Black
        Color = Index+Palette
        If Color > 255
          Color - 256
        EndIf
       
        SetPaletteColor(Palette, Index, Color << 8)
      Next
  Next
 
  Palette = 0
  Repeat
    FlipBuffers()                                 ; Flip for DoubleBuffering
    ClearScreen(RGB(0, 0, 0))
   
    DisplayPalette(Palette)
    DisplaySprite(0, 100, 100)
   
    Palette+1
    If Palette > 255 : Palette = 0 : EndIf
     
    ExamineKeyboard()
  Until KeyboardPushed(#PB_Key_Escape)
EndIf

End  

; 
; EPb 

Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

Re: 2 bugs ?

Message par Backup »

Pour le 2em code , chez moi ça compile (meme en mode 8 pour le screen)
mais je n'arrive pas a voir la palette .... :roll:
(meme l'exemple donné dans la Doc )

je pense que ma carte graphique ne supporte pas vraiment le mode 8 (256 couleurs)
Mesa
Messages : 1126
Inscription : mer. 14/sept./2011 16:59

Re: 2 bugs ?

Message par Mesa »

Je pense aussi que les cartes graphiques moderne ne supporte plus ce mode.

J'ai un autre bug, toujours dans la doc de PB.
Le terrain ne s'affiche pas, le skydôme lui s'affiche.

Code : Tout sélectionner

;
; ------------------------------------------------------------
;
;   PureBasic - Terrain
;
;    (c) 2003 - Fantaisie Software
;
; ------------------------------------------------------------
;

#CameraSpeed = 1

IncludeFile #PB_Compiler_Home +"Examples/3D/Screen3DRequester.pb"

Define.f KeyX, KeyY, MouseX, MouseY

If InitEngine3D()
  Add3DArchive(#PB_Compiler_Home +"Examples/3D/Data/Textures", #PB_3DArchive_FileSystem)
  Add3DArchive(#PB_Compiler_Home +"Examples/3D/Data/Models", #PB_3DArchive_FileSystem)
  
  InitSprite()
  InitKeyboard()
  InitMouse()
  
  If Screen3DRequester()
    
    KeyboardMode(#PB_Keyboard_International)  
    
    AmbientColor(RGB(255, 255, 255))
    
    CreateMaterial(0,LoadTexture(0, "terrain_texture.jpg"))
    AddMaterialLayer(0, LoadTexture(1, "terrain_detail.jpg"), #PB_Material_Add)
    CreateTerrain("terrain.png", MaterialID(0), 2, 2, 2, 4)
    
    SkyDome("clouds.jpg",10)
    
    CreateCamera(0, 0, 0, 100, 100)
    
    CameraLocate(0, 0,10,0)
    
    
    Repeat
      Screen3DEvents()
      
      If ExamineMouse()
        MouseX = -MouseDeltaX() * #CameraSpeed * 0.05
        MouseY = -MouseDeltaY() * #CameraSpeed * 0.05
      EndIf      
      
      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 
          Debug keyY  
        Else
          KeyY = 0
        EndIf
        
      EndIf
      
      Height.f = TerrainHeight(CameraX(0), CameraZ(0))
      MoveCamera(0, KeyX, height, KeyY)
      RotateCamera(0, MouseY, MouseX, 0, #PB_Relative)
      
      RenderWorld()
      Screen3DStats()
      FlipBuffers()
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
  EndIf
  
Else
  MessageRequester("Error", "The 3D Engine can't be initialized", 0)
EndIf

End

Mesa.
Répondre