Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

SlimDX / D3D9 / VertexDeclaration problem with DeclarationUsage.Position

4: Adsense

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   

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


#2 qventura   Members   

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.