Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


SlimDX / D3D9 / VertexDeclaration problem with DeclarationUsage.Position


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 qventura   Members   -  Reputation: 107

Like
0Likes
Like

Posted 03 February 2012 - 09:32 AM

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();
	}
}


Sponsor:

#2 qventura   Members   -  Reputation: 107

Like
0Likes
Like

Posted 03 February 2012 - 10:10 AM

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 !




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS