Wednesday, March 7, 2012

device is ambiguous in the namespace microsoft.directx.direc3d

Can anybody tell me what this error message means. I get it when trying to use directx3d. The code is included below.

I have checked and double checked that I have all the necessary references and includes. Obviously I am missing something.
Thanks Dick

Imports System

Imports System.Drawing

Imports System.Windows.Forms

Imports Microsoft.DirectX

Imports Microsoft.DirectX.Direct3D

Public Class Form1

Inherits System.Windows.Forms.Form

Dim device As Device ' Our rendering device

#Region "Windows Form Designer generated code "

Public Sub New()

MyBase.New()

'This call is required by the Windows Form Designer.

InitializeComponent()

End Sub

'Form overrides dispose to clean up the component list.

Protected Overloads Overrides Sub Dispose(ByVal Disposing As Boolean)

If Disposing Then

If Not components Is Nothing Then

components.Dispose()

End If

End If

MyBase.Dispose(Disposing)

End Sub

'Required by the Windows Form Designer

#End Region

Public Function InitializeGraphics() As Boolean

Try

' Now let's setup our D3D stuff

Dim presentParams As PresentParameters = New PresentParameters()

presentParams.Windowed = True

presentParams.SwapEffect = SwapEffect.Discard

device = New Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParams)

Return True

Catch

Return False

End Try

End Function

Private Sub Render()

If device Is Nothing Then

Exit Sub

End If

'Clear the backbuffer to a blue color

device.Clear(ClearFlags.Target, System.Drawing.Color.Blue, 1.0F, 0)

'Begin the scene

device.BeginScene()

' Rendering of scene objects can happen here

'End the scene

device.EndScene()

device.Present()

End Sub

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

If Not InitializeGraphics() Then

MessageBox.Show("Could not initialize Direct3D. This tutorial will exit.")

Exit Sub

End If

Me.Show()

' While the form is still valid, render and process messages

Do While Me.Created

Render()

Application.DoEvents()

Loop

End Sub

End Class

This is a SQL Server forum. I think you've accidentally posted to the wrong place...

No comments:

Post a Comment