CgFX and Direct3D?

Started by
0 comments, last by griffin2000 17 years, 8 months ago
Hi, I'm currently working on a simple render framework which can use different API's to render it's scene (currently Direct3D9 and OpenGL are supported). Until now I didn't encounter real difficulties but now I'm at the stage where I want to add support for Effect files and I'm a bit stuck. To keep the framework platform independent, Directx .fx files are out of the question, but luckely there is CgFX. I found a lot of articles talking about OpenGL and CgFX but I'm having unsolved questions concerning CgFX-files and Direct3D. It seems there are next to none articles who handle the subject. I know the CgFX files are nearly identical to Directx .fx files, but how far does this go? Can I write CgFX files and use them as if they are .fx files without a problem in my Direct3D9 renderer? Also, I downloaded the nVidia FX Composer and I noticed they don't even support their own format (CgFX)?! Is this because the two formats are identical or is CgFX being dumped? (which would be a shame) Thanks a lot!
Advertisement
The CGFX API works on directX as well as openGL there are examples in C:\Program Files\NVIDIA Corporation\Cg\examples\Direct3D9_Basic

Most people doing DirectX programing use the DX effects API, but it makes perfect sense to use CGFX if you are doing a cross platform (or at least cross-API) project. That said I've not actually compared the performance of the two APIs (FX and CGFX).

The syntax is different enough that you will have problems if you try and compile FX files with the CGFX compiler and vice-versa. But they are close enough so you can use macros to handle the differences if you had to use different APIs. e.g. define a PIXEL_PROGRAM(_func) macro that defines to "FragmentProgram = compile arbfp1 _func" in CGFX, "PixelShader = compile ps_3_0 _func" in FX.


This topic is closed to new replies.

Advertisement