Skip to content
MPGHThe Dark Arts
/
RegisterLog in
Forum
Community
What's NewLatest posts across the boardTrendingHottest threads right nowSubscribedThreads you follow
Discussion
GeneralIntroductionsEntertainmentDebate FortFlaming & Rage
Board
News & AnnouncementsMPGH TimesSuggestions & HelpGiveaways
More Sections
Art & Graphic DesignProgrammingHackingCryptocurrency
Hacks & Cheats
Games
ValorantCS2 / CS:GOCall of Duty / WarzoneFortniteApex LegendsEscape From Tarkov
+14 moreLeague of LegendsGTA VMinecraftRustROTMGBattlefieldTroveBattleOnCombat ArmsCrossFireBlackshotRuneScapeDayZDead by Daylight
Resources
Game Hacking TutorialsReverse EngineeringGeneral Game HackingAnti-CheatConsole Game Hacking
Tools
Game Hacking ToolsTrainers & CheatsHack/Release NewsNew
Submit a release →Share your cheat, tool, or config with the community.
AINEW
AI Tools
General & DiscussionPrompt EngineeringLLM JailbreaksHotAI Agents & AutomationLocal / Open Models
AI × Gaming
AI Aimbots & VisionML Anti-CheatGame Bots & Automation
Create
AI Coding / Vibe CodingAI Art & MediaAI Voice & TTS
The AI frontier →Where game hacking meets modern machine learning. Jump in.
Marketplace
Buy & Sell
SellingBuyingTradingUser Services
Trust & Safety
Middleman LoungeMarketplace TalkVouch Copy Profiles
Money
Cryptocurrency TalkCurrency ExchangeWork & Job Offers
Start selling →List accounts, services, and goods. Use the middleman to trade safe.
MPGH The Dark Arts

A community for offensive security research, reverse engineering, and AI.

Community

ForumMarketplaceSearch

Account

RegisterLog in

Legal

Privacy PolicyForum RulesHelp & FAQ
© 2026 MPGH · All rights reserved.Built by the community, for the community. For educational purposes onlyContent is shared for security research and education — we don't condone illegal use. You're responsible for complying with applicable laws. Use at your own risk.
Home › Forum › Programming › Visual Basic Programming › [TUT] VB.net DirectX [TUT]

Arrow[TUT] VB.net DirectX [TUT]

Posts 1–15 of 20 · Page 1 of 2
XG
XGelite
[TUT] VB.net DirectX [TUT]
~DIRECTX in VB.NET~

Tutorial 1

"The Basics - The BlueScreen"



Interested in exploring the world of directX? Then read on!

Alright lets see, where should we start? Ahhh yes, lets start with the basics, the very very basics, rendering a blank screen.
lets get started.


- What you need -

{

-Visual Basic 2008 or 2005
-the most recent DirectX SDK - you can get it here Download details: DirectX SDK - (February 2010)
-a decent video card.

}

- Creating the Project -

{

1. Create a new Windows project in Visual Basics 2008( will work with earlier versions of VB.net)
2. Add a new reference to Microsoft.Microsoft.DirectX , Microsoft.DirectX.Direct3D , and Microsoft.DirectX.Direct3D.D3DX .
If you don't know how to do this already, follow the Steps Listed in " -Adding the References- "

}

-Adding The References-

{

1. Goto to the "project" drop down menu and you should see "Add Reference". Wait for it to load up (sometimes it takes a minute or to as it is searching the computer for references)
2. Scroll down and add all these References:
Code:
 - Microsoft.Microsoft.DirectX , 
           Microsoft.DirectX.Direct3D , 
           Microsoft.DirectX.Direct3D.3DX
}


-Using the References-

{

1. Add these lines to the top of your code.

Code:
Imports Microsoft.DirectX
Imports Microsoft.DirectX.Direct3D
Imports Microsoft.DirectX.Direct3D.D3DX
}

We are not going to be using form1 Just yet. Instead we are going to be adding a class.

-Creating the gameClass-

