Jump to content
  • Advertisement
Sign in to follow this  
qventura

SlimDX / D3D9 / VertexDeclaration problem with DeclarationUsage.Position

This topic is 2503 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

Hi everyone,
My code below is working, with a DeclarationUsage.PositionTransformed.

Now i want to add a camera, so i need to use DeclarationUsage.Position, But, even if i'm not doing anything, (I'm not modifyinf the position, and applying a fixed color to the pixel, nothing append ...

Does anyone see something wrong ?

My Vertex struct

public struct VertexTexture
{
public Vector4 Position;
public Vector2 TextureCoord;
}


My rendering function
viewMatrix = camera.ViewMatrix;
projectionMatrix = camera.ProjectionMatrix;
D3Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, new Color4(System.Drawing.Color.Red), 1, 0);
D3Device.BeginScene();
D3Device.SetStreamSource(0, vertices, 0, 24);
D3Device.VertexDeclaration = vertexDecl;
D3Device.Indices = indices;

int numPasses = effect.Begin();
{
for (int i = 0; i < numPasses; i++)
{
effect.BeginPass(i);
D3Device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, /* Dynamic */6, 0, 2);
effect.EndPass();
}
}
effect.End();
D3Device.EndScene();
D3Device.Present();


My VertexDeclaration
vertexDecl = new VertexDeclaration(D3Device, new[]
{
new VertexElement(0, 0, DeclarationType.Float4, DeclarationMethod.Default, DeclarationUsage.Position, 0),
new VertexElement(0, 16, DeclarationType.Float2, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 0),
VertexElement.VertexDeclarationEnd
});


There is my shaders. I'm remove everything, just want to display my quad with a fixed color

float4x4 WorldProjection;
texture textureToApply;
struct VS_OUT
{
float4 Position : POSITION;
float2 TextureCoord : TEXCOORD0;
};
struct PS_OUT
{
float4 Color : COLOR0;
};
VS_OUT VS( float4 Position : POSITION, float2 TextureCoord : TEXCOORD0 )
{
VS_OUT output = (VS_OUT)0;
output.Position = Position;
output.TextureCoord = TextureCoord;
return output;
}
PS_OUT PS( VS_OUT input)
{
PS_OUT output;
output.Color = float4(0.0f, 1.0f, 0.0f, 1.0f);
return output;
}
technique Render
{
pass P0
{
VertexShader = compile vs_3_0 VS();
PixelShader = compile ps_3_0 PS();
}
}

Share this post


Link to post
Share on other sites
Advertisement
Ok I was using the wrong coordinate system ..
I should use screen coordinate (pixel) with PositionTransformed, and -1;1 system with Position ... I feel stupid !

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!