Page 1 of 1

Basic DirectX/Variable/Function

Posted: Sat Jun 16, 2007 3:19 pm
by Spartan025
Really basic
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
Your code>VB looks for it>Make the executable.
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
Here the lineup now.
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
This creates the directx object. It controls all the objects/things that you will use in the application.

->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()
Now here is something I should talk about.
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
There are three 5 parts to a VB6 Function
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
Image


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


This variable explanation applys to all vbusers, including vb6 and vb05

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
The important keyword here is Dim
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.
So declaration just created in the computer memory myVariable As a string data type.

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
Here we put in the string literal ">[JB]<KageLink" into the variable JKAName.

Re: Basic DirectX/Variable/Function

Posted: Sat Jun 16, 2007 3:35 pm
by Prey
A lot of this is just plain crap :roll: ..and if your gonna make a tut at least use a spell checker; your post just gets progressively worse >_>

Posted: Fri Jun 22, 2007 4:04 pm
by Veegie[Temp]
What a horribly stupid post. :(

Posted: Fri Jun 22, 2007 4:07 pm
by xbox7887
This tutorial does nothing, it just explains how to initialize some classes which you never use. The first steps to using DirectX would be setting up your graphics device with some present params and such, and binding a render scene to a control panel :?

Posted: Fri Jun 22, 2007 10:34 pm
by kornman00
I just died a little inside :/....