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


shaders not working?

Recommended Posts

im trying to get shaders working on my engine, i go some nice samples from: 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, 
                                       "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