Simple DirectX Initialize Not Working
Simple DirectX Initialize Not Working
Simple DirectX Initialize Not Working
Simple DirectX Initialize Not Working
Simple DirectX Initialize Not Working
Simple DirectX Initialize Not Working Simple DirectX Initialize Not Working Simple DirectX Initialize Not Working Simple DirectX Initialize Not Working Simple DirectX Initialize Not Working Simple DirectX Initialize Not Working Simple DirectX Initialize Not Working Simple DirectX Initialize Not Working
Simple DirectX Initialize Not Working Simple DirectX Initialize Not Working
Simple DirectX Initialize Not Working
Go Back  Xtreme Visual Basic Talk > > > > Simple DirectX Initialize Not Working


Reply
 
Thread Tools Display Modes
  #1  
Old 02-05-2005, 02:17 PM
djpeterson83 djpeterson83 is offline
Newcomer
 
Join Date: Feb 2005
Posts: 2
Question Simple DirectX Initialize Not Working


Ok, I've followed two tutorials sofar (Microsoft, and a 3rd party) and keep getting the same strange error at the same line of code. I've worked with DirectX before in VB6 and got through it, but I'm basically knew to DX9 and Managed language programming (the two put together, I know VB.NET and C# rather well). Basically, my ever descriptive error is something along the lines of "Error in the application". It happens when I initialize a new device.

Code:
Dim Device As Device Dim Disp As DisplayMode Dim bQuit As Boolean = False Public Function SetFullScreen(ByVal frm As Control, ByVal Width As Integer, ByVal Height As Integer, ByVal BitDepth As Direct3D.Format) Disp.Width = Width Disp.Height = Height Disp.Format = BitDepth InitializeGraphics(frm, Disp, True) End Function Private Function InitializeGraphics(ByVal frm As Control, ByVal Disp As DisplayMode, ByVal Windowed As Boolean) Dim PParams As PresentParameters = New PresentParameters() PParams.Windowed = Windowed PParams.PresentationInterval = PresentInterval.Immediate PParams.SwapEffect = SwapEffect.Discard Rem THIS ERRORS Device = New Device(Manager.Adapters.Default.Adapter, DeviceType.Hardware, frm, CreateFlags.SoftwareVertexProcessing, PParams) End Function

As I had to "fix" Microsoft code in a Socket tutorial a little while back ago, I decided to check out other tutorials, but I still get this error. Any help would definetely be appreciated!
Reply With Quote
  #2  
Old 02-06-2005, 02:46 PM
sgt_pinky's Avatar
sgt_pinky sgt_pinky is offline
Contributor
 
Join Date: Feb 2004
Location: Melbourne, Australia
Posts: 633
Default

Which version of the SDK do you have, and have you tried running the SDK tutorials? If so, do they work?

The reason I ask is because you use a slightly different method of creating the rendering device.
Reply With Quote
  #3  
Old 02-09-2005, 01:28 AM
ardman ardman is offline
Contributor
 
Join Date: Jan 2002
Posts: 126
Default

Are you already using
Code:
Imports System.Windows.Forms
at the top of your code?

Also, have you tried changing the Manager.Adapters.Default.Adapter to a 0?
__________________
Cheers
Reply With Quote
  #4  
Old 02-11-2005, 08:59 PM
djpeterson83 djpeterson83 is offline
Newcomer
 
Join Date: Feb 2005
Posts: 2
Default

ardman, yes i import Forms, and yes I have tried the adapter to 0. That has no affect. I believe the DX SDK that I have to be the latest. I'll redownload I suppose. Also, I think this is cuz of VB.NET 2002, but I don't actually get the DLL's in the .NET reference dialog. I manually pointed to them. I don't think this is the problem, however, since I already tried playing sounds through VB.NET and DirectX with another tut, and that worked fine! I'll post again in a bit once I finish dloading DX9 SDK again.

