psychotomusSim
10-07-2006, 02:15 PM
im converting this C++ code to vb.net
C++
private VertexBuffer vb;
public void createTriangle()
{
CustomVertex.PositionColored[] triangle = new CustomVertex.PositionColored[3]; //create an array of 3 vertices
//using the CustomVertex.PositionColored constructor to set each vertex
triangle[0] = new CustomVertex.PositionColored(-0.1f, 0.0f, 1.0f, Color.Blue.ToArgb());
triangle[1] = new CustomVertex.PositionColored(-0.1f, 0.2f, 1.0f, Color.Red.ToArgb());
triangle[2] = new CustomVertex.PositionColored(0.1f, 0.0f, 1.0f, Color.Green.ToArgb());
vb = new VertexBuffer(typeof(CustomVertex.PositionColored), 3, direct3d.XilathDevice, Usage.WriteOnly, CustomVertex.PositionColored.Format, Pool.Managed);
GraphicsStream stm; //our GraphicsStream object that we will use to access the
//lock the VB. Locks a range of vertex data and obtains the vertex buffer memory and stores it in the GraphicsStream object (stm)
stm = vb.Lock(0, 0, LockFlags.None);
stm.Write(triangle); //write the triangle array to the GraphicsStream Object
vb.Unlock(); //unlock the VertexBuffer, we are finished writing the data to it.
}
VB
Dim triangle(2) As CustomVertex.PositionColored
triangle(0) = New CustomVertex.PositionColored(-0.1F, 0.0F, 1.0F, Color.Blue.ToArgb())
triangle(1) = New CustomVertex.PositionColored(-0.1F, 0.2F, 1.0F, Color.Red.ToArgb())
triangle(2) = New CustomVertex.PositionColored(0.1F, 0.0F, 1.0F, Color.Green.ToArgb())
vertex = New VertexBuffer(typeof(CustomVertex.PositionColored), 3, GraphicsDevice, Usage.WriteOnly, CustomVertex.PositionColored.Format, Pool.Managed)
Dim stm As GraphicsStream
'lock the VB. Locks a range of vertex data and obtains the vertex buffer memory and stores it in the GraphicsStream object (stm)
stm = vertex.Lock(0, 0, LockFlags.None)
stm.Write(triangle) 'write the triangle array to the GraphicsStream Object
vertex.Unlock() 'unlock the VertexBuffer, we are finished writing the data to it.
i get an error on this line
vertex = New VertexBuffer(typeof(CustomVertex.PositionColored), 3, GraphicsDevice, Usage.WriteOnly, CustomVertex.PositionColored.Format, Pool.Managed)
saying CustomVertex.PositionColored cant no be used as an expression.
C++
private VertexBuffer vb;
public void createTriangle()
{
CustomVertex.PositionColored[] triangle = new CustomVertex.PositionColored[3]; //create an array of 3 vertices
//using the CustomVertex.PositionColored constructor to set each vertex
triangle[0] = new CustomVertex.PositionColored(-0.1f, 0.0f, 1.0f, Color.Blue.ToArgb());
triangle[1] = new CustomVertex.PositionColored(-0.1f, 0.2f, 1.0f, Color.Red.ToArgb());
triangle[2] = new CustomVertex.PositionColored(0.1f, 0.0f, 1.0f, Color.Green.ToArgb());
vb = new VertexBuffer(typeof(CustomVertex.PositionColored), 3, direct3d.XilathDevice, Usage.WriteOnly, CustomVertex.PositionColored.Format, Pool.Managed);
GraphicsStream stm; //our GraphicsStream object that we will use to access the
//lock the VB. Locks a range of vertex data and obtains the vertex buffer memory and stores it in the GraphicsStream object (stm)
stm = vb.Lock(0, 0, LockFlags.None);
stm.Write(triangle); //write the triangle array to the GraphicsStream Object
vb.Unlock(); //unlock the VertexBuffer, we are finished writing the data to it.
}
VB
Dim triangle(2) As CustomVertex.PositionColored
triangle(0) = New CustomVertex.PositionColored(-0.1F, 0.0F, 1.0F, Color.Blue.ToArgb())
triangle(1) = New CustomVertex.PositionColored(-0.1F, 0.2F, 1.0F, Color.Red.ToArgb())
triangle(2) = New CustomVertex.PositionColored(0.1F, 0.0F, 1.0F, Color.Green.ToArgb())
vertex = New VertexBuffer(typeof(CustomVertex.PositionColored), 3, GraphicsDevice, Usage.WriteOnly, CustomVertex.PositionColored.Format, Pool.Managed)
Dim stm As GraphicsStream
'lock the VB. Locks a range of vertex data and obtains the vertex buffer memory and stores it in the GraphicsStream object (stm)
stm = vertex.Lock(0, 0, LockFlags.None)
stm.Write(triangle) 'write the triangle array to the GraphicsStream Object
vertex.Unlock() 'unlock the VertexBuffer, we are finished writing the data to it.
i get an error on this line
vertex = New VertexBuffer(typeof(CustomVertex.PositionColored), 3, GraphicsDevice, Usage.WriteOnly, CustomVertex.PositionColored.Format, Pool.Managed)
saying CustomVertex.PositionColored cant no be used as an expression.