Aujourd'hui c'est champi!

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
Ollivier
Messages : 4197
Inscription : ven. 29/juin/2007 17:50
Localisation : Encore ?
Contact :

Aujourd'hui c'est champi!

Message par Ollivier »

J'étais en train de triper sur l'accès direct à la mémoire Video. Alors je vous fais partager ce truc inutile:

Code : Tout sélectionner

; Start without debugger to see full speed!

#ScreenWidth  = 1024 ; Feel free to change this to see the pixel filling speed !
#ScreenHeight = 768

If InitSprite() = 0 Or InitKeyboard()=0
  MessageRequester("Error","DirectX 7+ is needed.",0)
EndIf

Structure Pixel
  Pixel.l
EndStructure

Procedure.f GSin(angle.f)
  ProcedureReturn Sin(angle*(2*3.14/360))
EndProcedure

; Pre-calculated values are faster than realtime calculated ones...
; ... so we save them in an array before starting gfx operations
Dim CosTable(#ScreenWidth*2)
Dim ColorTable(255)

For i = 0 To #ScreenWidth*2
  CosTable(i) = GSin(360*i/320)* 32 + 32
Next


If OpenScreen(#ScreenWidth, #ScreenHeight, 32, "PB Plasma")

    t.f = 0.000001
  Repeat

    Wave+10
    If Wave > 320 : Wave = 0 : EndIf
    
    If StartDrawing(ScreenOutput())
      Buffer      = DrawingBuffer()             ; Get the start address of the screen buffer
      Pitch       = DrawingBufferPitch()        ; Get the length (in byte) took by one horizontal line
      PixelFormat = DrawingBufferPixelFormat()  ; Get the pixel format. 
          
      t * 1.1
      For y = 0 To #ScreenHeight-1
        pos1 = CosTable(y+wave)
        
        *Line.Pixel = Buffer+Pitch*y
        
        For x = 0 To #ScreenWidth-1
          pos2 = (CosTable(x+Wave) + CosTable(x+y) + pos1)
          *Line\Pixel = ((x-512) * (y-384)) * t
          *Line+4
        Next
      Next
      
      StopDrawing()
    EndIf
    
    ExamineKeyboard()
    
    FlipBuffers()
     
  Until KeyboardPushed(#PB_Key_Escape)

Else
  MessageRequester("Error","Can't open the screen !",0)
EndIf

End

Ollivier
Messages : 4197
Inscription : ven. 29/juin/2007 17:50
Localisation : Encore ?
Contact :

Message par Ollivier »

Ah oui j'oubliais, il faut tout désactiver: débugger, thread, machin, tout ça sinon ça ne rame pas un rond.
Avatar de l’utilisateur
Kwai chang caine
Messages : 6989
Inscription : sam. 23/sept./2006 18:32
Localisation : Isere

Message par Kwai chang caine »

Super joli bravo, j'en ai pris plein les mirettes :D
Frenchy Pilou
Messages : 2194
Inscription : jeu. 27/janv./2005 19:07

Message par Frenchy Pilou »

Cela ressemble à des papiers peints cérébraux :)
http://hypo.ge-dip.etat-ge.ch/www/math/html/node35.html
Ollivier
Messages : 4197
Inscription : ven. 29/juin/2007 17:50
Localisation : Encore ?
Contact :

Message par Ollivier »

Tout à fait Pilou. D'ailleurs il est bien le lien que tu as mis. Ici je ne me suis pas foulé.

Code : Tout sélectionner

*Line\Pixel = ((x-512) * (y-384)) * t
J'ai repris l'exemple de l'aide PB et comme on peut voir, c'est juste une multiplication (x * y) avec centrage (donc (x- 512) * (y-384) ). Le coef t est augmenté de 10% à chaque image, ce qui donne cet effet de recul.
N'hésitez pas à modifier le calcul ci-dessus en fonction de x, y et t. ça fera d'autre effet :lol:
Répondre