Skip to main content
gamedev.net
🔒 Locked

Question About Vertex Declarations?

Started by stefu 3 replies 400+ views
Original Post
stefu
stefu
Hi all! Should I prefer this
    D3DVSD_STREAM(0),
    D3DVSD_REG( D3DVSDE_POSITION, D3DVSDT_FLOAT3 ),
    D3DVSD_REG( D3DVSDE_NORMAL, D3DVSDT_FLOAT3 ),
    D3DVSD_REG( D3DVSDE_TEXCOORD0, D3DVSDT_FLOAT2 ),
    D3DVSD_END()
 
to this
    D3DVSD_STREAM(0),
    D3DVSD_REG( 0, D3DVSDT_FLOAT3 ),
    D3DVSD_REG( 1, D3DVSDT_FLOAT3 ),
    D3DVSD_REG( 2, D3DVSDT_FLOAT2 ),
    D3DVSD_END()
 
I use the second with my vertexshader. Why there are those D3DVSDE_*? Is there any compatibility problems if I don''t use them? Or are they just some default alternate?
Buster
Buster
If the values like D3DVSDE_POSITION ever change, you''ll be screwed. It''s better to use the constant names.
DrunkenHyena
DrunkenHyena
G''day!

More importantly it''s a step towards self-documenting code. It may seem simple, but you''d be surprised how easy it is to think ''1'' means one thing when it actually means another, especially during late night hacking sessions.

There''s no penalty in using the defined values, I would highly recommend it.



Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena</FON
stefu
stefu
I''ll use 0,1,2,... because I don''t get it work with D3DVSDE_*. CreateVertexShader fails.

This is written top of my shader file:
; Inputs: v0 = Position
; v1 = Normal
; v2 = Tex

For me it''s much more clear to use 0,1,2 instead of D3DVSDE_*.


But now I have another problem. How to use D3DXMesh with shaders? I create mesh by D3DXCreateMesh. FVF mesh works well but I want use shaders.

One parameter when creating mesh is ptr to the Declaration above.
SDK says:
----
pDeclaration
[in] Pointer to a DWORD value, representing the declarator that describes the vertex format for the returned mesh. This parameter must map directly to an FVF.
----
What does it mean? This parameter must map directly to an FVF? I don''t use FVF!

The problem comes when I lock vertexbuffer and fill it. A get accces violation. I think it''s due to too small vertex buffer.
When I create non-FVF vertexbuffer, I need to know the vertex stride. But how does non-FVF mesh know the stride to create VB?

I think there''s something I don''t know? What it might be?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.