Post

 Resources 

Console

Home | Profile | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 VBGamer
 VBGamer
 VB.NET 2005 & DX
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Kal_Torak
Neophyte

6 Posts

Posted - May 22 2005 :  1:02:29 PM  Show Profile  Send Kal_Torak an AOL message  Click to see Kal_Torak's MSN Messenger address  Reply with Quote
Is anyone using the new 2005 versions of VB with DirectX?

I'm new to DirectX and with the lack of tutorials/documentation I am not doing very well. ( I can't even draw a triangle!!)

Any good ideas or helpfuls on this?

Krisc
Knave

69 Posts

Posted - May 23 2005 :  12:58:52 AM  Show Profile  Visit Krisc's Homepage  Send Krisc an AOL message  Click to see Krisc's MSN Messenger address  Reply with Quote
It works in the same was as VS.net 2003. You need to go to the Project menu and Add References. From there you scroll and click the DirectX and Direct3D references and add them. Beyond that I am not so sure, what tutorial are you using? What are the problems, do you just not see anything? Have you turned off lighting? We need more information to help you...

Go to Top of Page

Kal_Torak
Neophyte

6 Posts

Posted - May 26 2005 :  09:50:37 AM  Show Profile  Send Kal_Torak an AOL message  Click to see Kal_Torak's MSN Messenger address  Reply with Quote
I am following this tutorial: http://www.vbgamer.com/tutorial.asp?ndx=12

I did the first one about Initializing d3d first...



Here is my code with the error message in the Render sub.

  
Imports Microsoft.DirectX  
Imports Microsoft.DirectX.Direct3D  
  
Public Class Form1  
  
    Dim Dev As Device = Nothing  
    Private VertBuff As VertexBuffer  
    Private strings As String = "ASD"  
  
  
  
  
  
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load  
  
  
        If Init3ds() = False Then
            MessageBox.Show("Awww.. No D3D for you!")  
        End If
  
        Me.Show()  
        Do
            Render()  
            Application.DoEvents()  
        Loop
  
  
    End Sub
  
    Public Function Init3ds() As Boolean
        Try
            Dim pParams As New PresentParameters()  
            pParams.Windowed = True
            pParams.SwapEffect = SwapEffect.Discard  
            Dev = New Device(0, DeviceType.Hardware, Me, CreateFlags.SoftwareVertexProcessing, pParams)  
            Return True
  
            MakeVerts()  
  
        Catch e As DirectXException  
            Return False
        End Try
    End Function
  
    Private Sub Render()  
        'grab the error with Catch  
        'A first chance exception of type 'Microsoft.DirectX.Direct3D.InvalidCallException' occurred in Microsoft.DirectX.Direct3D.dll  
        'Error in the application.  
        '-2005530516 (D3DERR_INVALIDCALL)  
        'at(Microsoft.DirectX.Direct3D.Device.BeginScene())  
        'at DX.Form1.Render() in C:\...\Form1.vb:line 49  
  
        Try
            Dev.Clear(ClearFlags.Target, System.Drawing.Color.Blue, 1.0F, 0)  
            Dev.BeginScene()  
            '==============  
            Dev.SetStreamSource(0, VertBuff, 0)  
            Dev.VertexFormat = CustomVertex.TransformedColored.Format  
            Dev.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 1)  
            '==============  
            Dev.EndScene()  
            Dev.Present()  
        Catch ex As DirectXException  
            Debug.WriteLine(ex)  
  
  
        End Try
  
  
  
    End Sub
  
  
    Public Sub MakeVerts()  
        VertBuff = New VertexBuffer(GetType(CustomVertex.TransformedColored), 3, Dev, 0, CustomVertex.TransformedColored.Format, Pool.Default)  
        Dim verts As CustomVertex.TransformedColored() = CType(VertBuff.Lock(0, 0), CustomVertex.TransformedColored())  
        verts(0).X = 150  
        verts(0).Y = 50  
        verts(0).Z = 0.5F  
        verts(0).Rhw = 1  
        verts(0).Color = Color.Aqua.ToArgb  
  
        verts(1).X = 250  
        verts(1).Y = 250  
        verts(1).Z = 0.5F  
        verts(1).Rhw = 1  
        verts(1).Color = Color.Brown.ToArgb  
  
        verts(2).X = 50  
        verts(2).Y = 250  
        verts(2).Z = 0.5F  
        verts(2).Rhw = 1  
        verts(2).Color = Color.LightPink.ToArgb  
  
        VertBuff.Unlock()  
    End Sub
  
