VB icon

A chaotic ScreenSaver using DirectX 7

Email
Submitted on: 1/6/2015 3:27:00 AM
By: Stephan Kirchmaier (from psc cd)  
Level: Advanced
User Rating: By 7 Users
Compatibility: VB 5.0, VB 6.0
Views: 1265
 
     It's my first DirectX Project. Please say what you think of it!
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: A chaotic ScreenSaver using DirectX 7
' Description:It's my first DirectX Project. Please say what you think of it!
' By: Stephan Kirchmaier (from psc cd)
'
' Inputs:You must link "DirectX7 for Visual Basic Type Library" to your Project.
'
' Assumes:The ScreenSaver ends by clicking on the screen.
'**************************************

Option Explicit
Private DX7 As DirectX7
Private DXD As DirectDraw7
Private DXDS As DirectDrawSurface7
Private DXSD As DDSURFACEDESC2
Private Sub Form_Load()
 Dim i As Long, j As Long
 
 frmMain.Show
 'Create a DirectX7-Object and a DirectDraw-Object
 Set DX7 = New DirectX7
 Set DXD = DX7.DirectDrawCreate("")
 With DXSD
.lFlags = DDSD_CAPS
.ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE
 End With
 'Fullscreen and set the resolution to 640 X 480
 DXD.SetCooperativeLevel frmMain.hWnd, DDSCL_EXCLUSIVE Or DDSCL_FULLSCREEN
 DXD.SetDisplayMode 640, 480, 16, 0, DDSDM_DEFAULT
 'Create the Surface using the Surfacedescription DXSD
 Set DXDS = DXD.CreateSurface(DXSD)
 i = 0
 Do Until DoEvents()
For j = 0 To ScaleWidth Step 50
 'Set the Linecolor
 DXDS.SetForeColor i
 'Draw the line
 DXDS.DrawLine Rnd * Screen.Width, Rnd * Screen.Height, j, 0
 i = i + 1
 'Change the color
 If i = 65536 Then
i = 0
 End If
Next j
 Loop
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
 Call endp
End Sub
Private Sub endp()
 'Clean up things
 DXD.RestoreDisplayMode
 Set DX7 = Nothing
 Set DXD = Nothing
 Set DXDS = Nothing
 End
End Sub


Other 7 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.