Jump to content
  • Advertisement
Sign in to follow this  
Chainsaw101

Noob vertex buffer question

This topic is 4819 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Okay, say I have a struct like the following C# code: struct VertexType { Vector3 Position; Vector3 Normal; Vector2 UV; Color Color; }; I have an array of these and I would like to get them into a vertex buffer. The problemm is that I have no idea how to create a vertex buffer to hold something that isnt a CustomeVertex.Something predifined type. I need them in vertex buffer to pass in to a vertex shader. A shiney new donkey to the person who can enlighten me.

Share this post


Link to post
Share on other sites
Advertisement
I do not know about C# .. but I think you need to create what the documentation calls a

VERTEX DECLARATION.

In this you tell the hardware what each field of your vertex structure is. I think this consists of information like - data type of each field, its size, and to which shader register will it be associated with.


Share this post


Link to post
Share on other sites
If you're using OpenGL, check the redbook for Vertex Arrays. If you're using DirectX, as I would think you are as you're working in C#...well, I just don't know. Are there C# OpenGL libraries, by the way?

Share this post


Link to post
Share on other sites
I'm working in directx, and on the opengl thing I have no idea if there Opengl libs for C#. I know about the Vertex Declaration thing. More specifically my question is how do I get the format parameter for creating a matching vertex buffer.

Share this post


Link to post
Share on other sites
Why don't you change the order of your vertex and use this FVF

struct CUSTOMVERTEX {
FLOAT x, y, z;
FLOAT rhw;
DWORD color;
FLOAT tu, tv; // Texture coordinates
};

// Custom flexible vertex format (FVF) describing the custom vertex structure
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1)



difference is .. move color up and tecture coords down in your vertex structure!




-not sure if I answered your question!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!