{

In this part of the tutorial we'll be adding a class to our project. Classes are very important. Without classes you would end up
writing the same code over and over again, and that's not very fun or efficient. Using Classes also make your project much more organized. You'll understand why later on.

Lets add a class to our project!

1. GoTo the "Project" drop down menu and you should see "Add New Item", Click on it.
2. Click on the Class template. Name our class "gameClass".
3. Lets add the Imports Statements to the top of our class. (you can get rid of any other Statements)

Code:
  Imports Microsoft.DirectX
       Imports Microsoft.DirectX.Direct3D
       Imports Microsoft.DirectX.Direct3D.D3DX
}

- Declaring our variables -

{

We need to add some variables to our class.
1. Open up the code page for our gameClass
2. add these variables :

Code:
 Private displaySettings As DisplayMode
        
        Private deviceParameters As PresentParameters

        Public device As Device
        
        Public gameExit As Boolean
}


Now we need to add a new Sub to our class.

- Adding the Initialize Sub -

{

1. Add a new Sub and call it Initialize.

Code:
 Public Sub Initialize (ByVal fullScreen As Boolean)

          End Sub

2. Add this code inside of the Sub:

Code:
 If fullScreen Then

            displaySettings.Width = 800
           
            displaySettings.Height = 600
       
            displaySettings.Format = Format.X8R8G8B8

        Else
           
            displaySettings = Manager.Adapters.Default.CurrentDisplayMode

        End If
What we just did:

- first we checked to see if fullScreen is true
if true, we set the resolution to 800 by 600 and set the format to 32bits, else we set it to the CurrentDisplayMode of the Computer.



3. Now add this code right under it:

Code:
 deviceParameters = New PresentParameters()

            deviceParameters.BackBufferWidth = displaySettings.Width

            deviceParameters.BackBufferHeight = displaySettings.Height

            deviceParameters.BackBufferFormat = displaySettings.Format

            deviceParameters.SwapEffect = SwapEffect.Discard

            deviceParameters.PresentationInterval = PresentInterval.Immediate


            If fullScreen Then
              deviceParameters.Windowed = False
            Else
              deviceParameters.Windowed = True
            End If

What we just did:

- We set the deviceParameters to the displaySettings. Then we set the SwapEffect to discard and then PresentInterval to Immediate.
but what does SwapEffect and PresentationInterval even mean? Well the SwapEffect tells the device how to go from one frame to the next. We have set it to overwrite the previous frames. The PresentationInterval tells the device how often to show the frames. We've set it to show the frames immediately, not to wait for anything.
- After we set up the deviceParameters, we checked if fullScreen was true again. If true we set the display window to Fullscreen, if false, We set the display window to windowed.

}



Lets add another sub to our gameClass

- Adding the LoadContent sub -

{

The loadContent sub is where we are going to load all our textures and models later on.

1.Add a new sub and call it loadContent()

2.Add this line of code inside of it.

Code:
 device = New Device(Manager.Adapters.Default.Adapter, DeviceType.Hardware, Form1.Handle, CreateFlags.SoftwareVertexProcessing, deviceParameters)
3. add this code to the end of our initialize sub

Code:
  loadContent()

What we just did:
- we set the up the device. Which gets the graphics adapter, sets the devicetype, gets the window to draw to, sets the vertex processing to Software processing, and gets the deviceParameters.
i could explain this more if you would like..but i figured you just want to move along
- then we told it to execute the loadContent sub inside of our initialize sub.

info : You may be wondering what vertex's are? Well there the points that make up the triangles, and the triangles make up everything. Well be using triangles and verticals in the next tutorial.

}

We will be adding yet another sub to our gameClass.

- Adding the Draw sub -

{

The Draw Sub is where we will be doing all our rendering.

1. Add a new sub to your gameClass and call it Draw

Code:
     Public Sub Draw()
           End sub

2. now add this code inside the Draw sub:

Code:
  Do While Not gameExit

          Loop

          
          thisExit()
What we just did :

- We added a loop inside of our Draw sub. We are going to render inside this loop. Then we told
the game to excectute a sub called, thisExit(), if the loop is no longer true. We are going to create
the thisExit() sub now. We are not finished with the draw sub yet, but will be back to it in a minute.

}

