PRobleme Directx7 et directDraw

izords Messages postés 20 Date d'inscription samedi 27 avril 2002 Statut Membre Dernière intervention 4 mars 2013 - 5 août 2004 à 21:02
cs_EBArtSoft Messages postés 4525 Date d'inscription dimanche 29 septembre 2002 Statut Modérateur Dernière intervention 22 avril 2019 - 6 août 2004 à 09:54
Salut j'aimerais savoir pkoi lorsque je dessine une line a l'aide du backbuffer dans un boucle il m'affiche seuelement la derniere ligne comme s'il ne dessinais pas les autre.

Voici mon code

Sub Main()

Key = ""
Set DD = DX.DirectDrawCreate("")
DD.SetCooperativeLevel Form1.hWnd, DDSCL_FULLSCREEN Or DDSCL_EXCLUSIVE Or DDSCL_ALLOWREBOOT
DD.SetDisplayMode 640, 480, 16, 0, DDSDM_DEFAULT


DirectInputKeyboardInit
DIDevice.Acquire

Dim ddsd As DDSURFACEDESC2
ddsd.lFlags = DDSD_BACKBUFFERCOUNT Or DDSD_CAPS
ddsd.lBackBufferCount = 1
ddsd.ddscaps.lCaps = DDSCAPS_COMPLEX Or DDSCAPS_FLIP Or DDSCAPS_PRIMARYSURFACE Or DDSCAPS_VIDEOMEMORY

Set Primary = DD.CreateSurface(ddsd)

Dim ddscaps As DDSCAPS2
ddscaps.lCaps = DDSCAPS_BACKBUFFER Or DDSCAPS_VIDEOMEMORY
Set Backbuffer = Primary.GetAttachedSurface(ddscaps)
Dim i As Integer
Dim rec As RECT
rec.Bottom = 480
rec.Left = 0
rec.Right = 640
rec.Top = 0
Backbuffer.BltColorFill rec, 0
Backbuffer.SetFontTransparency True

Do

Backbuffer.BltColorFill rec, 0
Backbuffer.SetForeColor RGB(256, 0, 0)
Backbuffer.SetForeColor RGB(0, 256, 0)
DIDevice.GetDeviceStateKeyboard DIState
If DIState.Key(DxVBLib.CONST_DIKEYFLAGS.DIK_RIGHT) Then
If Key <> "Right" Then
NbrLigne = NbrLigne + 1
Key = "Right"
End If
x2 = x2 + 1
End If
If DIState.Key(DxVBLib.CONST_DIKEYFLAGS.DIK_LEFT) Then
If Key <> "Left" Then
NbrLigne = NbrLigne + 1
Key = "Left"
End If
x2 = x2 - 1
End If
If DIState.Key(DxVBLib.CONST_DIKEYFLAGS.DIK_UP) Then
NbrLigne = NbrLigne + 1
y2 = y2 - 1
End If
If DIState.Key(DxVBLib.CONST_DIKEYFLAGS.DIK_DOWN) Then
If Key <> "Down" Then
NbrLigne = NbrLigne + 1
Key = "Down"
ReDim Ligne(NbrLigne)
End If
y1 = x2
y2 = y2 + 1
End If

*****************************
For i = 1 To NbrLigne
Backbuffer.DrawLine x1, y1, x2, y2
Next
******************************

Backbuffer.DrawText 40, 450, x1 & " " & y1 & " " & x2 & " " & y2, False

DoEvents
If ok% = -1 Then GoTo suib
Primary.Flip Nothing, DDFLIP_WAIT

Loop
suib:
Unload Form1
End Sub

1 réponse

cs_EBArtSoft Messages postés 4525 Date d'inscription dimanche 29 septembre 2002 Statut Modérateur Dernière intervention 22 avril 2019 9
6 août 2004 à 09:54
par c que si tu regarde ton code tu vera tres nettement
que x1,y1,x2,y2 un une et une seul valeur !

la boucle for i=1 to NbrLigne ne te sert a rien
dans ton exemple il faudrait faire ceci :

x1(i),y1(i),x2(i),y1(i)

mais pour ça faut modifier tout ton code

@+

E.B.
0
Rejoignez-nous