Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

supagu

shaders not working?

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

im trying to get shaders working on my engine, i go some nice samples from: http://www.codesampler.com/dx9src.htm for some reason i cant get it working in my engine. a few questions 1) does the vertex format in my shader file, have to be the same as the vertex format in my engine (pixel and vertex shaders)?



bool Direct3D::InitShader() 
{ 
   contextCG = cgCreateContext(); 

   cgD3D9SetDevice( pD3DDevice ); 

   CGprofile pixelProfile  = cgD3D9GetLatestPixelProfile(); 

   const char *pixelOptions[] = { cgD3D9GetOptimalOptions(pixelProfile), 0 }; 

   pixelProgramCG = cgCreateProgramFromFile( contextCG, 
                                               CG_SOURCE, 
                                               "pixel_shader.cg", 
                                                pixelProfile, 
                                       "main",                                       pixelOptions ); 

   if( !cgIsProgramCompiled( pixelProgramCG ) ) 
      systemLog.WriteLog("Pixel Shader Compile [FAILED]"); 

   cgD3D9BindProgram( pixelProgramCG ); 

   return true; 
} 
 
this function is called after i set up directx9 also each time i go into the render function i call cgD3D9BindProgram( pixelProgramCG ); here is my shader:
 

struct vertout 
{ 
   float4 position  : POSITION; 
   float4 normal    : NORMAL; 
   float2 texcoord0 : TEXCOORD0; 
}; 

struct pixout 
{ 
   float4 color : COLOR; 
}; 

pixout main( vertout IN ) 
{ 
   pixout OUT; 
    
   OUT.color = float4( 1.0f, 0.0f, 0.0f, 1.0f ); 

   return OUT; 
} 

 
thats it, any ideas? thanks

Share this post


Link to post
Share on other sites
Advertisement

  • 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!