Post

 Resources 

Console

Home | Profile | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 VBGamer
 VBGamer
 Help with Intializing Direct3d device

Note: You must be registered in order to post a reply.

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List Spell Checker
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

   Insert an File
Check here to include your profile signature.
Check here to subscribe to this topic.
    

T O P I C    R E V I E W
brase Posted - Jan 16 2006 : 2:03:42 PM
I am trying to initialize Direct 3d with this code:
Imports Microsoft.DirectX  
Imports Microsoft.DirectX.Direct3D  
  
Public Class Form1  
    Dim device As Device  
    Public Sub New()  
  
        ' This call is required by the Windows Form Designer.  
        InitializeComponent()  
  
        ' Add any initialization after the InitializeComponent() call.  
  
    End Sub
    Public Function init3d()  
        Try
            Dim pparams As New PresentParameters  
            pparams.Windowed = True
            pparams.SwapEffect = SwapEffect.Discard  
            device = New Device(0, DeviceType.Software, Me, CreateFlags.SoftwareVertexProcessing, pparams)  
            Return True
        Catch ex As DirectXException  
            Return False
        End Try
    End Function
    Private Sub render()  
        Me.device.Clear(ClearFlags.Target, Color.Blue, 1.0F, 0)  
        Me.device.BeginScene()  
        Me.device.EndScene()  
        Me.device.Present()  
    End Sub
  
    Sub main()  
        If init3d() = False Then
            MsgBox("Couldn't initialize graphics", MsgBoxStyle.OkCancel, "Error")  
        End If
    End Sub
  
    Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)  
        Me.render()  
    End Sub
End Class  

when i try to debug i get this error:
quote:
Me.device.Clear(ClearFlags.Target, Color.Blue, 1.0F, 0)  

Object reference not set to an instance of an object.


All help is greatly appreciated.
3   L A T E S T    R E P L I E S    (Newest First)
VBBR Posted - Jan 23 2006 : 08:33:43 AM
He is probably starting in the form, hence main() is NEVER called and thus the device is not setup.

Call main in the form constructor and see what happens.
Lachlan87 Posted - Jan 22 2006 : 09:24:15 AM
Surely that isn't the code you're using? I can't figure how you get as far as you do if it is. If you are using VB.NET 2002/2003, it should error out before it ever gets to that point. Sub Main must be declared as "Shared Sub Main" in order to work. Even if you make it shared, you still have the problem that you can't refer to init3d() without refering to a specific instance of Form1. And here I'm confused again, because if you are starting from sub main, you never make any instances of form1. And if you are not starting from sub Main, then sub main is never called, and therefore you haven't set device to equal a new device yet.

But frankly, I can't get your code to even go far enough to get the error you do. Are you sure this is a Copy and paste of the code your using?
VBBR Posted - Jan 17 2006 : 08:35:30 AM
From what I remember you presumably had to do more stuf than that to init D3D... Are you sure you can init the device using "New Device" instead of creating it from the DX root class or whatever? I'm not good with DX9 so thta's only a guess.

VBGamer © Go To Top Of Page
This page was generated in 0.18 seconds. Snitz Forums 2000

Copyright © 2002 - 2004 Eric Coleman, Peter Kuchnio , et. al.