Sign in to follow this  

Help getting simple vertex shader to work

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

I've been trying to learn vertex shaders. I made a simple vertex shader using hlsl and compiled it to assembly language in vp.vp and then try to use it in my code but don't get any display at all (I do when I just use the fixed pipeline). Am I missing some vital step, or have I messed something up?
	D3DXAssembleShaderFromFile("c:\\source\\vp.vp", NULL, NULL, 0, &b, &e);
	if (e != NULL)
	{
		MessageBox(NULL, (char*)e->GetBufferPointer(), "Error", MB_OK);
		exit(0);
	}
	g_pd3dDevice->CreateVertexShader((DWORD*)b->GetBufferPointer(), &pVertexShader);
	g_pd3dDevice->SetVertexShader(pVertexShader);

The code of my shader is
struct in_s
{
	float4 position : POSITION;
	float4 Col0	: COLOR0;
};

struct out_s
{
	float4 HPos	: POSITION;
	float4 Col0	: COLOR0;
};

out_s main(in_s IN, uniform float4x4 ModelViewProj)
{
	out_s OUT;	

	OUT.HPos = mul(ModelViewProj, IN.position);
	OUT.Col0 = IN.Col0;
	OUT.Col0.x = 1.0;

	return OUT;
}

Share this post


Link to post
Share on other sites
Or if nobody is able to help me on that does anyone have a very simple example of the code needed to load a vertex shader that does as little as possible and just renders a square or something using it so I can figure out how my code is wrong?



Thanks

Share this post


Link to post
Share on other sites

This topic is 4838 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this