Hello. I am programming the rendering part of my little engine and I am stuck in a little problem. I hope you could help me.
I have written a VertexBuffer class which contains a dynamic array of Vertices (of type Vertex). It's something like "Vertex* vertices". The vertices are allocated by the constructor of the VertexBuffer class.
Vertex is structured as follows:
struct Vertex
{
Vector3D position;
Vector3D normal;
Vector3D tangent;
Vector3D bitangent;
Color color;
};
Vector3D and Color are classes, they contains methods, operators and members (position and color) as an array of floats.
I have noticed that DirectX10 requires a pointer to the starting address where I have saved my vertices, I am referring to:
D3D10_SUBRESOURCE_DATA initData;
initData.pSysMem = address_of_vertices;
I have tried to pass DirectX the address of the array "Vertex* vertices" which is contained in the VertexBuffer class but I have noticed that, obviously, it doesn't draw anything because it's an array of structures ( Vertex ) which contain classes and not structures. They doesn't contain just positions and colors.
How could I solve this situation? I have seen that in the official DirectX10 tutorials they represent the Vertex as a structure which contains some D3DXVECTOR3 instances for position and color and they passes the address of this array of Vertices to DirectX.
How do they do, considering the fact that D3DXVECTOR3 is a class and not a structure? The area of memory of the vertices should contain members and functions of D3DXVECTOR3 and not just vertices, so I don't know how it could work. I am probably wrong in something. Have I to define the overloading of some operators?
Thanks in advance.