End Class  
  
  
  
  

Go to Top of Page

Krisc
Knave

69 Posts

Posted - May 27 2005 :  6:15:56 PM  Show Profile  Visit Krisc's Homepage  Send Krisc an AOL message  Click to see Krisc's MSN Messenger address  Reply with Quote
It can never call MakeVerts() because it returns true and exits the function. Try putting the return true after the MakeVerts() call.
Go to Top of Page

Kal_Torak
Neophyte

6 Posts

Posted - May 27 2005 :  7:54:33 PM  Show Profile  Send Kal_Torak an AOL message  Click to see Kal_Torak's MSN Messenger address  Reply with Quote
Eh! Thanks! I drew my first triangle! Excitment! lol

Now will someone write a tut showing how to use a .X mesh ?
:)
Go to Top of Page

Krisc
Knave

69 Posts

Posted - May 28 2005 :  9:09:11 PM  Show Profile  Visit Krisc's Homepage  Send Krisc an AOL message  Click to see Krisc's MSN Messenger address  Reply with Quote
I would ask around and/or look for a book that is highly similar to Miller's Managed DirectX 9.0 Kick Start book because I know the version I got is written in C#. It is an amazing book and resource, you learn how to do a ton of useful stuff in Direct3D and you even make a really simple game.
Go to Top of Page

Kal_Torak
Neophyte

6 Posts

Posted - May 29 2005 :  08:36:26 AM  Show Profile  Send Kal_Torak an AOL message  Click to see Kal_Torak's MSN Messenger address  Reply with Quote
Yeah, I have looked quite a lot for books on it.. but all I found was Millers that looked like what I wanted. I almost bought it then I realized it was not VB

Go to Top of Page

cbx
Swordmaster

Canada
296 Posts

Posted - Jun 06 2005 :  11:18:48 AM  Show Profile  Visit cbx's Homepage  Send cbx an ICQ Message  Click to see cbx's MSN Messenger address  Send cbx a Yahoo! Message  Reply with Quote
I have a few example code snips on my web site at http://www.createdbyx.com/Default.aspx?tabid=32 that may help you get started.

Created by: X
http://www.createdbyx.com/
Go to Top of Page

Lachlan87
Moderator

USA
160 Posts

Posted - Jun 07 2005 :  12:18:24 PM  Show Profile  Reply with Quote
It's not in VB, but the CD that comes with it has the VB.NET Source code. Also, I think you'll find it pretty easy to convert C# code to VB.NET. I did.
Go to Top of Page

Kal_Torak
Neophyte

6 Posts

Posted - Jun 11 2005 :  8:02:36 PM  Show Profile  Send Kal_Torak an AOL message  Click to see Kal_Torak's MSN Messenger address  Reply with Quote
Hmm, mabye I'll buy the book then...
I'll go look at that site cbx.
I found a kickstart for DX9 that works in VB 2k5, so I'm not totally stuck now ;)
Go to Top of Page

Kal_Torak
Neophyte

6 Posts

Posted - Jun 11 2005 :  8:03:51 PM  Show Profile  Send Kal_Torak an AOL message  Click to see Kal_Torak's MSN Messenger address  Reply with Quote
Hehe cbx! I had already found that site via search engine, and downloaded most of the tutorials about 3 days ago. :)
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
VBGamer © Go To Top Of Page
This page was generated in 0.31 seconds. Snitz Forums 2000

Copyright © 2002 - 2004 Eric Coleman, Peter Kuchnio , et. al.