[EDIT]
Well, just tried the new SDK (Feb 2005), and it didn't work. First off, I could only find one VB example and since it was probably compiled in 2003, it couldn't load the solution. I tried creating a new project for it, but it imports this "Imports Microsoft.Samples.DirectX.UtilityToolkit". I have no idea what that is or where it is from, so I cannot continue.

Does anyone have any tested code that they might be able to post on just getting a simple device going? Seems my above code should run, but it doesn't.

Last edited by djpeterson83; 02-11-2005 at 10:03 PM.
Reply With Quote
  #5  
Old 03-15-2005, 09:52 AM
NGN_VBdotNET NGN_VBdotNET is offline
Newcomer
 
Join Date: Mar 2005
Posts: 6
Default Handles!

Hello!

I think Your problem start whit:
"Public Function SetFullScreen(ByVal frm As Control, ..."

Try to change this to a 'handle'.
-> 'Public Function SetFullScreen(ByVal frm As System.IntPtr, ...'
and
"Private Function InitializeGraphics(ByVal frm As Control"
-> 'Private Function InitializeGraphics(ByVal frm As System.IntPtr, ...'

To the function You now can pass: 'SetFullScreen(Form.Handle, ...'

Look at the definition (from DX9.0c SDK) below:
'New Device(
' adapter As Integer,
' deviceType As Microsoft.DirectX.Direct3D.DiveceType,
' renderWindowHandle As System.IntPtr,
' behaviorFlags As Microsoft.DirectX.Direct3D.CreateFlags,
' ParamArray presentationParameters() As Microsoft.DirectX.Direct3D.PresentParameters)

Good Luck!
Reply With Quote
  #6  
Old 03-18-2005, 12:59 PM
NGN_VBdotNET NGN_VBdotNET is offline
Newcomer
 
Join Date: Mar 2005
Posts: 6
Default

I took a closer look.

This code works for me, now.
(DX9.0c, .NET Framework 1.1 and VB.NET 2003)

Code:
Imports Microsoft.directx
Imports Microsoft.directx.Direct3D
Public Class Form1
    Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
#End Region
    Dim Device As Device
    Dim Disp As DisplayMode

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        SetFullScreen(Me, 800, 600, Format.D16)

        Me.Show()

        Device.Clear(ClearFlags.Target, Color.Blue, 1, 0)
        Device.BeginScene()
        Device.EndScene()
        Device.Present()
        Application.DoEvents()

    End Sub

    Public Function SetFullScreen(ByVal frm As Control, ByVal Width As Integer, ByVal Height As Integer, ByVal BitDepth As Direct3D.Format) As Boolean
        Disp.Width = Width
        Disp.Height = Height
        Disp.Format = BitDepth
        InitializeGraphics(frm, Disp, True)
    End Function

    Private Function InitializeGraphics(ByVal frm As Control, ByVal Disp As DisplayMode, ByVal Windowed As Boolean) As Boolean
        Dim PParams As PresentParameters = New PresentParameters
        PParams.Windowed = Windowed
        PParams.PresentationInterval = PresentInterval.Immediate
        PParams.SwapEffect = SwapEffect.Discard

        REM THIS ERRORS NO MORE
        Device = New Device(Manager.Adapters.Default.Adapter, DeviceType.Hardware, frm, CreateFlags.SoftwareVertexProcessing, PParams)
    End Function
End Class
Hope this works for You!

NGN
Sweden
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Simple DirectX Initialize Not Working
Simple DirectX Initialize Not Working
Simple DirectX Initialize Not Working Simple DirectX Initialize Not Working
Simple DirectX Initialize Not Working
Simple DirectX Initialize Not Working
Simple DirectX Initialize Not Working Simple DirectX Initialize Not Working Simple DirectX Initialize Not Working Simple DirectX Initialize Not Working Simple DirectX Initialize Not Working Simple DirectX Initialize Not Working Simple DirectX Initialize Not Working
Simple DirectX Initialize Not Working
Simple DirectX Initialize Not Working
 
Simple DirectX Initialize Not Working
Simple DirectX Initialize Not Working
 
-->