Jump to content
  • Advertisement
Sign in to follow this  
jbb

Help getting simple vertex shader to work

This topic is 5055 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!