| Poster | : The+Coder | | Posts | : 2 | | Country | : N/A | | City | : N/A |
| | | | Posted by The+Coder on 12/03/2007 at 19:10:09
| | | in my attempts at vb, i have succeeded in doing something rather of no value to my objective (a 3d Engine). That is to cause the whole form to the screen. I want to be able to have a 'viewscreen' that is where 3D material is located. I have utterly failed to get it to use a Picturebox over the mainform. It continously says "Object reference not set to an instance of an object" and the debugger points at my Class Name instead of a chunk of fixable code! Can anybody help me? I use vb.net almost exclusively but all i need is to be able to draw a triangle in a picturebox with vb.net. Once i do that i can use tons of other C# tutorials examples to build this! Please help! | |
|
|
| |
| |
| Poster | : The+Coder | | Posts | : 2 | | Country | : N/A | | City | : N/A |
| | | | Posted by The+Coder on 12/03/2007 at 19:11:40
| | | (error: to become the screen, not to the screen) | |
|
|
| |
| |
| Poster | : lore7460 | | Posts | : 1 | | Country | : usa | | City | : lake jackson |
| | | | Posted by lore7460 on 15/05/2008 at 16:35:36
| | 'I know this post is a bit old but I'll add my part to it.
'I just started messing around with the project in Studio 2005
'here is what I got.
Imports Microsoft.DirectX
Imports Microsoft.DirectX.Direct3D
Module DX
Private device As Direct3D.Device
Private _Target As Control = Nothing
Public Sub Initialize(ByVal Target As Control)
_Target = Target
Dim present As PresentParameters = New PresentParameters
present.Windowed = True 'we?ll draw on a window
present.SwapEffect = SwapEffect.Discard 'discuss later
device = New Direct3D.Device(0, DeviceType.Hardware, _Target, CreateFlags.SoftwareVertexProcessing, present)
End Sub
Public Sub RefreshPaint()
Dim vertices As CustomVertex.TransformedColored() = New CustomVertex.TransformedColored(0 To 2) {} 'create an array of vertices
vertices(0).Position = New Vector4(150, 100, 0, 1)
vertices(0).Color = Color.Red.ToArgb 'encode color in Argb
vertices(1).Position = New Vector4(_Target.Width / 2 + 100, 100, 0, 1)
vertices(1).Color = Color.Green.ToArgb
vertices(2).Position = New Vector4(250, 300, 0, 1)
vertices(2).Color = Color.Yellow.ToArgb
device.Clear(ClearFlags.Target, Color.Black, 1.0, 0)
device.BeginScene() 'all drawings after this line
device.VertexFormat = CustomVertex.TransformedColored.Format
device.DrawUserPrimitives(PrimitiveType.TriangleList, 1, vertices)
device.EndScene() 'all drawings before this line
device.Present()
_Target.Invalidate() 'redraw
End Sub
End Module
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' Me.SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.Opaque, True) 'Do not draw form?s background\
Me.Text = "DirectX Tutorial using Visual Basic"
Initialize(Panel1)
End Sub
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint, Me.Paint
RefreshPaint()
End Sub
End Class
' I created a CustomControl so that I can unhook the drawing methods
Public Class CustomControl1
Public Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
Me.BackColor = Color.Black
' Add any initialization after the InitializeComponent() call.
End Sub
Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
If Me.DesignMode Then
MyBase.OnPaintBackground(pevent)
End If
End Sub
End Class
' I added the CustomControl to my Form1 and renamed it Panel1, and added the handle to the paint event.
'Now if you want to draw on the form it self. you need to pass the form in the Initalize(Me) command in the form load.
'be sure to Uncoment the first line in the form load sub. That line disables the forms redrawing.
'Hope that helps.
| |
|
|
| |
| |
| Poster | : m_Maky | | Posts | : 67 | | Country | : france | | City | : Nice |
| | | | Posted by m_Maky on 16/05/2008 at 01:31:40
| | | thanks for that! i've been looking for code like this a while ago but couldn't find it anywhere. | |
|
|
| |
| |
| Poster | : Anonymous | | Posts | : | | Country | : | | City | : |
| | | | Posted by Anonymous on 16/05/2008 at 09:10:43
| | Why do you not use "CustomVertex.PositionNormalColored" and create your vertices in 3D : vertices(0).Position = New Vector3(150, 100, 0) ?
I try to do that but it doesn't work.. :S
Can you give me the code for a Vector3 ?
thanks. | |
|
|
| |
| |
| Poster | : graemeian | | Posts | : 6 | | Country | : us | | City | : durham |
| | | | Posted by graemeian on 05/02/2011 at 21:57:15
| | I tried this program using visual studio 2010 and my PC could not find.
Imports Microsoft.DirectX
Imports Microsoft.DirectX.Direct3D
Where are they? | |
|
|
| |
| |
| Poster | : graemeian | | Posts | : 6 | | Country | : us | | City | : durham |
| | | | Posted by graemeian on 05/02/2011 at 22:35:59
| | I found the DLLs. However, here is part of the code.
Imports Microsoft.DirectX
Imports Microsoft.DirectX.Direct3D
Public Class Form1
Private device As Direct3D.Device
I then get an error that reads " Direct3D.Device not defined"
ANy suggestions? | |
|
|
| |
| |
| Poster | : Anonymous | | Posts | : | | Country | : | | City | : |
| | | | Posted by Anonymous on 31/05/2011 at 22:49:48
| | | Wow, thatÂ’s a raelly clever way of thinking about it! | |
|
|
| |
| |
| Poster | : Anonymous | | Posts | : | | Country | : | | City | : |
| | | | Posted by Anonymous on 11/07/2012 at 03:56:32
| |
I too get the error that "Direct3D.Device is not defined" when using VS 2010 and the latest DirectX SDK.
I've got .Net Framework set to 3.5 and it's set to x86 for CPU. I'm running Windows 7 Ult x64 SP1 and I have a single ATI Radeon 5570 HD 1GB for graphics.
Perhaps my card isn't supported? Any Ideas on how to get passed this error? | |
|
|