Learning Direct3D

WebKill2k

Member
Joined
May 15, 2008
Messages
14
Programming Experience
1-3
I'm trying to learn some Direct3D but having some trouble with this tutorial.

I got to the section near the bottom called "The Game Loop":

VB.NET:
Shared Sub Main()
        'The playarea object is an instance of our form.
        Dim PlayArea As New Form1
 
        PlayArea.Show() 'Show the form.
        PlayArea.InitializeGraphics() 'Initialize all the graphical elements
 
        Try
            While PlayArea.Created 'The Game loop
                PlayArea.Render()      'This will be used to display all of our graphics
                Application.DoEvents() 'This gives Windows a chance to do its stuff.
            End While
        Finally
            PlayArea.Dispose() 'Clean up our form when we are done.
        End Try
    End Sub

but for the lines PlayArea.InitializeGraphics() and PlayArea.Render() I get an error that says
Error 1 'InitializeGraphics' is not a member of 'WindowsApplication1.Form1'.
Error 2 'Render' is not a member of 'WindowsApplication1.Form1'.
 
Ok, I figured it out, made a stupid error. Now I am trying to run the code and I am getting this error:

DLL 'C:\WINDOWS\assembly\GAC\Microsoft.DirectX\1.0.2902.0__31bf3856ad364e35\Microsoft.DirectX.dll' is attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.

on the line:

VB.NET:
Dim current As Format = Direct3D.Manager.Adapters(0).CurrentDisplayMode.Format

Within this sub:
VB.NET:
    Private Sub InitializeGraphics()
        'set our presentation parameters
        presentParams.SwapEffect = SwapEffect.Discard

        ' use the users current display mode
        Dim current As Format = Direct3D.Manager.Adapters(0).CurrentDisplayMode.Format

        'Check to see if fullscreen mode is supported before you use it.
        If Direct3D.Manager.CheckDeviceType(0, Direct3D.DeviceType.Hardware, current, current, False) Then
            ' Perfect, this is valid
            presentParams.Windowed = False
            presentParams.BackBufferFormat = current
            presentParams.BackBufferCount = 1
            presentParams.BackBufferWidth = 800 'this is the resolution of your display
            presentParams.BackBufferHeight = 600
        Else 'If it doesn't supports fullscreen mode, go windowed
            presentParams.Windowed = True
        End If

        'Create our device
        GraphicsDevice = New Direct3D.Device(0, Direct3D.DeviceType.Hardware, Me, CreateFlags.SoftwareVertexProcessing, presentParams)

    End Sub
 
Back
Top