Lets now add the thisExit sub.

- Adding the thisExit sub -

{
This sub will be the Exit sub for our app.

1. Add a new sub to your gameClass and call it thisExit()

2. add this code inside:

Code:
 displaySettings = Nothing
         deviceParameters = Nothing
         device.Dispose()
         device = Nothing
         Application.Exit()

What We just did.

First we cleared the displaySettings, deviceParameters, and the device. Then We Exited the
application.

}

Now we go back to our Draw sub

- Setting up our Draw Sub -

1. We need to add this code to our Draw Sub inside the loop we added earlier.

Code:
device.Clear(ClearFlags.Target, Color.CornFlowerBlue, 1, 0)

   device.BeginScene()

   device.EndScene()
   
   device.Present()
  
   Application.DoEvents()
What We just did:

-We set the device to clear the screen everytime the loop is executed. We set the back color to blue.
then we began the drawScene(). This is were we draw everything. Then we Ended the Scene
and we added Application.DoEvents to so that our application wont freeze and ignore keypresses.

}

We are now going to load our gameClass and detect keypresses.

- Detecting Keypresses, loading our class, and Exiting the game -

{

1. Go to our Form1 one and go to the code page.

2. Add this varable in our globals.

Code:
    Dim game As New gameClass
4. Add this code.

Code:
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If e.KeyCode = Keys.Escape Then game.gameExit = True
End sub
5. Now add this code inside the Form1_Load sub:

Code:
   Me.Show()

   game.Initialize(True)
   game.Draw()

What we just did:

- First We detected if the "Escape" key was pressed, then we told we set the gameExit to true which will exit the game.
- then we loaded up our Initialize and Draw subs.

}



Now run this code and you should get a blue screen! Aren't you exited! A blue screen isn't very exciting is it. Don't worry, well be getting into some
more exciting stuff in the next tutorial! Don't feel like you wasted your time. Its very important to get a grasp of the basics. Ive tried to help you do that. This code is the backbone for everything else.
Suggestion: While your waiting for the next tutorial, i recommend learning it so you can write it out from memory. That should not be to difficult, as its not much code.

Now that we have the base of our code set up, We are ready to start rendering. We will learn how to render a sprite, a triangle in 3d space, and
draw text to our screen in the next tutorial "Basic rendering".



Your gameClass Code should look something like this:

Code:
Imports Microsoft.DirectX
Imports Microsoft.DirectX.Direct3D
Imports Microsoft.DirectX.Direct3D.D3DX

Public Class gameClass

    Private displaySettings As DisplayMode 

    Private deviceParameters As PresentParameters 

    Public device As Device 

    Public gameExit As Boolean

    Public Sub Initialize(ByVal fullScreen As Boolean)





        If fullScreen Then

            displaySettings.Width = 800

            displaySettings.Height = 600

            displaySettings.Format = Format.X8R8G8B8

        Else

            displaySettings = Manager.Adapters.Default.CurrentDisplayMode

        End If




        deviceParameters = New PresentParameters()

        deviceParameters.BackBufferWidth = displaySettings.Width

        deviceParameters.BackBufferHeight = displaySettings.Height

        deviceParameters.BackBufferFormat = displaySettings.Format

        deviceParameters.SwapEffect = SwapEffect.Discard

        deviceParameters.PresentationInterval = PresentInterval.Immediate


        If fullScreen Then
            deviceParameters.Windowed = False
        Else
            deviceParameters.Windowed = True
        End If

        LoadContent()


    End Sub

    Public Sub LoadContent()
        device = New Device(Manager.Adapters.Default.Adapter, DeviceType.Hardware, Form1.Handle, CreateFlags.SoftwareVertexProcessing, deviceParameters)

    End Sub

    Public Sub Draw()

        Do While Not gameExit

            device.Clear(ClearFlags.Target, Color.CornFlowerBlue, 1, 0)

            device.BeginScene()

            device.EndScene()

            device.Present()

            Application.DoEvents()

        Loop


        thisExit()

    End Sub

    Public Sub thisExit()
        displaySettings = Nothing
        deviceParameters = Nothing
        device.Dispose()
        device = Nothing
        Application.Exit()
    End Sub
