Skip to main content
gamedev.net
🔒 Locked

problem with D3DFVF_NORMAL

Started by GekkoCube 2 replies 350+ views
Original Post
GekkoCube
GekkoCube
when i use this flag for my vertices, everything is either one color like gray with no apparant shading, or flickering and one shade of color. here''s the render part, assuming everything else, like the material is set properly, which i think it is since i took it straight from d3d''s help.
  
#define D3DFVF_CUSTOMVERTEX_TEX ( D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX2 | D3DFVF_NORMAL )

struct CUSTOMVERTEX_TEX {
    FLOAT x, y, z;      // The transformed position for a vertex

    DWORD color;        // The vertex color 

    float tu, tv;       // texture coordinates

    float nx, ny, nz;
};
  

  
// Set render state(s)

	lpDevice->SetRenderState( D3DRS_ZENABLE, FALSE );

	// Set the material

	lpDevice->SetMaterial( &mtrl );

	// Set texture style(s)

	lpDevice->SetTexture( 0, m_pTexture );

	// Prepare vertex buffer and then draw

	lpDevice->SetStreamSource( 0, m_pVB, sizeof(CUSTOMVERTEX_TEX) );// )

	lpDevice->SetVertexShader( D3DFVF_CUSTOMVERTEX_TEX );
	lpDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 10 );

	// Set render state(s) back to normal

	lpDevice->SetRenderState( D3DRS_ZENABLE, TRUE );

	// Set texture setting to NULL

	lpDevice->SetTexture( 0, NULL );
  
don
don
The normal should immediately follow the vertex position.

GekkoCube
GekkoCube
Really???

I didn''t think it mattered as long as I keep it consistent with my custom vertex.

If the normal comes right after the position, then my vertex set must be way out of whack!!

What is the standard anyway? I guess i should look it up on the d3d reference.

thanks for the help.
d000hg
d000hg
Yeah the order of components in the vertex struct is essential. Otherwise how does D3D expect to know where to find stuff - you don''t declare it anywhere else!



Read about my game, project #1
NEW (18th December)2 new screenshots, one from the engine and one from the level editor



John 3:16

Topic Locked

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

Sign in to reply to this topic.