Forum
Contact





DirectX using C#
DirectX using C++
DirectX using Visual Basic



Latest Forum posts

 Tutorial 3 for Windows Phone 7
  Posted by: Anonymous
  When: 20/05/2013 at 02:30:13

 No download link for 2d series: shooter
  Posted by: zaboleq
  When: 07/05/2013 at 15:46:28

 Collision Class?
  Posted by: Anonymous
  When: 05/05/2013 at 19:03:59

 stack overflow
  Posted by: cityguy
  When: 07/04/2013 at 01:58:38

 Meshes looks strange.
  Posted by: ab_saratov
  When: 01/04/2013 at 04:31:08

 Lamppost Not loaded
  Posted by: Anonymous
  When: 22/03/2013 at 06:43:52

 Collision Class?
  Posted by: Da_Boom
  When: 21/03/2013 at 01:23:09

 Math boggles me
  Posted by: cityguy
  When: 17/03/2013 at 03:44:48

 Collision Class?
  Posted by: Da_Boom
  When: 16/03/2013 at 03:44:42

 Tree update
  Posted by: Anonymous
  When: 15/03/2013 at 21:11:22

 XNA 4.0
  Posted by: Anonymous
  When: 15/03/2013 at 19:43:57

 Error when I try to run.
  Posted by: Anonymous
  When: 15/03/2013 at 19:21:06

 Error With the Effect File
  Posted by: Anonymous
  When: 15/03/2013 at 18:21:01

 Can only get shadowmap
  Posted by: Anonymous
  When: 15/03/2013 at 15:48:52

 Vertex and Pixel Shader Versions?
  Posted by: Anonymous
  When: 15/03/2013 at 15:07:16

 Unsupported properties
  Posted by: Anonymous
  When: 15/03/2013 at 14:23:00

 Problem Loading Skybox
  Posted by: Rana
  When: 15/03/2013 at 10:34:45

 Black Screen Of Death - Help!
  Posted by: Anonymous
  When: 15/03/2013 at 03:43:43

 2.0 anyone?
  Posted by: Anonymous
  When: 15/03/2013 at 02:19:48

 Defitinition of tha rotation axis
  Posted by: Anonymous
  When: 15/03/2013 at 00:55:14




Topic: Need Help with First Triangle!



  
Goto parent category
  
Create a new user account


   Need Help with First Triangle!
 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?

  
Post a new reply
 





Google
 
Web www.riemers.net
If you appreciate the amount of time I spend creating and updating
these pages, feel free to donate -- any amount is welcome !
- Website design & DirectX code : Riemer Grootjans -
©2006 Riemer Grootjans


News
Home
Forum
XNA 2.0 Recipes Book (8)
XNA 3.0 Recipes Book (8)
Downloads
Extra Reading (3)
Matrices: geometrical
Matrix Mathematics
Homogenous matrices
Community Projects (1)
Tutorials (160)
XNA 4.0 using C# (89)
DirectX using C# (54)
Series 1:Terrain (14)
Opening a window
Linking to the Device
Drawing a triangle
Camera
Rotation - Translation
Indices
Terrain creation
Terrain from file
DirectInput
Importing bmp files
Colored vertices
DirectX Light basics
Mesh creation
Mesh lighting
Series 2: Flightsim (19)
Series 3: HLSL (19)
Short Tuts (2)
Resizing problem
Checking Device caps
DirectX using C++ (15)
DirectX using VB (2)