End Class

Next Tutorial - " The Basics - Basic Rendering "

Upcoming Tutorials:

- "Basic Rendering"
- "Loading a Model"
- "Texturing"
- "Cameras and Movement"
#1 · edited 16y ago · 16y ago
NextGen1
NextGen1
Something everyone has been waiting for
#2 · 16y ago
XG
XGelite
Quote Originally Posted by NextGen1 View Post
Something everyone has been waiting for
Thats good
Im working on it right now!
#3 · 16y ago
MugNuf
MugNuf
So, what is this going to be. DirectX coding in VB, or coding both, VB and DirectX?
#4 · 16y ago
XG
XGelite
Quote Originally Posted by MugNuf View Post
So, what is this going to be. DirectX coding in VB, or coding both, VB and DirectX?
How to use DirectX in VB.net.
#5 · 16y ago
Zoom
Zoom
Quote Originally Posted by XGelite View Post
How to use DirectX in VB.net.
OMG I have always wondering how to do it!
#6 · 16y ago
XG
XGelite
/discard this post
#7 · edited 16y ago · 16y ago
NextGen1
NextGen1
I put it in post one, Very good tut, very clean...
I like it,
#8 · 16y ago
|-|3|_][({}PT3R12
|-|3|_][({}PT3R12
Nice job Really, really good.

PS: I like the brackets around the different "functions" :P
#9 · 16y ago
XG
XGelite
Ill be starting on "Basic Rendering" Next week. My plan is to release one every week if i have the time.
These tutorials should draw more traffic to this section and mpgh.
#10 · 16y ago
Blubb1337
Blubb1337
I would like to do my own boxhead game LOLZ I'd be so proud of myself xD

Thank you for your tutorial I'm going to read it when I'm done with my homework -_-

' Yes I do know adobe flash is better to create such games, however this should also be possible in vb, isn't it?

Link didn't work for me tho...

DX SDK -> Feb 2010 Download
#11 · edited 16y ago · 16y ago
XG
XGelite
Quote Originally Posted by Blubb1337 View Post
I would like to do my own boxhead game LOLZ I'd be so proud of myself xD

Thank you for your tutorial I'm going to read it when I'm done with my homework -_-

' Yes I do know adobe flash is better to create such games, however this should also be possible in vb, isn't it?

Link didn't work for me tho...

DX SDK -> Feb 2010 Download

not sure what a boxhead game is.. but whatever it is, yeah you should be able to.

hmm, my link work just fine for me.
#12 · 16y ago
Blubb1337
Blubb1337
Boxhead 2Play - Spiele-Zone A less advanced for sure =D
#13 · 16y ago
why06
why06
Lol. Im a little late to the party here, but very nice tut XGelite. This is excellent. Now perhaps the VB section can try to incorporate some DirectX stuff in their hacks.

kudos!
#14 · 16y ago
Lolland
Lolland
tl;dw, looks good.

Thanks, may read in the future.
#15 · 16y ago
Posts 1–15 of 20 · Page 1 of 2

Post a Reply

Similar Threads

  • [TUT][VB.NET] Hardware ID RegistrationBy steph777 in Programming Tutorials
    23Last post 3y ago
  • Tut How To Set Up Mpgh.Net PublicsBy Cheesesong in CrossFire Hacks & Cheats
    10Last post 17y ago
  • [TUT] How to make an Updater [VB.net]By Ugleh in Visual Basic Programming
    7Last post 16y ago
  • [VB.NET] Video TUTs[MADE BY ME]By Deto in Programming Tutorials
    12Last post 15y ago
  • [Tut]Using VB.net to recieve emailsBy Bombsaway707 in Visual Basic Programming
    25Last post 15y ago

Tags for this Thread

#directx#vb.net#vb.net directx#visual basic directx#visual basics