There are 3 parts to this Eplanation
1.Directx
2.DirectX classes/functions
3.Applying DirectX
DirectX
Direct X is a set of programs and files that are used to make games and graphics. Direct X in programming is also known as and SDK or Self-Development Kit. This contains classes/functions that create 3D applications, such as a BSP viewer, 3DS Max, or even Star Wars Jedi Knight Jedi Academy.
DirectX and its classes/functions
DirectX has a classes/functions that are needed to create 3D apps. First let's ask this question. Why do we need to get the directX sdk, and why we need to add reference?
Ok, first Visual Basic was not develpoed for gaming. Because of the easy code and use, people could make programs, really fast, mostly buisness ones. But game programmers saw how easy VB is and applied DirectX to VB. Since Visual Basic by default doesnt support 3D so, you have to add a reference.
What is a reference
When you code goes into compile time, all the code is checked to the things its reffering to. Example
Code: Select all
Dim Kage As String
' When this code goes to compile time this is what goes behind the scenes of VB
Since this is default, it only needs to look in VB. Now if its 3D here's what happens
Code: Select all
Dim 3dobj As DirectX8
Your Code>VB looks in DirectX Refernce>Finds the Directx8 datatype>Succesfully created at 3d object.
Ok now lets look hwo you can apply it.
Applying DirectX
Applying DirectX to your application.
I'll show code then I'll explain all
Code: Select all
Dim 3dobj As DirectX8
Set 3dobj = New Directx8
' Make A Direct X Object
->Example
To make a 3d object out of the direct x you made you must have the 3dobj. In here i'm going to do whas variable intializing. It means giving the variable something to put in when its made
Code: Select all
'First the DirectX
Dim d3dobj As New Directx8
'Now you can make a 3D object
Dim d_o As Direct3d8 = d3dobj.Direct3DCreate()
The Direct3DCreate().
Ok this here is a function.
A function gets a value then returns it.
An example of a function is
Code: Select all
Function xfunc() As String
End Functions
1.Key word Function, you need this keyword
2.Then the name. The name cant be a VB keyword and has to start with a letter.
3.The arguments(), the things that are passed in. It could have 0 to as many arguments
4.Function Code, stuff that the function does.
5.Return function, End - Return value and end.
A function diagram

Ok for all users of VB6 who want to make 3D
applications such as games. First you must download Miscrosoft Direct8 SDK from miscrosoft then install it. In VB6, click File>New then select exe. Then on your my projects right-click and select Add Reference. Then it gives you a list of all the references you could use. Scroll to the D's and pick DirectX 8
*Note to all VB05 users, this method does not work in Visual Basic 2005 because of the .NET, I will show how to do this in another TUT
What is a reference?
A reference gives you acces to other types of classes that were not installed with VB6.
Exapmle
Code: Select all
' Attempting to create directx 3d object w/o refernce
Dim 3dobject As ' No classes available because no reference for 3d
' Making a 3D object with reference
Dim 3dobject As DirectX8 'Succesfully created a variable that hold a 3d object
' Direct X type is only availble if you add the reference
What is a variable?
In order to understand what I just did you have to understand variables.
A variable in VB or in other programming languages
is a place in the computers memory that hold data types. There are many different data types. To use a variable , you must declare it.
Code: Select all
'Example
Dim myVariable As String
Dim mean dimension in VB.
Let's look at this variable and take apart all the aspects used to make it.
Code: Select all
Dim myVariable As String
'Dim is the keyword
' myVariable, is the variable name
' you can name variables anything you want as long as its not a keyword in Visaul Basic
' As Keyword declares the variable 'AS'
' String = data type.
' Stings are variables that hold letters or the standard ASCII characters, the ones that are on your keyboard.
No that you made a variable, you would want to put data in it. To do that all you have to do is this.
Code: Select all
' Inputing Data from the code.
Dim JKAName As String
JKAName = ">[JB]<KageLink